Fix lint warnings

This commit is contained in:
Christoph Loy 2020-03-02 18:20:48 +01:00
parent 804c8ac584
commit 8d3e9c223b
No known key found for this signature in database
GPG key ID: 9179970615A6E7C9

View file

@ -3,6 +3,7 @@ package it.niedermann.owncloud.notes.android.activity;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
@ -26,7 +27,7 @@ public abstract class LockedActivity extends AppCompatActivity {
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
if(isTaskRoot()) {
if (isTaskRoot()) {
askToUnlock();
}
}
@ -52,31 +53,26 @@ public abstract class LockedActivity extends AppCompatActivity {
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_CODE_UNLOCK: {
if (resultCode == RESULT_OK) {
Log.v(TAG, "Successfully unlocked device");
Notes.unlock();
} else {
Log.e(TAG, "Result code of unlocking was " + resultCode);
finish();
}
break;
if (requestCode == REQUEST_CODE_UNLOCK) {
if (resultCode == RESULT_OK) {
Log.v(TAG, "Successfully unlocked device");
Notes.unlock();
} else {
Log.e(TAG, "Result code of unlocking was " + resultCode);
finish();
}
}
}
private void askToUnlock() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
if (Notes.isLocked()) {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if (keyguardManager != null) {
Intent i = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.unlock_notes), null);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(i, REQUEST_CODE_UNLOCK);
} else {
Log.e(TAG, "Keyguard manager is null");
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Notes.isLocked()) {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if (keyguardManager != null) {
Intent i = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.unlock_notes), null);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(i, REQUEST_CODE_UNLOCK);
} else {
Log.e(TAG, "Keyguard manager is null");
}
}
}