mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-12 04:25:09 -05:00
added option to hide donation screens
This commit is contained in:
parent
ff77a04710
commit
d0350e8d9d
@ -30,7 +30,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
foreach (Reminder r in GetReminders())
|
foreach (Reminder r in GetReminders())
|
||||||
{
|
{
|
||||||
if ((DateTime.Now > r.From)
|
if ((DateTime.Now >= r.From)
|
||||||
&& (DateTime.Now < r.To))
|
&& (DateTime.Now < r.To))
|
||||||
{
|
{
|
||||||
SetContentView(r.ResourceToShow);
|
SetContentView(r.ResourceToShow);
|
||||||
@ -38,7 +38,16 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
FindViewById(Resource.Id.ok_donate).Click += (sender, args) => { Util.GotoDonateUrl(this);Finish(); };
|
FindViewById(Resource.Id.ok_donate).Click += (sender, args) => { Util.GotoDonateUrl(this);Finish(); };
|
||||||
FindViewById(Resource.Id.no_donate).Click += (sender, args) => { Finish(); };
|
FindViewById(Resource.Id.no_donate).Click += (sender, args) =>
|
||||||
|
{
|
||||||
|
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
ISharedPreferencesEditor edit = prefs.Edit();
|
||||||
|
edit.PutBoolean("DismissedDonateReminder", true);
|
||||||
|
EditorCompat.Apply(edit);
|
||||||
|
|
||||||
|
Finish();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
static IEnumerable<Reminder> GetReminders()
|
static IEnumerable<Reminder> GetReminders()
|
||||||
{
|
{
|
||||||
@ -60,17 +69,34 @@ namespace keepass2android
|
|||||||
yield return new Reminder
|
yield return new Reminder
|
||||||
{
|
{
|
||||||
From = new DateTime(2017, 09, 16),
|
From = new DateTime(2017, 09, 16),
|
||||||
To = new DateTime(2017, 10, 04),
|
To = new DateTime(2017, 09, 25),
|
||||||
Key = "DonationOktoberfest2017b"//b because year was incorrectly set to 2015 in 0.9.8b
|
Key = "DonationOktoberfest2017b"//b because year was incorrectly set to 2015 in 0.9.8b
|
||||||
,ResourceToShow = Resource.Layout.donate
|
,
|
||||||
|
ResourceToShow = Resource.Layout.donate
|
||||||
|
};
|
||||||
|
yield return new Reminder
|
||||||
|
{
|
||||||
|
From = new DateTime(2017, 09, 25),
|
||||||
|
To = new DateTime(2017, 10, 04),
|
||||||
|
Key = "DonationOktoberfest2017b-2"
|
||||||
|
,
|
||||||
|
ResourceToShow = Resource.Layout.donate
|
||||||
};
|
};
|
||||||
yield return new Reminder
|
yield return new Reminder
|
||||||
{
|
{
|
||||||
From = new DateTime(2018, 09, 22),
|
From = new DateTime(2018, 09, 22),
|
||||||
To = new DateTime(2018, 10, 08),
|
To = new DateTime(2018, 03, 30),
|
||||||
Key = "DonationOktoberfest2018b"//b because year was incorrectly set to 2015 in 0.9.8b
|
Key = "DonationOktoberfest2018b"//b because year was incorrectly set to 2015 in 0.9.8b
|
||||||
,ResourceToShow = Resource.Layout.donate
|
,ResourceToShow = Resource.Layout.donate
|
||||||
};
|
};
|
||||||
|
yield return new Reminder
|
||||||
|
{
|
||||||
|
From = new DateTime(2018, 09, 30),
|
||||||
|
To = new DateTime(2018, 10, 08),
|
||||||
|
Key = "DonationOktoberfest2018b-2"
|
||||||
|
,
|
||||||
|
ResourceToShow = Resource.Layout.donate
|
||||||
|
};
|
||||||
|
|
||||||
int thisYear = DateTime.Now.Year;
|
int thisYear = DateTime.Now.Year;
|
||||||
|
|
||||||
@ -92,12 +118,20 @@ namespace keepass2android
|
|||||||
|
|
||||||
public static void ShowDonateReminderIfAppropriate(Activity context)
|
public static void ShowDonateReminderIfAppropriate(Activity context)
|
||||||
{
|
{
|
||||||
|
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context);
|
||||||
|
if (prefs.GetBoolean(context.GetString(Resource.String.NoDonationReminder_key), false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
long usageCount = prefs.GetLong(context.GetString(Resource.String.UsageCount_key), 0);
|
||||||
|
|
||||||
|
if (usageCount <= 5)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (Reminder r in GetReminders())
|
foreach (Reminder r in GetReminders())
|
||||||
{
|
{
|
||||||
if ((DateTime.Now >= r.From )
|
if ((DateTime.Now >= r.From )
|
||||||
&& (DateTime.Now < r.To))
|
&& (DateTime.Now < r.To))
|
||||||
{
|
{
|
||||||
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context);
|
|
||||||
if (prefs.GetBoolean(r.Key, false) == false)
|
if (prefs.GetBoolean(r.Key, false) == false)
|
||||||
{
|
{
|
||||||
ISharedPreferencesEditor edit = prefs.Edit();
|
ISharedPreferencesEditor edit = prefs.Edit();
|
||||||
@ -105,6 +139,7 @@ namespace keepass2android
|
|||||||
EditorCompat.Apply(edit);
|
EditorCompat.Apply(edit);
|
||||||
|
|
||||||
context.StartActivity(new Intent(context, typeof(DonateReminder)));
|
context.StartActivity(new Intent(context, typeof(DonateReminder)));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1575,14 +1575,8 @@ namespace keepass2android
|
|||||||
base.OnStart();
|
base.OnStart();
|
||||||
_starting = true;
|
_starting = true;
|
||||||
|
|
||||||
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
|
|
||||||
|
|
||||||
long usageCount = prefs.GetLong(GetString(Resource.String.UsageCount_key), 0);
|
|
||||||
|
|
||||||
if (usageCount > 5)
|
|
||||||
{
|
|
||||||
DonateReminder.ShowDonateReminderIfAppropriate(this);
|
DonateReminder.ShowDonateReminderIfAppropriate(this);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +148,13 @@ namespace keepass2android
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnStart()
|
||||||
|
{
|
||||||
|
base.OnStart();
|
||||||
|
DonateReminder.ShowDonateReminderIfAppropriate(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
|
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
|
||||||
{
|
{
|
||||||
if (requestCode == FingerprintPermissionRequestCode && grantResults[0] == Permission.Granted)
|
if (requestCode == FingerprintPermissionRequestCode && grantResults[0] == Permission.Granted)
|
||||||
|
@ -107,6 +107,7 @@
|
|||||||
<string name="LockWhenNavigateBack_key">kp2a_switch_rootedLockWhenNavigateBack</string>
|
<string name="LockWhenNavigateBack_key">kp2a_switch_rootedLockWhenNavigateBack</string>
|
||||||
|
|
||||||
<string name="NoDonateOption_key">NoDonateOption</string>
|
<string name="NoDonateOption_key">NoDonateOption</string>
|
||||||
|
<string name="NoDonationReminder_key">NoDonationReminder</string>
|
||||||
|
|
||||||
<string name="UseOfflineCache_key">UseOfflineCache</string>
|
<string name="UseOfflineCache_key">UseOfflineCache</string>
|
||||||
<string name="AcceptAllServerCertificates_key">AcceptAllServerCertificates</string>
|
<string name="AcceptAllServerCertificates_key">AcceptAllServerCertificates</string>
|
||||||
|
@ -331,6 +331,9 @@
|
|||||||
<string name="NoDonateOption_summary">This setting is for donators. It is available after using Keepass2Android for a while only.</string>
|
<string name="NoDonateOption_summary">This setting is for donators. It is available after using Keepass2Android for a while only.</string>
|
||||||
<string name="NoDonateOption_question">Without donations, this app would not exist and would not be improved continually! If you have not yet donated, please consider making a donation now.</string>
|
<string name="NoDonateOption_question">Without donations, this app would not exist and would not be improved continually! If you have not yet donated, please consider making a donation now.</string>
|
||||||
|
|
||||||
|
<string name="NoDonationReminder_title">Never ever ask for donation</string>
|
||||||
|
<string name="NoDonationReminder_summary">I won\'t give you a dime or I have already donated. Don\'t ask for a donation, not even at the author\'s birthday.</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="UseOfflineCache_title">Database caching</string>
|
<string name="UseOfflineCache_title">Database caching</string>
|
||||||
<string name="UseOfflineCache_summary">Keep a copy of remote database files in the application cache directory. This allows to use remote databases even when offline.</string>
|
<string name="UseOfflineCache_summary">Keep a copy of remote database files in the application cache directory. This allows to use remote databases even when offline.</string>
|
||||||
|
@ -233,6 +233,14 @@
|
|||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:title="@string/NoDonateOption_title"
|
android:title="@string/NoDonateOption_title"
|
||||||
android:key="@string/NoDonateOption_key" />
|
android:key="@string/NoDonateOption_key" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:enabled="true"
|
||||||
|
android:persistent="true"
|
||||||
|
android:summary="@string/NoDonationReminder_summary"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:title="@string/NoDonationReminder_title"
|
||||||
|
android:key="@string/NoDonationReminder_key" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
@ -337,6 +337,7 @@ namespace keepass2android
|
|||||||
FindPreference(GetString(Resource.String.keyfile_key)).PreferenceChange += OnRememberKeyFileHistoryChanged;
|
FindPreference(GetString(Resource.String.keyfile_key)).PreferenceChange += OnRememberKeyFileHistoryChanged;
|
||||||
FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged;
|
FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged;
|
||||||
PrepareNoDonatePreference(Activity, FindPreference(GetString(Resource.String.NoDonateOption_key)));
|
PrepareNoDonatePreference(Activity, FindPreference(GetString(Resource.String.NoDonateOption_key)));
|
||||||
|
PrepareNoDonationReminderPreference(Activity, ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key))), FindPreference(GetString(Resource.String.NoDonationReminder_key)));
|
||||||
|
|
||||||
FindPreference(GetString(Resource.String.design_key)).PreferenceChange += (sender, args) => Activity.Recreate();
|
FindPreference(GetString(Resource.String.design_key)).PreferenceChange += (sender, args) => Activity.Recreate();
|
||||||
|
|
||||||
@ -422,6 +423,18 @@ namespace keepass2android
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrepareNoDonationReminderPreference(Activity ctx, PreferenceScreen screen, Preference preference)
|
||||||
|
{
|
||||||
|
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(ctx);
|
||||||
|
|
||||||
|
if (!prefs.GetBoolean("DismissedDonateReminder", false))
|
||||||
|
{
|
||||||
|
screen.RemovePreference(preference);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupErrorReportModePref(ListPreference errorReportModePref)
|
private void SetupErrorReportModePref(ListPreference errorReportModePref)
|
||||||
|
Loading…
Reference in New Issue
Block a user