Add support for default credentials

This commit is contained in:
Hari 2017-10-12 00:05:08 +05:30 committed by AndyScherzinger
parent 2997b14eea
commit 528440e598
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
3 changed files with 22 additions and 0 deletions

View file

@ -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));
}
}

View file

@ -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);

View file

@ -44,6 +44,9 @@
android:key="lock"
android:dialogTitle="@string/prefs_lock_title"
android:defaultValue="none"/>
<com.owncloud.android.ui.ThemeableSwitchPreference
android:title="@string/prefs_use_device_credentials"
android:key="use_device_credentials"/>
<com.owncloud.android.ui.ThemeableSwitchPreference
android:title="@string/prefs_show_hidden_files"
android:key="show_hidden_files"/>