From 6a89d788a13d5089954e22838422fc39b1b9d0bf Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 2 Jan 2025 13:34:05 +0100 Subject: [PATCH] Sidebar: Add donation link to app drawer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This creates a donation link that leads to our donation page on the NewPipe website. It will open the browser and display a “thank you” message toast when the button is pressed. --- .../java/org/schabi/newpipe/MainActivity.java | 16 +++++++++++++++- .../res/drawable-mdpi/volunteer_activism_ic.xml | 9 +++++++++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable-mdpi/volunteer_activism_ic.xml diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 175694125..1d6eb6422 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -42,6 +42,7 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.FrameLayout; import android.widget.Spinner; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -92,6 +93,7 @@ import org.schabi.newpipe.util.SerializedCache; import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.StateSaver; import org.schabi.newpipe.util.ThemeHelper; +import org.schabi.newpipe.util.external_communication.ShareUtils; import org.schabi.newpipe.views.FocusOverlayView; import java.util.ArrayList; @@ -120,7 +122,8 @@ public class MainActivity extends AppCompatActivity { private static final int ITEM_ID_DOWNLOADS = -4; private static final int ITEM_ID_HISTORY = -5; private static final int ITEM_ID_SETTINGS = 0; - private static final int ITEM_ID_ABOUT = 1; + private static final int ITEM_ID_DONATION = 1; + private static final int ITEM_ID_ABOUT = 2; private static final int ORDER = 0; @@ -262,6 +265,10 @@ public class MainActivity extends AppCompatActivity { drawerLayoutBinding.navigation.getMenu() .add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings) .setIcon(R.drawable.ic_settings); + drawerLayoutBinding.navigation.getMenu() + .add(R.id.menu_options_about_group, ITEM_ID_DONATION, ORDER, + R.string.donation_title) + .setIcon(R.drawable.volunteer_activism_ic); drawerLayoutBinding.navigation.getMenu() .add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about) .setIcon(R.drawable.ic_info_outline); @@ -337,6 +344,12 @@ public class MainActivity extends AppCompatActivity { case ITEM_ID_SETTINGS: NavigationHelper.openSettings(this); break; + case ITEM_ID_DONATION: + ShareUtils.openUrlInBrowser(this, getString(R.string.donation_url)); + Toast.makeText(this, + getString(R.string.donation_thank_you), Toast.LENGTH_SHORT) + .show(); + break; case ITEM_ID_ABOUT: NavigationHelper.openAbout(this); break; @@ -924,4 +937,5 @@ public class MainActivity extends AppCompatActivity { return sheetState == BottomSheetBehavior.STATE_HIDDEN || sheetState == BottomSheetBehavior.STATE_COLLAPSED; } + } diff --git a/app/src/main/res/drawable-mdpi/volunteer_activism_ic.xml b/app/src/main/res/drawable-mdpi/volunteer_activism_ic.xml new file mode 100644 index 000000000..de6985c53 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/volunteer_activism_ic.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6099fe4ca..19665e453 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -190,6 +190,7 @@ Website Besuche die NewPipe Website für weitere Informationen und Neuigkeiten. NewPipe wird von Freiwilligen entwickelt, die ihre Freizeit dafür verwenden, dir die beste Nutzererfahrung zu bieten. Gib etwas zurück, indem du den Entwicklern hilfst, NewPipe noch weiter zu verbessern, während sie sich an einer Tasse Kaffee erfreuen. + Vielen Dank für deine Spende! Kein Stream-Player gefunden (du kannst VLC installieren, um den Stream abzuspielen). Bevorzugtes Land des Inhalts Immer diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 766491d53..cc576c34b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -372,6 +372,7 @@ View on GitHub Donate NewPipe is developed by volunteers spending their free time bringing you the best user experience. Give back to help developers make NewPipe even better while they enjoy a cup of coffee. + Thank you so much for donating! Give back Website Visit the NewPipe Website for more info and news.