From d54a6e0b0e0c8e1e290d115a505f509cc68a6a19 Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Sat, 14 Oct 2017 14:09:49 -0700 Subject: [PATCH] -Added helper text on click for background and popup button on detail fragment for feature discovery. -Fixed popup video queuing causes existing popup player to change quality. --- .../fragments/detail/VideoDetailFragment.java | 19 + .../newpipe/player/BackgroundPlayer.java | 4 +- .../org/schabi/newpipe/player/BasePlayer.java | 3 + .../newpipe/player/MainVideoPlayer.java | 6 +- .../newpipe/player/PopupVideoPlayer.java | 5 +- .../schabi/newpipe/player/VideoPlayer.java | 6 +- .../main/res/layout/fragment_video_detail.xml | 701 +++++++++--------- app/src/main/res/values/strings.xml | 2 +- 8 files changed, 383 insertions(+), 363 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 e99a07f56..177166996 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 @@ -28,6 +28,7 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -144,6 +145,7 @@ public class VideoDetailFragment extends BaseStateFragment implement private TextView detailControlsBackground; private TextView detailControlsPopup; + private TextView appendControlsDetail; private LinearLayout videoDescriptionRootLayout; private TextView videoUploadDateView; @@ -419,6 +421,7 @@ public class VideoDetailFragment extends BaseStateFragment implement detailControlsBackground = rootView.findViewById(R.id.detail_controls_background); detailControlsPopup = rootView.findViewById(R.id.detail_controls_popup); + appendControlsDetail = rootView.findViewById(R.id.touch_append_detail); videoDescriptionRootLayout = rootView.findViewById(R.id.detail_description_root_layout); videoUploadDateView = rootView.findViewById(R.id.detail_upload_date_view); @@ -469,6 +472,22 @@ public class VideoDetailFragment extends BaseStateFragment implement detailControlsPopup.setLongClickable(true); detailControlsBackground.setOnLongClickListener(this); detailControlsPopup.setOnLongClickListener(this); + detailControlsBackground.setOnTouchListener(getOnControlsTouchListener()); + detailControlsPopup.setOnTouchListener(getOnControlsTouchListener()); + } + + private View.OnTouchListener getOnControlsTouchListener() { + return new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + appendControlsDetail.setVisibility(View.VISIBLE); + } else { + appendControlsDetail.setVisibility(View.GONE); + } + return false; + } + }; } private void initThumbnailViews(StreamInfo info) { 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 e4f02f578..6b99f86e0 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -289,9 +289,7 @@ public final class BackgroundPlayer extends Service { } @Override - public void handleIntent(Intent intent) { - super.handleIntent(intent); - + protected void postProcess(@NonNull final Intent intent) { resetNotification(); startForeground(NOTIFICATION_ID, notBuilder.build()); 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 d543ef5c4..6a4fc820e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -251,6 +251,8 @@ public abstract class BasePlayer implements Player.EventListener, }); } + protected abstract void postProcess(@NonNull final Intent intent); + public void handleIntent(Intent intent) { if (DEBUG) Log.d(TAG, "handleIntent() called with: intent = [" + intent + "]"); if (intent == null) return; @@ -284,6 +286,7 @@ public abstract class BasePlayer implements Player.EventListener, // Good to go... initPlayback(this, queue); + postProcess(intent); } protected void initPlayback(@NonNull final PlaybackListener listener, @NonNull final PlayQueue queue) { 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 0b5d0c9d3..c20b5d3e2 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -270,11 +270,7 @@ public final class MainVideoPlayer extends Activity { @Override public int getPreferredResolution() { if (sharedPreferences == null || context == null) return Integer.MAX_VALUE; - - return Localization.resolutionOf(sharedPreferences.getString( - context.getString(R.string.default_resolution_key), - context.getString(R.string.default_resolution_value) - )); + return Localization.resolutionOf(sharedPreferences.getString(context.getString(R.string.default_resolution_key), context.getString(R.string.default_resolution_value))); } /*////////////////////////////////////////////////////////////////////////// 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 335dfec5b..784c9140b 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -411,10 +411,7 @@ public final class PopupVideoPlayer extends Service { @Override public int getPreferredResolution() { if (sharedPreferences == null || context == null) return Integer.MAX_VALUE; - return Localization.resolutionOf(sharedPreferences.getString( - context.getString(R.string.default_popup_resolution_key), - context.getString(R.string.default_popup_resolution_value) - )); + return Localization.resolutionOf(sharedPreferences.getString(context.getString(R.string.default_popup_resolution_key), context.getString(R.string.default_popup_resolution_value))); } @Override 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 4c0982d72..7f79048b7 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -217,11 +217,7 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer. } @Override - @SuppressWarnings("unchecked") - public void handleIntent(Intent intent) { - super.handleIntent(intent); - if (intent == null) return; - + protected void postProcess(@NonNull final Intent intent) { final int resolutionTarget = intent.getIntExtra(MAX_RESOLUTION, getPreferredResolution()); trackSelector.setParameters( // Assume video is horizontal diff --git a/app/src/main/res/layout/fragment_video_detail.xml b/app/src/main/res/layout/fragment_video_detail.xml index b067db7bc..bded5fc2a 100644 --- a/app/src/main/res/layout/fragment_video_detail.xml +++ b/app/src/main/res/layout/fragment_video_detail.xml @@ -1,308 +1,368 @@ - - - + + + android:visibility="visible" + app:parallax_factor="1.9"> - + + android:layout_height="wrap_content" + android:orientation="vertical"> - - + + android:background="@android:color/black" + android:clickable="true" + android:focusable="true" + android:foreground="?attr/selectableItemBackground"> - - + + + + + + + + + + + + android:focusable="true" + android:paddingLeft="12dp" + android:paddingRight="12dp"> - + tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a ultricies ex. Integer sit amet sodales risus. Duis non mi et urna pretium bibendum. Nunc eleifend est quis ipsum porttitor egestas. Sed facilisis, nisl quis eleifend pellentesque, orci metus egestas dolor, at accumsan eros metus quis libero."/> + android:id="@+id/detail_toggle_description_view" + android:layout_width="15dp" + android:layout_height="15dp" + android:layout_gravity="center_vertical|right" + android:layout_marginLeft="5dp" + android:src="@drawable/arrow_down" + tools:ignore="ContentDescription,RtlHardcoded"/> - - + + + + + + + + android:layout_below="@+id/detail_title_root_layout" + android:orientation="vertical" + android:visibility="gone" + tools:visibility="visible"> - - + + + + + + + + + + + + + + + + + + + + + + + + android:paddingRight="12dp" + android:paddingTop="8dp"> + + + + tools:text="Uploader"/> - + android:layout_marginRight="12dp" + android:text="@string/rss_button_title" + android:textSize="12sp" + android:theme="@style/RedButton" + android:drawableLeft="@drawable/ic_rss_feed_white_24dp" + tools:ignore="RtlHardcoded" + android:visibility="gone"/>--> + - - - - + android:layout_height="1px" + android:layout_marginLeft="8dp" + android:layout_marginRight="8dp" + android:background="?attr/separator_color"/> - - - - + - - + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/video_item_detail_upload_date_text_size" + android:textStyle="bold" + tools:text="Published on Oct 2, 2009"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:layout_marginBottom="8dp" + android:layout_marginLeft="12dp" + android:layout_marginRight="12dp" + android:layout_marginTop="3dp" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textIsSelectable="true" + android:textSize="@dimen/video_item_detail_description_text_size" + tools:text="Description Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a ultricies ex. Integer sit amet sodales risus. Duis non mi et urna pretium bibendum."/> - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c2e4f858d..2454cef9c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -301,5 +301,5 @@ Remove Details Audio Settings - + Hold To Append