mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Move lock timestamp pref to AppPreferences
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
parent
63b057d7de
commit
44625a08e4
4 changed files with 15 additions and 7 deletions
|
@ -109,5 +109,8 @@ public interface AppPreferences {
|
|||
float getGridColumns();
|
||||
void setGridColumns(float gridColumns);
|
||||
|
||||
long getLockTimestamp();
|
||||
void setLockTimestamp(long timestamp);
|
||||
|
||||
void removeLegacyPreferences();
|
||||
}
|
||||
|
|
|
@ -489,12 +489,12 @@ public final class PreferenceManager implements AppPreferences {
|
|||
saveIntPreference(context, AUTO_PREF__LAST_SEEN_VERSION_CODE, versionCode);
|
||||
}
|
||||
|
||||
public static long getLockTimestamp(Context context) {
|
||||
return getDefaultSharedPreferences(context).getLong(PREF__LOCK_TIMESTAMP, 0);
|
||||
public long getLockTimestamp() {
|
||||
return preferences.getLong(PREF__LOCK_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
public static void setLockTimestamp(Context context, long timestamp) {
|
||||
saveLongPreference(context, PREF__LOCK_TIMESTAMP, timestamp);
|
||||
public void setLockTimestamp(long timestamp) {
|
||||
preferences.edit().putLong(PREF__LOCK_TIMESTAMP, timestamp).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,7 +78,7 @@ public final class PassCodeManager {
|
|||
}
|
||||
|
||||
public void onActivityStarted(Activity activity) {
|
||||
Long timestamp = PreferenceManager.getLockTimestamp(activity);
|
||||
Long timestamp = PreferenceManager.fromContext(activity).getLockTimestamp();
|
||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) && passCodeShouldBeRequested(timestamp)) {
|
||||
|
||||
Intent i = new Intent(MainApp.getAppContext(), PassCodeActivity.class);
|
||||
|
@ -110,7 +110,7 @@ public final class PassCodeManager {
|
|||
}
|
||||
|
||||
private void setUnlockTimestamp(Activity activity) {
|
||||
PreferenceManager.setLockTimestamp(activity, System.currentTimeMillis());
|
||||
PreferenceManager.fromContext(activity).setLockTimestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private boolean passCodeShouldBeRequested(Long timestamp) {
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.request.animation.GlideAnimation;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.PreferenceManager;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
|
@ -204,6 +205,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|||
private ExternalLinksProvider externalLinksProvider;
|
||||
private ArbitraryDataProvider arbitraryDataProvider;
|
||||
|
||||
private AppPreferences preferences;
|
||||
|
||||
/**
|
||||
* Initializes the drawer, its content and highlights the menu item with the given id.
|
||||
* This method needs to be called after the content view has been set.
|
||||
|
@ -1150,6 +1153,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
preferences = PreferenceManager.fromContext(this);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mIsAccountChooserActive = savedInstanceState.getBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, false);
|
||||
mCheckedMenuItem = savedInstanceState.getInt(KEY_CHECKED_MENU_ITEM, Menu.NONE);
|
||||
|
@ -1254,7 +1259,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|||
|
||||
if (result == RequestCredentialsActivity.KEY_CHECK_RESULT_CANCEL) {
|
||||
Log_OC.d(TAG, "PassCodeManager cancelled");
|
||||
PreferenceManager.setLockTimestamp(this, 0);
|
||||
preferences.setLockTimestamp(0);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue