Merge pull request #3128 from Stypox/drawer-fix

Reintroduce "Settings" button in app bar
This commit is contained in:
Tobias Groza 2020-02-22 14:08:37 +01:00 committed by GitHub
commit e14b7851b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 66 additions and 49 deletions

View file

@ -453,15 +453,9 @@ public class MainActivity extends AppCompatActivity {
NavigationHelper.openMainActivity(this);
}
if (sharedPreferences.getBoolean(Constants.KEY_ENABLE_WATCH_HISTORY, true)) {
if (DEBUG) Log.d(TAG, "do not show History-menu as its disabled in settings");
drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(true);
}
if (!sharedPreferences.getBoolean(Constants.KEY_ENABLE_WATCH_HISTORY, true)) {
if (DEBUG) Log.d(TAG, "show History-menu as its enabled in settings");
drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(false);
}
final boolean isHistoryEnabled = sharedPreferences.getBoolean(
getString(R.string.enable_watch_history_key), true);
drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(isHistoryEnabled);
}
@Override

View file

@ -88,13 +88,6 @@ public class AboutActivity extends AppCompatActivity {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_about, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {

View file

@ -12,6 +12,7 @@ import android.view.MenuItem;
import android.view.ViewTreeObserver;
import org.schabi.newpipe.R;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ThemeHelper;
import us.shandian.giga.service.DownloadManagerService;
@ -76,11 +77,9 @@ public class DownloadActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: {
case android.R.id.home:
onBackPressed();
return true;
}
default:
return super.onOptionsItemSelected(item);
}

View file

@ -600,22 +600,27 @@ public class VideoDetailFragment
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (isLoading.get()) {
// if is still loading block menu
int id = item.getItemId();
if (id == R.id.action_settings) {
NavigationHelper.openSettings(requireContext());
return true;
}
if (isLoading.get()) {
// if still loading, block menu buttons related to video info
return true;
}
int id = item.getItemId();
switch (id) {
case R.id.menu_item_share: {
if (currentInfo != null) {
ShareUtils.shareUrl(this.getContext(), currentInfo.getName(), currentInfo.getOriginalUrl());
ShareUtils.shareUrl(requireContext(), currentInfo.getName(), currentInfo.getOriginalUrl());
}
return true;
}
case R.id.menu_item_openInBrowser: {
if (currentInfo != null) {
ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl());
ShareUtils.openUrlInBrowser(requireContext(), currentInfo.getOriginalUrl());
}
return true;
}

View file

@ -175,17 +175,20 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
NavigationHelper.openSettings(requireContext());
break;
case R.id.menu_item_rss:
openRssFeed();
break;
case R.id.menu_item_openInBrowser:
if (currentInfo != null) {
ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl());
ShareUtils.openUrlInBrowser(requireContext(), currentInfo.getOriginalUrl());
}
break;
case R.id.menu_item_share:
if (currentInfo != null) {
ShareUtils.shareUrl(this.getContext(), name, currentInfo.getOriginalUrl());
ShareUtils.shareUrl(requireContext(), name, currentInfo.getOriginalUrl());
}
break;
default:

View file

@ -222,11 +222,14 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
NavigationHelper.openSettings(requireContext());
break;
case R.id.menu_item_openInBrowser:
ShareUtils.openUrlInBrowser(this.getContext(), url);
ShareUtils.openUrlInBrowser(requireContext(), url);
break;
case R.id.menu_item_share:
ShareUtils.shareUrl(this.getContext(), name, url);
ShareUtils.shareUrl(requireContext(), name, url);
break;
case R.id.menu_item_bookmark:
onBookmarkClicked();

View file

@ -156,6 +156,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
case android.R.id.home:
finish();
return true;
case R.id.action_settings:
NavigationHelper.openSettings(this);
return true;
case R.id.action_append_playlist:
appendAllToPlaylist();
return true;

View file

@ -11,7 +11,5 @@ public class Constants {
public static final String KEY_THEME_CHANGE = "key_theme_change";
public static final String KEY_MAIN_PAGE_CHANGE = "key_main_page_change";
public static final String KEY_ENABLE_WATCH_HISTORY = "enable_watch_history";
public static final int NO_SERVICE_ID = -1;
}

View file

@ -26,5 +26,4 @@
android:icon="?attr/ic_delete"
android:title="@string/clear_download_history"
app:showAsAction="ifRoom" />
</menu>

View file

@ -1,6 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.schabi.newpipe.about.AboutActivity">
</menu>

View file

@ -4,11 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context=".fragments.list.impl.ChannelFragment">
<item
android:id="@+id/menu_item_openInBrowser"
android:title="@string/open_in_browser"
app:showAsAction="never"/>
<item
android:id="@+id/menu_item_rss"
android:icon="?attr/rss"
@ -22,4 +17,16 @@
android:icon="?attr/share"
android:title="@string/share"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="1"
android:title="@string/settings"
app:showAsAction="never"/>
<item
android:id="@+id/menu_item_openInBrowser"
android:orderInCategory="2"
android:title="@string/open_in_browser"
app:showAsAction="never"/>
</menu>

View file

@ -10,13 +10,18 @@
android:visible="true"
app:showAsAction="ifRoom"/>
<item android:id="@+id/action_settings"
android:orderInCategory="1"
android:title="@string/settings"
app:showAsAction="never"/>
<item android:id="@+id/action_system_audio"
android:orderInCategory="996"
android:orderInCategory="2"
android:title="@string/play_queue_audio_settings"
app:showAsAction="never"/>
<item android:id="@+id/action_switch_main"
android:orderInCategory="999"
android:orderInCategory="3"
android:title="@string/switch_to_main"
app:showAsAction="never"/>
</menu>

View file

@ -3,11 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/menu_item_openInBrowser"
android:title="@string/open_in_browser"
app:showAsAction="never"/>
<item
android:id="@+id/menu_item_share"
android:icon="?attr/share"
@ -21,4 +16,16 @@
android:visible="true"
app:showAsAction="ifRoom"
tools:visible="true"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="1"
android:title="@string/settings"
app:showAsAction="never"/>
<item
android:id="@+id/menu_item_openInBrowser"
android:orderInCategory="2"
android:title="@string/open_in_browser"
app:showAsAction="never"/>
</menu>

View file

@ -14,8 +14,15 @@
android:title="@string/share"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="1"
android:title="@string/settings"
app:showAsAction="never"/>
<item
android:id="@+id/menu_item_openInBrowser"
android:orderInCategory="2"
android:title="@string/open_in_browser"
app:showAsAction="never"/>
</menu>