summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-12-28 16:08:48 +0100
committercyBerta <cyberta@riseup.net>2020-12-28 16:08:48 +0100
commit10a6c27ab03189cf5c504d09affedb309d1dafe6 (patch)
treea439d440282c301b18787a6ea369dadfa8e222cd /app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
parentc057256828743fd1f7ee9d735d84b3a077dac2a8 (diff)
check once a week for an app update
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java b/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
index 5ca2ec75..5b62d0ff 100644
--- a/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
@@ -22,6 +22,7 @@ import static se.leap.bitmaskclient.Constants.ALLOW_TETHERING_WIFI;
import static se.leap.bitmaskclient.Constants.ALWAYS_ON_SHOW_DIALOG;
import static se.leap.bitmaskclient.Constants.DEFAULT_SHARED_PREFS_BATTERY_SAVER;
import static se.leap.bitmaskclient.Constants.EXCLUDED_APPS;
+import static se.leap.bitmaskclient.Constants.LAST_UPDATE_CHECK;
import static se.leap.bitmaskclient.Constants.LAST_USED_PROFILE;
import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED;
import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION;
@@ -122,6 +123,14 @@ public class PreferenceHelper {
apply();
}
+ public static void setLastAppUpdateCheck(Context context) {
+ putLong(context, LAST_UPDATE_CHECK, System.currentTimeMillis());
+ }
+
+ public static long getLastAppUpdateCheck(Context context) {
+ return getLong(context, LAST_UPDATE_CHECK, 0);
+ }
+
public static void restartOnUpdate(Context context, boolean isEnabled) {
putBoolean(context, RESTART_ON_UPDATE, isEnabled);
}
@@ -223,6 +232,16 @@ public class PreferenceHelper {
return preferences.getStringSet(EXCLUDED_APPS, new HashSet<>());
}
+ public static long getLong(Context context, String key, long defValue) {
+ SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
+ return preferences.getLong(key, defValue);
+ }
+
+ public static void putLong(Context context, String key, long value) {
+ SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
+ preferences.edit().putLong(key, value).apply();
+ }
+
public static String getString(Context context, String key, String defValue) {
SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
return preferences.getString(key, defValue);