From 6d6609187bc481613cd4cb1cdae977a3fe62dac5 Mon Sep 17 00:00:00 2001 From: marin Date: Thu, 9 Nov 2017 11:29:02 +0100 Subject: [PATCH 1/9] Add dropdown menu and switch to background option --- .../newpipe/player/MainVideoPlayer.java | 102 ++++++++++++++++-- .../schabi/newpipe/player/VideoPlayer.java | 17 ++- .../drawable-hdpi/ic_more_vert_black_24dp.png | Bin 0 -> 132 bytes .../drawable-hdpi/ic_more_vert_white_24dp.png | Bin 0 -> 134 bytes .../drawable-mdpi/ic_more_vert_black_24dp.png | Bin 0 -> 108 bytes .../drawable-mdpi/ic_more_vert_white_24dp.png | Bin 0 -> 112 bytes .../ic_more_vert_black_24dp.png | Bin 0 -> 155 bytes .../ic_more_vert_white_24dp.png | Bin 0 -> 158 bytes .../ic_more_vert_black_24dp.png | Bin 0 -> 205 bytes .../ic_more_vert_white_24dp.png | Bin 0 -> 216 bytes .../ic_more_vert_black_24dp.png | Bin 0 -> 272 bytes .../ic_more_vert_white_24dp.png | Bin 0 -> 305 bytes .../main/res/layout/activity_main_player.xml | 32 ++---- app/src/main/res/menu/menu_videooptions.xml | 21 ++++ app/src/main/res/values/attrs.xml | 1 + app/src/main/res/values/styles.xml | 2 + 16 files changed, 134 insertions(+), 41 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_more_vert_black_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_more_vert_white_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_more_vert_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_more_vert_white_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_more_vert_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_more_vert_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_more_vert_black_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_more_vert_white_24dp.png create mode 100644 app/src/main/res/menu/menu_videooptions.xml 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 c275e55a7..3beab8188 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -23,6 +23,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.res.Configuration; import android.graphics.Color; import android.media.AudioManager; import android.os.Build; @@ -33,6 +34,7 @@ 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; @@ -58,6 +60,8 @@ import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.ThemeHelper; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.List; import static org.schabi.newpipe.util.AnimationUtils.animateView; @@ -150,6 +154,17 @@ public final class MainVideoPlayer extends Activity { if (playerImpl != null) playerImpl.destroy(); } + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + if (playerImpl.isSomePopupMenuVisible()) { + playerImpl.moreOptionsPopupMenu.dismiss(); + playerImpl.getQualityPopupMenu().dismiss(); + playerImpl.getPlaybackSpeedPopupMenu().dismiss(); + } + } + /*////////////////////////////////////////////////////////////////////////// // Utils //////////////////////////////////////////////////////////////////////////*/ @@ -222,7 +237,6 @@ public final class MainVideoPlayer extends Activity { private ImageButton repeatButton; private ImageButton shuffleButton; - private ImageButton screenRotationButton; private ImageButton playPauseButton; private ImageButton playPreviousButton; private ImageButton playNextButton; @@ -234,6 +248,10 @@ public final class MainVideoPlayer extends Activity { private boolean queueVisible; + private ImageButton moreOptionsButton; + public int moreOptionsPopupMenuGroupId = 89; + public PopupMenu moreOptionsPopupMenu; + VideoPlayerImpl(final Context context) { super("VideoPlayerImpl" + MainVideoPlayer.TAG, context); } @@ -249,10 +267,12 @@ public final class MainVideoPlayer extends Activity { this.repeatButton = rootView.findViewById(R.id.repeatButton); this.shuffleButton = rootView.findViewById(R.id.shuffleButton); - this.screenRotationButton = rootView.findViewById(R.id.screenRotationButton); this.playPauseButton = rootView.findViewById(R.id.playPauseButton); this.playPreviousButton = rootView.findViewById(R.id.playPreviousButton); 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()); titleTextView.setSelected(true); channelTextView.setSelected(true); @@ -276,7 +296,7 @@ public final class MainVideoPlayer extends Activity { playPauseButton.setOnClickListener(this); playPreviousButton.setOnClickListener(this); playNextButton.setOnClickListener(this); - screenRotationButton.setOnClickListener(this); + moreOptionsButton.setOnClickListener(this); } /*////////////////////////////////////////////////////////////////////////// @@ -348,6 +368,28 @@ public final class MainVideoPlayer extends Activity { finish(); } + public void onPlayBackgroundButtonClicked() { + if (DEBUG) Log.d(TAG, "onPlayBackgroundButtonClicked() called"); + if (playerImpl.getPlayer() == null) return; + + setRecovery(); + final Intent intent = NavigationHelper.getPlayerIntent( + context, + BackgroundPlayer.class, + this.getPlayQueue(), + this.getRepeatMode(), + this.getPlaybackSpeed(), + this.getPlaybackPitch(), + this.getPlaybackQuality() + ); + context.startService(intent); + + ((View) getControlAnimationView().getParent()).setVisibility(View.GONE); + destroy(); + finish(); + } + + @Override public void onClick(View v) { super.onClick(v); @@ -360,9 +402,6 @@ public final class MainVideoPlayer extends Activity { } else if (v.getId() == playNextButton.getId()) { onPlayNext(); - } else if (v.getId() == screenRotationButton.getId()) { - onScreenRotationClicked(); - } else if (v.getId() == queueButton.getId()) { onQueueClicked(); return; @@ -372,6 +411,8 @@ public final class MainVideoPlayer extends Activity { } else if (v.getId() == shuffleButton.getId()) { onShuffleClicked(); return; + } else if (v.getId() == moreOptionsButton.getId()) { + onMoreOptionsClicked(); } if (getCurrentState() != STATE_COMPLETED) { @@ -405,6 +446,32 @@ public final class MainVideoPlayer extends Activity { queueVisible = false; } + 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); + } + private void onScreenRotationClicked() { if (DEBUG) Log.d(TAG, "onScreenRotationClicked() called"); toggleOrientation(); @@ -555,6 +622,27 @@ public final class MainVideoPlayer extends Activity { setShuffleButton(shuffleButton, playQueue.isShuffled()); } + private void buildMoreOptionsMenu() { + if (moreOptionsPopupMenu == null) return; + moreOptionsPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + switch (menuItem.getItemId()) { + case R.id.toggleOrientation: + onScreenRotationClicked(); + break; + case R.id.switchPopup: + onFullScreenButtonClicked(); + break; + case R.id.switchBackground: + onPlayBackgroundButtonClicked(); + break; + } + return false; + } + }); + } + private void buildQueue() { queueLayout = findViewById(R.id.playQueuePanel); @@ -785,4 +873,4 @@ public final class MainVideoPlayer extends Activity { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 1a386d45d..ef72bfd90 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -124,12 +124,11 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer. private View topControlsRoot; private TextView qualityTextView; - private ImageButton fullScreenButton; private ValueAnimator controlViewAnimator; private Handler controlsVisibilityHandler = new Handler(); - private boolean isSomePopupMenuVisible = false; + boolean isSomePopupMenuVisible = false; private int qualityPopupMenuGroupId = 69; private PopupMenu qualityPopupMenu; @@ -166,7 +165,6 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer. this.bottomControlsRoot = rootView.findViewById(R.id.bottomControls); this.topControlsRoot = rootView.findViewById(R.id.topControls); this.qualityTextView = rootView.findViewById(R.id.qualityTextView); - this.fullScreenButton = rootView.findViewById(R.id.fullScreenButton); //this.aspectRatioFrameLayout.setAspectRatio(16.0f / 9.0f); @@ -186,7 +184,6 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer. super.initListeners(); playbackSeekBar.setOnSeekBarChangeListener(this); playbackSpeedTextView.setOnClickListener(this); - fullScreenButton.setOnClickListener(this); qualityTextView.setOnClickListener(this); } @@ -453,9 +450,7 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer. @Override public void onClick(View v) { if (DEBUG) Log.d(TAG, "onClick() called with: v = [" + v + "]"); - if (v.getId() == fullScreenButton.getId()) { - onFullScreenButtonClicked(); - } else if (v.getId() == qualityTextView.getId()) { + if (v.getId() == qualityTextView.getId()) { onQualitySelectorClicked(); } else if (v.getId() == playbackSpeedTextView.getId()) { onPlaybackSpeedClicked(); @@ -753,14 +748,14 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer. return qualityTextView; } - public ImageButton getFullScreenButton() { - return fullScreenButton; - } - public PopupMenu getQualityPopupMenu() { return qualityPopupMenu; } + public PopupMenu getPlaybackSpeedPopupMenu() { + return playbackSpeedPopupMenu; + } + public View getSurfaceForeground() { return surfaceForeground; } diff --git a/app/src/main/res/drawable-hdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_more_vert_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..22acc550088d98f9d98ced517de75b5e8ead3c7c GIT binary patch literal 132 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B5}8r;B4q1>@UGdwClSM3^70uIQ21 z47_&cJkx~*+Z%R2IKOxGVZM^fH+7^Mmwc{S?NKJ@tD@b{HffqWt7pJW9xm}`3bIR@ eOD6DrGLJi>8B(9~m^Tk-EQ6=3pUXO@geCy;;w$k0 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_more_vert_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..67f07e473442d1f5bd5dc486a42ce4bedf40b425 GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;ucwP+h{y4_mv-_VP!M4WR9aA@ zB9L2TV$k7bqBi~Tf{Y7K)@EPe&B(sMnUQ&cV?}1b!p)H;o34MJ iAa}{R%7g#se7OLo1Hz}Zd6xqXX7F_Nb6Mw<&;$T!hAw^p literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_more_vert_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..0e4f2f6ea0564fe9d6ebdb4bea0df48aced9de0f GIT binary patch literal 108 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1V^0^ykP60RiERoU4^0niv(+!U z$~^Ty`=RMavMX4xeQ2uS{l}xxJ=eVCD820|N5W*kJjJ67$C*FG*QAUgq7iWp7Wo)^m*JsBN#kg L{an^LB{Ts5on9xv literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_more_vert_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..9f10aa2759a2e53beb129849c9b0e6ee5f7ae97b GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DBu^K|kP61PR}A@_6b0BGTJ|c& z&2zArUdgs%qoJD@@9neO|NgtXV7^DW)MQ81qkHN%-79zXF}ZeKv~Tuphvz#4Z3DJ9 zo+<2n{rTU)UWQJm<&*zc>PM$^=S_g|6%VwoI2{_d>%srJ7&|&vk-TbVh<5S;l;%8hhyk$Kc9U$ho zN!;a@as7tMKN^!>mP|UmC!qU^(pC>$p{$8fOT;)oR_iUC=UG0_`?VR+LIzJ)KbLh* G2~7aOZ8w1c literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..94d5ab98c6d3b3548536f04a2d635fb5c4a05b88 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhawrg*wIhEy=Vy=KqV>>$DV@#Ph3 zmm-(IJxlAmHdKggydBZHA?LrN(f;zraK2yFla}<&ocsFTF&FO*>g+$WJLfsbvhR#o zqU5?6`INL2k&sND<*?!p=%CFlpb5%Rrp)D#!8^w7WtAYxjJ8qaZaq8!Lha3*C xpO9i0)g!jJUB|8aV$u`{=V%64OvRJ&URzP%pP$_?yn*gx@O1TaS?83{1OO~yQ~m$| literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d32281307232fefc363e19d9d2728af62b440a8d GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw=6kw0hGg7(d(E5ckb#KX!!teA z8+IJIbSd_mp~lgrEob_e9cxnR1kZ18I^5b~uj)DJpG>-%nby>)6J_QWKRvd(S?`Ri~_DWys(>8rgyQv zG%aCaz>Js9>y=L)eUVgRxJx3oN6$@sv5NTO?u&4dNh*K$SbOB%sZae;9uIUXgQu&X J%Q~loCIECSTxI|O literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_more_vert_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..4642a3b66e690a25544c7a65b5484607c76e9e4d GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%xcgu6w#ThEy=Vz2TVE>>%O(aeKF| z&%}AAoaYX07I~@2Qzf){=E~b*b6q_X?JD-aXZn{o>8SH070*d=@0yRCD&F7PI4|Iy zgr>dT{)s<*uuMbP?bJzL!+Uj>du1MOpP(^y_vJlXtsXdjo_CdTHuJx`L9zyy z_bjw};Pttx=xP2JS*8CI?{O?lw)*qOUytSD#5&t0XL`98ez{Y*;jMY`-`}^VtDMwJ z5#Pjpv-OQrnIiiQFtvL^tj8o3AbA2TH#1Zw0j|Uo=)7NS4apHKER!-ifL>(qboFyt I=akR{05Df}#Q*>R literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_more_vert_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..2f2cb3d004f6e828917b5f6b1decc7fe5d99b445 GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%xcget5b#hE&{od&7{g$w9>R;>#mP zB_2gJIy{WxDHIfl;54zZ?(Dj(@bmNJ>M(=pX9D&J05vf@IA0RFIB;_s@2aW4t^P!s z?~T5q@wxa<`?f89Li_gpTlKB*dwsOb9#+$?m6!M>7BklVVk|aEPh1DJ$>V{EJl=XH?V({#-awY-(QL|0?dORlc*XtSl(} z&d3n4k$a}x{MZxU-fiZ-$+m%8aD#C}>V?${Gwe!OwoRt{8X v))3p#FqiR-(={Oe2E;4(u$C!;+}~cs6m#}#(>L)Q#vrbztDnm{r-UW|mL!4d literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml index 5c6349c35..6086dd5cb 100644 --- a/app/src/main/res/layout/activity_main_player.xml +++ b/app/src/main/res/layout/activity_main_player.xml @@ -209,7 +209,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="2dp" - android:layout_toLeftOf="@+id/screenRotationButton" + android:layout_toLeftOf="@+id/queueButton" android:gravity="center" android:minHeight="35dp" android:minWidth="40dp" @@ -218,28 +218,13 @@ tools:ignore="RtlHardcoded,RtlSymmetry" tools:text="1x" /> - - @@ -454,4 +440,4 @@ tools:visibility="visible"/> - \ No newline at end of file + diff --git a/app/src/main/res/menu/menu_videooptions.xml b/app/src/main/res/menu/menu_videooptions.xml new file mode 100644 index 000000000..2fbde0412 --- /dev/null +++ b/app/src/main/res/menu/menu_videooptions.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index abf7c7b09..81fb5752d 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -20,6 +20,7 @@ + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8f0bb02cd..5aa777956 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -27,6 +27,7 @@ @drawable/ic_history_black_24dp @drawable/ic_drag_handle_black_24dp @drawable/ic_fiber_manual_record_black_24dp + @drawable/ic_more_vert_black_24dp @color/light_separator_color @color/light_contrast_background_color @@ -65,6 +66,7 @@ @drawable/ic_history_white_24dp @drawable/ic_drag_handle_white_24dp @drawable/ic_fiber_manual_record_white_24dp + @drawable/ic_more_vert_white_24dp @color/dark_separator_color @color/dark_contrast_background_color From 77678b8f31afb03f57d1ba33e61644597fcbb12b Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Mon, 13 Nov 2017 21:13:52 -0800 Subject: [PATCH 2/9] -Modified InfoItem LRU cache expire to allow expiration (current default 4 hours). -Modified info type display on InfoItemDialog to show uploader name if exists. --- .../fragments/detail/VideoDetailFragment.java | 2 + .../fragments/list/BaseListFragment.java | 2 + .../list/channel/ChannelFragment.java | 2 + .../list/playlist/PlaylistFragment.java | 3 +- .../newpipe/info_list/InfoItemDialog.java | 26 ++++++-- .../org/schabi/newpipe/util/InfoCache.java | 63 +++++++++++++++++-- app/src/main/res/layout/dialog_title.xml | 10 ++- 7 files changed, 94 insertions(+), 14 deletions(-) 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 a4ee01ccc..d0460c347 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 @@ -485,6 +485,8 @@ public class VideoDetailFragment extends BaseStateFragment implement private void showStreamDialog(final StreamInfoItem item) { final Context context = getContext(); + if (context == null || context.getResources() == null || getActivity() == null) return; + final String[] commands = new String[]{ context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_popup) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index fd1e9ea63..ae17dafff 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -192,6 +192,8 @@ public abstract class BaseListFragment extends BaseStateFragment implem protected void showStreamDialog(final StreamInfoItem item) { final Context context = getContext(); + if (context == null || context.getResources() == null || getActivity() == null) return; + final String[] commands = new String[]{ context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_popup) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 348495079..857fb81e0 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -154,6 +154,8 @@ public class ChannelFragment extends BaseListInfoFragment { @Override protected void showStreamDialog(final StreamInfoItem item) { final Context context = getContext(); + if (context == null || context.getResources() == null || getActivity() == null) return; + final String[] commands = new String[]{ context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_popup), diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index 878dbf385..e7f7e9968 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -15,7 +15,6 @@ import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -109,6 +108,8 @@ public class PlaylistFragment extends BaseListInfoFragment { @Override protected void showStreamDialog(final StreamInfoItem item) { final Context context = getContext(); + if (context == null || context.getResources() == null || getActivity() == null) return; + final String[] commands = new String[]{ context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_popup), diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java index 72152500f..1cc2ca19e 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java @@ -4,28 +4,44 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.InfoItem; +import org.schabi.newpipe.extractor.stream.StreamInfoItem; public class InfoItemDialog { private final AlertDialog dialog; public InfoItemDialog(@NonNull final Activity activity, - @NonNull final InfoItem item, + @NonNull final StreamInfoItem info, @NonNull final String[] commands, @NonNull final DialogInterface.OnClickListener actions) { + this(activity, commands, actions, info.name, info.uploader_name); + } + + public InfoItemDialog(@NonNull final Activity activity, + @NonNull final String[] commands, + @NonNull final DialogInterface.OnClickListener actions, + @NonNull final String title, + @Nullable final String additionalDetail) { final LayoutInflater inflater = activity.getLayoutInflater(); final View bannerView = inflater.inflate(R.layout.dialog_title, null); bannerView.setSelected(true); + TextView titleView = bannerView.findViewById(R.id.itemTitleView); - titleView.setText(item.name); - TextView typeView = bannerView.findViewById(R.id.itemTypeView); - typeView.setText(item.info_type.name()); + titleView.setText(title); + + TextView detailsView = bannerView.findViewById(R.id.itemAdditionalDetails); + if (additionalDetail != null) { + detailsView.setText(additionalDetail); + detailsView.setVisibility(View.VISIBLE); + } else { + detailsView.setVisibility(View.GONE); + } dialog = new AlertDialog.Builder(activity) .setCustomTitle(bannerView) 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 5b22af86a..a3fd7805a 100644 --- a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java +++ b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java @@ -26,6 +26,9 @@ import android.util.Log; import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.extractor.Info; +import java.util.Map; +import java.util.concurrent.TimeUnit; + public final class InfoCache { private static final boolean DEBUG = MainActivity.DEBUG; @@ -37,9 +40,10 @@ public final class InfoCache { * Trim the cache to this size */ private static final int TRIM_CACHE_TO = 30; + private static final int DEFAULT_TIMEOUT_HOURS = 4; // TODO: Replace to one with timeout (like the one from guava) - private static final LruCache lruCache = new LruCache<>(MAX_ITEMS_ON_CACHE); + private static final LruCache lruCache = new LruCache<>(MAX_ITEMS_ON_CACHE); private InfoCache() { //no instance @@ -52,28 +56,29 @@ public final class InfoCache { public Info getFromKey(int serviceId, @NonNull String url) { if (DEBUG) Log.d(TAG, "getFromKey() called with: serviceId = [" + serviceId + "], url = [" + url + "]"); synchronized (lruCache) { - return lruCache.get(serviceId + url); + return getInfo(lruCache, keyOf(serviceId, url)); } } public void putInfo(@NonNull Info info) { if (DEBUG) Log.d(TAG, "putInfo() called with: info = [" + info + "]"); synchronized (lruCache) { - lruCache.put(info.service_id + info.url, info); + final CacheData data = new CacheData(info, DEFAULT_TIMEOUT_HOURS, TimeUnit.HOURS); + lruCache.put(keyOf(info), data); } } public void removeInfo(@NonNull Info info) { if (DEBUG) Log.d(TAG, "removeInfo() called with: info = [" + info + "]"); synchronized (lruCache) { - lruCache.remove(info.service_id + info.url); + lruCache.remove(keyOf(info)); } } public void removeInfo(int serviceId, @NonNull String url) { if (DEBUG) Log.d(TAG, "removeInfo() called with: serviceId = [" + serviceId + "], url = [" + url + "]"); synchronized (lruCache) { - lruCache.remove(serviceId + url); + lruCache.remove(keyOf(serviceId, url)); } } @@ -87,6 +92,7 @@ public final class InfoCache { public void trimCache() { if (DEBUG) Log.d(TAG, "trimCache() called"); synchronized (lruCache) { + removeStaleCache(lruCache); lruCache.trimToSize(TRIM_CACHE_TO); } } @@ -97,4 +103,51 @@ public final class InfoCache { } } + private static String keyOf(@NonNull final Info info) { + return keyOf(info.service_id, info.url); + } + + private static String keyOf(final int serviceId, @NonNull final String url) { + return serviceId + url; + } + + private static void removeStaleCache(@NonNull final LruCache cache) { + for (Map.Entry entry : cache.snapshot().entrySet()) { + final CacheData data = entry.getValue(); + if (data != null && data.isExpired()) { + cache.remove(entry.getKey()); + } + } + } + + private static Info getInfo(@NonNull final LruCache cache, + @NonNull final String key) { + final CacheData data = cache.get(key); + if (data == null) return null; + + if (data.isExpired()) { + cache.remove(key); + return null; + } + + return data.info; + } + + final private static class CacheData { + final private long expireTimestamp; + final private Info info; + + private CacheData(@NonNull final Info info, + final long timeout, + @NonNull final TimeUnit timeUnit) { + this.expireTimestamp = System.currentTimeMillis() + + TimeUnit.MILLISECONDS.convert(timeout, timeUnit); + + this.info = info; + } + + private boolean isExpired() { + return System.currentTimeMillis() > expireTimestamp; + } + } } diff --git a/app/src/main/res/layout/dialog_title.xml b/app/src/main/res/layout/dialog_title.xml index dc76a4f20..fa7e155d2 100644 --- a/app/src/main/res/layout/dialog_title.xml +++ b/app/src/main/res/layout/dialog_title.xml @@ -6,7 +6,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:clickable="false" - android:padding="@dimen/video_item_search_padding"> + android:paddingLeft="@dimen/video_item_search_padding" + android:paddingRight="@dimen/video_item_search_padding" + android:paddingTop="@dimen/video_item_search_padding"> \ No newline at end of file From 979bd09b29ff8326ef875ae158c8f895d89b35bc Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 14 Nov 2017 10:13:36 -0800 Subject: [PATCH 3/9] -Fixed popup player not in foreground when opened by external intent. -Fixed popup overlay permission causing exception when opened externally. --- app/src/main/AndroidManifest.xml | 2 +- .../org/schabi/newpipe/RouterPopupActivity.java | 1 + .../schabi/newpipe/player/PopupVideoPlayer.java | 14 +++++++++----- app/src/main/res/values/styles.xml | 8 ++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4f97a7201..dab6fb2ec 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -185,7 +185,7 @@ android:name=".RouterPopupActivity" android:label="@string/popup_mode_share_menu_title" android:taskAffinity="" - android:theme="@android:style/Theme.NoDisplay"> + android:theme="@style/PopupPermissionsTheme"> diff --git a/app/src/main/java/org/schabi/newpipe/RouterPopupActivity.java b/app/src/main/java/org/schabi/newpipe/RouterPopupActivity.java index 1cff0ca76..2e7089300 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterPopupActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterPopupActivity.java @@ -21,6 +21,7 @@ public class RouterPopupActivity extends RouterActivity { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !PermissionHelper.checkSystemAlertWindowPermission(this)) { Toast.makeText(this, R.string.msg_popup_permission, Toast.LENGTH_LONG).show(); + finish(); return; } StreamingService service; diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index a3fd0f7a7..5f8b36449 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -842,6 +842,8 @@ public final class PopupVideoPlayer extends Service { } savePositionAndSize(); } + + v.performClick(); return true; } @@ -880,23 +882,25 @@ public final class PopupVideoPlayer extends Service { private final Context context; private final Handler mainHandler; - FetcherHandler(Context context, int serviceId, String url) { + private FetcherHandler(Context context, int serviceId, String url) { this.mainHandler = new Handler(PopupVideoPlayer.this.getMainLooper()); this.context = context; this.url = url; this.serviceId = serviceId; } - /*package-private*/ void onReceive(final StreamInfo info) { + private void onReceive(final StreamInfo info) { mainHandler.post(new Runnable() { @Override public void run() { - playerImpl.initPlayback(new SinglePlayQueue(info)); + final Intent intent = NavigationHelper.getPlayerIntent(getApplicationContext(), + PopupVideoPlayer.class, new SinglePlayQueue(info)); + playerImpl.handleIntent(intent); } }); } - protected void onError(final Throwable exception) { + private void onError(final Throwable exception) { if (DEBUG) Log.d(TAG, "onError() called with: exception = [" + exception + "]"); exception.printStackTrace(); mainHandler.post(new Runnable() { @@ -922,7 +926,7 @@ public final class PopupVideoPlayer extends Service { stopSelf(); } - /*package-private*/ void onReCaptchaException() { + private void onReCaptchaException() { Toast.makeText(context, R.string.recaptcha_request_toast, Toast.LENGTH_LONG).show(); // Starting ReCaptcha Challenge Activity Intent intent = new Intent(context, ReCaptchaActivity.class); diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8f0bb02cd..d69bba254 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -160,4 +160,12 @@ @color/dark_youtube_primary_color + From 98e617001dd63200003041bcacfcdb095c42fb11 Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 14 Nov 2017 10:51:44 -0800 Subject: [PATCH 4/9] -Added search suggestion insert per #840. --- .../fragments/list/search/SearchFragment.java | 7 +- .../list/search/SuggestionListAdapter.java | 24 ++++-- .../ic_arrow_top_left_black_24dp.png | Bin 0 -> 554 bytes .../ic_arrow_top_left_white_24dp.png | Bin 0 -> 546 bytes .../ic_arrow_top_left_black_24dp.png | Bin 0 -> 418 bytes .../ic_arrow_top_left_white_24dp.png | Bin 0 -> 427 bytes .../ic_arrow_top_left_black_24dp.png | Bin 0 -> 492 bytes .../ic_arrow_top_left_white_24dp.png | Bin 0 -> 500 bytes .../ic_arrow_top_left_black_24dp.png | Bin 0 -> 570 bytes .../ic_arrow_top_left_white_24dp.png | Bin 0 -> 573 bytes .../ic_arrow_top_left_black_24dp.png | Bin 0 -> 675 bytes .../ic_arrow_top_left_white_24dp.png | Bin 0 -> 730 bytes .../res/layout/item_search_suggestion.xml | 80 ++++++++++++------ app/src/main/res/values/attrs.xml | 1 + app/src/main/res/values/styles.xml | 2 + 15 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_top_left_black_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_top_left_white_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_top_left_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_top_left_white_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_top_left_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_top_left_white_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_top_left_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_top_left_white_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_arrow_top_left_black_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_arrow_top_left_white_24dp.png diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index fae97bb7b..597c8d74f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -165,7 +165,7 @@ public class SearchFragment extends BaseListFragment items = new ArrayList<>(); private final Context context; private OnSuggestionItemSelected listener; - private boolean showSugestinHistory = true; + private boolean showSuggestionHistory = true; public interface OnSuggestionItemSelected { void onSuggestionItemSelected(SuggestionItem item); + void onSuggestionItemInserted(SuggestionItem item); void onSuggestionItemLongClick(SuggestionItem item); } @@ -32,7 +33,7 @@ public class SuggestionListAdapter extends RecyclerView.Adapter items) { this.items.clear(); - if (showSugestinHistory) { + if (showSuggestionHistory) { this.items.addAll(items); } else { // remove history items if history is disabled @@ -49,8 +50,8 @@ public class SuggestionListAdapter extends RecyclerView.Adapter|k1|%Oc%$NbBSkfJR9T^xl_H+M9WCijWi-X*q z7}lMWc?skwBzpw;GB8xBF)%c=FfjZA3N^f7U???UV0e|lz+eS5K)hhiu0R{01Y44~ zy9wy$!fk$L9koEv$x0Bg+K*noN7srr@!*8cKavd@dU|7DDU%=)U*Iq5V zWiK2*2-dc6DcL!Hc;UGJ;nm3x*mG>R9DSvlwp+1DQlrFk)693v1UOij>fKT#_&4@Gttwrp zx*_jK@TqGny>6;S*LWw3^66~CoRIOlk7jeO&>D!23MQWL&KtEOCgze??@ zVUPNOsh_k8S@ha|vM=E0SzQru^tab7Zov(Y{%UR7yf$RQCs&`!4cQCX4L)kJtoM3) z;Ldg*-!uFnY62X8RQ!X*J%62OC7#SFv>lzyB8k&R{ zT38tw0FkzVft7)Q^7o6MP&DM`r(~v8;?@wfD$@_BK?7t%aap=mQettcZfQ{_Lt17| ss+GRJeo1bDer{rVW^%S}nP+i9ak8WPm6!+bfO;4_UHx3vIVCg!0K|k1|%Oc%$NbBSkfJR9T^xl_H+M9WCijWi-X*q z7}lMWc?skwBzpw;GB8xBF)%c=FfjZA3N^f7U???UV0e|lz+eS5K)hhiu0R{01Y44~ zy9wy$!fk$L9koEv$x0Bg+K*nQF7srr@!*8cLavd@daJ}EbE@0F5=+xv6 zJr@3pOW6Y)yS86^%n^5>&RkE0+w|oTt!Iu4m!5n-+vl>=!hj#fZ*KZ}CMQgpQERk$ z@#?ipyk3TAo`175?16)Q;yKn8jn9tmSW>o>gSSC(gTdzTpo>Sgy!lgL$NX*5ooG4X z9gJoC*NYc?o7Tk}%^GB!zjB3wad6(s7ZdITc`{lqouvMJQdX!h-^y#Y-=`Jbl$?K~ zmce6|SJeIfm(q``C%t;G{{6p?J-UZfa+y~;Py8ji^26L+Ub9NnMAn2TXWm@tvmxm2 zIv=1L!}1~oWKZY|WdK8pLAAs+q9i4;B-JXpC>2OC7#SFv>lzyB8k&R{T38tw0FkzV zft7)Q^7o6MP&DM`r(~v8;?@wfD$@_BK?7t%aap=mQettcZfQ{_Lt17|s+GRJeo1bD jer{rVW^%S}fNrRZw^LD|th;#(P!EHrtDnm{r-UW|&5FRu literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_top_left_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_arrow_top_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..056a0ff28fe1c73e040bbcfe98d4916e35d2c2c1 GIT binary patch literal 418 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ua371Hn({-St38vK4 z>mKHF>KMOU+RAF+{SB!2#f4K%fd(fS8P;&S6G7^>bP0l+XkK DgQ!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ua371Hn({-St32@2ahr!d; K&t;ucLK6U^dWg{g literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_top_left_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_top_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e4255a18aa1fe5067cc5f6cb263513c3f8ce30a3 GIT binary patch literal 492 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzC{oH>NS%G}U;vjb? zhIQv;UIIA^$sR$z3=CCj3=9n|3=F@3LJcn%7)pVryh>nTu$sZZAYL$MSD+10f-TA0 z-33Sk!B6Mi^+1ZVz$3C4NPB>>+sSM@AY-kki(^Q}y|>play2^$v^+F?BKUNc&HSnP z60Ev8E_;vc<-Qp?S6+wZ;Lkl?4w_4+1l5_grK=w=Pp|${apk_SLQwECDaJi}j$dUs zq_Ayqd-LxnwwIVP821RiP}#=d;w;1Hq*&Bo(Ba=8(2>tjbwrZE^pQ@3SR!M9(i#RU z7tRK*K&}OjR~Rw`wsIbvB%l+^G;za!+qZk%BctcL@IQEIyJAVp)6?xT>!$>H-Q6sy zeRmH}h2>g4pu<&5Tq8Hb>+6@~7U<_Dre`K+ d>zW(71{u1ByYM$<^#JuSc)I$ztaD0e0sw$6n)?6% literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_top_left_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_top_left_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..db578cab9eaea2867b9fc4c52666df450747b034 GIT binary patch literal 500 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzC{oH>NS%G}U;vjb? zhIQv;UIIA^$sR$z3=CCj3=9n|3=F@3LJcn%7)pVryh>nTu$sZZAYL$MSD+10f-TA0 z-33Sk!B6Mi^+1ZVz$3C4NPB>>+sSM@AY-eii(^Q}y|>p5`I-#`TmogDcAW4%=RQ@M zZOKB<#sdPkBi`uDyx%xsM!ME6Kh336g34O&urn@r+3kFy?t5VWHT9xWrX8HWeHr4e z{XWM~qad{S_>s~r_ad2IFxK3u>HPZZy{&zR$N|wL{s(M@ECr1}SQofIVOSx!lOf85 zvq313Yk~6>h7|%^8KjO#GVm@ssL0_sQ9$P|tKi1Jwz6x=rz%a0f5iJBbMHzvK}H_E z>`X#vq k`nieenaSC@5hdZ}ArZlTr+>{_3Dm>j>FVdQ&MBb@0DXj_ZvX%Q literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_top_left_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_top_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..566b5c5d3a8ab9360f3aa48e743fa9bc717cc45f GIT binary patch literal 570 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!Ea{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ua371Hn({-St3hV4g#(hm$!br&+`9@ z6UUF-u#Fo84d3N#I;~>--RabU+lMEq2?;_#;0iwN`}50o-M(}2Wy5aH1x^g2Oe+K& z=FaXp?|kWI^_yvpmz1tDEOlAM>eX)2ZXhbeR&s!Mp z@u22wC(AjX=6m<&bbl96f`CQ6-!C8<`)MX5lF!N|bS zT-VT0*U%)y(89{d0En~=46F#UX>ItDnm{r-UW|QUSgU literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_top_left_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_top_left_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..89d726f6caf5ccaf2af95e40a989a91cc4136b56 GIT binary patch literal 573 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!Ea{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ua371Hn({-St3+# zD1N*-r;oeY&?(w$Z^irn>sy|D@jmQyT@VU(u3BFiImyTEd+pVCll;Wk|14+lVhK=c z5MsPy^z{3Ll8yJOQx?qdXm$8F!HnUkQRdP`(kYX@0 zFf`XSG}JXT2{E*=GBN-nZ36=<0|Vvn7eAqB$jwj5OsmALA!t>mA5en^$cEywbgQJq z;#A$zqD+Rg%$!s!eSQ6s+yedF#PrPMY+d8f%w+$v0G}_Or!s(g7(8A5T-G@yGywp5 C0mMWA literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_top_left_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_top_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d536127b5539a902072bbeeb5a5a1879901954e6 GIT binary patch literal 675 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ua371Hn({-St3w(+=}`CtE2=T;s2ELti$LB(?t6urIb+{w) zd89R@zzJEaP#gIJ-rpWn2MQnHXv|`kQ1tL-P-e;CO=xk;K3%JC@wqhb43_TZ)PGd-DDTron5Olf<6l__^%izXwQ3xor#*{%~ zp{EOjfz#F%Ks8zu84qyGc4cQ!&bg!vl!;gm6jZVWY7G0z$KbXj3#jtYem7PIcrvS~YInBl3*3i`bz3jW-CZPId2`!uwiA-)Y8U)oanA}h0`Q$dY-(5Y) z{Gn*YDY=sK>s$+dHpg^5_{9EO^59eTNQ?gu>`X#vq`nieenaSC@{#Ch!QI$E4*R)ff Q0QE3!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ua371Hn({-St3X>)PK*Tk0x%7fpep(CP z?M>ys>ls@1Va6WERxXQ=<@-F}Nm_6Fyq;qzP&W*0%j&upFlkf#t9RV~!9T3GSDf5; z;GUp@B;zDFvCZxD9M#&C`?bPiYzj_O+8A6qE=VMl3%dOgwwn^P@0*aK@`0U6XBSTS zr1^42!T#rAA3H0je>wbo#bkHkuTn~1f`kve?zrHb%dlS6X^SP}o_QP-pRs)~cInup z(lB4ysbwkSA05G{tt=ltyJTFHI#4Z;xUz%cUOR`k3+snCml@hd4d0ayooQ@k`!LUC zhT)nI4ELsUOl^K8bf8*zVUovPriywc8;OAH40g>NOHtd=s>#Q!}$x> zh#hz?_%KUhHQR@oEcJn8aS90 z4l$rJ9WDi4%1> - + android:layout_height="wrap_content"> - - - + + + + + + + - \ No newline at end of file + android:src="?attr/search_add" + android:background="?attr/selectableItemBackgroundBorderless" + tools:ignore="ContentDescription,RtlHardcoded"/> + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index abf7c7b09..e51ab9ffd 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -20,6 +20,7 @@ + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d69bba254..d41b3fe31 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -27,6 +27,7 @@ @drawable/ic_history_black_24dp @drawable/ic_drag_handle_black_24dp @drawable/ic_fiber_manual_record_black_24dp + @drawable/ic_arrow_top_left_black_24dp @color/light_separator_color @color/light_contrast_background_color @@ -65,6 +66,7 @@ @drawable/ic_history_white_24dp @drawable/ic_drag_handle_white_24dp @drawable/ic_fiber_manual_record_white_24dp + @drawable/ic_arrow_top_left_white_24dp @color/dark_separator_color @color/dark_contrast_background_color From 0fe5a44e5a2b8c917eebe1c7e37643a26c6af34b Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 14 Nov 2017 10:58:01 -0800 Subject: [PATCH 5/9] -Removed todo for timeout feature on info cache. --- app/src/main/java/org/schabi/newpipe/util/InfoCache.java | 1 - 1 file changed, 1 deletion(-) 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 a3fd7805a..794c3dd78 100644 --- a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java +++ b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java @@ -42,7 +42,6 @@ public final class InfoCache { private static final int TRIM_CACHE_TO = 30; private static final int DEFAULT_TIMEOUT_HOURS = 4; - // TODO: Replace to one with timeout (like the one from guava) private static final LruCache lruCache = new LruCache<>(MAX_ITEMS_ON_CACHE); private InfoCache() { From 5e16969d61b19c7bb4cf3fdfe7fc1a502c008abd Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 14 Nov 2017 11:32:50 -0800 Subject: [PATCH 6/9] -Increased search item insert arrow click space. --- .../res/layout/item_search_suggestion.xml | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/app/src/main/res/layout/item_search_suggestion.xml b/app/src/main/res/layout/item_search_suggestion.xml index f6facf29e..374339bbc 100644 --- a/app/src/main/res/layout/item_search_suggestion.xml +++ b/app/src/main/res/layout/item_search_suggestion.xml @@ -3,7 +3,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:orientation="horizontal"> @@ -44,17 +44,28 @@ tools:text="Search query"/> - + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:paddingBottom="8dp" + android:paddingTop="8dp"> + + + + + From 69374e25fec2cd3478186ddcfa1fe70daaedbecc Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 14 Nov 2017 15:58:13 -0800 Subject: [PATCH 7/9] -Fixed cursor position to point to end after search text insert. -Reduced and slightly changed offset of search text insert image. --- .../newpipe/fragments/list/search/SearchFragment.java | 1 + app/src/main/res/layout/item_search_suggestion.xml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 597c8d74f..fb54a15c3 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -449,6 +449,7 @@ public class SearchFragment extends BaseListFragment + android:paddingTop="10dp"> From d6e4f3c80982c41f5f3c2546fd3d5c0b32511332 Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Wed, 15 Nov 2017 20:09:01 -0800 Subject: [PATCH 8/9] -Saves the recovery timestamp when player source fails during a valid stream playback. --- .../org/schabi/newpipe/player/BasePlayer.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) 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 3da976991..427c97741 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -134,6 +134,7 @@ public abstract class BasePlayer implements Player.EventListener, PlaybackListen protected final static int FAST_FORWARD_REWIND_AMOUNT = 10000; // 10 Seconds protected final static int PLAY_PREV_ACTIVATION_LIMIT = 5000; // 5 seconds protected final static int PROGRESS_LOOP_INTERVAL = 500; + protected final static int RECOVERY_SKIP_THRESHOLD = 3000; // 3 seconds protected SimpleExoPlayer simpleExoPlayer; protected AudioReactor audioReactor; @@ -453,16 +454,20 @@ public abstract class BasePlayer implements Player.EventListener, PlaybackListen final PlayQueueItem currentSourceItem = playQueue.getItem(); // Check if already playing correct window - final boolean isCurrentWindowCorrect = simpleExoPlayer.getCurrentWindowIndex() == currentSourceIndex; + final boolean isCurrentWindowCorrect = + simpleExoPlayer.getCurrentWindowIndex() == currentSourceIndex; // Check if recovering - if (isCurrentWindowCorrect && currentSourceItem != null && - currentSourceItem.getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET) { + if (isCurrentWindowCorrect && currentSourceItem != null) { /* Recovering with sub-second position may cause a long buffer delay in ExoPlayer, * rounding this position to the nearest second will help alleviate this.*/ final long position = currentSourceItem.getRecoveryPosition(); - if (DEBUG) Log.d(TAG, "Rewinding to recovery window: " + currentSourceIndex + " at: " + getTimeString((int)position)); + /* Skip recovering if the recovery position is not set.*/ + if (position == PlayQueueItem.RECOVERY_UNSET) return; + + if (DEBUG) Log.d(TAG, "Rewinding to recovery window: " + currentSourceIndex + + " at: " + getTimeString((int)position)); simpleExoPlayer.seekTo(currentSourceItem.getRecoveryPosition()); playQueue.unsetRecovery(currentSourceIndex); } @@ -514,10 +519,10 @@ public abstract class BasePlayer implements Player.EventListener, PlaybackListen } break; case Player.STATE_READY: //3 + recover(); if (!isPrepared) { isPrepared = true; onPrepared(playWhenReady); - recover(); break; } if (currentState == STATE_PAUSED_SEEK) break; @@ -544,14 +549,18 @@ public abstract class BasePlayer implements Player.EventListener, PlaybackListen * an error to the play queue based on if the current error can be skipped. * * This is done because ExoPlayer reports the source exceptions before window is - * transitioned on seamless playback. + * transitioned on seamless playback. Because player error causes ExoPlayer to go + * back to {@link Player#STATE_IDLE STATE_IDLE}, we reset and prepare the media source + * again to resume playback. * - * Because player error causes ExoPlayer to go back to {@link Player#STATE_IDLE STATE_IDLE}, - * we reset and prepare the media source again to resume playback.

+ * In the event that this error is produced during a valid stream playback, we save the + * current position so the playback may be recovered and resumed manually by the user. This + * happens only if the playback is {@link #RECOVERY_SKIP_THRESHOLD} milliseconds until complete. + *

* * {@link ExoPlaybackException#TYPE_UNEXPECTED TYPE_UNEXPECTED}:

* If a runtime error occurred, then we can try to recover it by restarting the playback - * after setting the timestamp recovery. + * after setting the timestamp recovery.

* * {@link ExoPlaybackException#TYPE_RENDERER TYPE_RENDERER}:

* If the renderer failed, treat the error as unrecoverable. @@ -568,6 +577,10 @@ public abstract class BasePlayer implements Player.EventListener, PlaybackListen switch (error.type) { case ExoPlaybackException.TYPE_SOURCE: + if (simpleExoPlayer.getCurrentPosition() < + simpleExoPlayer.getDuration() - RECOVERY_SKIP_THRESHOLD) { + setRecovery(); + } playQueue.error(isCurrentWindowValid()); showStreamError(error); break; From 2da411c1ecd3995c5f2afb9a361cd1efcd5aab44 Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Wed, 15 Nov 2017 20:42:05 -0800 Subject: [PATCH 9/9] -#836: Modified notifications texts to use custom colors instead of device-specific styles. --- app/src/main/res/layout/player_notification.xml | 4 ++-- app/src/main/res/layout/player_notification_expanded.xml | 6 +++--- app/src/main/res/layout/player_popup_notification.xml | 4 ++-- app/src/main/res/values/colors.xml | 3 +++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/layout/player_notification.xml b/app/src/main/res/layout/player_notification.xml index 157615bb7..2a3e7aff3 100644 --- a/app/src/main/res/layout/player_notification.xml +++ b/app/src/main/res/layout/player_notification.xml @@ -34,22 +34,22 @@ diff --git a/app/src/main/res/layout/player_notification_expanded.xml b/app/src/main/res/layout/player_notification_expanded.xml index d37087312..7d59720e0 100644 --- a/app/src/main/res/layout/player_notification_expanded.xml +++ b/app/src/main/res/layout/player_notification_expanded.xml @@ -46,22 +46,22 @@ @@ -80,7 +80,6 @@ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 3750bdb78..b77a2d229 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -39,7 +39,10 @@ #EEFFFFFF #ffffff #66000000 + #323232 + #ffffff + #999999 #e53935 #fff