mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
parent
b40f0ffeb0
commit
4696837f2f
@ -1118,8 +1118,14 @@
|
||||
<string name="text_secure_normal__help">Help</string>
|
||||
|
||||
<!-- reminder_header -->
|
||||
<string name="reminder_header_expired_build">Your build of Signal has expired!</string>
|
||||
<string name="reminder_header_expired_build_details">Messages will no longer send successfully, please update to the most recent version.</string>
|
||||
<string name="reminder_header_outdated_build">Your version of Signal is outdated</string>
|
||||
<plurals name="reminder_header_outdated_build_details">
|
||||
<item quantity="one">Your version of Signal will expire in 1 day. Tap to update to the most recent version.</item>
|
||||
<item quantity="other">Your version of Signal will expire in %d days. Tap to update to the most recent version.</item>
|
||||
</plurals>
|
||||
<string name="reminder_header_outdated_build_details_today">Your version of Signal will expire today. Tap to update to the most recent version.</string>
|
||||
<string name="reminder_header_expired_build">Your version of Signal has expired!</string>
|
||||
<string name="reminder_header_expired_build_details">Messages will no longer send successfully. Tap to update to the most recent version.</string>
|
||||
<string name="reminder_header_expired_build_button">UPDATE</string>
|
||||
<string name="reminder_header_sms_default_title">Use as default SMS app</string>
|
||||
<string name="reminder_header_sms_default_text">Tap to make Signal your default SMS app.</string>
|
||||
|
@ -54,6 +54,7 @@ import android.view.ViewGroup;
|
||||
import org.thoughtcrime.securesms.ConversationListAdapter.ItemClickListener;
|
||||
import org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.Reminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.ReminderView;
|
||||
@ -166,8 +167,10 @@ public class ConversationListFragment extends Fragment
|
||||
new AsyncTask<Context, Void, Optional<? extends Reminder>>() {
|
||||
@Override protected Optional<? extends Reminder> doInBackground(Context... params) {
|
||||
final Context context = params[0];
|
||||
if (ExpiredBuildReminder.isEligible(context)) {
|
||||
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)) {
|
||||
|
@ -31,8 +31,8 @@ public class ExpiredBuildReminder extends Reminder {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEligible(Context context) {
|
||||
return !Util.isBuildFresh();
|
||||
public static boolean isEligible() {
|
||||
return Util.getDaysTillBuildExpiry() <= 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
package org.thoughtcrime.securesms.components.reminder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.View;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
public class OutdatedBuildReminder extends Reminder {
|
||||
|
||||
public OutdatedBuildReminder(final Context context) {
|
||||
super(context.getString(R.string.reminder_header_outdated_build),
|
||||
getPluralsText(context));
|
||||
setOkListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
|
||||
} catch (android.content.ActivityNotFoundException anfe) {
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + context.getPackageName())));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static CharSequence getPluralsText(final Context context) {
|
||||
int days = Util.getDaysTillBuildExpiry() - 1;
|
||||
if (days == 0) {
|
||||
return context.getString(R.string.reminder_header_outdated_build_details_today);
|
||||
}
|
||||
return context.getResources().getQuantityString(R.plurals.reminder_header_outdated_build_details, days, days);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDismissable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEligible() {
|
||||
return Util.getDaysTillBuildExpiry() <= 10;
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,7 @@ public abstract class SendJob extends MasterSecretJob {
|
||||
|
||||
@Override
|
||||
public final void onRun(MasterSecret masterSecret) throws Exception {
|
||||
if (!Util.isBuildFresh()) {
|
||||
if (Util.getDaysTillBuildExpiry() <= 0) {
|
||||
throw new TextSecureExpiredException(String.format("TextSecure expired (build %d, now %d)",
|
||||
BuildConfig.BUILD_TIMESTAMP,
|
||||
System.currentTimeMillis()));
|
||||
|
@ -327,8 +327,9 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBuildFresh() {
|
||||
return BuildConfig.BUILD_TIMESTAMP + TimeUnit.DAYS.toMillis(90) > System.currentTimeMillis();
|
||||
public static int getDaysTillBuildExpiry() {
|
||||
int age = (int)TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - BuildConfig.BUILD_TIMESTAMP);
|
||||
return 90 - age;
|
||||
}
|
||||
|
||||
@TargetApi(VERSION_CODES.LOLLIPOP)
|
||||
|
Loading…
Reference in New Issue
Block a user