Skip to content

Commit e00f843

Browse files
theScrabiProfpatsch
authored andcommitted
Sidebar: Add donation link to app drawer
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.
1 parent 3fc0147 commit e00f843

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

app/src/main/java/org/schabi/newpipe/MainActivity.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import android.widget.ArrayAdapter;
4343
import android.widget.FrameLayout;
4444
import android.widget.Spinner;
45+
import android.widget.Toast;
4546

4647
import androidx.annotation.NonNull;
4748
import androidx.annotation.Nullable;
@@ -92,6 +93,7 @@
9293
import org.schabi.newpipe.util.ServiceHelper;
9394
import org.schabi.newpipe.util.StateSaver;
9495
import org.schabi.newpipe.util.ThemeHelper;
96+
import org.schabi.newpipe.util.external_communication.ShareUtils;
9597
import org.schabi.newpipe.views.FocusOverlayView;
9698

9799
import java.util.ArrayList;
@@ -120,7 +122,8 @@ public class MainActivity extends AppCompatActivity {
120122
private static final int ITEM_ID_DOWNLOADS = -4;
121123
private static final int ITEM_ID_HISTORY = -5;
122124
private static final int ITEM_ID_SETTINGS = 0;
123-
private static final int ITEM_ID_ABOUT = 1;
125+
private static final int ITEM_ID_DONATION = 1;
126+
private static final int ITEM_ID_ABOUT = 2;
124127

125128
private static final int ORDER = 0;
126129

@@ -262,6 +265,10 @@ private void addDrawerMenuForCurrentService() throws ExtractionException {
262265
drawerLayoutBinding.navigation.getMenu()
263266
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
264267
.setIcon(R.drawable.ic_settings);
268+
drawerLayoutBinding.navigation.getMenu()
269+
.add(R.id.menu_options_about_group, ITEM_ID_DONATION, ORDER,
270+
R.string.donation_title)
271+
.setIcon(R.drawable.volunteer_activism_ic);
265272
drawerLayoutBinding.navigation.getMenu()
266273
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
267274
.setIcon(R.drawable.ic_info_outline);
@@ -337,6 +344,12 @@ private void optionsAboutSelected(final MenuItem item) {
337344
case ITEM_ID_SETTINGS:
338345
NavigationHelper.openSettings(this);
339346
break;
347+
case ITEM_ID_DONATION:
348+
ShareUtils.openUrlInApp(this, getString(R.string.donation_url));
349+
Toast.makeText(this,
350+
getString(R.string.donation_thank_you), Toast.LENGTH_SHORT)
351+
.show();
352+
break;
340353
case ITEM_ID_ABOUT:
341354
NavigationHelper.openAbout(this);
342355
break;
@@ -924,4 +937,5 @@ private boolean bottomSheetHiddenOrCollapsed() {
924937
return sheetState == BottomSheetBehavior.STATE_HIDDEN
925938
|| sheetState == BottomSheetBehavior.STATE_COLLAPSED;
926939
}
940+
927941
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960">
6+
<path
7+
android:pathData="M640,520 L474,358q-31,-30 -52.5,-66.5T400,212q0,-55 38.5,-93.5T532,80q32,0 60,13.5t48,36.5q20,-23 48,-36.5t60,-13.5q55,0 93.5,38.5T880,212q0,43 -21,79.5T807,358L640,520ZM640,408 L749,301q19,-19 35,-40.5t16,-48.5q0,-22 -15,-37t-37,-15q-14,0 -26.5,5.5T700,182l-60,72 -60,-72q-9,-11 -21.5,-16.5T532,160q-22,0 -37,15t-15,37q0,27 16,48.5t35,40.5l109,107ZM280,740l278,76 238,-74q-5,-9 -14.5,-15.5T760,720L558,720q-27,0 -43,-2t-33,-8l-93,-31 22,-78 81,27q17,5 40,8t68,4q0,-11 -6.5,-21T578,606l-234,-86h-64v220ZM40,880v-440h304q7,0 14,1.5t13,3.5l235,87q33,12 53.5,42t20.5,66h80q50,0 85,33t35,87v40L560,900l-280,-78v58L40,880ZM120,800h80v-280h-80v280ZM640,254Z"
8+
android:fillColor="#FF000000"/>
9+
</vector>

app/src/main/res/values-de/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
<string name="website_title">Website</string>
191191
<string name="website_encouragement">Besuche die NewPipe Website für weitere Informationen und Neuigkeiten.</string>
192192
<string name="donation_encouragement">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.</string>
193+
<string name="donation_thank_you">Vielen Dank für deine Spende!</string>
193194
<string name="no_player_found_toast">Kein Stream-Player gefunden (du kannst VLC installieren, um den Stream abzuspielen).</string>
194195
<string name="default_content_country_title">Bevorzugtes Land des Inhalts</string>
195196
<string name="always">Immer</string>

app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@
372372
<string name="view_on_github">View on GitHub</string>
373373
<string name="donation_title">Donate</string>
374374
<string name="donation_encouragement">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.</string>
375+
<string name="donation_thank_you">Thank you so much for donating!</string>
375376
<string name="give_back">Give back</string>
376377
<string name="website_title">Website</string>
377378
<string name="website_encouragement">Visit the NewPipe Website for more info and news.</string>

0 commit comments

Comments
 (0)