That fuck shit the fascists are using
1package org.tm.archive.lock;
2
3
4import android.content.Context;
5
6import androidx.annotation.NonNull;
7
8import org.tm.archive.util.TextSecurePreferences;
9
10import java.util.NavigableSet;
11import java.util.TreeSet;
12import java.util.concurrent.TimeUnit;
13
14public class RegistrationLockReminders {
15
16 private static final NavigableSet<Long> INTERVALS = new TreeSet<Long>() {{
17 add(TimeUnit.HOURS.toMillis(6));
18 add(TimeUnit.HOURS.toMillis(12));
19 add(TimeUnit.DAYS.toMillis(1));
20 add(TimeUnit.DAYS.toMillis(3));
21 add(TimeUnit.DAYS.toMillis(7));
22 }};
23
24 public static final long INITIAL_INTERVAL = INTERVALS.first();
25
26 public static boolean needsReminder(@NonNull Context context) {
27 long lastReminderTime = TextSecurePreferences.getRegistrationLockLastReminderTime(context);
28 long nextIntervalTime = TextSecurePreferences.getRegistrationLockNextReminderInterval(context);
29
30 return System.currentTimeMillis() > lastReminderTime + nextIntervalTime;
31 }
32
33 public static void scheduleReminder(@NonNull Context context, boolean success) {
34 if (success) {
35 long timeSinceLastReminder = System.currentTimeMillis() - TextSecurePreferences.getRegistrationLockLastReminderTime(context);
36 Long nextReminderInterval = INTERVALS.higher(timeSinceLastReminder);
37
38 if (nextReminderInterval == null) {
39 nextReminderInterval = INTERVALS.last();
40 }
41
42 TextSecurePreferences.setRegistrationLockLastReminderTime(context, System.currentTimeMillis());
43 TextSecurePreferences.setRegistrationLockNextReminderInterval(context, nextReminderInterval);
44 } else {
45 long timeSinceLastReminder = TextSecurePreferences.getRegistrationLockLastReminderTime(context) + TimeUnit.MINUTES.toMillis(5);
46 TextSecurePreferences.setRegistrationLockLastReminderTime(context, timeSinceLastReminder);
47 }
48 }
49}