mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
parent
aff65abe91
commit
41d06fc8c2
@ -14,23 +14,6 @@ public class RegistrationLockReminders {
|
||||
|
||||
public static final long INITIAL_INTERVAL = TimeUnit.HOURS.toMillis(6);
|
||||
|
||||
private static Map<Long, Long> INTERVAL_PROGRESSION = new HashMap<Long, Long>() {{
|
||||
put(TimeUnit.HOURS.toMillis(6), TimeUnit.HOURS.toMillis(12));
|
||||
put(TimeUnit.HOURS.toMillis(12), TimeUnit.DAYS.toMillis(1));
|
||||
put(TimeUnit.DAYS.toMillis(1), TimeUnit.DAYS.toMillis(3));
|
||||
put(TimeUnit.DAYS.toMillis(3), TimeUnit.DAYS.toMillis(7));
|
||||
put(TimeUnit.DAYS.toMillis(7), TimeUnit.DAYS.toMillis(7));
|
||||
}};
|
||||
|
||||
|
||||
private static Map<Long, Long> INTERVAL_REGRESSION = new HashMap<Long, Long>() {{
|
||||
put(TimeUnit.HOURS.toMillis(12), TimeUnit.HOURS.toMillis(6));
|
||||
put(TimeUnit.DAYS.toMillis(1), TimeUnit.HOURS.toMillis(12));
|
||||
put(TimeUnit.DAYS.toMillis(3), TimeUnit.DAYS.toMillis(1));
|
||||
put(TimeUnit.DAYS.toMillis(7), TimeUnit.DAYS.toMillis(3));
|
||||
}};
|
||||
|
||||
|
||||
public static boolean needsReminder(@NonNull Context context) {
|
||||
if (!TextSecurePreferences.isRegistrationtLockEnabled(context)) return false;
|
||||
|
||||
@ -45,11 +28,16 @@ public class RegistrationLockReminders {
|
||||
long nextReminderInterval;
|
||||
|
||||
if (success) {
|
||||
if (INTERVAL_PROGRESSION.containsKey(lastReminderInterval)) nextReminderInterval = INTERVAL_PROGRESSION.get(lastReminderInterval);
|
||||
else nextReminderInterval = INTERVAL_PROGRESSION.get(TimeUnit.HOURS.toMillis(6));
|
||||
if (lastReminderInterval <= TimeUnit.HOURS.toMillis(6)) nextReminderInterval = TimeUnit.HOURS.toMillis(12);
|
||||
else if (lastReminderInterval <= TimeUnit.HOURS.toMillis(12)) nextReminderInterval = TimeUnit.DAYS.toMillis(1);
|
||||
else if (lastReminderInterval <= TimeUnit.DAYS.toMillis(1)) nextReminderInterval = TimeUnit.DAYS.toMillis(3);
|
||||
else if (lastReminderInterval <= TimeUnit.DAYS.toMillis(3)) nextReminderInterval = TimeUnit.DAYS.toMillis(7);
|
||||
else nextReminderInterval = TimeUnit.DAYS.toMillis(7);
|
||||
} else {
|
||||
if (INTERVAL_REGRESSION.containsKey(lastReminderInterval)) nextReminderInterval = INTERVAL_REGRESSION.get(lastReminderInterval);
|
||||
else nextReminderInterval = INTERVAL_REGRESSION.get(TimeUnit.HOURS.toMillis(12));
|
||||
if (lastReminderInterval >= TimeUnit.DAYS.toMillis(7)) nextReminderInterval = TimeUnit.DAYS.toMillis(3);
|
||||
else if (lastReminderInterval >= TimeUnit.DAYS.toMillis(3)) nextReminderInterval = TimeUnit.DAYS.toMillis(1);
|
||||
else if (lastReminderInterval >= TimeUnit.DAYS.toMillis(1)) nextReminderInterval = TimeUnit.HOURS.toMillis(12);
|
||||
else nextReminderInterval = TimeUnit.HOURS.toMillis(6);
|
||||
}
|
||||
|
||||
TextSecurePreferences.setRegistrationLockLastReminderTime(context, System.currentTimeMillis());
|
||||
|
Loading…
x
Reference in New Issue
Block a user