mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-02-19 20:00:09 -05:00
added donate-reminder for birthday
This commit is contained in:
parent
5693970665
commit
7b7a4eb8a5
@ -6,6 +6,7 @@ using System.Text;
|
|||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
|
using Android.Preferences;
|
||||||
using Android.Runtime;
|
using Android.Runtime;
|
||||||
using Android.Views;
|
using Android.Views;
|
||||||
using Android.Widget;
|
using Android.Widget;
|
||||||
@ -16,14 +17,76 @@ namespace keepass2android
|
|||||||
[Activity(Label = AppNames.AppName, Theme = "@style/Base")]
|
[Activity(Label = AppNames.AppName, Theme = "@style/Base")]
|
||||||
public class DonateReminder : Activity
|
public class DonateReminder : Activity
|
||||||
{
|
{
|
||||||
|
class Reminder
|
||||||
|
{
|
||||||
|
public DateTime From, To;
|
||||||
|
public int ResourceToShow;
|
||||||
|
public string Key;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnCreate(Bundle bundle)
|
protected override void OnCreate(Bundle bundle)
|
||||||
{
|
{
|
||||||
base.OnCreate(bundle);
|
base.OnCreate(bundle);
|
||||||
|
|
||||||
SetContentView(Resource.Layout.donate);
|
foreach (Reminder r in GetReminders())
|
||||||
|
{
|
||||||
|
if ((DateTime.Now > r.From)
|
||||||
|
&& (DateTime.Now < r.To))
|
||||||
|
{
|
||||||
|
SetContentView(r.ResourceToShow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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) => { Finish(); };
|
||||||
}
|
}
|
||||||
|
static IEnumerable<Reminder> GetReminders()
|
||||||
|
{
|
||||||
|
yield return new Reminder
|
||||||
|
{
|
||||||
|
From = new DateTime(2014, 09, 20),
|
||||||
|
To = new DateTime(2014, 10, 06),
|
||||||
|
Key = "DonationOktoberfest2014"
|
||||||
|
,ResourceToShow = Resource.Layout.donate
|
||||||
|
};
|
||||||
|
|
||||||
|
int thisYear = DateTime.Now.Year;
|
||||||
|
|
||||||
|
yield return new Reminder
|
||||||
|
{
|
||||||
|
From = new DateTime(thisYear, 05, 10),
|
||||||
|
To = new DateTime(thisYear, 05, 11),
|
||||||
|
Key = "DonationBirthday" + thisYear,
|
||||||
|
ResourceToShow = Resource.Layout.donate_bday
|
||||||
|
};
|
||||||
|
yield return new Reminder
|
||||||
|
{
|
||||||
|
From = new DateTime(thisYear, 05, 11),
|
||||||
|
To = new DateTime(thisYear, 05, 16),
|
||||||
|
Key = "DonationBirthday" + thisYear,
|
||||||
|
ResourceToShow = Resource.Layout.donate_bdaymissed
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ShowDonateReminderIfAppropriate(Activity context)
|
||||||
|
{
|
||||||
|
foreach (Reminder r in GetReminders())
|
||||||
|
{
|
||||||
|
if ((DateTime.Now >= r.From )
|
||||||
|
&& (DateTime.Now < r.To))
|
||||||
|
{
|
||||||
|
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context);
|
||||||
|
if (prefs.GetBoolean(r.Key, false) == false)
|
||||||
|
{
|
||||||
|
ISharedPreferencesEditor edit = prefs.Edit();
|
||||||
|
edit.PutBoolean(r.Key, true);
|
||||||
|
EditorCompat.Apply(edit);
|
||||||
|
|
||||||
|
context.StartActivity(new Intent(context, typeof(DonateReminder)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -831,20 +831,9 @@ namespace keepass2android
|
|||||||
|
|
||||||
long usageCount = prefs.GetLong(GetString(Resource.String.UsageCount_key), 0);
|
long usageCount = prefs.GetLong(GetString(Resource.String.UsageCount_key), 0);
|
||||||
|
|
||||||
if ((DateTime.Now > new DateTime(2013, 09, 21))
|
if (usageCount > 5)
|
||||||
&& (DateTime.Now < new DateTime(2013, 10, 07))
|
|
||||||
&& (usageCount > 5)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const string donationOkt2013Key = "HasAskedForDonationOktoberfest2013";
|
DonateReminder.ShowDonateReminderIfAppropriate(this);
|
||||||
if (prefs.GetBoolean(donationOkt2013Key, false) == false)
|
|
||||||
{
|
|
||||||
ISharedPreferencesEditor edit = prefs.Edit();
|
|
||||||
edit.PutBoolean(donationOkt2013Key, true);
|
|
||||||
EditorCompat.Apply(edit);
|
|
||||||
|
|
||||||
StartActivity(new Intent(this, typeof(DonateReminder)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BIN
src/keepass2android/Resources/drawable/donate_cake.png
Normal file
BIN
src/keepass2android/Resources/drawable/donate_cake.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
45
src/keepass2android/Resources/layout/donate_bday.xml
Normal file
45
src/keepass2android/Resources/layout/donate_bday.xml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/donate_question"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:text="@string/donate_bday_question" />
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imgoktfest"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/donate_question"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/donate_cake" />
|
||||||
|
<Button
|
||||||
|
android:text="@string/ok_donate"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/imgoktfest"
|
||||||
|
android:id="@+id/ok_donate"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="@string/no_thanks"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/ok_donate"
|
||||||
|
android:id="@+id/no_donate"
|
||||||
|
/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
45
src/keepass2android/Resources/layout/donate_bdaymissed.xml
Normal file
45
src/keepass2android/Resources/layout/donate_bdaymissed.xml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/donate_question"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:text="@string/donate_missedbday_question" />
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imgoktfest"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/donate_question"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/donate_cake" />
|
||||||
|
<Button
|
||||||
|
android:text="@string/ok_donate"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/imgoktfest"
|
||||||
|
android:id="@+id/ok_donate"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="@string/no_thanks"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/ok_donate"
|
||||||
|
android:id="@+id/no_donate"
|
||||||
|
/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
Loading…
x
Reference in New Issue
Block a user