From 10faa45182bb8532fbbcacf5b940453d90028f42 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Sun, 22 Mar 2020 16:26:53 -0300 Subject: [PATCH 1/3] Align and enable autosizing for the app name text view in drawer header - Use a proper drop up/down arrow icon. - Move selected service views for better visibility. - Show the selected service icon next to its name. - Add a subtle fade background to the service name/icon for better readability. --- .../java/org/schabi/newpipe/MainActivity.java | 27 +-- .../res/drawable-hdpi/ic_arrow_down_white.png | Bin 267 -> 0 bytes .../res/drawable-hdpi/ic_arrow_up_white.png | Bin 261 -> 0 bytes .../res/drawable-mdpi/ic_arrow_down_white.png | Bin 210 -> 0 bytes .../res/drawable-mdpi/ic_arrow_up_white.png | Bin 201 -> 0 bytes .../drawable-xhdpi/ic_arrow_down_white.png | Bin 425 -> 0 bytes .../res/drawable-xhdpi/ic_arrow_up_white.png | Bin 415 -> 0 bytes .../drawable-xxhdpi/ic_arrow_down_white.png | Bin 470 -> 0 bytes .../res/drawable-xxhdpi/ic_arrow_up_white.png | Bin 458 -> 0 bytes .../drawer_header_bottom_background.xml | 7 + .../ic_arrow_drop_down_white_24dp.xml | 9 + .../drawable/ic_arrow_drop_up_white_24dp.xml | 9 + app/src/main/res/layout-v21/drawer_header.xml | 82 -------- app/src/main/res/layout/drawer_header.xml | 176 ++++++++++-------- app/src/main/res/values-v21/dimens.xml | 6 + app/src/main/res/values/colors.xml | 2 +- app/src/main/res/values/dimens.xml | 12 ++ 17 files changed, 159 insertions(+), 171 deletions(-) delete mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_down_white.png delete mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_up_white.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_down_white.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_up_white.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_down_white.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_up_white.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_down_white.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_up_white.png create mode 100644 app/src/main/res/drawable/drawer_header_bottom_background.xml create mode 100644 app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml create mode 100644 app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml delete mode 100644 app/src/main/res/layout-v21/drawer_header.xml create mode 100644 app/src/main/res/values-v21/dimens.xml diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 1d7a930ba..4ca16082a 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -83,11 +83,12 @@ public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release"); - private ActionBarDrawerToggle toggle = null; - private DrawerLayout drawer = null; - private NavigationView drawerItems = null; - private TextView headerServiceView = null; - private Button toggleServiceButton = null; + private ActionBarDrawerToggle toggle; + private DrawerLayout drawer; + private NavigationView drawerItems; + private ImageView headerServiceIcon; + private TextView headerServiceView; + private Button toggleServiceButton; private boolean servicesShown = false; private ImageView serviceArrow; @@ -285,11 +286,10 @@ public class MainActivity extends AppCompatActivity { View hView = navigationView.getHeaderView(0); serviceArrow = hView.findViewById(R.id.drawer_arrow); + headerServiceIcon = hView.findViewById(R.id.drawer_header_service_icon); headerServiceView = hView.findViewById(R.id.drawer_header_service_view); toggleServiceButton = hView.findViewById(R.id.drawer_header_action_button); - toggleServiceButton.setOnClickListener(view -> { - toggleServices(); - }); + toggleServiceButton.setOnClickListener(view -> toggleServices()); } private void toggleServices() { @@ -299,7 +299,6 @@ public class MainActivity extends AppCompatActivity { drawerItems.getMenu().removeGroup(R.id.menu_tabs_group); drawerItems.getMenu().removeGroup(R.id.menu_options_about_group); - if(servicesShown) { showServices(); } else { @@ -312,7 +311,7 @@ public class MainActivity extends AppCompatActivity { } private void showServices() { - serviceArrow.setImageResource(R.drawable.ic_arrow_up_white); + serviceArrow.setImageResource(R.drawable.ic_arrow_drop_up_white_24dp); for(StreamingService s : NewPipe.getServices()) { final String title = s.getServiceInfo().getName() + @@ -370,7 +369,7 @@ public class MainActivity extends AppCompatActivity { } private void showTabs() throws ExtractionException { - serviceArrow.setImageResource(R.drawable.ic_arrow_down_white); + serviceArrow.setImageResource(R.drawable.ic_arrow_drop_down_white_24dp); //Tabs int currentServiceId = ServiceHelper.getSelectedServiceId(this); @@ -428,9 +427,11 @@ public class MainActivity extends AppCompatActivity { // when the user returns to MainActivity drawer.closeDrawer(GravityCompat.START, false); try { - String selectedServiceName = NewPipe.getService( - ServiceHelper.getSelectedServiceId(this)).getServiceInfo().getName(); + final int selectedServiceId = ServiceHelper.getSelectedServiceId(this); + final String selectedServiceName = NewPipe.getService(selectedServiceId).getServiceInfo().getName(); headerServiceView.setText(selectedServiceName); + headerServiceIcon.setImageResource(ServiceHelper.getIcon(selectedServiceId)); + headerServiceView.post(() -> headerServiceView.setSelected(true)); toggleServiceButton.setContentDescription( getString(R.string.drawer_header_description) + selectedServiceName); diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-hdpi/ic_arrow_down_white.png deleted file mode 100644 index 33939600dc2d073a03e4497711fa9a1197976ac3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 267 zcmV+m0rdWfP)?2_s$!CLf|`ZSY(tFw$6h((bst}CysR<$O&<~e6SNfogd_cZ|8%ZIH&W0PDt40 zot=p3{7Fv4cHY^EF`ajGLSQc6=>$gS4?2O>`A#P=JKy1iq`5pHgb+eVG9HZfEM%y3 RpMU@W002ovPDHLkV1m?ech3L- diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_up_white.png b/app/src/main/res/drawable-hdpi/ic_arrow_up_white.png deleted file mode 100644 index 0972a9bca6204b20bb5622004e0bf350fb3ee4e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 261 zcmV+g0s8)lP)1_T`n|v!^#-4!qM6Z|8f#!vjQq>*=s^FM4o3Rc5b=gY&fqu+_wg^R?M&;==hm z|3viQyuBtGowwD*pU&H9;(_yHn-FwfzX@UIb(`qqyj~L>o$uR(qVw`iC_69P#31M8 zni%N(vnC8V-`<2V=i8bv>iqpC=(5mO+U9KK%nLqX0RR91;LZF1c%LkAkrJ0^00000 LNkvXXu0mjfTI6^a diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-mdpi/ic_arrow_down_white.png deleted file mode 100644 index 40a0f499ef07d39a3a2a26678d8d28c058afa4e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJnVv3=Ar-gYhTP_DP~Z_!OO`9Y z)YxU6XgFzw;}(bC3->pYb4L(VRUOSW4t&9@HP_r!b#IQgw)FuzlEKr} K&t;ucLK6TKV^+QZ diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_up_white.png b/app/src/main/res/drawable-mdpi/ic_arrow_up_white.png deleted file mode 100644 index fe67b46738ca43b8d76c8e6e73f67eeb0b211b80..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJ37#&FAr-gYPP@q4pdjFU@NC4< zn>~j)tRK#FXi`y{Q~u+!+WGr&*}f)hO$r?=B_2Di>3pjHS=sPChta0iN{=VXZ`M57 zXK=pas+!!S>n}_`PKw#ynN_e*cxR%~nS6H-6@Gci{HDm=XI{UEvHs4Xz4Ke(t@!q! zPy5uSOx`|QK<>^DgO?9GdT*!~S6cnK;UG}L^xwz5nMLbLInZqkp00i_>zopr02)A3 A)Bpeg diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-xhdpi/ic_arrow_down_white.png deleted file mode 100644 index 86bc5db3b3c9ce752b93e4ad1dbb395383c0416c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 425 zcmV;a0apHrP)kfi2426v$5O@q9Pu(A%5w<{lCmcy@_u)kV4|h)A6<{ion?P>FF*`1JD(iV*UiFjyIzfJF##Pmn>k z{Z5_W%Rp`O^Nhx!kLKqY6v5>^L3z>k0gB+_p75WaXEF|Z?+Gf3!t>M#wmZSCpJ%ia z+Gu{B(KtwU#wM^%m{W{l{5&JY*hTa6%*G+@w%>415Nuo>00000000000J7i(rKBTA TWkLv}00000NkvXXu0mjffs($V^SF?dYOSjNh zrFq(WUH^Z}>Ee1cH>ZWSB}`i0F!F4T!BP?LnQ7PG>D1Z)bwh!TVPEnx70<|=XT?jG z2l>vL_k80F{})%Zmo|o6%=Xkty)XT2>#ykT%|>AXE6t6cZI#-!Y{%@MQ+h({&&+;n z5Ig(c(LD<;y$hRh{nZQGM|!FE^9q=Cd)LYy5v`7UXY+HX*M#Xi)g@Bz zTN>ow6aKNC`R_S--RfxTl$f)xIoDer++(T!VYWo(w)j~eV!Zu(DtS`R@0WdHlGXog z>$3AxWSY(jMEqmE5N-z;Uih@xe*=)RDxbf>=zRM%%ik@%mGhjfcidKg zbLR8Hr)l#G41mHLYnv9^oL?$?WZt~#;Vv{#miRa%bmRPem#2I_zO zdggt$ncivGzwpi5w+rOFmQKH9ZR9)8`%fSvER;I>`Maf+em-Wpz8oav>FVdQ&MBb@ E0O&Bi`2YX_ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_down_white.png deleted file mode 100644 index 7e901e098ffbd5fcf985fbe67b7374208c3f7ba4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 470 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V4Ume;uunK>+N;JJSIZ{hrleZ zCAtsHUKY&}c>B{~(V{bR&EhgAD{*x-@y^?NfBLe;QtLndpUn%@4+jm;W-QB`{!I1k z>dIGVtnZ&?-{AXs-m^*14%?*aoj$icetUvPu}|@~Iql~wZ+`vod40zGXS!!kPLeZQ zo_hRu^!tN}KO1L%n4w>P@9o3&?v?vv1oNG4{{Qp%tp5M$&JxqyA7xeEERHR+{1fh< zZY`y2P<<@__Rh`1Zsrf)>DTKBW?3m-|I97ZJK^-g;rCihX_@50C_!D(a5U6*&Ca`fW?Z zy!(;rN51^=vr^pl-25Kr>koh2tP^AB-H%XTbNRFMtCo$Dw<9Cfw>FSI{rf7`Op#y&#*%gdjQR*5OrrB;p4!{4yXi{B_*QFqku!B0_Z jB!QbP0l+XkK4a?h) diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_up_white.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_up_white.png deleted file mode 100644 index bc71e23de06a99326ed125a7c052dcd5ccec5f48..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 458 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V4Udb;uunK>+SV}Sxkl^4uRA2 zSiYX#_0Hk<^t?NzZ|!}RT?7{Ds$Sfq^8Ao+;GI2ZEWYQN0d*sQKuc-t_RMKE(bAP~ zKb2?NU8;GybKm`&XR@c&pWwD%zVnIY^YeUWU+z4Wzg)A-@~-ZGv*my8UR*Y>{OSKK ze~vpBsN1}>|G)j|efg$zr_|e(f6o8U&O6Ui7V?l`T8`E9`g32+yLqQo|65v6;1^HC zIj7pjtFwHlnJaMMbEy-<`RkmFHgJLG?^+z@*#o(s|Ln96%M9Ql0w zP0Kl(`Zazpu6#cJvZc><|9d})6Q6&-ZaHYPf4!f?mCwIlv>ddxFH`q<^wZEf(dc~t zRnEy(b#we?-1vOEjOl#-4NjZ=iRvHzw9P&6SsGd3*xU(m-!kuA+B19lxzgvqc@aU$ cz|ipU2iv^Kc`Mj0uY<)sUHx3vIVCg!0H1T#vj6}9 diff --git a/app/src/main/res/drawable/drawer_header_bottom_background.xml b/app/src/main/res/drawable/drawer_header_bottom_background.xml new file mode 100644 index 000000000..913522274 --- /dev/null +++ b/app/src/main/res/drawable/drawer_header_bottom_background.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml b/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml new file mode 100644 index 000000000..588d26403 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml b/app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml new file mode 100644 index 000000000..2a2ceba52 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_drop_up_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout-v21/drawer_header.xml b/app/src/main/res/layout-v21/drawer_header.xml deleted file mode 100644 index 9ed9f833a..000000000 --- a/app/src/main/res/layout-v21/drawer_header.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - -