Fixed PIN reminders showing too often, reminder UI improvements.

This commit is contained in:
Greyson Parrelli
2020-02-11 11:34:10 -05:00
parent 944adb5d7c
commit 0b6a52277d
5 changed files with 76 additions and 35 deletions

View File

@@ -13,13 +13,12 @@ import org.thoughtcrime.securesms.database.model.MegaphoneRecord;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.lock.RegistrationLockDialog;
import org.thoughtcrime.securesms.lock.RegistrationLockReminders;
import org.thoughtcrime.securesms.lock.SignalPinReminderDialog;
import org.thoughtcrime.securesms.lock.SignalPinReminders;
import org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity;
import org.thoughtcrime.securesms.lock.v2.KbsMigrationActivity;
import org.thoughtcrime.securesms.lock.v2.PinUtil;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.util.FeatureFlags;
import java.util.LinkedHashMap;
@@ -42,6 +41,8 @@ import java.util.Objects;
*/
public final class Megaphones {
private static final String TAG = Log.tag(Megaphones.class);
private Megaphones() {}
static @Nullable Megaphone getNextMegaphone(@NonNull Context context, @NonNull Map<Event, MegaphoneRecord> records) {
@@ -81,7 +82,7 @@ public final class Megaphones {
return new LinkedHashMap<Event, MegaphoneSchedule>() {{
put(Event.REACTIONS, new ForeverSchedule(true));
put(Event.PINS_FOR_ALL, new PinsForAllSchedule());
put(Event.PIN_REMINDER, new PinReminderSchedule());
put(Event.PIN_REMINDER, new SignalPinReminderSchedule());
}};
}
@@ -161,15 +162,17 @@ public final class Megaphones {
SignalPinReminderDialog.show(controller.getMegaphoneActivity(), controller::onMegaphoneNavigationRequested, new SignalPinReminderDialog.Callback() {
@Override
public void onReminderDismissed(boolean includedFailure) {
Log.i(TAG, "[PinReminder] onReminderDismissed(" + includedFailure + ")");
if (includedFailure) {
SignalStore.pinValues().onEntryFailure();
SignalStore.pinValues().onEntrySkipWithWrongGuess();
}
}
@Override
public void onReminderCompleted(boolean includedFailure) {
Log.i(TAG, "[PinReminder] onReminderCompleted(" + includedFailure + ")");
if (includedFailure) {
SignalStore.pinValues().onEntryFailure();
SignalStore.pinValues().onEntrySuccessWithWrongGuess();
} else {
SignalStore.pinValues().onEntrySuccess();
}

View File

@@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.megaphone;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.FeatureFlags;
final class PinReminderSchedule implements MegaphoneSchedule {
final class SignalPinReminderSchedule implements MegaphoneSchedule {
@Override
public boolean shouldDisplay(int seenCount, long lastSeen, long firstVisible, long currentTime) {