From 37549177f75543566271989fcdb95c5929b0f0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schu=CC=88ller?= Date: Tue, 25 Dec 2018 14:22:16 +0100 Subject: [PATCH] - Added options menu to video playback - Changed video background color to black - Changed layout of video OSD --- .../peertube/activity/VideoPlayActivity.java | 10 +++ .../fragment/VideoOptionsFragment.java | 34 ++++++++ .../main/res/layout/activity_video_play.xml | 3 +- .../bottom_sheet_video_options_fragment.xml | 24 ++++++ .../res/layout/exo_playback_control_view.xml | 79 +++++++++++++++---- .../main/res/menu/menu_video_play_options.xml | 7 ++ app/src/main/res/values/colors.xml | 1 + 7 files changed, 143 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java create mode 100644 app/src/main/res/layout/bottom_sheet_video_options_fragment.xml create mode 100644 app/src/main/res/menu/menu_video_play_options.xml diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index e43af9d..ddb5f88 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -39,6 +39,7 @@ import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoRendererEventListener; import com.squareup.picasso.Picasso; import net.schueller.peertube.R; +import net.schueller.peertube.fragment.VideoOptionsFragment; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.helper.MetaDataHelper; import net.schueller.peertube.intents.Intents; @@ -241,6 +242,7 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere TextView videoMeta = findViewById(R.id.videoMeta); ImageView avatarView = findViewById(R.id.avatar); ImageButton moreButton = findViewById(R.id.moreButton); + ImageButton videoOptions = findViewById(R.id.exo_more); Video video = response.body(); @@ -287,6 +289,14 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere popup.show(); }); + videoOptions.setOnClickListener(v -> { + + VideoOptionsFragment videoOptionsFragment = + VideoOptionsFragment.newInstance(); + videoOptionsFragment.show(getSupportFragmentManager(), + "video_options_fragment"); + }); + mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl()); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java new file mode 100644 index 0000000..27bf542 --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -0,0 +1,34 @@ +package net.schueller.peertube.fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.google.android.material.bottomsheet.BottomSheetDialogFragment; + +import net.schueller.peertube.R; + +import androidx.annotation.Nullable; + +public class VideoOptionsFragment extends BottomSheetDialogFragment { + + public static VideoOptionsFragment newInstance() { + return new VideoOptionsFragment(); + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, + @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container, + false); + + // get the views and attach the listener + + return view; + + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_video_play.xml b/app/src/main/res/layout/activity_video_play.xml index 4416157..85bf81d 100644 --- a/app/src/main/res/layout/activity_video_play.xml +++ b/app/src/main/res/layout/activity_video_play.xml @@ -17,6 +17,7 @@ android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="250dp" + android:background="@color/videoBackgroundColor" app:layout_constraintDimensionRatio="H,3:1" app:layout_constraintEnd_toEndOf="parent" @@ -111,6 +112,6 @@ - + diff --git a/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml b/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml new file mode 100644 index 0000000..7646e31 --- /dev/null +++ b/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml index c61cf6d..05296fc 100644 --- a/app/src/main/res/layout/exo_playback_control_view.xml +++ b/app/src/main/res/layout/exo_playback_control_view.xml @@ -2,13 +2,44 @@ + + + + + + + + + + + + - - @@ -36,11 +64,18 @@ + + + + - + android:layout_height="0dp" + android:layout_weight="1" /> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_video_play_options.xml b/app/src/main/res/menu/menu_video_play_options.xml new file mode 100644 index 0000000..0af63ab --- /dev/null +++ b/app/src/main/res/menu/menu_video_play_options.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 7c9e076..e5588c1 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -4,6 +4,7 @@ #d69b9b9b #e300aaff #7ca6a6a6 + #000000