From e538420559ef48874d996749df603edf96c213ad Mon Sep 17 00:00:00 2001
From: Janne Koschinski <janne@kuschku.de>
Date: Tue, 16 Feb 2016 22:38:49 +0100
Subject: [PATCH] Minor update

---
 .../ui/chat/ToolbarWrapper.java               | 61 +++++++++++++++++++
 .../kuschku/util/ui/ObservableTextBinder.java | 52 ++++++++++++++++
 app/src/main/res/values-sw600dp/dimens.xml    | 25 ++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ToolbarWrapper.java
 create mode 100644 app/src/main/java/de/kuschku/util/ui/ObservableTextBinder.java
 create mode 100644 app/src/main/res/values-sw600dp/dimens.xml

diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ToolbarWrapper.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ToolbarWrapper.java
new file mode 100644
index 000000000..5ec6cac6d
--- /dev/null
+++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ToolbarWrapper.java
@@ -0,0 +1,61 @@
+/*
+ * QuasselDroid - Quassel client for Android
+ * Copyright (C) 2016 Janne Koschinski
+ * Copyright (C) 2016 Ken Børge Viktil
+ * Copyright (C) 2016 Magnus Fjell
+ * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.quasseldroid_ng.ui.chat;
+
+import android.support.annotation.StringRes;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+import android.widget.TextView;
+
+import de.kuschku.quasseldroid_ng.R;
+
+public class ToolbarWrapper {
+    private final TextView title;
+    private final TextView subtitle;
+    private final View actionArea;
+
+    public ToolbarWrapper(Toolbar toolbar) {
+        this.title = (TextView) toolbar.findViewById(R.id.toolbar_title);
+        this.subtitle = (TextView) toolbar.findViewById(R.id.toolbar_subtitle);
+        this.actionArea = toolbar.findViewById(R.id.toolbar_action_area);
+    }
+
+    public void setTitle(@StringRes int id) {
+        title.setText(id);
+    }
+
+    public void setTitle(CharSequence text) {
+        title.setText(text);
+    }
+
+    public void setSubtitle(@StringRes int id) {
+        subtitle.setText(id);
+    }
+
+    public void setSubtitle(CharSequence text) {
+        subtitle.setText(text);
+    }
+
+    public void setOnClickListener(View.OnClickListener listener) {
+        actionArea.setOnClickListener(listener);
+    }
+}
diff --git a/app/src/main/java/de/kuschku/util/ui/ObservableTextBinder.java b/app/src/main/java/de/kuschku/util/ui/ObservableTextBinder.java
new file mode 100644
index 000000000..688db48ab
--- /dev/null
+++ b/app/src/main/java/de/kuschku/util/ui/ObservableTextBinder.java
@@ -0,0 +1,52 @@
+/*
+ * QuasselDroid - Quassel client for Android
+ * Copyright (C) 2016 Janne Koschinski
+ * Copyright (C) 2016 Ken Børge Viktil
+ * Copyright (C) 2016 Magnus Fjell
+ * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.util.ui;
+
+import android.databinding.Observable;
+import android.databinding.ObservableField;
+import android.widget.TextView;
+
+public class ObservableTextBinder {
+    private ObservableField<CharSequence> text;
+    private TextView view;
+
+    public ObservableTextBinder(ObservableField<CharSequence> text) {
+        this.text = text;
+        this.text.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
+            @Override
+            public void onPropertyChanged(Observable sender, int propertyId) {
+                updateView();
+            }
+        });
+    }
+
+    private void updateView() {
+        if (view != null) {
+            view.setText(text.get());
+        }
+    }
+
+    public void bind(TextView view) {
+        this.view = view;
+        updateView();
+    }
+}
diff --git a/app/src/main/res/values-sw600dp/dimens.xml b/app/src/main/res/values-sw600dp/dimens.xml
new file mode 100644
index 000000000..2a1754ece
--- /dev/null
+++ b/app/src/main/res/values-sw600dp/dimens.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ QuasselDroid - Quassel client for Android
+  ~ Copyright (C) 2016 Janne Koschinski
+  ~ Copyright (C) 2016 Ken Børge Viktil
+  ~ Copyright (C) 2016 Magnus Fjell
+  ~ Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org>
+  ~
+  ~ This program is free software: you can redistribute it and/or modify it
+  ~ under the terms of the GNU General Public License as published by the Free
+  ~ Software Foundation, either version 3 of the License, or (at your option)
+  ~ any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License along
+  ~ with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<resources>
+    <dimen name="action_bar_default_padding_start_material">8dp</dimen>
+</resources>
-- 
GitLab