From 6a9e3ef63940a752b22d8450c2b68cf1504ce980 Mon Sep 17 00:00:00 2001 From: John Zhen M Date: Wed, 11 Oct 2017 21:16:28 -0700 Subject: [PATCH] -Added dropdown menu for background player activity. -Added icons for shuffle and drag handle. -Fixed exception when returning to background player activity after service shuts down. -Fixed open detail only working for Youtube. --- .../newpipe/player/BackgroundPlayer.java | 3 ++ .../player/BackgroundPlayerActivity.java | 39 +++++++++--------- .../drawable-hdpi/ic_reorder_black_24dp.png | Bin 0 -> 107 bytes .../drawable-hdpi/ic_reorder_white_24dp.png | Bin 0 -> 110 bytes .../drawable-hdpi/ic_shuffle_white_24dp.png | Bin 0 -> 300 bytes .../drawable-mdpi/ic_reorder_black_24dp.png | Bin 0 -> 82 bytes .../drawable-mdpi/ic_reorder_white_24dp.png | Bin 0 -> 84 bytes .../drawable-mdpi/ic_shuffle_white_24dp.png | Bin 0 -> 217 bytes .../drawable-xhdpi/ic_reorder_black_24dp.png | Bin 0 -> 101 bytes .../drawable-xhdpi/ic_reorder_white_24dp.png | Bin 0 -> 93 bytes .../drawable-xhdpi/ic_shuffle_white_24dp.png | Bin 0 -> 310 bytes .../drawable-xxhdpi/ic_reorder_black_24dp.png | Bin 0 -> 113 bytes .../drawable-xxhdpi/ic_reorder_white_24dp.png | Bin 0 -> 96 bytes .../drawable-xxhdpi/ic_shuffle_white_24dp.png | Bin 0 -> 486 bytes .../ic_reorder_black_24dp.png | Bin 0 -> 116 bytes .../ic_reorder_white_24dp.png | Bin 0 -> 99 bytes .../ic_shuffle_white_24dp.png | Bin 0 -> 517 bytes .../res/layout/activity_background_player.xml | 2 +- app/src/main/res/layout/play_queue_item.xml | 4 +- app/src/main/res/menu/menu_play_queue.xml | 20 +++++++++ app/src/main/res/values/attrs.xml | 1 + app/src/main/res/values/strings.xml | 6 ++- app/src/main/res/values/styles.xml | 2 + 23 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_reorder_black_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_shuffle_white_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_reorder_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_shuffle_white_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_reorder_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_shuffle_white_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_reorder_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_shuffle_white_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_reorder_black_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_shuffle_white_24dp.png create mode 100644 app/src/main/res/menu/menu_play_queue.xml diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index d4e2b0dbe..e39035013 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -139,7 +139,10 @@ public final class BackgroundPlayer extends Service { if (DEBUG) Log.d(TAG, "destroy() called"); releaseWifiAndCpu(); stopForeground(true); + if (basePlayerImpl != null) basePlayerImpl.destroy(); + basePlayerImpl = null; + mBinder = null; } @Override diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java index 2087f943d..ffa1e68bd 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java @@ -1,12 +1,12 @@ package org.schabi.newpipe.player; import android.content.ComponentName; -import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Build; import android.os.Bundle; import android.os.IBinder; +import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -24,16 +24,13 @@ import android.widget.TextView; import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; -import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.playlist.PlayQueueItem; import org.schabi.newpipe.playlist.PlayQueueItemBuilder; import org.schabi.newpipe.playlist.PlayQueueItemHolder; -import org.schabi.newpipe.settings.SettingsActivity; -import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.Localization; +import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ThemeHelper; public class BackgroundPlayerActivity extends AppCompatActivity @@ -101,15 +98,26 @@ public class BackgroundPlayerActivity extends AppCompatActivity bind(); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_play_queue, menu); + return true; + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; + case R.id.action_history: + NavigationHelper.openHistory(this); + return true; case R.id.action_settings: - Intent intent = new Intent(this, SettingsActivity.class); - startActivity(intent); + NavigationHelper.openSettings(this); + return true; + case R.id.action_system_audio: + startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS)); return true; } return super.onOptionsItemSelected(item); @@ -264,7 +272,7 @@ public class BackgroundPlayerActivity extends AppCompatActivity private void buildItemPopupMenu(final PlayQueueItem item, final View view) { final PopupMenu menu = new PopupMenu(this, view); - final MenuItem remove = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 0, Menu.NONE, "Remove"); + final MenuItem remove = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 0, Menu.NONE, R.string.play_queue_remove); remove.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { @@ -274,11 +282,11 @@ public class BackgroundPlayerActivity extends AppCompatActivity } }); - final MenuItem detail = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1, Menu.NONE, "Detail"); + final MenuItem detail = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1, Menu.NONE, R.string.play_queue_stream_detail); detail.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { - onOpenDetail(BackgroundPlayerActivity.this, item.getUrl(), item.getTitle()); + onOpenDetail(item.getServiceId(), item.getUrl(), item.getTitle()); return true; } }); @@ -346,15 +354,8 @@ public class BackgroundPlayerActivity extends AppCompatActivity }; } - private void onOpenDetail(Context context, String videoUrl, String videoTitle) { - Intent i = new Intent(context, MainActivity.class); - i.putExtra(Constants.KEY_SERVICE_ID, 0); - i.putExtra(Constants.KEY_URL, videoUrl); - i.putExtra(Constants.KEY_TITLE, videoTitle); - i.putExtra(Constants.KEY_LINK_TYPE, StreamingService.LinkType.STREAM); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(i); - context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); + private void onOpenDetail(int serviceId, String videoUrl, String videoTitle) { + NavigationHelper.openVideoDetail(this, serviceId, videoUrl, videoTitle); } private void scrollToSelected() { diff --git a/app/src/main/res/drawable-hdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_reorder_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..142d71505c8c1a4855394adf3a392990224b3ecf GIT binary patch literal 107 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;k*AAeNCjguLt~%;myCqei3UE2 xXAG?WCo@WCqzOEYJIu0pqnT7TjNo!(WLRe8?4Thc6$sSL;OXk;vd$@?2>^ks8BYKJ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_reorder_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..bacaaef289f3649b07b62b20364f6f4346628a26 GIT binary patch literal 110 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;si%u$h{y5d1PRu~4UG@?AO6o~ zw19b;Bk%u{jJzf$9Z_-8H3=ry+>&!)#K8lM3=`xS=RNX2yAWsqgQu&X%Q~loCIHJs BAZY*q literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_shuffle_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..ab55a83f486a4aab2a13d44cc1a95efa029857be GIT binary patch literal 300 zcmV+{0n`48P)`mAnb=FHqFxBf*u_`h zN6%^D5H#75AGfrv9sTJ43v{n;PR5MY{Yz3nr&1fi?SH(m%6X$ZvBlcU! z*!*BVfe918UoeRko;5ZzhXy2>M5f@`VBZXV$XGWRr=IX^IYJ)_W*~QNkUnHg9mc5< y4KWHPvEYb?xZ|W51$pl&9p(T6`dj}Ax>m87qb8W literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_shuffle_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d13a258a35e575cc3e11970529b36c07e366fdc1 GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+i1)eUBAr`%NCmHe`G7w;SFSyb9 z<(ChvTKjnSG+MM>`^h47H6TG#&91wJZ`+o%C7-ig|7pCjNJ`7^^YGG~!w?_tb?||A zEARF$g{DLXwl_TAT|xy8KJz+M&C|Dn%X8=E^B=FrYc+A0J-p8Of5z5|-=^mhvvMT= zDJ(g5rztt(MPtL#;OwQUd+z%kX65L)Wx{0>d_{Ne*0dKA*@w!W?y0x%*E;tq$J|Y( Q73fw5Pgg&ebxsLQ09?&iApigX literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_reorder_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..0b080a18715edfcda140aed629af49df20a337a9 GIT binary patch literal 101 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}t9Zwg>kch)?FB=LnFmNz${AJE7 yXCby@2~%AbQ%$h9@C^13%#42=80-ZY^s?9ex4rLXcYi8SAA_f>pUXO@geCw|yc$0M literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_reorder_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..6b4c5286156d9cbfa28e13d5563f273fd96373c8 GIT binary patch literal 93 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZA`BpB)|k7xlYrjj7PU0b=6JR`TD310nIojpU;hpb=-!3n07od=7~6_mn)~dEI)&ZV>pyl6z>O^0D$0fK?ekvsIXK=P-CwUjo{lyOtpET307*qo IM6N<$f~|dk;{X5v literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_reorder_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..0a66529bfeac1f43a44606a11b23344a7864c141 GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xf3?%cF6R(1{pgYCW9j{U8QwIH3Iu6{1-oD!M< D>%<$U literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_reorder_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..a0d2543f250627756d7457c4b6248a9cce9cb72c GIT binary patch literal 96 zcmeAS@N?(olHy`uVBq!ia0vp^9w5vJBp7O^^}Pa8OeH~n!3+##lh0ZJd6J$kjv*C{ r$r4Kz{IloyqdeDDz1sb)>>LIL+k3Me`&$)jL0Uas{an^LB{Ts53DX%= literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_shuffle_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..dc8e5341b011ddd483c6d3b61864e31e47948454 GIT binary patch literal 486 zcmV@P)%5l9=_ zQ1^eYuCA`GPFsD~N?~%X2Kj}@1-Z5wCG9u~gA7NK_MC)4hBH42fnJoZDD$0bx?l zIKCiCIx13*2Qkv;jC0{%#2l36IZJ`ofI~r?LtB7DK%CQ+aTLlpXT;$k&fzV>;ULa= zr*CQy2yspsXO(hvlXM}Z=W)bH&*OMf3qXhy^hJ_9$vw~@$NVPpMn61Bn|YqF(Qzh_ zHu@u#gQ9xR`8O%yFc9E)()&9Hg8;{qe&0Feps1tL?F`40#6g^slQ@WT011Gi4uq4D zIu4qj6Ox-%0?Lm16>&B>hk`z6oRb4USsyhPa)!CD{U?o>(^?J$E&un_vQgTe~ HDWM4f9he}? literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_reorder_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..bc4fde512c835126d14b87913b0e6ccf76a94fb2 GIT binary patch literal 99 zcmeAS@N?(olHy`uVBq!ia0vp^2_Vb}Bp6OT_L>T$m`Z~Df*BafCZDwc@?<<+978G? ulNp)<5B!(svb!+BIsJdnuk0$hLxsxTHV&LAM5C0qgS#)1TAOK`zYfab)^y|IJcO9g&ks!{W@d7kHa zp67XC}G06w1w@cBG|&&L4QpHBdGNIn4I^8o;# z4*>Xl0Kn(p0stU?n#q6Dq%8;F^CeXgE|p(KxLkgJ3Ig!?O9Xo5cvfFDnB8d zr2+t&pAY~*n!hc0Eerto{7!%Xe10b&06w4p+=kERKX~Hv#RA^>d=_w{4?dp+1cA>7 z0YTvNF+dQGd_D literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_background_player.xml b/app/src/main/res/layout/activity_background_player.xml index 3a4a4454d..f2efd7411 100644 --- a/app/src/main/res/layout/activity_background_player.xml +++ b/app/src/main/res/layout/activity_background_player.xml @@ -209,7 +209,7 @@ android:clickable="true" android:focusable="true" android:scaleType="fitXY" - android:src="@drawable/ic_palette_white_24dp" + android:src="@drawable/ic_shuffle_white_24dp" tools:ignore="ContentDescription"/> + + + + + + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 047038e50..216cc1605 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -18,6 +18,7 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7609a7730..9054397a6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -293,6 +293,10 @@ New & hot %1$s/%2$s - + Background Player + Remove + Details + Audio Settings + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c556cce50..0ec8093bc 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -25,6 +25,7 @@ @drawable/ic_palette_black_24dp @drawable/ic_language_black_24dp @drawable/ic_history_black_24dp + @drawable/ic_reorder_black_24dp @color/light_selector @color/light_separator_color @@ -60,6 +61,7 @@ @drawable/ic_palette_white_24dp @drawable/ic_language_white_24dp @drawable/ic_history_white_24dp + @drawable/ic_reorder_white_24dp @color/dark_selector @color/dark_separator_color