mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-10-25 14:15:48 +03:00
Fix lint warnings
This commit is contained in:
parent
804c8ac584
commit
8d3e9c223b
1 changed files with 17 additions and 21 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue