From 975a121c551a06dc4d9efec0795d1284ed145459 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Sun, 17 Mar 2019 20:51:42 -0700 Subject: [PATCH] Show a warning for users on API < 19. We'll be updating minSdk to 19 in 4.37. This lets these users continue to use the app, but they'll be warned with a persistent banner saying that they can't receive updates. --- res/values/strings.xml | 1 + .../securesms/ConversationListFragment.java | 3 +++ .../UnsupportedAndroidVersionReminder.java | 23 +++++++++++++++++++ src/org/thoughtcrime/securesms/util/Util.java | 8 +++++-- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/org/thoughtcrime/securesms/components/reminder/UnsupportedAndroidVersionReminder.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 24bf38bc3..e55f37dcb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1397,6 +1397,7 @@ Invite your friends! The more friends use Signal, the better it gets. Signal is experiencing technical difficulties. We are working hard to restore service as quickly as possible. + The latest Signal features won\'t work on this version of Android. Please upgrade this device to receive future Signal updates. Save diff --git a/src/org/thoughtcrime/securesms/ConversationListFragment.java b/src/org/thoughtcrime/securesms/ConversationListFragment.java index 90852fa25..de333787b 100644 --- a/src/org/thoughtcrime/securesms/ConversationListFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationListFragment.java @@ -71,6 +71,7 @@ import org.thoughtcrime.securesms.components.reminder.ServiceOutageReminder; import org.thoughtcrime.securesms.components.reminder.ShareReminder; import org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder; import org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder; +import org.thoughtcrime.securesms.components.reminder.UnsupportedAndroidVersionReminder; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo; import org.thoughtcrime.securesms.database.loaders.ConversationListLoader; @@ -201,6 +202,8 @@ public class ConversationListFragment extends Fragment final Context context = params[0]; if (UnauthorizedReminder.isEligible(context)) { return Optional.of(new UnauthorizedReminder(context)); + } else if (UnsupportedAndroidVersionReminder.isEligible()) { + return Optional.of(new UnsupportedAndroidVersionReminder(context)); } else if (ExpiredBuildReminder.isEligible()) { return Optional.of(new ExpiredBuildReminder(context)); } else if (ServiceOutageReminder.isEligible(context)) { diff --git a/src/org/thoughtcrime/securesms/components/reminder/UnsupportedAndroidVersionReminder.java b/src/org/thoughtcrime/securesms/components/reminder/UnsupportedAndroidVersionReminder.java new file mode 100644 index 000000000..7f94ff242 --- /dev/null +++ b/src/org/thoughtcrime/securesms/components/reminder/UnsupportedAndroidVersionReminder.java @@ -0,0 +1,23 @@ +package org.thoughtcrime.securesms.components.reminder; + +import android.content.Context; +import android.os.Build; +import android.support.annotation.NonNull; + +import org.thoughtcrime.securesms.R; + +public class UnsupportedAndroidVersionReminder extends Reminder { + + public UnsupportedAndroidVersionReminder(@NonNull Context context) { + super(null, context.getString(R.string.reminder_header_the_latest_signal_features_wont_work)); + } + + @Override + public boolean isDismissable() { + return false; + } + + public static boolean isEligible() { + return Build.VERSION.SDK_INT < 19; + } +} diff --git a/src/org/thoughtcrime/securesms/util/Util.java b/src/org/thoughtcrime/securesms/util/Util.java index 3c0400c7e..3422da5b1 100644 --- a/src/org/thoughtcrime/securesms/util/Util.java +++ b/src/org/thoughtcrime/securesms/util/Util.java @@ -395,8 +395,12 @@ public class Util { } public static int getDaysTillBuildExpiry() { - int age = (int)TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - BuildConfig.BUILD_TIMESTAMP); - return 90 - age; + if (Build.VERSION.SDK_INT < 19) { + return Integer.MAX_VALUE; + } else { + int age = (int) TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - BuildConfig.BUILD_TIMESTAMP); + return 90 - age; + } } @TargetApi(VERSION_CODES.LOLLIPOP)