summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2022-12-06 12:51:59 +0100
committercyberta <cyberta@riseup.net>2022-12-06 12:51:59 +0100
commit0c3a6a5822e8af94bb168fc5423bd6be7589764d (patch)
tree2c3b60bf11c53f67a815bad9130e04bd55c32198 /app/src/main/java/se/leap
parent64427ae7fa3b6ff14d484efd3dc513744a615945 (diff)
fix: show message of thew day only once a day
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java3
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java6
2 files changed, 5 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
index 6e557236..58b057b7 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
@@ -276,7 +276,8 @@ public class StartActivity extends Activity{
String hash = message.hash();
lastSeenHashes.add(hash);
p.setMotdLastSeenHashes(lastSeenHashes);
- PreferenceHelper.persistProvider(this, p);
+ p.setLastMotdSeen(System.currentTimeMillis());
+ PreferenceHelper.persistProviderAsync(this, p);
ProviderObservable.getInstance().updateProvider(p);
}
showMotdFragment(message);
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
index 76e54794..ff3b5ab1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
@@ -95,7 +95,7 @@ public class PreferenceHelper {
return preferences.getStringSet(toFetch + "." + providerDomain, new HashSet<>());
}
- public static void persistProvider(Context context, Provider provider) {
+ public static void persistProviderAsync(Context context, Provider provider) {
SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
storeProviderInPreferences(preferences, provider, true);
}
@@ -106,7 +106,7 @@ public class PreferenceHelper {
// TODO: replace commit with apply after refactoring EIP
//FIXME: don't save private keys in shared preferences! use the keystore
- public static void storeProviderInPreferences(SharedPreferences preferences, Provider provider, boolean apply) {
+ public static void storeProviderInPreferences(SharedPreferences preferences, Provider provider, boolean async) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(PROVIDER_CONFIGURED, true).
putString(Provider.PROVIDER_IP, provider.getProviderIp()).
@@ -123,7 +123,7 @@ public class PreferenceHelper {
putStringSet(PROVIDER_MOTD_HASHES, provider.getMotdLastSeenHashes()).
putLong(PROVIDER_MOTD_LAST_SEEN, provider.getLastMotdSeen()).
putLong(PROVIDER_MOTD_LAST_UPDATED, provider.getLastMotdUpdate());
- if (apply) {
+ if (async) {
editor.apply();
} else {
editor.commit();