From 63fb5d98cca5368389e1c7a522b68c051f4dcb04 Mon Sep 17 00:00:00 2001
From: SoyaLeaf <597231656@qq.com>
Date: Sat, 17 Feb 2018 14:09:21 +0800
Subject: [PATCH] Change ShowHidePasswordEditText to TextInputEditText.
change the input fields in the AccountActivity to use the TextInputLayout.
Rollback format and change toggle tint
---
.gitignore | 1 +
build.gradle | 2 +-
gradle.properties | 19 +-
.../ui/ChangePasswordActivity.java | 5 -
.../conversations/ui/EditAccountActivity.java | 38 +++-
src/main/res/drawable/ic_visibility.xml | 9 +
src/main/res/drawable/ic_visibility_off.xml | 9 +
.../drawable/visibility_toggle_drawable.xml | 5 +
.../res/layout/activity_change_password.xml | 64 +++---
src/main/res/layout/activity_edit_account.xml | 207 ++++++++----------
10 files changed, 194 insertions(+), 165 deletions(-)
create mode 100644 src/main/res/drawable/ic_visibility.xml
create mode 100644 src/main/res/drawable/ic_visibility_off.xml
create mode 100644 src/main/res/drawable/visibility_toggle_drawable.xml
diff --git a/.gitignore b/.gitignore
index 81a61fc22..9921b2ffb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@ src/playstore/res/values/gcm.xml
# https://github.com/github/gitignore/blob/master/Gradle.gitignore
.gradle/
build/
+gradle.properties
captures/
signing.properties
# Ignore Gradle GUI config
diff --git a/build.gradle b/build.gradle
index 7833fc76d..722492254 100644
--- a/build.gradle
+++ b/build.gradle
@@ -41,6 +41,7 @@ dependencies {
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:support-emoji-appcompat:$supportLibVersion"
implementation "com.android.support:support-emoji:$supportLibVersion"
+ implementation "com.android.support:design:$supportLibVersion"
freeImplementation "com.android.support:support-emoji-bundled:$supportLibVersion"
implementation 'org.bouncycastle:bcmail-jdk15on:1.58'
implementation 'org.jitsi:org.otr4j:0.22'
@@ -53,7 +54,6 @@ dependencies {
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation "com.wefika:flowlayout:0.4.1"
implementation 'net.ypresto.androidtranscoder:android-transcoder:0.2.0'
- implementation 'com.github.scottyab:showhidepasswordedittext:0.8'
}
ext {
diff --git a/gradle.properties b/gradle.properties
index 4a9594aee..a73918612 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1 +1,18 @@
-org.gradle.jvmargs=-Xmx2048M
\ No newline at end of file
+## Project-wide Gradle settings.
+#
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+#
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx1024m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+#
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+#Sat Feb 17 18:50:27 CST 2018
+systemProp.http.proxyHost=127.0.0.1
+org.gradle.jvmargs=-Xmx2048M
+systemProp.http.proxyPort=1080
diff --git a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java
index 3a7db5a2f..6af47f880 100644
--- a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java
@@ -5,7 +5,6 @@ import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
-import android.widget.TextView;
import android.widget.Toast;
import eu.siacs.conversations.R;
@@ -39,7 +38,6 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
}
}
};
- private TextView mCurrentPasswordLabel;
private EditText mCurrentPassword;
private EditText mNewPassword;
private Account mAccount;
@@ -48,10 +46,8 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
void onBackendConnected() {
this.mAccount = extractAccount(getIntent());
if (this.mAccount != null && this.mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) {
- this.mCurrentPasswordLabel.setVisibility(View.GONE);
this.mCurrentPassword.setVisibility(View.GONE);
} else {
- this.mCurrentPasswordLabel.setVisibility(View.VISIBLE);
this.mCurrentPassword.setVisibility(View.VISIBLE);
}
}
@@ -64,7 +60,6 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
mCancelButton.setOnClickListener(view -> finish());
this.mChangePasswordButton = findViewById(R.id.right_button);
this.mChangePasswordButton.setOnClickListener(this.mOnChangePasswordButtonClicked);
- this.mCurrentPasswordLabel = findViewById(R.id.current_password_label);
this.mCurrentPassword = findViewById(R.id.current_password);
this.mCurrentPassword.setCustomSelectionActionModeCallback(new DisabledActionModeCallback());
this.mNewPassword = findViewById(R.id.new_password);
diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index 2cbb26c28..98c8a22a6 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -1,7 +1,5 @@
package eu.siacs.conversations.ui;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AlertDialog.Builder;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
@@ -10,11 +8,14 @@ import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
import android.provider.Settings;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AlertDialog.Builder;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
@@ -50,9 +51,9 @@ import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.BarcodeProvider;
-import eu.siacs.conversations.services.XmppConnectionService.OnCaptchaRequested;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
+import eu.siacs.conversations.services.XmppConnectionService.OnCaptchaRequested;
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.ui.widget.DisabledActionModeCallback;
import eu.siacs.conversations.utils.CryptoHelper;
@@ -272,8 +273,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
private boolean mSavedInstanceInit = false;
private Button mClearDevicesButton;
private XmppUri pendingUri = null;
+ private boolean mUseTor;
- public void refreshUiReal() {
+ public void refreshUiReal() {
invalidateOptionsMenu();
if (mAccount != null
&& mAccount.getStatus() != Account.State.ONLINE
@@ -356,7 +358,25 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
}
};
- private final OnClickListener mAvatarClickListener = new OnClickListener() {
+ private View.OnFocusChangeListener mEditTextFocusListener = new View.OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View view, boolean b) {
+ EditText et = (EditText) view;
+ if (b) {
+ int resId = mUsernameMode ? R.string.username : R.string.account_settings_example_jabber_id;
+ if (view.getId() == R.id.hostname) {
+ resId = mUseTor ? R.string.hostname_or_onion : R.string.hostname_example;
+ }
+ final int res = resId;
+ new Handler().postDelayed(() -> et.setHint(res),200);
+ } else {
+ et.setHint(null);
+ }
+ }
+ };
+
+
+ private final OnClickListener mAvatarClickListener = new OnClickListener() {
@Override
public void onClick(final View view) {
if (mAccount != null) {
@@ -514,7 +534,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
setContentView(R.layout.activity_edit_account);
this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
this.mAccountJid.addTextChangedListener(this.mTextWatcher);
- this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label);
+ this.mAccountJid.setOnFocusChangeListener(this.mEditTextFocusListener);
this.mPassword = (EditText) findViewById(R.id.account_password);
this.mPassword.addTextChangedListener(this.mTextWatcher);
this.mAvatar = (ImageView) findViewById(R.id.avater);
@@ -553,6 +573,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.mNamePort = (LinearLayout) findViewById(R.id.name_port);
this.mHostname = (EditText) findViewById(R.id.hostname);
this.mHostname.addTextChangedListener(mTextWatcher);
+ this.mHostname.setOnFocusChangeListener(mEditTextFocusListener);
this.mClearDevicesButton = (Button) findViewById(R.id.clear_devices);
this.mClearDevicesButton.setOnClickListener(new OnClickListener() {
@Override
@@ -668,9 +689,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
}
}
SharedPreferences preferences = getPreferences();
- boolean useTor = Config.FORCE_ORBOT || preferences.getBoolean("use_tor", false);
- this.mShowOptions = useTor || preferences.getBoolean("show_connection_options", false);
- mHostname.setHint(useTor ? R.string.hostname_or_onion : R.string.hostname_example);
+ mUseTor = Config.FORCE_ORBOT || preferences.getBoolean("use_tor", false);
+ this.mShowOptions = mUseTor || preferences.getBoolean("show_connection_options", false);
this.mNamePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
}
diff --git a/src/main/res/drawable/ic_visibility.xml b/src/main/res/drawable/ic_visibility.xml
new file mode 100644
index 000000000..e02f1d191
--- /dev/null
+++ b/src/main/res/drawable/ic_visibility.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/src/main/res/drawable/ic_visibility_off.xml b/src/main/res/drawable/ic_visibility_off.xml
new file mode 100644
index 000000000..689f3f47c
--- /dev/null
+++ b/src/main/res/drawable/ic_visibility_off.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/src/main/res/drawable/visibility_toggle_drawable.xml b/src/main/res/drawable/visibility_toggle_drawable.xml
new file mode 100644
index 000000000..9c887e7e9
--- /dev/null
+++ b/src/main/res/drawable/visibility_toggle_drawable.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ 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 cab48c47b..5faa05567 100644
--- a/src/main/res/layout/activity_change_password.xml
+++ b/src/main/res/layout/activity_change_password.xml
@@ -1,9 +1,9 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?attr/color_background_secondary">
-
-
+ android:layout_height="wrap_content"
+ app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
+ app:passwordToggleEnabled="true"
+ app:passwordToggleTint="?attr/color_text_secondary">
-
-
+ android:textSize="?attr/TextSizeBody" />
+
-
-
-
+ android:layout_height="wrap_content"
+ app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
+ app:passwordToggleEnabled="true"
+ app:passwordToggleTint="?attr/color_text_secondary">
-
-
+ android:textSize="?attr/TextSizeBody" />
+
@@ -89,14 +77,14 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/cancel"/>
+ android:text="@string/cancel" />
+ android:background="?attr/divider" />
+ android:text="@string/change_password" />
\ No newline at end of file
diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml
index 4953e07f7..677a4388c 100644
--- a/src/main/res/layout/activity_edit_account.xml
+++ b/src/main/res/layout/activity_edit_account.xml
@@ -1,10 +1,10 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?attr/color_background_secondary">
+ app:riv_corner_radius="2dp" />
-
-
-
+ android:hint="@string/account_settings_jabber_id">
-
+
+
-
+ android:layout_height="wrap_content"
+ app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
+ app:passwordToggleEnabled="true"
+ app:passwordToggleTint="?attr/color_text_secondary">
-
-
-
+ android:textSize="?attr/TextSizeBody" />
+
-
+ android:hint="@string/account_settings_hostname">
-
+
+
+ android:orientation="vertical">
-
-
-
+ android:layout_height="wrap_content"
+ android:hint="@string/account_settings_port">
+
+
+
@@ -157,7 +142,7 @@
android:layout_marginTop="8dp"
android:text="@string/register_account"
android:textColor="?attr/color_text_primary"
- android:textSize="?attr/TextSizeBody"/>
+ android:textSize="?attr/TextSizeBody" />
@@ -181,7 +166,7 @@
android:text="@string/battery_optimizations_enabled"
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeHeadline"
- android:textStyle="bold"/>
+ android:textStyle="bold" />
+ android:textSize="?attr/TextSizeBody" />
+ android:textColor="@color/accent" />
@@ -240,7 +225,7 @@
android:singleLine="true"
android:text="@string/server_info_session_established"
android:textColor="?attr/color_text_primary"
- android:textSize="?attr/TextSizeBody"/>
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
@@ -274,7 +259,7 @@
android:singleLine="true"
android:text="@string/server_info_pep"
android:textColor="?attr/color_text_primary"
- android:textSize="?attr/TextSizeBody"/>
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
+ android:textSize="?attr/TextSizeBody" />
+ tools:ignore="RtlHardcoded" />
+ android:textSize="?attr/TextSizeBody" />
+ android:textSize="?attr/TextSizeBody" />
+ android:textSize="?attr/TextSizeBody" />
+ android:textSize="?attr/TextSizeBody" />
@@ -500,7 +485,7 @@
android:fontFamily="monospace"
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeBody"
- android:typeface="monospace"/>
+ android:typeface="monospace" />
+ android:textSize="?attr/TextSizeInfo" />
+ android:visibility="visible" />
+ android:typeface="monospace" />
+ android:textSize="?attr/TextSizeInfo" />
+ android:visibility="visible" />
+
+ android:typeface="monospace" />
+ android:textSize="?attr/TextSizeInfo" />
+ android:visibility="visible" />
+ android:visibility="gone" />
@@ -655,7 +641,7 @@
android:text="@string/other_devices"
android:textColor="?attr/color_text_primary"
android:textSize="?attr/TextSizeHeadline"
- android:textStyle="bold"/>
+ android:textStyle="bold" />
-
+ android:showDividers="middle">
+ android:textColor="@color/accent" />
@@ -695,14 +680,14 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/cancel"
- android:textColor="?attr/color_text_primary"/>
+ android:textColor="?attr/color_text_primary" />
+ android:background="?attr/divider" />
+ android:textColor="?attr/color_text_secondary" />