aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-01 14:36:58 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-01 14:40:14 +0200
commit29b2adf5fd6725b47a647634657aeb8a94756534 (patch)
tree0da0775e9087c31294bcc7953bd06c525efe727d /src/main
parent725b1a7406a06584e1b15a1cc273e926ec9e6804 (diff)
changed some of the jid entering dialogs to textinputlayout
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/ui/EnterJidDialog.java64
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/DelayedHintHelper.java47
-rw-r--r--src/main/res/layout/activity_change_password.xml11
-rw-r--r--src/main/res/layout/activity_edit_account.xml26
-rw-r--r--src/main/res/layout/create_conference_dialog.xml37
-rw-r--r--src/main/res/layout/enter_jid_dialog.xml29
-rw-r--r--src/main/res/layout/join_conference_dialog.xml33
-rw-r--r--src/main/res/values/dimens.xml3
-rw-r--r--src/main/res/values/styles.xml7
10 files changed, 136 insertions, 126 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java b/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java
index b9ffcb35d..2f3315d22 100644
--- a/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java
+++ b/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java
@@ -15,6 +15,7 @@ import java.util.List;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.ui.adapter.KnownHostsAdapter;
+import de.pixart.messenger.ui.util.DelayedHintHelper;
import de.pixart.messenger.xmpp.jid.InvalidJidException;
import de.pixart.messenger.xmpp.jid.Jid;
@@ -47,8 +48,6 @@ public class EnterJidDialog {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
final View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null);
- final TextView jabberIdDesc = dialogView.findViewById(R.id.jabber_id);
- jabberIdDesc.setText(R.string.account_settings_jabber_id);
final TextView yourAccount = dialogView.findViewById(R.id.your_account);
final Spinner spinner = dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid);
@@ -63,7 +62,7 @@ public class EnterJidDialog {
}
}
- jid.setHint(R.string.account_settings_example_jabber_id);
+ DelayedHintHelper.setHint(R.string.account_settings_example_jabber_id, jid);
if (multipleAccounts) {
yourAccount.setVisibility(View.VISIBLE);
@@ -89,42 +88,35 @@ public class EnterJidDialog {
builder.setPositiveButton(positiveButton, null);
this.dialog = builder.create();
- this.dialogOnClick = new View.OnClickListener() {
- @Override
- public void onClick(final View v) {
- final Jid accountJid;
- if (!spinner.isEnabled() && account == null) {
- return;
- }
- try {
- if (Config.DOMAIN_LOCK != null) {
- if (spinner.getSelectedItem().toString().contains("@")) {
- accountJid = Jid.fromString((String) spinner.getSelectedItem());
- } else {
- accountJid = Jid.fromParts(String.valueOf(spinner.getSelectedItem()), Config.DOMAIN_LOCK, null);
- }
- } else {
- accountJid = Jid.fromString((String) spinner.getSelectedItem());
- }
- } catch (final InvalidJidException e) {
- return;
- }
- final Jid contactJid;
- try {
- contactJid = Jid.fromString(jid.getText().toString());
- } catch (final InvalidJidException e) {
- jid.setError(context.getString(R.string.invalid_jid));
- return;
+ this.dialogOnClick = v -> {
+ final Jid accountJid;
+ if (!spinner.isEnabled() && account == null) {
+ return;
+ }
+ try {
+ if (Config.DOMAIN_LOCK != null) {
+ accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
+ } else {
+ accountJid = Jid.fromString((String) spinner.getSelectedItem());
}
+ } catch (final InvalidJidException e) {
+ return;
+ }
+ final Jid contactJid;
+ try {
+ contactJid = Jid.fromString(jid.getText().toString());
+ } catch (final InvalidJidException e) {
+ jid.setError(context.getString(R.string.invalid_jid));
+ return;
+ }
- if (listener != null) {
- try {
- if (listener.onEnterJidDialogPositive(accountJid, contactJid)) {
- dialog.dismiss();
- }
- } catch (JidError error) {
- jid.setError(error.toString());
+ if(listener != null) {
+ try {
+ if(listener.onEnterJidDialogPositive(accountJid, contactJid)) {
+ dialog.dismiss();
}
+ } catch(JidError error) {
+ jid.setError(error.toString());
}
}
};
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 04b3d860a..685632e11 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -70,6 +70,7 @@ import de.pixart.messenger.services.EmojiService;
import de.pixart.messenger.services.XmppConnectionService.OnRosterUpdate;
import de.pixart.messenger.ui.adapter.KnownHostsAdapter;
import de.pixart.messenger.ui.adapter.ListItemAdapter;
+import de.pixart.messenger.ui.util.DelayedHintHelper;
import de.pixart.messenger.utils.XmppUri;
import de.pixart.messenger.xmpp.OnUpdateBlocklist;
import de.pixart.messenger.xmpp.XmppConnection;
@@ -478,9 +479,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
final TextView yourAccount = dialogView.findViewById(R.id.your_account);
final Spinner spinner = dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid);
- final TextView jabberIdDesc = dialogView.findViewById(R.id.jabber_id);
- jabberIdDesc.setText(R.string.conference_address);
- jid.setHint(R.string.conference_address_example);
+ DelayedHintHelper.setHint(R.string.conference_address_example, jid);
jid.setAdapter(new KnownHostsAdapter(this, R.layout.simple_list_item, mKnownConferenceHosts));
if (prefilledJid != null) {
jid.append(prefilledJid);
diff --git a/src/main/java/de/pixart/messenger/ui/util/DelayedHintHelper.java b/src/main/java/de/pixart/messenger/ui/util/DelayedHintHelper.java
new file mode 100644
index 000000000..c289b6673
--- /dev/null
+++ b/src/main/java/de/pixart/messenger/ui/util/DelayedHintHelper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018, Daniel Gultsch All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package de.pixart.messenger.ui.util;
+
+import android.os.Handler;
+import android.support.annotation.StringRes;
+import android.widget.EditText;
+
+public class DelayedHintHelper {
+
+ public static void setHint(@StringRes final int res, EditText editText) {
+ editText.setOnFocusChangeListener((v, hasFocus) -> {
+ if (hasFocus) {
+ new Handler().postDelayed(() -> editText.setHint(res), 200);
+ } else {
+ editText.setHint(null);
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/src/main/res/layout/activity_change_password.xml b/src/main/res/layout/activity_change_password.xml
index 1dfdc8309..55cd7dd53 100644
--- a/src/main/res/layout/activity_change_password.xml
+++ b/src/main/res/layout/activity_change_password.xml
@@ -39,10 +39,7 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="@string/current_password"
- android:inputType="textPassword"
- android:textColor="?attr/color_text_primary"
- android:textColorHint="?attr/color_text_secondary"
- android:textSize="?attr/TextSizeBody" />
+ android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
@@ -58,11 +55,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
- android:hint="@string/new_password"
- android:inputType="textPassword"
- android:textColor="?attr/color_text_primary"
- android:textColorHint="?attr/color_text_secondary"
- android:textSize="?attr/TextSizeBody" />
+ android:hint="@string/new_password" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml
index 229c3c4ad..01cd2b5de 100644
--- a/src/main/res/layout/activity_edit_account.xml
+++ b/src/main/res/layout/activity_edit_account.xml
@@ -64,10 +64,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
- android:inputType="textEmailAddress"
- android:textColor="?attr/color_text_primary"
- android:textColorHint="?attr/color_text_secondary"
- android:textSize="?attr/TextSizeBody" />
+ android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
@@ -83,10 +80,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
- android:inputType="textPassword"
- android:textColor="@color/black87"
- android:textColorHint="@color/black54"
- android:textSize="?attr/TextSizeBody" />
+ android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
@@ -113,10 +107,7 @@
android:id="@+id/hostname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:inputType="textNoSuggestions"
- android:textColor="?attr/color_text_primary"
- android:textColorHint="?attr/color_text_secondary"
- android:textSize="?attr/TextSizeBody" />
+ android:inputType="textNoSuggestions" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
@@ -137,10 +128,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="number"
- android:maxLength="5"
- android:textColor="?attr/color_text_primary"
- android:textColorHint="?attr/color_text_secondary"
- android:textSize="?attr/TextSizeBody" />
+ android:maxLength="5" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
@@ -150,9 +138,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
- android:text="@string/register_account"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody" />
+ android:text="@string/register_account" />
<TextView
android:id="@+id/account_confirm_password_desc"
@@ -666,10 +652,10 @@
android:id="@+id/other_device_keys_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_margin="@dimen/list_padding"
android:text="@string/other_devices"
android:textColor="@color/black87"
android:textSize="?attr/TextSizeHeadline"
- android:layout_margin="@dimen/list_padding"
android:textStyle="bold" />
<LinearLayout
diff --git a/src/main/res/layout/create_conference_dialog.xml b/src/main/res/layout/create_conference_dialog.xml
index e33b4516e..0b83d1d84 100644
--- a/src/main/res/layout/create_conference_dialog.xml
+++ b/src/main/res/layout/create_conference_dialog.xml
@@ -10,11 +10,10 @@
<TextView
android:id="@+id/your_account"
- android:layout_width="wrap_content"
+ style="@style/InputLabel"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/your_account"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody"
android:visibility="gone" />
<Spinner
@@ -23,22 +22,22 @@
android:layout_height="wrap_content"
android:visibility="gone" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:text="@string/conference_subject"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody" />
+ <View
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:focusable="true"
+ android:focusableInTouchMode="true" />
- <EditText
- android:id="@+id/subject"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:hint="@string/edit_subject_hint"
- android:inputType="textAutoComplete"
- android:textColor="@color/black87"
- android:textColorHint="@color/black54"
- android:textSize="?attr/TextSizeBody" />
+ <android.support.design.widget.TextInputLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <android.support.design.widget.TextInputEditText
+ android:id="@+id/subject"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/edit_subject_hint"
+ android:nextFocusDown="@+id/subject"
+ android:nextFocusUp="@+id/subject" />
+ </android.support.design.widget.TextInputLayout>
</LinearLayout> \ No newline at end of file
diff --git a/src/main/res/layout/enter_jid_dialog.xml b/src/main/res/layout/enter_jid_dialog.xml
index 765c438ce..a5d8f4a96 100644
--- a/src/main/res/layout/enter_jid_dialog.xml
+++ b/src/main/res/layout/enter_jid_dialog.xml
@@ -10,11 +10,10 @@
<TextView
android:id="@+id/your_account"
+ style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/your_account"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody"
android:visibility="gone" />
<Spinner
@@ -23,23 +22,17 @@
android:layout_height="wrap_content"
android:visibility="gone" />
- <TextView
- android:id="@+id/jabber_id"
- android:layout_width="wrap_content"
+ <android.support.design.widget.TextInputLayout
+ android:id="@+id/account_jid_layout"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:text="@string/account_settings_jabber_id"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody" />
+ android:hint="@string/account_settings_jabber_id">
- <AutoCompleteTextView
- android:id="@+id/jid"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:hint="@string/account_settings_example_jabber_id"
- android:inputType="textEmailAddress"
- android:textColor="@color/black87"
- android:textColorHint="@color/black54"
- android:textSize="?attr/TextSizeBody" />
+ <AutoCompleteTextView
+ android:id="@+id/jid"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textEmailAddress" />
+ </android.support.design.widget.TextInputLayout>
</LinearLayout> \ No newline at end of file
diff --git a/src/main/res/layout/join_conference_dialog.xml b/src/main/res/layout/join_conference_dialog.xml
index a615346fc..5916586e5 100644
--- a/src/main/res/layout/join_conference_dialog.xml
+++ b/src/main/res/layout/join_conference_dialog.xml
@@ -10,11 +10,10 @@
<TextView
android:id="@+id/your_account"
+ style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/your_account"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody"
android:visibility="gone" />
<Spinner
@@ -23,24 +22,18 @@
android:layout_height="wrap_content"
android:visibility="gone" />
- <TextView
- android:id="@+id/jabber_id"
- android:layout_width="wrap_content"
+ <android.support.design.widget.TextInputLayout
+ android:id="@+id/account_jid_layout"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:text="@string/conference_address"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody" />
+ android:hint="@string/conference_address">
- <AutoCompleteTextView
- android:id="@+id/jid"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:hint="@string/conference_address_example"
- android:inputType="textEmailAddress"
- android:textColor="@color/black87"
- android:textColorHint="@color/black54"
- android:textSize="?attr/TextSizeBody" />
+ <AutoCompleteTextView
+ android:id="@+id/jid"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textEmailAddress" />
+ </android.support.design.widget.TextInputLayout>
<CheckBox
android:id="@+id/bookmark"
@@ -48,8 +41,6 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checked="true"
- android:text="@string/save_as_bookmark"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody" />
+ android:text="@string/save_as_bookmark" />
</LinearLayout> \ No newline at end of file
diff --git a/src/main/res/values/dimens.xml b/src/main/res/values/dimens.xml
index d6a9a5ede..c29eded86 100644
--- a/src/main/res/values/dimens.xml
+++ b/src/main/res/values/dimens.xml
@@ -11,6 +11,9 @@
<dimen name="audio_player_width">224dp</dimen>
<dimen name="avatar_item_distance">16dp</dimen>
+ <dimen name="input_label_vertical_spacing">4dp</dimen>
+ <dimen name="input_label_horizontal_spacing">4dp</dimen>
+
<!-- scanner -->
<dimen name="scan_laser_width">4dp</dimen>
<dimen name="scan_dot_size">8dp</dimen>
diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml
index 1b3798eca..d8e201664 100644
--- a/src/main/res/values/styles.xml
+++ b/src/main/res/values/styles.xml
@@ -3,4 +3,11 @@
<style name="TextAppearance.Conversations.Body1.Secondary" parent="TextAppearance.AppCompat.Body1">
<item name="android:textColor">?android:textColorSecondary</item>
</style>
+
+ <style name="InputLabel" parent="TextAppearance.AppCompat.Caption">
+ <item name="android:paddingBottom">@dimen/input_label_vertical_spacing</item>
+ <item name="android:paddingLeft">@dimen/input_label_horizontal_spacing</item>
+ <item name="android:paddingRight">@dimen/input_label_horizontal_spacing</item>
+ </style>
+
</resources> \ No newline at end of file