Search in sources :

Example 1 with PushRegistrationReminder

use of org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder in project Signal-Android by WhisperSystems.

the class ConversationListFragment method updateReminders.

private void updateReminders() {
    reminderView.hide();
    new AsyncTask<Context, Void, Optional<? extends Reminder>>() {

        @Override
        protected Optional<? extends Reminder> doInBackground(Context... params) {
            final Context context = params[0];
            if (ExpiredBuildReminder.isEligible()) {
                return Optional.of(new ExpiredBuildReminder(context));
            } else if (OutdatedBuildReminder.isEligible()) {
                return Optional.of(new OutdatedBuildReminder(context));
            } else if (DefaultSmsReminder.isEligible(context)) {
                return Optional.of(new DefaultSmsReminder(context));
            } else if (Util.isDefaultSmsProvider(context) && SystemSmsImportReminder.isEligible(context)) {
                return Optional.of((new SystemSmsImportReminder(context, masterSecret)));
            } else if (PushRegistrationReminder.isEligible(context)) {
                return Optional.of((new PushRegistrationReminder(context, masterSecret)));
            } else if (ShareReminder.isEligible(context)) {
                return Optional.of(new ShareReminder(context));
            } else if (DozeReminder.isEligible(context)) {
                return Optional.of(new DozeReminder(context));
            } else {
                return Optional.absent();
            }
        }

        @Override
        protected void onPostExecute(Optional<? extends Reminder> reminder) {
            if (reminder.isPresent() && getActivity() != null && !isRemoving()) {
                reminderView.showReminder(reminder.get());
            }
        }
    }.execute(getActivity());
}
Also used : Context(android.content.Context) PushRegistrationReminder(org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder) ShareReminder(org.thoughtcrime.securesms.components.reminder.ShareReminder) DozeReminder(org.thoughtcrime.securesms.components.reminder.DozeReminder) ShareReminder(org.thoughtcrime.securesms.components.reminder.ShareReminder) DefaultSmsReminder(org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder) ExpiredBuildReminder(org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder) DozeReminder(org.thoughtcrime.securesms.components.reminder.DozeReminder) SystemSmsImportReminder(org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder) OutdatedBuildReminder(org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder) PushRegistrationReminder(org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder) Reminder(org.thoughtcrime.securesms.components.reminder.Reminder) Optional(org.whispersystems.libsignal.util.guava.Optional) DefaultSmsReminder(org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder) ExpiredBuildReminder(org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder) OutdatedBuildReminder(org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder) SystemSmsImportReminder(org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder)

Example 2 with PushRegistrationReminder

use of org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder in project Signal-Android by WhisperSystems.

the class ConversationListFragment method updateReminders.

private void updateReminders() {
    Context context = requireContext();
    SimpleTask.run(getViewLifecycleOwner().getLifecycle(), () -> {
        if (UnauthorizedReminder.isEligible(context)) {
            return Optional.of(new UnauthorizedReminder(context));
        } else if (ExpiredBuildReminder.isEligible()) {
            return Optional.of(new ExpiredBuildReminder(context));
        } else if (ServiceOutageReminder.isEligible(context)) {
            ApplicationDependencies.getJobManager().add(new ServiceOutageDetectionJob());
            return Optional.of(new ServiceOutageReminder(context));
        } else if (OutdatedBuildReminder.isEligible()) {
            return Optional.of(new OutdatedBuildReminder(context));
        } else if (PushRegistrationReminder.isEligible(context)) {
            return Optional.of((new PushRegistrationReminder(context)));
        } else if (DozeReminder.isEligible(context)) {
            return Optional.of(new DozeReminder(context));
        } else {
            return Optional.<Reminder>absent();
        }
    }, reminder -> {
        if (reminder.isPresent() && getActivity() != null && !isRemoving()) {
            if (!reminderView.resolved()) {
                initializeReminderView();
            }
            reminderView.get().showReminder(reminder.get());
        } else if (reminderView.resolved() && !reminder.isPresent()) {
            reminderView.get().hide();
        }
    });
}
Also used : Context(android.content.Context) PushRegistrationReminder(org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder) DozeReminder(org.thoughtcrime.securesms.components.reminder.DozeReminder) ServiceOutageReminder(org.thoughtcrime.securesms.components.reminder.ServiceOutageReminder) ExpiredBuildReminder(org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder) OutdatedBuildReminder(org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder) UnauthorizedReminder(org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder) ServiceOutageDetectionJob(org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob)

Aggregations

Context (android.content.Context)2 DozeReminder (org.thoughtcrime.securesms.components.reminder.DozeReminder)2 ExpiredBuildReminder (org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder)2 OutdatedBuildReminder (org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder)2 PushRegistrationReminder (org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder)2 DefaultSmsReminder (org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder)1 Reminder (org.thoughtcrime.securesms.components.reminder.Reminder)1 ServiceOutageReminder (org.thoughtcrime.securesms.components.reminder.ServiceOutageReminder)1 ShareReminder (org.thoughtcrime.securesms.components.reminder.ShareReminder)1 SystemSmsImportReminder (org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder)1 UnauthorizedReminder (org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder)1 ServiceOutageDetectionJob (org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob)1 Optional (org.whispersystems.libsignal.util.guava.Optional)1