mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Add banner warning about API 19 deprecation.
This commit is contained in:
committed by
Alex Hart
parent
7617a164fc
commit
564b9f47ee
@@ -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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||
import org.thoughtcrime.securesms.util.PlayStoreUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -17,10 +19,15 @@ import java.util.List;
|
||||
public class ExpiredBuildReminder extends Reminder {
|
||||
|
||||
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));
|
||||
addAction(new Action(context.getString(R.string.ExpiredBuildReminder_update_now), R.id.reminder_action_update_now));
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
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
|
||||
|
||||
@@ -82,11 +82,11 @@ public abstract class Reminder {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
CharSequence getTitle() {
|
||||
public CharSequence getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
int getActionId() {
|
||||
public int getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user