mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Merge branch 'password-activity-improvements' into 'master'
Improve PasswordActivity * removing screen border visible on small screens * showing noticeable error message on wrong password input * showing keyboard again after entering wrong password * making lost password link easier to recognize as link * renaming keyboard toggle method from 'hide' to 'toggle' See merge request !53
This commit is contained in:
@@ -1,65 +1,81 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
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">
|
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:id="@+id/title_password"
|
|
||||||
style="@style/BriarTextTitle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:padding="@dimen/margin_large"
|
|
||||||
android:text="@string/enter_password" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/edit_password"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/title_password"
|
android:orientation="vertical"
|
||||||
android:hint="@string/password_hint"
|
android:paddingBottom="@dimen/margin_activity_vertical"
|
||||||
android:imeOptions="actionDone"
|
android:paddingEnd="@dimen/margin_activity_horizontal"
|
||||||
android:inputType="textPassword"
|
android:paddingRight="@dimen/margin_activity_horizontal"
|
||||||
android:maxLines="1" />
|
android:paddingStart="@dimen/margin_activity_horizontal"
|
||||||
|
android:paddingLeft="@dimen/margin_activity_horizontal"
|
||||||
|
android:paddingTop="@dimen/margin_activity_vertical">
|
||||||
|
|
||||||
<Button
|
<TextView
|
||||||
android:id="@+id/btn_sign_in"
|
android:id="@+id/title_password"
|
||||||
style="@style/BriarButton.Default"
|
style="@style/BriarTextTitle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/edit_password"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="@dimen/margin_xlarge"
|
android:padding="@dimen/margin_large"
|
||||||
android:onClick="onSignInClick"
|
android:text="@string/enter_password" />
|
||||||
android:text="@string/sign_in_button" />
|
|
||||||
|
|
||||||
<ProgressBar
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/progress_wheel"
|
android:id="@+id/password_layout"
|
||||||
style="?android:attr/progressBarStyleInverse"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_alignTop="@id/btn_sign_in"
|
android:layout_below="@id/title_password"
|
||||||
android:layout_alignBottom="@id/btn_sign_in"
|
app:errorEnabled="true">
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:gravity="center"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
<TextView
|
<EditText
|
||||||
style="@style/BriarTextBody"
|
android:id="@+id/edit_password"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/btn_sign_in"
|
android:imeOptions="actionDone"
|
||||||
android:layout_centerHorizontal="true"
|
android:inputType="textPassword"
|
||||||
android:layout_marginTop="@dimen/margin_large"
|
android:maxLines="1" />
|
||||||
android:clickable="true"
|
|
||||||
android:onClick="onForgottenPasswordClick"
|
|
||||||
android:text="@string/forgotten_password"
|
|
||||||
android:textColor="?android:attr/textColorLink" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_sign_in"
|
||||||
|
style="@style/BriarButton.Default"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/password_layout"
|
||||||
|
android:layout_marginTop="@dimen/margin_medium"
|
||||||
|
android:onClick="onSignInClick"
|
||||||
|
android:text="@string/sign_in_button" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_wheel"
|
||||||
|
style="?android:attr/progressBarStyleInverse"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignTop="@id/btn_sign_in"
|
||||||
|
android:layout_alignBottom="@id/btn_sign_in"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="invisible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/BriarTextBody"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/btn_sign_in"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="@dimen/margin_large"
|
||||||
|
android:clickable="true"
|
||||||
|
android:onClick="onForgottenPasswordClick"
|
||||||
|
android:text="@string/forgotten_password"
|
||||||
|
android:textColor="?android:attr/textColorLink" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<color name="briar_primary">#2D3E50</color>
|
<color name="briar_primary">#2D3E50</color>
|
||||||
<color name="briar_primary_dark">#0f1720</color>
|
<color name="briar_primary_dark">#0f1720</color>
|
||||||
|
|
||||||
<color name="briar_text_link">#2D3E50</color>
|
<color name="briar_text_link">#75ab0d</color>
|
||||||
<color name="briar_green_light">#95d220</color>
|
<color name="briar_green_light">#95d220</color>
|
||||||
<color name="briar_green_dark">#75ab0d</color>
|
<color name="briar_green_dark">#75ab0d</color>
|
||||||
<color name="briar_text_primary">#333333</color>
|
<color name="briar_text_primary">#333333</color>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
<string name="forgotten_password">I have forgotten my password</string>
|
<string name="forgotten_password">I have forgotten my password</string>
|
||||||
<string name="try_again">Wrong password, try again:</string>
|
<string name="try_again">Wrong password, try again!</string>
|
||||||
<string name="sign_in_button">Sign In</string>
|
<string name="sign_in_button">Sign In</string>
|
||||||
<string name="startup_failed_notification_title">Briar could not start</string>
|
<string name="startup_failed_notification_title">Briar could not start</string>
|
||||||
<string name="startup_failed_notification_text">You may need to reinstall Briar.</string>
|
<string name="startup_failed_notification_text">You may need to reinstall Briar.</string>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
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.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
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;
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity
|
public abstract class BaseActivity extends AppCompatActivity
|
||||||
@@ -155,8 +157,19 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||||||
gotoAndFinish(classInstance, Integer.MIN_VALUE);
|
gotoAndFinish(classInstance, Integer.MIN_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void hideSoftKeyboard() {
|
protected void toggleSoftKeyboard() {
|
||||||
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
||||||
((InputMethodManager) o).toggleSoftInput(HIDE_IMPLICIT_ONLY, 0);
|
((InputMethodManager) o).toggleSoftInput(HIDE_IMPLICIT_ONLY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showSoftKeyboard(View view) {
|
||||||
|
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
((InputMethodManager) o).showSoftInput(view, SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void hideSoftKeyboard(View view) {
|
||||||
|
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
((InputMethodManager) o).hideSoftInputFromWindow(view.getWindowToken(),
|
||||||
|
0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import android.app.AlertDialog;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -14,6 +16,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.TextView.OnEditorActionListener;
|
import android.widget.TextView.OnEditorActionListener;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
|
import org.briarproject.android.util.AndroidUtils;
|
||||||
import org.briarproject.api.crypto.CryptoComponent;
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.api.crypto.CryptoExecutor;
|
import org.briarproject.api.crypto.CryptoExecutor;
|
||||||
import org.briarproject.api.crypto.SecretKey;
|
import org.briarproject.api.crypto.SecretKey;
|
||||||
@@ -36,6 +39,7 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
private Button signInButton;
|
private Button signInButton;
|
||||||
private ProgressBar progress;
|
private ProgressBar progress;
|
||||||
private TextView title;
|
private TextView title;
|
||||||
|
private TextInputLayout input;
|
||||||
private EditText password;
|
private EditText password;
|
||||||
|
|
||||||
private byte[] encrypted;
|
private byte[] encrypted;
|
||||||
@@ -59,16 +63,31 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
signInButton = (Button) findViewById(R.id.btn_sign_in);
|
signInButton = (Button) findViewById(R.id.btn_sign_in);
|
||||||
progress = (ProgressBar) findViewById(R.id.progress_wheel);
|
progress = (ProgressBar) findViewById(R.id.progress_wheel);
|
||||||
title = (TextView) findViewById(R.id.title_password);
|
title = (TextView) findViewById(R.id.title_password);
|
||||||
|
input = (TextInputLayout) findViewById(R.id.password_layout);
|
||||||
password = (EditText) findViewById(R.id.edit_password);
|
password = (EditText) findViewById(R.id.edit_password);
|
||||||
password.setOnEditorActionListener(new OnEditorActionListener() {
|
password.setOnEditorActionListener(new OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId,
|
public boolean onEditorAction(TextView v, int actionId,
|
||||||
KeyEvent event) {
|
KeyEvent event) {
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(password);
|
||||||
validatePassword(encrypted, password.getText());
|
validatePassword(encrypted, password.getText());
|
||||||
return true;
|
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
|
@Override
|
||||||
@@ -107,7 +126,7 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void validatePassword(final byte[] encrypted, Editable e) {
|
private void validatePassword(final byte[] encrypted, Editable e) {
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(password);
|
||||||
// Replace the button with a progress bar
|
// Replace the button with a progress bar
|
||||||
signInButton.setVisibility(INVISIBLE);
|
signInButton.setVisibility(INVISIBLE);
|
||||||
progress.setVisibility(VISIBLE);
|
progress.setVisibility(VISIBLE);
|
||||||
@@ -129,10 +148,14 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
private void tryAgain() {
|
private void tryAgain() {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
title.setText(R.string.try_again);
|
AndroidUtils.setError(input, getString(R.string.try_again),
|
||||||
|
true);
|
||||||
signInButton.setVisibility(VISIBLE);
|
signInButton.setVisibility(VISIBLE);
|
||||||
progress.setVisibility(INVISIBLE);
|
progress.setVisibility(INVISIBLE);
|
||||||
password.setText("");
|
password.setText("");
|
||||||
|
|
||||||
|
// show the keyboard again
|
||||||
|
showSoftKeyboard(password);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(v);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ public class ConversationActivity extends BriarActivity
|
|||||||
timestamp = Math.max(timestamp, getMinTimestampForNewMessage());
|
timestamp = Math.max(timestamp, getMinTimestampForNewMessage());
|
||||||
createMessage(StringUtils.toUtf8(message), timestamp);
|
createMessage(StringUtils.toUtf8(message), timestamp);
|
||||||
content.setText("");
|
content.setText("");
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getMinTimestampForNewMessage() {
|
private long getMinTimestampForNewMessage() {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ implements OnEditorActionListener, OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
|
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(textView);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ implements OnEditorActionListener, OnClickListener {
|
|||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (view == createForumButton) {
|
if (view == createForumButton) {
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(view);
|
||||||
if (!validateName()) return;
|
if (!validateName()) return;
|
||||||
createForumButton.setVisibility(GONE);
|
createForumButton.setVisibility(GONE);
|
||||||
progress.setVisibility(VISIBLE);
|
progress.setVisibility(VISIBLE);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ implements OnEditorActionListener, OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
|
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(textView);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ implements OnEditorActionListener, OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
hideSoftKeyboard();
|
hideSoftKeyboard(view);
|
||||||
if (!validateNickname()) return;
|
if (!validateNickname()) return;
|
||||||
// Replace the button with a progress bar
|
// Replace the button with a progress bar
|
||||||
createIdentityButton.setVisibility(GONE);
|
createIdentityButton.setVisibility(GONE);
|
||||||
|
|||||||
Reference in New Issue
Block a user