diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index da8a733d8..2ec0dc14f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -25,6 +25,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Color; import android.media.AudioManager; import android.os.Build; @@ -37,7 +38,6 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.util.Log; import android.view.GestureDetector; -import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; @@ -62,6 +62,7 @@ import org.schabi.newpipe.util.AnimationUtils; import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PermissionHelper; +import org.schabi.newpipe.util.PopupMenuIconHacker; import org.schabi.newpipe.util.ThemeHelper; import java.lang.reflect.Field; @@ -326,7 +327,7 @@ public final class MainVideoPlayer extends Activity { this.playNextButton = rootView.findViewById(R.id.playNextButton); this.moreOptionsButton = rootView.findViewById(R.id.moreOptionsButton); this.moreOptionsPopupMenu = new PopupMenu(context, moreOptionsButton); - this.moreOptionsPopupMenu.getMenuInflater().inflate(R.menu.menu_videooptions, moreOptionsPopupMenu.getMenu()); + buildMoreOptionsMenu(); titleTextView.setSelected(true); channelTextView.setSelected(true); @@ -499,25 +500,7 @@ public final class MainVideoPlayer extends Activity { private void onMoreOptionsClicked() { if (DEBUG) Log.d(TAG, "onMoreOptionsClicked() called"); - buildMoreOptionsMenu(); - try { - Field[] fields = moreOptionsPopupMenu.getClass().getDeclaredFields(); - for (Field field : fields) { - if ("mPopup".equals(field.getName())) { - field.setAccessible(true); - Object menuPopupHelper = field.get(moreOptionsPopupMenu); - Class classPopupHelper = Class.forName(menuPopupHelper - .getClass().getName()); - Method setForceIcons = classPopupHelper.getMethod( - "setForceShowIcon", boolean.class); - setForceIcons.invoke(menuPopupHelper, true); - break; - } - } - } catch (Exception e) { - e.printStackTrace(); - } moreOptionsPopupMenu.show(); isSomePopupMenuVisible = true; showControls(300); @@ -659,7 +642,9 @@ public final class MainVideoPlayer extends Activity { } private void buildMoreOptionsMenu() { - if (moreOptionsPopupMenu == null) return; + this.moreOptionsPopupMenu.getMenuInflater().inflate(R.menu.menu_videooptions, + moreOptionsPopupMenu.getMenu()); + moreOptionsPopupMenu.setOnMenuItemClickListener(menuItem -> { switch (menuItem.getItemId()) { case R.id.toggleOrientation: @@ -674,6 +659,22 @@ public final class MainVideoPlayer extends Activity { } return false; }); + + try { + PopupMenuIconHacker.setShowPopupIcon(moreOptionsPopupMenu); + } catch (Exception e) { + e.printStackTrace(); + } + + // fix icon theme + if(ThemeHelper.isLightThemeSelected(MainVideoPlayer.this)) { + moreOptionsPopupMenu.getMenu() + .findItem(R.id.toggleOrientation) + .setIcon(R.drawable.ic_screen_rotation_black_24dp); + moreOptionsPopupMenu.getMenu() + .findItem(R.id.switchPopup) + .setIcon(R.drawable.ic_fullscreen_exit_black_24dp); + } } private void buildQueue() { diff --git a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java index 0f082cc11..46c08b01b 100644 --- a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java +++ b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java @@ -1,4 +1,4 @@ -/* +/** * Copyright 2017 Mauricio Colli * InfoCache.java is part of NewPipe * diff --git a/app/src/main/java/org/schabi/newpipe/util/PopupMenuIconHacker.java b/app/src/main/java/org/schabi/newpipe/util/PopupMenuIconHacker.java new file mode 100644 index 000000000..70affb900 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/util/PopupMenuIconHacker.java @@ -0,0 +1,48 @@ +package org.schabi.newpipe.util; + +import android.widget.PopupMenu; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * Created by Christian Schabesberger on 20.01.18. + * Copyright 2018 Christian Schabesberger + * PopupMenuIconHacker.java is part of NewPipe + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +public class PopupMenuIconHacker { + public static void setShowPopupIcon(PopupMenu menu) throws Exception { + try { + Field[] fields = menu.getClass().getDeclaredFields(); + for (Field field : fields) { + if ("mPopup".equals(field.getName())) { + field.setAccessible(true); + Object menuPopupHelper = field.get(menu); + Class classPopupHelper = Class.forName(menuPopupHelper + .getClass().getName()); + Method setForceIcons = classPopupHelper.getMethod( + "setForceShowIcon", boolean.class); + setForceIcons.invoke(menuPopupHelper, true); + break; + } + } + } catch (Exception e) { + throw new Exception("Could not make Popup menu show Icons", e); + } + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_fullscreen_exit_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_fullscreen_exit_black_24dp.png new file mode 100644 index 000000000..8328e2efe Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_fullscreen_exit_black_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_screen_rotation_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_screen_rotation_black_24dp.png new file mode 100644 index 000000000..9a55a65b7 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_screen_rotation_black_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_fullscreen_exit_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_fullscreen_exit_black_24dp.png new file mode 100644 index 000000000..c8394487c Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_fullscreen_exit_black_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_screen_rotation_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_screen_rotation_black_24dp.png new file mode 100644 index 000000000..012a32d4f Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_screen_rotation_black_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_fullscreen_exit_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_fullscreen_exit_black_24dp.png new file mode 100644 index 000000000..5fc3166ac Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_fullscreen_exit_black_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_screen_rotation_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_screen_rotation_black_24dp.png new file mode 100644 index 000000000..ae2be1fa8 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_screen_rotation_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_black_24dp.png new file mode 100644 index 000000000..5691b5541 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_black_24dp.png new file mode 100644 index 000000000..bfd31c55a Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_black_24dp.png new file mode 100644 index 000000000..2221235df Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_black_24dp.png new file mode 100644 index 000000000..29fef9a47 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_black_24dp.png differ diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml index 6086dd5cb..36222f5bc 100644 --- a/app/src/main/res/layout/activity_main_player.xml +++ b/app/src/main/res/layout/activity_main_player.xml @@ -244,7 +244,7 @@ android:clickable="true" android:focusable="true" android:scaleType="fitXY" - android:src="?attr/options" + android:src="@drawable/ic_more_vert_white_24dp" tools:ignore="ContentDescription,RtlHardcoded"/> diff --git a/app/src/main/res/menu/menu_videooptions.xml b/app/src/main/res/menu/menu_videooptions.xml index 1887ec1dd..ce69ba9c1 100644 --- a/app/src/main/res/menu/menu_videooptions.xml +++ b/app/src/main/res/menu/menu_videooptions.xml @@ -4,17 +4,18 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> -