mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-28 02:53:57 +03:00
parent
f14711b57b
commit
cc5b91ffaf
2 changed files with 46 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
package it.niedermann.owncloud.notes.android.activity;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.sqlite.SQLiteConstraintException;
|
||||
|
@ -187,6 +189,18 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
|
|||
setupNavigationList(categoryAdapterSelectedItem);
|
||||
setupNavigationMenu();
|
||||
setupNotesList();
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
||||
if (keyguardManager != null) {
|
||||
Intent i = keyguardManager.createConfirmDeviceCredentialIntent(null, null);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivityForResult(i, 999);
|
||||
} else {
|
||||
Log.e(TAG, "Keyguard manager is null");
|
||||
// finishWithResult(-45);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package it.niedermann.owncloud.notes.util;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
/**
|
||||
* Utility class with methods for handling device credentials.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
class DeviceCredentialUtils {
|
||||
|
||||
private static final String TAG = DeviceCredentialUtils.class.getCanonicalName();
|
||||
|
||||
private DeviceCredentialUtils() {
|
||||
// utility class -> private constructor
|
||||
}
|
||||
|
||||
public static boolean areCredentialsAvailable(Context context) {
|
||||
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
|
||||
if (keyguardManager != null) {
|
||||
return keyguardManager.isKeyguardSecure();
|
||||
} else {
|
||||
Log.e(TAG, "Keyguard manager is null");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue