mirror of https://github.com/M66B/FairEmail.git
Allow hiding banner for a week
This commit is contained in:
parent
bad006eeb3
commit
f5306720e1
|
@ -91,14 +91,14 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
prefs.edit().putBoolean("banner", !isChecked).apply();
|
prefs.edit().putBoolean("banner", !isChecked).apply();
|
||||||
|
|
||||||
Intent daily = new Intent(getContext(), ServiceUI.class);
|
Intent banner = new Intent(getContext(), ServiceUI.class);
|
||||||
daily.setAction("daily");
|
banner.setAction("banner");
|
||||||
PendingIntent pi = PendingIntent.getService(getContext(), ServiceUI.PI_DAILY, daily, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pi = PendingIntent.getService(getContext(), ServiceUI.PI_BANNER, banner, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
AlarmManager am = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
|
AlarmManager am = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
long interval = AlarmManager.INTERVAL_DAY;
|
long interval = AlarmManager.INTERVAL_DAY * 7;
|
||||||
long due = interval - (now % interval);
|
long due = interval - (now % interval);
|
||||||
long trigger = now + due;
|
long trigger = now + due;
|
||||||
Log.i("Set banner alarm at " + new Date(trigger) + " due=" + due);
|
Log.i("Set banner alarm at " + new Date(trigger) + " due=" + due);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class ServiceUI extends IntentService {
|
||||||
static final int PI_IGNORED = 10;
|
static final int PI_IGNORED = 10;
|
||||||
static final int PI_THREAD = 11;
|
static final int PI_THREAD = 11;
|
||||||
static final int PI_WAKEUP = 12;
|
static final int PI_WAKEUP = 12;
|
||||||
static final int PI_DAILY = 13;
|
static final int PI_BANNER = 13;
|
||||||
|
|
||||||
public ServiceUI() {
|
public ServiceUI() {
|
||||||
this(ServiceUI.class.getName());
|
this(ServiceUI.class.getName());
|
||||||
|
@ -153,8 +153,8 @@ public class ServiceUI extends IntentService {
|
||||||
onWakeup(id);
|
onWakeup(id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "daily":
|
case "banner":
|
||||||
onDaily();
|
onBanner();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown UI action: " + parts[0]);
|
throw new IllegalArgumentException("Unknown UI action: " + parts[0]);
|
||||||
|
@ -428,7 +428,7 @@ public class ServiceUI extends IntentService {
|
||||||
ServiceSynchronize.eval(ServiceUI.this, "wakeup");
|
ServiceSynchronize.eval(ServiceUI.this, "wakeup");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDaily() {
|
private void onBanner() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
prefs.edit().remove("banner").apply();
|
prefs.edit().remove("banner").apply();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1001,7 +1001,7 @@
|
||||||
To make FairEmail sustainable in the long term, some convenience and advanced features are not free to use.
|
To make FairEmail sustainable in the long term, some convenience and advanced features are not free to use.
|
||||||
FairEmail displays a small message to remind you of this, which will be removed if you purchase the pro features.
|
FairEmail displays a small message to remind you of this, which will be removed if you purchase the pro features.
|
||||||
</string>
|
</string>
|
||||||
<string name="title_pro_hide">Hide small message until tomorrow</string>
|
<string name="title_pro_hide">Hide small message for a week</string>
|
||||||
<string name="title_pro_hint">Buying pro features will allow you to use all current and future pro features, will keep this app maintained, and supported.</string>
|
<string name="title_pro_hint">Buying pro features will allow you to use all current and future pro features, will keep this app maintained, and supported.</string>
|
||||||
<string name="title_pro_price">Please see <a href="https://github.com/M66B/FairEmail/blob/master/FAQ.md#user-content-faq19">this FAQ</a> about the price of the pro features</string>
|
<string name="title_pro_price">Please see <a href="https://github.com/M66B/FairEmail/blob/master/FAQ.md#user-content-faq19">this FAQ</a> about the price of the pro features</string>
|
||||||
<string name="title_pro_pending">Purchase pending</string>
|
<string name="title_pro_pending">Purchase pending</string>
|
||||||
|
|
Loading…
Reference in New Issue