Fix issue "home button" issue with screen lock

Fixes #7475
This commit is contained in:
Moxie Marlinspike 2018-03-09 10:25:29 -08:00
parent 29fcce23b1
commit 1a24885110
3 changed files with 42 additions and 7 deletions

View File

@ -51,7 +51,7 @@
<TextView android:layout_width="match_parent" <TextView android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="40dp" android:layout_marginBottom="40dp"
android:text="@string/prompt_passphrase_activity__unlock_signal" android:text="@string/prompt_passphrase_activity__signal_is_locked"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:textSize="25sp"/> android:textSize="25sp"/>
@ -66,6 +66,18 @@
android:layout_marginBottom="60dp" android:layout_marginBottom="60dp"
tools:visibility="visible"/> tools:visibility="visible"/>
<TextView android:id="@+id/lock_screen_auth_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_rectangle_dark"
android:backgroundTint="@color/signal_primary"
android:textColor="@color/white"
android:gravity="center_horizontal"
android:elevation="3dp"
android:padding="10dp"
android:text="@string/prompt_passphrase_activity__tap_to_unlock"
tools:visibility="gone"/>
<RelativeLayout android:id="@+id/password_auth_container" <RelativeLayout android:id="@+id/password_auth_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -1399,6 +1399,8 @@
<string name="RegistrationLockDialog_disable">Disable</string> <string name="RegistrationLockDialog_disable">Disable</string>
<string name="RegistrationActivity_continue">Continue</string> <string name="RegistrationActivity_continue">Continue</string>
<string name="preferences_chats__backups">Backups</string> <string name="preferences_chats__backups">Backups</string>
<string name="prompt_passphrase_activity__signal_is_locked">Signal is locked</string>
<string name="prompt_passphrase_activity__tap_to_unlock">TAP TO UNLOCK</string>
<!-- EOF --> <!-- EOF -->
</resources> </resources>

View File

@ -70,7 +70,9 @@ public class PassphrasePromptActivity extends PassphraseActivity {
private DynamicIntroTheme dynamicTheme = new DynamicIntroTheme(); private DynamicIntroTheme dynamicTheme = new DynamicIntroTheme();
private DynamicLanguage dynamicLanguage = new DynamicLanguage(); private DynamicLanguage dynamicLanguage = new DynamicLanguage();
private View passphraseAuthContainer;
private ImageView fingerprintPrompt; private ImageView fingerprintPrompt;
private TextView lockScreenButton;
private EditText passphraseText; private EditText passphraseText;
private ImageButton showButton; private ImageButton showButton;
@ -82,6 +84,7 @@ public class PassphrasePromptActivity extends PassphraseActivity {
private FingerprintListener fingerprintListener; private FingerprintListener fingerprintListener;
private boolean authenticated; private boolean authenticated;
private boolean failure;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -102,9 +105,13 @@ public class PassphrasePromptActivity extends PassphraseActivity {
dynamicTheme.onResume(this); dynamicTheme.onResume(this);
dynamicLanguage.onResume(this); dynamicLanguage.onResume(this);
if (TextSecurePreferences.isScreenLockEnabled(this) && !authenticated) { setLockTypeVisibility();
if (TextSecurePreferences.isScreenLockEnabled(this) && !authenticated && !failure) {
resumeScreenLock(); resumeScreenLock();
} }
failure = false;
} }
@Override @Override
@ -149,7 +156,7 @@ public class PassphrasePromptActivity extends PassphraseActivity {
handleAuthenticated(); handleAuthenticated();
} else { } else {
Log.w(TAG, "Authentication failed"); Log.w(TAG, "Authentication failed");
finish(); failure = true;
} }
} }
@ -196,15 +203,17 @@ public class PassphrasePromptActivity extends PassphraseActivity {
} }
private void initializeResources() { private void initializeResources() {
View passphraseAuthContainer = findViewById(R.id.password_auth_container);
ImageButton okButton = findViewById(R.id.ok_button); ImageButton okButton = findViewById(R.id.ok_button);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
showButton = findViewById(R.id.passphrase_visibility); showButton = findViewById(R.id.passphrase_visibility);
hideButton = findViewById(R.id.passphrase_visibility_off); hideButton = findViewById(R.id.passphrase_visibility_off);
visibilityToggle = findViewById(R.id.button_toggle); visibilityToggle = findViewById(R.id.button_toggle);
passphraseText = findViewById(R.id.passphrase_edit); passphraseText = findViewById(R.id.passphrase_edit);
passphraseAuthContainer = findViewById(R.id.password_auth_container);
fingerprintPrompt = findViewById(R.id.fingerprint_auth_container); fingerprintPrompt = findViewById(R.id.fingerprint_auth_container);
lockScreenButton = findViewById(R.id.lock_screen_auth_container);
fingerprintManager = FingerprintManagerCompat.from(this); fingerprintManager = FingerprintManagerCompat.from(this);
fingerprintCancellationSignal = new CancellationSignal(); fingerprintCancellationSignal = new CancellationSignal();
fingerprintListener = new FingerprintListener(); fingerprintListener = new FingerprintListener();
@ -227,12 +236,24 @@ public class PassphrasePromptActivity extends PassphraseActivity {
fingerprintPrompt.setImageResource(R.drawable.ic_fingerprint_white_48dp); fingerprintPrompt.setImageResource(R.drawable.ic_fingerprint_white_48dp);
fingerprintPrompt.getBackground().setColorFilter(getResources().getColor(R.color.signal_primary), PorterDuff.Mode.SRC_IN); fingerprintPrompt.getBackground().setColorFilter(getResources().getColor(R.color.signal_primary), PorterDuff.Mode.SRC_IN);
lockScreenButton.setOnClickListener(v -> resumeScreenLock());
}
private void setLockTypeVisibility() {
if (TextSecurePreferences.isScreenLockEnabled(this)) { if (TextSecurePreferences.isScreenLockEnabled(this)) {
passphraseAuthContainer.setVisibility(View.GONE); passphraseAuthContainer.setVisibility(View.GONE);
fingerprintPrompt.setVisibility(View.VISIBLE);
if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
fingerprintPrompt.setVisibility(View.VISIBLE);
lockScreenButton.setVisibility(View.GONE);
} else {
fingerprintPrompt.setVisibility(View.GONE);
lockScreenButton.setVisibility(View.VISIBLE);
}
} else { } else {
passphraseAuthContainer.setVisibility(View.VISIBLE); passphraseAuthContainer.setVisibility(View.VISIBLE);
fingerprintPrompt.setVisibility(View.GONE); fingerprintPrompt.setVisibility(View.GONE);
lockScreenButton.setVisibility(View.GONE);
} }
} }