changed some of the jid entering dialogs to textinputlayout

This commit is contained in:
Daniel Gultsch 2018-02-28 17:39:59 +01:00
parent 9d15d3b408
commit 3130d40262
11 changed files with 151 additions and 141 deletions

View file

@ -15,6 +15,7 @@ import java.util.List;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.ui.util.DelayedHintHelper;
import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.jid.Jid;
@ -47,10 +48,8 @@ public class EnterJidDialog {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title); builder.setTitle(title);
View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null); View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null);
final TextView jabberIdDesc = (TextView) dialogView.findViewById(R.id.jabber_id); final Spinner spinner = dialogView.findViewById(R.id.account);
jabberIdDesc.setText(R.string.account_settings_jabber_id); final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid);
final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
jid.setAdapter(new KnownHostsAdapter(context, R.layout.simple_list_item, knownHosts)); jid.setAdapter(new KnownHostsAdapter(context, R.layout.simple_list_item, knownHosts));
if (prefilledJid != null) { if (prefilledJid != null) {
jid.append(prefilledJid); jid.append(prefilledJid);
@ -62,7 +61,7 @@ public class EnterJidDialog {
} }
} }
jid.setHint(R.string.account_settings_example_jabber_id); DelayedHintHelper.setHint(R.string.account_settings_example_jabber_id,jid);
if (account == null) { if (account == null) {
StartConversationActivity.populateAccountSpinner(context, activatedAccounts, spinner); StartConversationActivity.populateAccountSpinner(context, activatedAccounts, spinner);
@ -80,9 +79,7 @@ public class EnterJidDialog {
builder.setPositiveButton(positiveButton, null); builder.setPositiveButton(positiveButton, null);
this.dialog = builder.create(); this.dialog = builder.create();
this.dialogOnClick = new View.OnClickListener() { this.dialogOnClick = v -> {
@Override
public void onClick(final View v) {
final Jid accountJid; final Jid accountJid;
if (!spinner.isEnabled() && account == null) { if (!spinner.isEnabled() && account == null) {
return; return;
@ -113,7 +110,6 @@ public class EnterJidDialog {
jid.setError(error.toString()); jid.setError(error.toString());
} }
} }
}
}; };
} }

View file

