1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Merge branch 'dev'

This commit is contained in:
TobiGr 2020-02-22 14:09:26 +01:00
commit 5b98d41637
14 changed files with 66 additions and 49 deletions

View File

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

View File

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

View File

@ -600,22 +600,27 @@ public class VideoDetailFragment
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (isLoading.get()) { int id = item.getItemId();
// if is still loading block menu 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; return true;
} }
int id = item.getItemId();
switch (id) { switch (id) {
case R.id.menu_item_share: { case R.id.menu_item_share: {
if (currentInfo != null) { if (currentInfo != null) {
ShareUtils.shareUrl(this.getContext(), currentInfo.getName(), currentInfo.getOriginalUrl()); ShareUtils.shareUrl(requireContext(), currentInfo.getName(), currentInfo.getOriginalUrl());
} }
return true; return true;
} }
case R.id.menu_item_openInBrowser: { case R.id.menu_item_openInBrowser: {
if (currentInfo != null) { if (currentInfo != null) {
ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl()); ShareUtils.openUrlInBrowser(requireContext(), currentInfo.getOriginalUrl());
} }
return true; return true;
} }

View File

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

View File

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

View File

@ -156,6 +156,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
case android.R.id.home: case android.R.id.home:
finish(); finish();
return true; return true;
case R.id.action_settings:
NavigationHelper.openSettings(this);
return true;
case R.id.action_append_playlist: case R.id.action_append_playlist:
appendAllToPlaylist(); appendAllToPlaylist();
return true; 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_THEME_CHANGE = "key_theme_change";
public static final String KEY_MAIN_PAGE_CHANGE = "key_main_page_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; public static final int NO_SERVICE_ID = -1;
} }

View File

@ -26,5 +26,4 @@
android:icon="?attr/ic_delete" android:icon="?attr/ic_delete"
android:title="@string/clear_download_history" android:title="@string/clear_download_history"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
</menu> </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" xmlns:tools="http://schemas.android.com/tools"
tools:context=".fragments.list.impl.ChannelFragment"> tools:context=".fragments.list.impl.ChannelFragment">
<item
android:id="@+id/menu_item_openInBrowser"
android:title="@string/open_in_browser"
app:showAsAction="never"/>
<item <item
android:id="@+id/menu_item_rss" android:id="@+id/menu_item_rss"
android:icon="?attr/rss" android:icon="?attr/rss"
@ -22,4 +17,16 @@
android:icon="?attr/share" android:icon="?attr/share"
android:title="@string/share" android:title="@string/share"
app:showAsAction="ifRoom"/> 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> </menu>

View File

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

View File

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

View File

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