From a8f5cfa64053e3ff78de25cd71050fb7a18da75d Mon Sep 17 00:00:00 2001 From: John Zhen M Date: Fri, 13 Oct 2017 21:07:19 -0700 Subject: [PATCH] -Added different toast for append long click on detail fragment. -Corrected drag handle icon. -Removed reorder icon. -Refactored play queue item selection. --- .../fragments/detail/VideoDetailFragment.java | 10 +++++-- .../org/schabi/newpipe/player/BasePlayer.java | 26 +++++++++++++----- .../newpipe/player/MainVideoPlayer.java | 9 +----- .../newpipe/player/ServicePlayerActivity.java | 9 +----- .../ic_drag_handle_black_24dp.png | Bin 0 -> 98 bytes .../ic_drag_handle_white_24dp.png | Bin 0 -> 99 bytes .../drawable-hdpi/ic_reorder_black_24dp.png | Bin 107 -> 0 bytes .../drawable-hdpi/ic_reorder_white_24dp.png | Bin 110 -> 0 bytes .../ic_drag_handle_black_24dp.png | Bin 0 -> 81 bytes .../ic_drag_handle_white_24dp.png | Bin 0 -> 82 bytes .../drawable-mdpi/ic_reorder_black_24dp.png | Bin 82 -> 0 bytes .../drawable-mdpi/ic_reorder_white_24dp.png | Bin 84 -> 0 bytes .../ic_drag_handle_black_24dp.png | Bin 0 -> 96 bytes .../ic_drag_handle_white_24dp.png | Bin 0 -> 91 bytes .../drawable-xhdpi/ic_reorder_black_24dp.png | Bin 101 -> 0 bytes .../drawable-xhdpi/ic_reorder_white_24dp.png | Bin 93 -> 0 bytes .../ic_drag_handle_black_24dp.png | Bin 0 -> 104 bytes .../ic_drag_handle_white_24dp.png | Bin 0 -> 94 bytes .../drawable-xxhdpi/ic_reorder_black_24dp.png | Bin 113 -> 0 bytes .../drawable-xxhdpi/ic_reorder_white_24dp.png | Bin 96 -> 0 bytes .../ic_drag_handle_black_24dp.png | Bin 0 -> 112 bytes .../ic_drag_handle_white_24dp.png | Bin 0 -> 95 bytes .../ic_reorder_black_24dp.png | Bin 116 -> 0 bytes .../ic_reorder_white_24dp.png | Bin 99 -> 0 bytes app/src/main/res/layout/play_queue_item.xml | 2 +- app/src/main/res/values/attrs.xml | 2 +- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/values/styles.xml | 4 +-- 28 files changed, 34 insertions(+), 30 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_drag_handle_black_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_drag_handle_white_24dp.png delete mode 100644 app/src/main/res/drawable-hdpi/ic_reorder_black_24dp.png delete mode 100644 app/src/main/res/drawable-hdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_drag_handle_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_drag_handle_white_24dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_reorder_black_24dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_drag_handle_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_drag_handle_white_24dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_reorder_black_24dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_drag_handle_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_drag_handle_white_24dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_reorder_black_24dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_reorder_white_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_drag_handle_black_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_drag_handle_white_24dp.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_reorder_black_24dp.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_reorder_white_24dp.png diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 024874d14..e99a07f56 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -767,15 +767,15 @@ public class VideoDetailFragment extends BaseStateFragment implement ((HistoryListener) activity).onVideoPlayed(currentInfo, getSelectedVideoStream()); } - Toast.makeText(activity, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show(); - final PlayQueue playQueue = new SinglePlayQueue(currentInfo); final VideoStream candidate = sortedStreamVideosList.get(actionBarHandler.getSelectedVideoStream()); final Intent intent; if (append) { + Toast.makeText(activity, R.string.popup_playing_append, Toast.LENGTH_SHORT).show(); intent = NavigationHelper.getPlayerIntent(activity, PopupVideoPlayer.class, playQueue, true); } else { + Toast.makeText(activity, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show(); intent = NavigationHelper.getPlayerIntent(activity, PopupVideoPlayer.class, playQueue, Localization.resolutionOf(candidate.resolution)); } activity.startService(intent); @@ -799,7 +799,11 @@ public class VideoDetailFragment extends BaseStateFragment implement private void openNormalBackgroundPlayer(final boolean append) { final PlayQueue playQueue = new SinglePlayQueue(currentInfo); activity.startService(NavigationHelper.getPlayerIntent(activity, BackgroundPlayer.class, playQueue, append)); - Toast.makeText(activity, R.string.background_player_playing_toast, Toast.LENGTH_SHORT).show(); + if (append) { + Toast.makeText(activity, R.string.background_player_append, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(activity, R.string.background_player_playing_toast, Toast.LENGTH_SHORT).show(); + } } private void openExternalBackgroundPlayer(AudioStream audioStream) { diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 3bab31293..d543ef5c4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -809,9 +809,13 @@ public abstract class BasePlayer implements Player.EventListener, else audioManager.abandonAudioFocus(this); if (getCurrentState() == STATE_COMPLETED) { - if (playQueue.getIndex() == 0) simpleExoPlayer.seekToDefaultPosition(); - else playQueue.setIndex(0); + if (playQueue.getIndex() == 0) { + simpleExoPlayer.seekToDefaultPosition(); + } else { + playQueue.setIndex(0); + } } + simpleExoPlayer.setPlayWhenReady(!isPlaying()); } @@ -846,11 +850,19 @@ public abstract class BasePlayer implements Player.EventListener, playQueue.offsetIndex(+1); } - public void onRestart() { - if (playQueue == null) return; - if (DEBUG) Log.d(TAG, "onRestart() called"); + public void onSelected(final PlayQueueItem item) { + final int index = playQueue.indexOf(item); + if (index == -1) return; - simpleExoPlayer.seekToDefaultPosition(); + if (playQueue.getIndex() == index) { + simpleExoPlayer.seekToDefaultPosition(); + } else { + playQueue.setIndex(index); + } + + if (!isPlaying()) { + onVideoPlayPause(); + } } public void seekBy(int milliSeconds) { @@ -873,7 +885,7 @@ public abstract class BasePlayer implements Player.EventListener, private final StringBuilder stringBuilder = new StringBuilder(); private final Formatter formatter = new Formatter(stringBuilder, Locale.getDefault()); private final NumberFormat speedFormatter = new DecimalFormat("0.##x"); - private final NumberFormat pitchFormatter = new DecimalFormat("##.##%"); + private final NumberFormat pitchFormatter = new DecimalFormat("##%"); // todo: merge this into Localization public String getTimeString(int milliSeconds) { 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 00b14d661..0b5d0c9d3 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -572,14 +572,7 @@ public final class MainVideoPlayer extends Activity { return new PlayQueueItemBuilder.OnSelectedListener() { @Override public void selected(PlayQueueItem item, View view) { - final int index = playQueue.indexOf(item); - if (index == -1) return; - - if (playQueue.getIndex() == index) { - onRestart(); - } else { - playQueue.setIndex(index); - } + onSelected(item); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index e7ce1d2a4..5de90dbbe 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -347,14 +347,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity return new PlayQueueItemBuilder.OnSelectedListener() { @Override public void selected(PlayQueueItem item, View view) { - final int index = player.playQueue.indexOf(item); - if (index == -1) return; - - if (player.playQueue.getIndex() == index) { - player.onRestart(); - } else { - player.playQueue.setIndex(index); - } + player.onSelected(item); } @Override diff --git a/app/src/main/res/drawable-hdpi/ic_drag_handle_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_drag_handle_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7ebc393581ea0ded4da66de660bd6d7304c8781f GIT binary patch literal 98 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;rl*TzNCjiE#Hj?4o~FPH4oXKj v|4n9FnJe%#PP%vN#fZh)60D08L>L$p9``T2cG>h2P!ofvtDnm{r-UW|EsGl= literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_drag_handle_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_drag_handle_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..8747b9ecb46b55c8cf5f6cc77686785df7cca225 GIT binary patch literal 99 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;mZytjh{y5d1PRu~2_ihPANDtz wblg@DVwB}sH0`=ua<0iWw}ToItXmiu5_|k0wldT1B8K;k*AAeNCjguLt~%;myCqei3UE2 xXAG?WCo@WCqzOEYJIu0pqnT7TjNo!(WLRe8?4Thc6$sSL;OXk;vd$@?2>^ks8BYKJ 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 deleted file mode 100644 index bacaaef289f3649b07b62b20364f6f4346628a26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/app/src/main/res/drawable-mdpi/ic_drag_handle_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_drag_handle_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e09d492fc37d61f9df9c11dc1ebabadf0c192367 GIT binary patch literal 81 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7~Txo-U3d6^zLeuM$N59Ou`(YVeBv dS92f(LzJ8S!7op=HvrWzc)I$ztaD0e0szlT71{s* literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_drag_handle_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_drag_handle_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e509264d3fe58b6b2e603cd9a685ecc6e33adb27 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1NlzEY5R22v2@>m87qb8W diff --git a/app/src/main/res/drawable-xhdpi/ic_drag_handle_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_drag_handle_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..906f5eee0a87aaaa952ed724c389b330f91f1276 GIT binary patch literal 96 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}tbx#+^kch)?FB=LnFz_%L{+XTU uYOr;>!UJ_7h98-yIKMFdabRG`i(;DipYhANb(eu!7(8A5T-G@yGywn}=o=^i literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_drag_handle_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_drag_handle_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..aa1547b049d5891ce2d79ecf895db11a103cc186 GIT binary patch literal 91 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZA`BpB)|k7xlYrjj7PUBlKmvv4FO#n+h7OMaN 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 deleted file mode 100644 index 0b080a18715edfcda140aed629af49df20a337a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 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 deleted file mode 100644 index 6b4c5286156d9cbfa28e13d5563f273fd96373c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 93 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZA`BpB)|k7xlYrjj7PUR(1{pgYCW9j{U8QwIH3Iu6{1-oD!M< D>%<$U 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 deleted file mode 100644 index a0d2543f250627756d7457c4b6248a9cce9cb72c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 96 zcmeAS@N?(olHy`uVBq!ia0vp^9w5vJBp7O^^}Pa8OeH~n!3+##lh0ZJd6J$kjv*C{ r$r4Kz{IloyqdeDDz1sb)>>LIL+k3Me`&$)jL0Uas{an^LB{Ts53DX%= diff --git a/app/src/main/res/drawable-xxxhdpi/ic_drag_handle_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_drag_handle_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d102adeb2e01aad5958eb7bb1b70171e4893cb46 GIT binary patch literal 112 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeK3?y%aJ*@^(YymzYu0R?HmZtAK52P4Ng8YIR z9G=}s19BuhT^vIy7?UOX5=8#AGf5S>{Wbn^P=kTtK39F?DPcW%kVa2eKbLh*2~7ZA CpB!ia literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_drag_handle_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_drag_handle_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..12269073810c06804d0825a862ac74747f7c234f GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^2_Vb}Bp6OT_L>T$m`Z~Df*BafCZDwc@+3T6978G? plO_5RMEgMr~bSAF9tVLf?}PES`qmvv4FO#tVb7(W02 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_reorder_black_24dp.png deleted file mode 100644 index 56a5bc8ba3ed86b692dd7fd3e4dbc5cdd3857d1e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeK3?y%aJ*@^(YymzYu0R?HmZtAK52P4Ng8YIR z9G=}s19D_MT^vIy7?T;A0uTI`=d!yn!8!eZ&#&|=_KO)9KAOpW$O(U+0n+U0>gTe~ HDWM4f9he}? 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 deleted file mode 100644 index bc4fde512c835126d14b87913b0e6ccf76a94fb2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 99 zcmeAS@N?(olHy`uVBq!ia0vp^2_Vb}Bp6OT_L>T$m`Z~Df*BafCZDwc@?<<+978G? ulNp)<5B!(svb!+BIsJdnuk - + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8295fd5a8..c2e4f858d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -91,6 +91,8 @@ Other Playing in background Playing in popup mode + Queued on background player + Queued on popup player https://www.c3s.cc/ Play Content diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0ec8093bc..6a8efb0c2 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -25,7 +25,7 @@ @drawable/ic_palette_black_24dp @drawable/ic_language_black_24dp @drawable/ic_history_black_24dp - @drawable/ic_reorder_black_24dp + @drawable/ic_drag_handle_black_24dp @color/light_selector @color/light_separator_color @@ -61,7 +61,7 @@ @drawable/ic_palette_white_24dp @drawable/ic_language_white_24dp @drawable/ic_history_white_24dp - @drawable/ic_reorder_white_24dp + @drawable/ic_drag_handle_white_24dp @color/dark_selector @color/dark_separator_color