diff --git a/src/main/java/com/owncloud/android/authentication/PassCodeManager.java b/src/main/java/com/owncloud/android/authentication/PassCodeManager.java
index 53d6ff5cc6..8a7f3dcebf 100644
--- a/src/main/java/com/owncloud/android/authentication/PassCodeManager.java
+++ b/src/main/java/com/owncloud/android/authentication/PassCodeManager.java
@@ -95,6 +95,14 @@ public class PassCodeManager {
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
}
+ if (!sExemptOfPasscodeActivites.contains(activity.getClass()) && Build.VERSION.SDK_INT >=
+ Build.VERSION_CODES.M && deviceCredentialsShouldBeRequested() &&
+ !DeviceCredentialUtils.tryEncrypt()) {
+ Intent i = new Intent(MainApp.getAppContext(), RequestCredentialsActivity.class);
+ i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ activity.startActivity(i);
+ }
+
visibleActivitiesCounter++; // keep it AFTER passCodeShouldBeRequested was checked
}
@@ -134,4 +142,10 @@ public class PassCodeManager {
(PreferenceManager.isUseFingerprint(MainApp.getAppContext())
&& DeviceCredentialUtils.areCredentialsAvailable(activity));
}
+
+ private boolean deviceCredentialsShouldBeRequested() {
+ SharedPreferences appPrefs = PreferenceManager
+ .getDefaultSharedPreferences(MainApp.getAppContext());
+ return (appPrefs.getBoolean(Preferences.PREFERENCE_USE_DEVICE_CREDENTIALS, false));
+ }
}
diff --git a/src/main/java/com/owncloud/android/ui/activity/Preferences.java b/src/main/java/com/owncloud/android/ui/activity/Preferences.java
index 96f03ea8b3..9e0c20cc08 100644
--- a/src/main/java/com/owncloud/android/ui/activity/Preferences.java
+++ b/src/main/java/com/owncloud/android/ui/activity/Preferences.java
@@ -93,6 +93,9 @@ public class Preferences extends PreferenceActivity
public static final String LOCK_DEVICE_CREDENTIALS = "device_credentials";
public final static String PREFERENCE_USE_FINGERPRINT = "use_fingerprint";
+
+ public final static String PREFERENCE_USE_DEVICE_CREDENTIALS= "use_device_credentials";
+
public static final String PREFERENCE_EXPERT_MODE = "expert_mode";
private static final int ACTION_REQUEST_PASSCODE = 5;
@@ -520,6 +523,8 @@ public class Preferences extends PreferenceActivity
setupLockPreference(preferenceCategoryDetails, fPassCodeEnabled, fDeviceCredentialsEnabled);
+ setupDeviceCredentialsPreference(preferenceCategoryDetails, fDeviceCredentialsEnabled);
+
setupHiddenFilesPreference(preferenceCategoryDetails, fShowHiddenFilesEnabled);
setupExpertModePreference(preferenceCategoryDetails, fSyncedFolderLightEnabled);
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index ce94444bb0..7cd59e9267 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -44,6 +44,9 @@
android:key="lock"
android:dialogTitle="@string/prefs_lock_title"
android:defaultValue="none"/>
+