From 0fb78ba6fc16b00d0b375e49b2368be937745072 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 23 Mar 2023 13:43:35 +0100 Subject: ui: bring back donation button For Google Play Store builds, we'll display an alert box. This was inspired by the discussion around StreetComplete; hopefully we'll have a similar okay outcome. Link: https://github.com/streetcomplete/streetcomplete/issues/3768 Signed-off-by: Jason A. Donenfeld --- .../android/preference/DonatePreference.kt | 38 ++++++++++++++++++++++ ui/src/main/res/values/strings.xml | 3 ++ ui/src/main/res/xml/preferences.xml | 2 ++ 3 files changed, 43 insertions(+) create mode 100644 ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt (limited to 'ui/src') diff --git a/ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt b/ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt new file mode 100644 index 00000000..57202c81 --- /dev/null +++ b/ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt @@ -0,0 +1,38 @@ +/* + * Copyright © 2017-2023 WireGuard LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.wireguard.android.preference + +import android.app.AlertDialog +import android.content.ActivityNotFoundException +import android.content.Context +import android.content.Intent +import android.net.Uri +import android.util.AttributeSet +import androidx.preference.Preference +import com.wireguard.android.BuildConfig +import com.wireguard.android.R + +class DonatePreference(context: Context, attrs: AttributeSet?) : Preference(context, attrs) { + override fun getSummary() = context.getString(R.string.donate_summary) + + override fun getTitle() = context.getString(R.string.donate_title) + + override fun onClick() { + if (BuildConfig.IS_GOOGLE_PLAY) { + AlertDialog.Builder(context) + .setTitle(R.string.donate_title) + .setMessage(R.string.donate_google_play_disappointment) + .show() + return + } + val intent = Intent(Intent.ACTION_VIEW) + intent.data = Uri.parse("https://www.wireguard.com/donations/") + try { + context.startActivity(intent) + } catch (ignored: ActivityNotFoundException) { + } + } +} \ No newline at end of file diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index 6c090199..ef2573eb 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -108,6 +108,9 @@ Select a storage drive Please install a file management utility to browse files Add a tunnel to get started + ♥ Donate to the WireGuard Project + Every contribution helps + Thank you for supporting the WireGuard Project!\n\nUnfortunately, due to Google\'s policies, we\'re not allowed to link to the part of the project webpage where you can make a donation. Hopefully you can figure this out!\n\nThanks again for your contribution. Disable config exporting Disabling config exporting makes private keys less accessible DNS servers diff --git a/ui/src/main/res/xml/preferences.xml b/ui/src/main/res/xml/preferences.xml index 5c9505d4..aa89f27c 100644 --- a/ui/src/main/res/xml/preferences.xml +++ b/ui/src/main/res/xml/preferences.xml @@ -40,4 +40,6 @@ android:summaryOff="@string/allow_remote_control_intents_summary_off" android:summaryOn="@string/allow_remote_control_intents_summary_on" android:title="@string/allow_remote_control_intents_title" /> + -- cgit v1.2.3