@ -76,6 +76,7 @@ import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.ui.adapter.ListItemAdapter; import eu.siacs.conversations.ui.adapter.ListItemAdapter;
import eu.siacs.conversations.ui.service.EmojiService; import eu.siacs.conversations.ui.service.EmojiService;
import eu.siacs.conversations.ui.util.DelayedHintHelper;
import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
@ -493,9 +494,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
final View dialogView = getLayoutInflater().inflate(R.layout.join_conference_dialog, null); final View dialogView = getLayoutInflater().inflate(R.layout.join_conference_dialog, null);
final Spinner spinner = dialogView.findViewById(R.id.account); final Spinner spinner = dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid); final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid);
final TextView jabberIdDesc = dialogView.findViewById(R.id.jabber_id); DelayedHintHelper.setHint(R.string.conference_address_example,jid);
jabberIdDesc.setText(R.string.conference_address);
jid.setHint(R.string.conference_address_example);
jid.setAdapter(new KnownHostsAdapter(this, R.layout.simple_list_item, mKnownConferenceHosts)); jid.setAdapter(new KnownHostsAdapter(this, R.layout.simple_list_item, mKnownConferenceHosts));
if (prefilledJid != null) { if (prefilledJid != null) {
jid.append(prefilledJid); jid.append(prefilledJid);

View file

@ -0,0 +1,48 @@
/*
* 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 eu.siacs.conversations.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);
}
});
}
}

View file

@ -39,10 +39,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:hint="@string/current_password" android:hint="@string/current_password"
android:inputType="textPassword" android:inputType="textPassword"/>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
@ -59,10 +56,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:hint="@string/new_password" android:hint="@string/new_password"
android:inputType="textPassword" android:inputType="textPassword"/>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>

View file

@ -61,10 +61,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:imeOptions="actionNext" android:imeOptions="actionNext"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"/>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
@ -82,10 +79,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:hint="@string/password" android:hint="@string/password"
android:inputType="textPassword" android:inputType="textPassword"/>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<LinearLayout <LinearLayout
@ -112,10 +106,7 @@
android:id="@+id/hostname" android:id="@+id/hostname"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textNoSuggestions" android:inputType="textNoSuggestions"/>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
</LinearLayout> </LinearLayout>
@ -136,10 +127,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:inputType="number" android:inputType="number"
android:maxLength="5" android:maxLength="5"/>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@ -149,9 +137,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:text="@string/register_account" android:text="@string/register_account"/>
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody"/>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>

View file

@ -7,36 +7,34 @@
android:paddingLeft="?attr/dialog_horizontal_padding" android:paddingLeft="?attr/dialog_horizontal_padding"
android:paddingRight="?attr/dialog_horizontal_padding" android:paddingRight="?attr/dialog_horizontal_padding"
android:paddingTop="?attr/dialog_vertical_padding"> android:paddingTop="?attr/dialog_vertical_padding">
<TextView <TextView
android:id="@+id/your_account" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/your_account" android:text="@string/your_account"
android:textColor="?attr/color_text_primary" style="@style/InputLabel" />
android:textSize="?attr/TextSizeBody" />
<Spinner <Spinner
android:id="@+id/account" android:id="@+id/account"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"/>
<TextView <View
android:layout_width="wrap_content" android:focusable="true"
android:layout_height="wrap_content" android:focusableInTouchMode="true"
android:layout_marginTop="8dp" android:layout_width="0dp"
android:text="@string/conference_subject" android:layout_height="0dp"/>
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody" />
<EditText <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:id="@+id/subject"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/edit_subject_hint" android:nextFocusUp="@+id/subject"
android:inputType="textAutoComplete" android:nextFocusDown="@+id/subject"
android:textColor="?attr/color_text_primary" android:hint="@string/edit_subject_hint"/>
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody" /> </android.support.design.widget.TextInputLayout>
</LinearLayout> </LinearLayout>

View file

@ -9,35 +9,27 @@
android:paddingTop="?attr/dialog_vertical_padding"> android:paddingTop="?attr/dialog_vertical_padding">
<TextView <TextView
android:id="@+id/your_account" style="@style/InputLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/your_account" android:text="@string/your_account"/>
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody" />
<Spinner <Spinner
android:id="@+id/account" android:id="@+id/account"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"/>
<TextView <android.support.design.widget.TextInputLayout
android:id="@+id/jabber_id" android:id="@+id/account_jid_layout"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:hint="@string/account_settings_jabber_id">
android:text="@string/account_settings_jabber_id"
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody" />
<AutoCompleteTextView <AutoCompleteTextView
android:id="@+id/jid" android:id="@+id/jid"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/account_settings_example_jabber_id" android:inputType="textEmailAddress"/>
android:inputType="textEmailAddress" </android.support.design.widget.TextInputLayout>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody" />
</LinearLayout> </LinearLayout>

View file

@ -7,38 +7,30 @@
android:paddingLeft="24dp" android:paddingLeft="24dp"
android:paddingRight="24dp" android:paddingRight="24dp"
android:paddingTop="16dp"> android:paddingTop="16dp">
<TextView <TextView
android:id="@+id/your_account" style="@style/InputLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/your_account" android:text="@string/your_account"/>
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody" />
<Spinner <Spinner
android:id="@+id/account" android:id="@+id/account"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView <android.support.design.widget.TextInputLayout
android:id="@+id/jabber_id" android:id="@+id/account_jid_layout"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:hint="@string/conference_address">
android:text="@string/conference_address"
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody" />
<AutoCompleteTextView <AutoCompleteTextView
android:id="@+id/jid" android:id="@+id/jid"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/conference_address_example" android:inputType="textEmailAddress"/>
android:inputType="textEmailAddress" </android.support.design.widget.TextInputLayout>
android:textColor="?attr/color_text_primary"
android:textColorHint="?attr/color_text_secondary"
android:textSize="?attr/TextSizeBody"/>
<CheckBox <CheckBox
android:id="@+id/bookmark" android:id="@+id/bookmark"
@ -46,8 +38,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:checked="true" android:checked="true"
android:text="@string/save_as_bookmark" android:text="@string/save_as_bookmark"/>
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody"/>
</LinearLayout> </LinearLayout>

View file

@ -18,8 +18,7 @@
android:id="@android:id/text1" android:id="@android:id/text1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="?attr/color_text_primary" android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="?attr/TextSizeBody"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"

View file

@ -15,6 +15,9 @@
<dimen name="publish_avatar_top_margin">8dp</dimen> <dimen name="publish_avatar_top_margin">8dp</dimen>
<dimen name="publish_avatar_size">96dp</dimen> <dimen name="publish_avatar_size">96dp</dimen>
<dimen name="input_label_vertical_spacing">4dp</dimen>
<dimen name="input_label_horizontal_spacing">4dp</dimen>
<!-- scanner --> <!-- scanner -->
<dimen name="scan_laser_width">4dp</dimen> <dimen name="scan_laser_width">4dp</dimen>
<dimen name="scan_dot_size">8dp</dimen> <dimen name="scan_dot_size">8dp</dimen>

View file

@ -2,4 +2,9 @@
<style name="TextAppearance.Conversations.Body1.Secondary" parent="TextAppearance.AppCompat.Body1"> <style name="TextAppearance.Conversations.Body1.Secondary" parent="TextAppearance.AppCompat.Body1">
<item name="android:textColor">?android:textColorSecondary</item> <item name="android:textColor">?android:textColorSecondary</item>
</style> </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> </resources>