Add banner warning about API 19 deprecation.
This commit is contained in:
parent
7617a164fc
commit
564b9f47ee
7 changed files with 114 additions and 5 deletions
|
@ -0,0 +1,45 @@
|
||||||
|
package org.thoughtcrime.securesms.components.reminder
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import org.thoughtcrime.securesms.R
|
||||||
|
import org.thoughtcrime.securesms.util.Util
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shown when a user has API 19.
|
||||||
|
*/
|
||||||
|
class Api19Reminder(context: Context) : Reminder(null, context.getString(R.string.API19Reminder_banner_message, getExpireDate())) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
addAction(
|
||||||
|
Action(
|
||||||
|
context.getString(R.string.API19Reminder_learn_more),
|
||||||
|
R.id.reminder_action_api_19_learn_more
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isDismissable(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getImportance(): Importance {
|
||||||
|
return Importance.TERMINAL
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun isEligible(): Boolean {
|
||||||
|
return Build.VERSION.SDK_INT < 21 && !ExpiredBuildReminder.isEligible()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getExpireDate(): String {
|
||||||
|
val formatter = SimpleDateFormat("MMMM d", Locale.getDefault())
|
||||||
|
val expireDate = Date(System.currentTimeMillis() + Util.getTimeUntilBuildExpiry())
|
||||||
|
return formatter.format(expireDate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package org.thoughtcrime.securesms.components.reminder;
|
package org.thoughtcrime.securesms.components.reminder;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
|
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||||
import org.thoughtcrime.securesms.util.PlayStoreUtil;
|
import org.thoughtcrime.securesms.util.PlayStoreUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,10 +19,15 @@ import java.util.List;
|
||||||
public class ExpiredBuildReminder extends Reminder {
|
public class ExpiredBuildReminder extends Reminder {
|
||||||
|
|
||||||
public ExpiredBuildReminder(final Context context) {
|
public ExpiredBuildReminder(final Context context) {
|
||||||
super(null, context.getString(R.string.ExpiredBuildReminder_this_version_of_signal_has_expired));
|
super(null, Build.VERSION.SDK_INT < 21
|
||||||
|
? context.getString(R.string.ExpiredBuildReminder_api_19_message)
|
||||||
|
: context.getString(R.string.ExpiredBuildReminder_this_version_of_signal_has_expired));
|
||||||
|
|
||||||
setOkListener(v -> PlayStoreUtil.openPlayStoreOrOurApkDownloadPage(context));
|
if (Build.VERSION.SDK_INT < 21) {
|
||||||
addAction(new Action(context.getString(R.string.ExpiredBuildReminder_update_now), R.id.reminder_action_update_now));
|
addAction(new Action(context.getString(R.string.API19Reminder_learn_more), R.id.reminder_action_api_19_learn_more));
|
||||||
|
} else {
|
||||||
|
addAction(new Action(context.getString(R.string.ExpiredBuildReminder_update_now), R.id.reminder_action_update_now));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -82,11 +82,11 @@ public abstract class Reminder {
|
||||||
this.actionId = actionId;
|
this.actionId = actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
CharSequence getTitle() {
|
public CharSequence getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getActionId() {
|
public int getActionId() {
|
||||||
return actionId;
|
return actionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1936,6 +1936,8 @@ public class ConversationParentFragment extends Fragment
|
||||||
InsightsLauncher.showInsightsDashboard(getChildFragmentManager());
|
InsightsLauncher.showInsightsDashboard(getChildFragmentManager());
|
||||||
} else if (reminderActionId == R.id.reminder_action_update_now) {
|
} else if (reminderActionId == R.id.reminder_action_update_now) {
|
||||||
PlayStoreUtil.openPlayStoreOrOurApkDownloadPage(requireContext());
|
PlayStoreUtil.openPlayStoreOrOurApkDownloadPage(requireContext());
|
||||||
|
} else if (reminderActionId == R.id.reminder_action_api_19_learn_more) {
|
||||||
|
CommunicationActions.openBrowserLink(requireContext(), "https://support.signal.org/hc/articles/5109141421850");
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown ID: " + reminderActionId);
|
throw new IllegalArgumentException("Unknown ID: " + reminderActionId);
|
||||||
}
|
}
|
||||||
|
@ -2974,6 +2976,11 @@ public class ConversationParentFragment extends Fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMediaMessage(@NonNull MediaSendActivityResult result) {
|
private void sendMediaMessage(@NonNull MediaSendActivityResult result) {
|
||||||
|
if (ExpiredBuildReminder.isEligible()) {
|
||||||
|
showExpiredDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long thread = this.threadId;
|
long thread = this.threadId;
|
||||||
long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
|
long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
|
||||||
QuoteModel quote = result.isViewOnce() ? null : inputPanel.getQuote().orElse(null);
|
QuoteModel quote = result.isViewOnce() ? null : inputPanel.getQuote().orElse(null);
|
||||||
|
@ -3052,6 +3059,11 @@ public class ConversationParentFragment extends Fragment
|
||||||
final boolean clearComposeBox,
|
final boolean clearComposeBox,
|
||||||
final @Nullable String metricId)
|
final @Nullable String metricId)
|
||||||
{
|
{
|
||||||
|
if (ExpiredBuildReminder.isEligible()) {
|
||||||
|
showExpiredDialog();
|
||||||
|
return new SettableFuture<>(null);
|
||||||
|
}
|
||||||
|
|
||||||
if (!viewModel.isDefaultSmsApplication() && sendType.usesSmsTransport() && recipient.get().hasSmsAddress()) {
|
if (!viewModel.isDefaultSmsApplication() && sendType.usesSmsTransport() && recipient.get().hasSmsAddress()) {
|
||||||
showDefaultSmsPrompt();
|
showDefaultSmsPrompt();
|
||||||
return new SettableFuture<>(null);
|
return new SettableFuture<>(null);
|
||||||
|
@ -3130,6 +3142,11 @@ public class ConversationParentFragment extends Fragment
|
||||||
private void sendTextMessage(@NonNull MessageSendType sendType, final long expiresIn, final boolean initiating, final @Nullable String metricId)
|
private void sendTextMessage(@NonNull MessageSendType sendType, final long expiresIn, final boolean initiating, final @Nullable String metricId)
|
||||||
throws InvalidMessageException
|
throws InvalidMessageException
|
||||||
{
|
{
|
||||||
|
if (ExpiredBuildReminder.isEligible()) {
|
||||||
|
showExpiredDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!viewModel.isDefaultSmsApplication() && sendType.usesSmsTransport() && recipient.get().hasSmsAddress()) {
|
if (!viewModel.isDefaultSmsApplication() && sendType.usesSmsTransport() && recipient.get().hasSmsAddress()) {
|
||||||
showDefaultSmsPrompt();
|
showDefaultSmsPrompt();
|
||||||
return;
|
return;
|
||||||
|
@ -3172,6 +3189,29 @@ public class ConversationParentFragment extends Fragment
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showExpiredDialog() {
|
||||||
|
Reminder reminder = new ExpiredBuildReminder(requireContext());
|
||||||
|
|
||||||
|
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setMessage(reminder.getText())
|
||||||
|
.setPositiveButton(android.R.string.ok, (d, w) -> d.dismiss());
|
||||||
|
|
||||||
|
List<Reminder.Action> actions = reminder.getActions();
|
||||||
|
if (actions.size() == 1) {
|
||||||
|
Reminder.Action action = actions.get(0);
|
||||||
|
|
||||||
|
builder.setNeutralButton(action.getTitle(), (d, i) -> {
|
||||||
|
if (action.getActionId() == R.id.reminder_action_update_now) {
|
||||||
|
PlayStoreUtil.openPlayStoreOrOurApkDownloadPage(requireContext());
|
||||||
|
} else if (action.getActionId() == R.id.reminder_action_api_19_learn_more) {
|
||||||
|
CommunicationActions.openBrowserLink(requireContext(), "https://support.signal.org/hc/articles/5109141421850");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateToggleButtonState() {
|
private void updateToggleButtonState() {
|
||||||
if (inputPanel.isRecordingInLockedMode()) {
|
if (inputPanel.isRecordingInLockedMode()) {
|
||||||
buttonToggle.display(sendButton);
|
buttonToggle.display(sendButton);
|
||||||
|
|
|
@ -97,6 +97,7 @@ import org.thoughtcrime.securesms.components.menu.ActionItem;
|
||||||
import org.thoughtcrime.securesms.components.menu.SignalBottomActionBar;
|
import org.thoughtcrime.securesms.components.menu.SignalBottomActionBar;
|
||||||
import org.thoughtcrime.securesms.components.menu.SignalContextMenu;
|
import org.thoughtcrime.securesms.components.menu.SignalContextMenu;
|
||||||
import org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton;
|
import org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton;
|
||||||
|
import org.thoughtcrime.securesms.components.reminder.Api19Reminder;
|
||||||
import org.thoughtcrime.securesms.components.reminder.CdsPermanentErrorReminder;
|
import org.thoughtcrime.securesms.components.reminder.CdsPermanentErrorReminder;
|
||||||
import org.thoughtcrime.securesms.components.reminder.CdsTemporyErrorReminder;
|
import org.thoughtcrime.securesms.components.reminder.CdsTemporyErrorReminder;
|
||||||
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
|
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
|
||||||
|
@ -158,6 +159,7 @@ import org.thoughtcrime.securesms.stories.tabs.ConversationListTabsViewModel;
|
||||||
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
||||||
import org.thoughtcrime.securesms.util.AppStartup;
|
import org.thoughtcrime.securesms.util.AppStartup;
|
||||||
import org.thoughtcrime.securesms.util.BottomSheetUtil;
|
import org.thoughtcrime.securesms.util.BottomSheetUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||||
import org.thoughtcrime.securesms.util.ConversationUtil;
|
import org.thoughtcrime.securesms.util.ConversationUtil;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.LifecycleDisposable;
|
import org.thoughtcrime.securesms.util.LifecycleDisposable;
|
||||||
|
@ -681,6 +683,8 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
||||||
CdsTemporaryErrorBottomSheet.show(getChildFragmentManager());
|
CdsTemporaryErrorBottomSheet.show(getChildFragmentManager());
|
||||||
} else if (reminderActionId == R.id.reminder_action_cds_permanent_error_learn_more) {
|
} else if (reminderActionId == R.id.reminder_action_cds_permanent_error_learn_more) {
|
||||||
CdsPermanentErrorBottomSheet.show(getChildFragmentManager());
|
CdsPermanentErrorBottomSheet.show(getChildFragmentManager());
|
||||||
|
} else if (reminderActionId == R.id.reminder_action_api_19_learn_more) {
|
||||||
|
CommunicationActions.openBrowserLink(requireContext(), "https://support.signal.org/hc/articles/5109141421850");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,6 +946,8 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
||||||
} else if (ServiceOutageReminder.isEligible(context)) {
|
} else if (ServiceOutageReminder.isEligible(context)) {
|
||||||
ApplicationDependencies.getJobManager().add(new ServiceOutageDetectionJob());
|
ApplicationDependencies.getJobManager().add(new ServiceOutageDetectionJob());
|
||||||
return Optional.of(new ServiceOutageReminder(context));
|
return Optional.of(new ServiceOutageReminder(context));
|
||||||
|
} else if (Api19Reminder.isEligible()) {
|
||||||
|
return Optional.of(new Api19Reminder(context));
|
||||||
} else if (OutdatedBuildReminder.isEligible()) {
|
} else if (OutdatedBuildReminder.isEligible()) {
|
||||||
return Optional.of(new OutdatedBuildReminder(context));
|
return Optional.of(new OutdatedBuildReminder(context));
|
||||||
} else if (PushRegistrationReminder.isEligible(context)) {
|
} else if (PushRegistrationReminder.isEligible(context)) {
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
<item name="reminder_action_cds_temporary_error_learn_more" type="id" />
|
<item name="reminder_action_cds_temporary_error_learn_more" type="id" />
|
||||||
<item name="reminder_action_cds_permanent_error_learn_more" type="id" />
|
<item name="reminder_action_cds_permanent_error_learn_more" type="id" />
|
||||||
|
|
||||||
|
<item name="reminder_action_api_19_learn_more" type="id" />
|
||||||
|
|
||||||
<item name="status_bar_guideline" type="id" />
|
<item name="status_bar_guideline" type="id" />
|
||||||
<item name="navigation_bar_guideline" type="id" />
|
<item name="navigation_bar_guideline" type="id" />
|
||||||
|
|
||||||
|
|
|
@ -653,6 +653,9 @@
|
||||||
<string name="ExpiredBuildReminder_this_version_of_signal_has_expired">This version of Signal has expired. Update now to send and receive messages.</string>
|
<string name="ExpiredBuildReminder_this_version_of_signal_has_expired">This version of Signal has expired. Update now to send and receive messages.</string>
|
||||||
<string name="ExpiredBuildReminder_update_now">Update now</string>
|
<string name="ExpiredBuildReminder_update_now">Update now</string>
|
||||||
|
|
||||||
|
<!-- A message in a banner shown at the top of the screen indicating that the user must upgrade their device to use signal. -->
|
||||||
|
<string name="ExpiredBuildReminder_api_19_message">Signal no longer works on this device. To use Signal again, update your device to a newer version of Android or switch to a newer device.</string>
|
||||||
|
|
||||||
<!-- PendingGroupJoinRequestsReminder -->
|
<!-- PendingGroupJoinRequestsReminder -->
|
||||||
<plurals name="PendingGroupJoinRequestsReminder_d_pending_member_requests">
|
<plurals name="PendingGroupJoinRequestsReminder_d_pending_member_requests">
|
||||||
<item quantity="one">%d pending member request.</item>
|
<item quantity="one">%d pending member request.</item>
|
||||||
|
@ -5482,4 +5485,10 @@
|
||||||
<!-- Displayed in the "clear filter" item in the chat feed if the user opened the filter from the overflow menu -->
|
<!-- Displayed in the "clear filter" item in the chat feed if the user opened the filter from the overflow menu -->
|
||||||
<string name="ChatFilter__tip_pull_down">Tip: Pull down on the chat list to filter</string>
|
<string name="ChatFilter__tip_pull_down">Tip: Pull down on the chat list to filter</string>
|
||||||
|
|
||||||
|
<!-- Text for a banner that is shown at the top of the screen letting users know that they're version of signal will soon expire. The placeholder is a date. -->
|
||||||
|
<string name="API19Reminder_banner_message">Signal will no longer support your device\'s version of Android soon. To keep using Signal, update your device, or switch to a newer device by %1$s.</string>
|
||||||
|
|
||||||
|
<!-- Text for a button in a banner shown at the top of the screen that users can click on to get more information. -->
|
||||||
|
<string name="API19Reminder_learn_more">Learn more</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Reference in a new issue