Skip to content

Commit

Permalink
BraveNewPipe: check for app updates from within the drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
evermind-zz committed Aug 2, 2024
1 parent 31197ab commit 3df7120
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/src/main/java/org/schabi/newpipe/BraveMainActivityHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.schabi.newpipe;

import android.content.Context;
import android.view.MenuItem;
import android.widget.Toast;

import org.schabi.newpipe.databinding.DrawerLayoutBinding;

public final class BraveMainActivityHelper {

private BraveMainActivityHelper() {
}

// make sure it won't collide with any ITEM_ID_... in MainActivity
static final int BRAVE_ITEM_ID_UPDATE = 100;

public static void addBraveDrawers(
final DrawerLayoutBinding drawerLayoutBinding,
final int order) {
drawerLayoutBinding.navigation.getMenu()
.add(R.id.menu_options_about_group, BraveMainActivityHelper.BRAVE_ITEM_ID_UPDATE,
order, R.string.settings_category_updates_title)
.setIcon(R.drawable.ic_newpipe_update);
}

public static void onSelectedItemInDrawer(
final Context context,
final MenuItem item) {

if (item.getItemId() == BRAVE_ITEM_ID_UPDATE) {
Toast.makeText(context, R.string.checking_updates_toast, Toast.LENGTH_SHORT).show();
NewVersionWorker.enqueueNewVersionCheckingWork(context, true);
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ private void addDrawerMenuForCurrentService() throws ExtractionException {
drawerLayoutBinding.navigation.getMenu()
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
.setIcon(R.drawable.ic_info_outline);
BraveMainActivityHelper.addBraveDrawers(drawerLayoutBinding, ORDER);
}

private boolean drawerItemSelected(final MenuItem item) {
Expand Down Expand Up @@ -341,6 +342,7 @@ private void optionsAboutSelected(final MenuItem item) {
NavigationHelper.openAbout(this);
break;
}
BraveMainActivityHelper.onSelectedItemInDrawer(this, item);
}

private void setupDrawerHeader() {
Expand Down

0 comments on commit 3df7120

Please sign in to comment.