summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-12 12:00:33 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-12 18:55:28 +0200
commitd8bad72fd620e788b259c8d9a78836dbdc78b973 (patch)
tree285f9f3ea910e904b45072b862cc358bb0921e32 /app/src/main/java/com/wireguard
parent927b32c99f60966ca558053f13e37b2561c33cf9 (diff)
preferences: add donation link
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard')
-rw-r--r--app/src/main/java/com/wireguard/android/preference/DonatePreference.java44
1 files changed, 44 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) {
+ }
+ }
+
+}