summaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/wireguard/android/preference/DonatePreference.java44
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/preferences.xml1
3 files changed, 47 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/android/preference/DonatePreference.java b/app/src/main/java/com/wireguard/android/preference/DonatePreference.java
new file mode 100644
index 00000000..6ae0622c
--- /dev/null
+++ b/app/src/main/java/com/wireguard/android/preference/DonatePreference.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2019 WireGuard LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package com.wireguard.android.preference;
+
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.util.AttributeSet;
+
+import com.wireguard.android.Application;
+import com.wireguard.android.BuildConfig;
+import com.wireguard.android.R;
+
+import java.util.Locale;
+
+import androidx.annotation.Nullable;
+import androidx.preference.Preference;
+
+public class DonatePreference extends Preference {
+ public DonatePreference(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public CharSequence getSummary() { return getContext().getString(R.string.donate_summary); }
+
+ @Override
+ public CharSequence getTitle() { return getContext().getString(R.string.donate_title); }
+
+ @Override
+ protected void onClick() {
+ final Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse("https://www.wireguard.com/donations/"));
+ try {
+ getContext().startActivity(intent);
+ } catch (final ActivityNotFoundException ignored) {
+ }
+ }
+
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3751cb05..bed5abc1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -66,6 +66,8 @@
<string name="dark_theme_title">Use dark theme</string>
<string name="delete">Delete</string>
<string name="deselect_all">Deselect All</string>
+ <string name="donate_title">♥ Donate to the WireGuard Project</string>
+ <string name="donate_summary">Every contribution helps.</string>
<string name="dns_servers">DNS servers</string>
<string name="edit">Edit</string>
<string name="endpoint">Endpoint</string>
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 27f5d1f3..ce96a4e5 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -15,4 +15,5 @@
android:summaryOff="@string/dark_theme_summary_off"
android:summaryOn="@string/dark_theme_summary_on"
android:title="@string/dark_theme_title" />
+ <com.wireguard.android.preference.DonatePreference />
</androidx.preference.PreferenceScreen>