From 677865f34715999b1d27de06357bfeb24a211ee5 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 20 Jan 2018 14:46:10 +0100 Subject: [PATCH] player popup menu icons for white theme --- .../newpipe/player/MainVideoPlayer.java | 43 ++++++++-------- .../org/schabi/newpipe/util/InfoCache.java | 2 +- .../newpipe/util/PopupMenuIconHacker.java | 48 ++++++++++++++++++ .../ic_fullscreen_exit_black_24dp.png | Bin 0 -> 103 bytes .../ic_screen_rotation_black_24dp.png | Bin 0 -> 478 bytes .../ic_fullscreen_exit_black_24dp.png | Bin 0 -> 93 bytes .../ic_screen_rotation_black_24dp.png | Bin 0 -> 321 bytes .../ic_fullscreen_exit_black_24dp.png | Bin 0 -> 111 bytes .../ic_screen_rotation_black_24dp.png | Bin 0 -> 645 bytes .../ic_fullscreen_exit_black_24dp.png | Bin 0 -> 122 bytes .../ic_screen_rotation_black_24dp.png | Bin 0 -> 916 bytes .../ic_fullscreen_exit_black_24dp.png | Bin 0 -> 123 bytes .../ic_screen_rotation_black_24dp.png | Bin 0 -> 1178 bytes .../main/res/layout/activity_main_player.xml | 2 +- app/src/main/res/menu/menu_videooptions.xml | 7 +-- 15 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/util/PopupMenuIconHacker.java create mode 100644 app/src/main/res/drawable-hdpi/ic_fullscreen_exit_black_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_screen_rotation_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_fullscreen_exit_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_screen_rotation_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_fullscreen_exit_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_screen_rotation_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_screen_rotation_black_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_black_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_black_24dp.png 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 0000000000000000000000000000000000000000..8328e2efe00875d42e2888ce9b498c82f8006487 GIT binary patch literal 103 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;o~MgrNCji^0XDaT8bA1(W++`T z&bYGR{|bTmcN9!APBa7>%u>jl^4pzPighsqLsReU)Sjm*uYo!lJYD@<);T3K0Ra3G B9xwm^ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..9a55a65b71f13287aac3164b996ba348d4702a23 GIT binary patch literal 478 zcmV<40U`d0P)dQkbxDPyIB9h!Ff8`5>b0Y;8clR&|oA8?t$TOiwF@2{R#HV3_^$! zgccoIN}3Y0^FB?te20fGkG}w*W!mjCD z=9Lh_Z>@wn)EB~vdM>kQFQt5Q)r8kV_+TW5nZsy8J#+=sbo7KTF6JZ+g=cw8In@#RT6s(vRr5ypY$%T@qps--H*=VjngjrB2%7-il*y;Gg}%!$ ztS2l&1*-5vxCah@30k(t}WKt=!;T*sn;nX+)pgo{+84A0? zrdmFgG62&;n5TrwVBopXGgCrkG1Pq&j#CO#11g7s5xYXqBSWBJKBaOPxMW)hZ(TQL zUsy`0JPg%AnVa^SDkTm}layh|xis8GW_Yd-nuk0;8*Kd6^I Uk(I={0{{R307*qoM6N<$f)~EYHUIzs literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c8394487c9c3e539520d57b899313ab0779ed6ab GIT binary patch literal 93 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*16;Bt(kP60RhQ`1T@*ERyFt2`S q&y&-%?yl!7t5P#MsIeDMx?*7l8LBL{Qe zfUGsaf0M0QYm&jzXF#r*oIHhle#={s2ZAY-E*=xfCX(y@nGW#UPyHH_*eM--)V(ID z9Y%sh4N2@U5qwhOz9IVmNNR_XgJ0eYj**55*v&s0jOND2QL#yTPx!fE}PTJn}WICX(A9-NFX{L$)8RM24-3FS#;OXk; Jvd$@?2>|5vARzz% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..ae2be1fa8932d77352eda38679f4720453461a3f GIT binary patch literal 645 zcmV;00($+4P)GxjtJ@5Dae(c+vxH!Zc_V`MbN6c}FV+1F`TbgZa zg((Ku7hQ}pPTEe$+GdWUMC1UABB@hoOKh|UWYs9q6Gi{DO;YTbXtG8os{Uh#M1?cx zYqmHWML$I!%fBTCMOy(NMxGsgloNhEfStHXi<4~1euFD+y^*j;u%hoG>(U#E5;k#7 zd?)SFI}%BKP%nwO^+NAo6T|v(7o2)WA}_n&NVxQlL`;87?m6|2L{>lQgKoW%C}XiM zdpA(JSTyy~6BDxY1ZC8#*Tm8v69eqYpIicATz}H~AXws=%+DdDsmtYZz{D+?-bE?U z44gPGvxg{93Xqtg#R-|bgU|_sFp0(gH}OG6nSYm9kU^Gq$^jD7DEH;E0)Z2Ch7c~u zl4q(5Qk4UX$$dPUrsu=NHx z{m;Bg5}S&VDA{_OYc%BM&zz#gO$M!mTQ6MKckzR1x&gQ?Utlxg)(bgmdh9(p?#L@U zQFZH;jC`YhT^mNiuUC2~QZo_>P^R@!&Wk=0DIT!hAu+@lBkYsIO!C4=1SZ8rW?A49 fU)W`hI1YXS>b5nQ^cC1(00000NkvXXu0mjfGOi(K literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5691b5541c38292b3be0081e700065a2a1040f76 GIT binary patch literal 122 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xf3?%cF6IITFDn zS$j+pMZH_e;>ya=YC&?z^N2R*J6zw|C?lmSk{o7#eqS3T8|Sz zs!$Kxa-vATF6V5dE`F2~d)%eVIUA{)pXJ0FFK5DASV)90gK4N8aof4GJ6u(u~Xw>2QKc zZB*(`PQA%hd^M9*;@Fawy}1)^!)Q*CV@Dd2xlyDD1yzm>=>~ZlSwy;7jxG?KHfc#d z+C~&!AqCQe%-n-Cj~g1PS0+Y~668W7#VC6F*Dz`&9~$X6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G|A{RBtYQ;4M?tLQij(hLSZ)=PRM8rBtRjLhL>gZI#j8` zv+{|D(XdfQL!=`qEX6jD;iP?NsAEEgS@2S@$9J@#0X~-DE8wMIkN*Yf>E7M{<|+>b zd;Bvr63Qa|C88ZX6s+-Y5t?n?1tjV^L87$_LxLyAFJ{g#x0f+0S@ z4qc}W3=|CU;c|YHg96tWC>Y|0e+Dmtfr24EWH>Ho0a*hDLwtahddey4Vpr($!3TIp z&lvzug@P*BY`c+=G(_Y&K9Z#0Pi{C%s74K*10nuHkyZl*Gkk#clyK639#Tw|n<6Nf;sb1_jMMTSb%X=^ zm|#N$1yg*0ZInVEu{w;8!$nXq#|K!?I8IBzt1JxR&rrb{U(>`$_ 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"> -