-
-
Notifications
You must be signed in to change notification settings - Fork 6k
/
OutdatedBuildReminder.java
45 lines (37 loc) · 1.45 KB
/
OutdatedBuildReminder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
}
}