diff --git a/briar-android/res/layout/activity_password.xml b/briar-android/res/layout/activity_password.xml
index dff9612aa..bda170a94 100644
--- a/briar-android/res/layout/activity_password.xml
+++ b/briar-android/res/layout/activity_password.xml
@@ -1,65 +1,81 @@
-
+ android:layout_height="match_parent">
-
-
-
+ android:orientation="vertical"
+ android:paddingBottom="@dimen/margin_activity_vertical"
+ android:paddingEnd="@dimen/margin_activity_horizontal"
+ android:paddingRight="@dimen/margin_activity_horizontal"
+ android:paddingStart="@dimen/margin_activity_horizontal"
+ android:paddingLeft="@dimen/margin_activity_horizontal"
+ android:paddingTop="@dimen/margin_activity_vertical">
-
+
-
+
-
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/briar-android/res/values/color.xml b/briar-android/res/values/color.xml
index 0ecc0f1ba..28cddbd4f 100644
--- a/briar-android/res/values/color.xml
+++ b/briar-android/res/values/color.xml
@@ -17,7 +17,7 @@
#2D3E50
#0f1720
- #2D3E50
+ #75ab0d
#95d220
#75ab0d
#333333
diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml
index db7f2bfc4..4934dceab 100644
--- a/briar-android/res/values/strings.xml
+++ b/briar-android/res/values/strings.xml
@@ -19,7 +19,7 @@
Yes
No
I have forgotten my password
- Wrong password, try again:
+ Wrong password, try again!
Sign In
Briar could not start
You may need to reinstall Briar.
diff --git a/briar-android/src/org/briarproject/android/BaseActivity.java b/briar-android/src/org/briarproject/android/BaseActivity.java
index f6b3641f3..6eabbc7df 100644
--- a/briar-android/src/org/briarproject/android/BaseActivity.java
+++ b/briar-android/src/org/briarproject/android/BaseActivity.java
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
+import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.google.inject.Inject;
@@ -31,6 +32,7 @@ import roboguice.util.RoboContext;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
+import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
public abstract class BaseActivity extends AppCompatActivity
@@ -155,8 +157,13 @@ public abstract class BaseActivity extends AppCompatActivity
gotoAndFinish(classInstance, Integer.MIN_VALUE);
}
- protected void hideSoftKeyboard() {
+ protected void toggleSoftKeyboard() {
Object o = getSystemService(INPUT_METHOD_SERVICE);
((InputMethodManager) o).toggleSoftInput(HIDE_IMPLICIT_ONLY, 0);
}
+
+ protected void showSoftKeyboard(View view) {
+ Object o = getSystemService(INPUT_METHOD_SERVICE);
+ ((InputMethodManager) o).showSoftInput(view, SHOW_IMPLICIT);
+ }
}
diff --git a/briar-android/src/org/briarproject/android/PasswordActivity.java b/briar-android/src/org/briarproject/android/PasswordActivity.java
index fed1a6201..60b7cd118 100644
--- a/briar-android/src/org/briarproject/android/PasswordActivity.java
+++ b/briar-android/src/org/briarproject/android/PasswordActivity.java
@@ -4,7 +4,9 @@ import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
+import android.support.design.widget.TextInputLayout;
import android.text.Editable;
+import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
@@ -14,6 +16,7 @@ import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import org.briarproject.R;
+import org.briarproject.android.util.AndroidUtils;
import org.briarproject.api.crypto.CryptoComponent;
import org.briarproject.api.crypto.CryptoExecutor;
import org.briarproject.api.crypto.SecretKey;
@@ -36,6 +39,7 @@ public class PasswordActivity extends BaseActivity {
private Button signInButton;
private ProgressBar progress;
private TextView title;
+ private TextInputLayout input;
private EditText password;
private byte[] encrypted;
@@ -59,16 +63,31 @@ public class PasswordActivity extends BaseActivity {
signInButton = (Button) findViewById(R.id.btn_sign_in);
progress = (ProgressBar) findViewById(R.id.progress_wheel);
title = (TextView) findViewById(R.id.title_password);
+ input = (TextInputLayout) findViewById(R.id.password_layout);
password = (EditText) findViewById(R.id.edit_password);
password.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
- hideSoftKeyboard();
+ toggleSoftKeyboard();
validatePassword(encrypted, password.getText());
return true;
}
});
+ password.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count,
+ int after) {}
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before,
+ int count) {
+ if (count > 0) AndroidUtils.setError(input, null, false);
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {}
+ });
}
@Override
@@ -107,7 +126,7 @@ public class PasswordActivity extends BaseActivity {
}
private void validatePassword(final byte[] encrypted, Editable e) {
- hideSoftKeyboard();
+ toggleSoftKeyboard();
// Replace the button with a progress bar
signInButton.setVisibility(INVISIBLE);
progress.setVisibility(VISIBLE);
@@ -129,10 +148,14 @@ public class PasswordActivity extends BaseActivity {
private void tryAgain() {
runOnUiThread(new Runnable() {
public void run() {
- title.setText(R.string.try_again);
+ AndroidUtils.setError(input, getString(R.string.try_again),
+ true);
signInButton.setVisibility(VISIBLE);
progress.setVisibility(INVISIBLE);
password.setText("");
+
+ // show the keyboard again
+ showSoftKeyboard(password);
}
});
}
diff --git a/briar-android/src/org/briarproject/android/SetupActivity.java b/briar-android/src/org/briarproject/android/SetupActivity.java
index 2713b9984..f80b3d313 100644
--- a/briar-android/src/org/briarproject/android/SetupActivity.java
+++ b/briar-android/src/org/briarproject/android/SetupActivity.java
@@ -129,7 +129,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
}
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- hideSoftKeyboard();
+ toggleSoftKeyboard();
return true;
}
diff --git a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
index 585778ed5..a0d553711 100644
--- a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
+++ b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
@@ -411,7 +411,7 @@ public class ConversationActivity extends BriarActivity
timestamp = Math.max(timestamp, getMinTimestampForNewMessage());
createMessage(StringUtils.toUtf8(message), timestamp);
content.setText("");
- hideSoftKeyboard();
+ toggleSoftKeyboard();
}
private long getMinTimestampForNewMessage() {
diff --git a/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java b/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java
index 89c230e18..750a98483 100644
--- a/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java
+++ b/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java
@@ -110,7 +110,7 @@ implements OnEditorActionListener, OnClickListener {
}
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
- hideSoftKeyboard();
+ toggleSoftKeyboard();
return true;
}
@@ -126,7 +126,7 @@ implements OnEditorActionListener, OnClickListener {
public void onClick(View view) {
if (view == createForumButton) {
- hideSoftKeyboard();
+ toggleSoftKeyboard();
if (!validateName()) return;
createForumButton.setVisibility(GONE);
progress.setVisibility(VISIBLE);
diff --git a/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java b/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java
index 81c348273..660470e88 100644
--- a/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java
+++ b/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java
@@ -118,7 +118,7 @@ implements OnEditorActionListener, OnClickListener {
}
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
- hideSoftKeyboard();
+ toggleSoftKeyboard();
return true;
}
@@ -134,7 +134,7 @@ implements OnEditorActionListener, OnClickListener {
}
public void onClick(View view) {
- hideSoftKeyboard();
+ toggleSoftKeyboard();
if (!validateNickname()) return;
// Replace the button with a progress bar
createIdentityButton.setVisibility(GONE);