Tweak the autoplay video control.

This commit is contained in:
Alex Ning 2021-07-20 20:55:23 +08:00
parent 568aa7a78f
commit a0879821ab
9 changed files with 119 additions and 117 deletions

View File

@ -1615,11 +1615,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
muteButton.setOnClickListener(view -> { muteButton.setOnClickListener(view -> {
if (helper != null) { if (helper != null) {
if (helper.getVolume() != 0) { if (helper.getVolume() != 0) {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_24dp));
helper.setVolume(0f); helper.setVolume(0f);
volume = 0f; volume = 0f;
} else { } else {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_24dp));
helper.setVolume(1f); helper.setVolume(1f);
volume = 1f; volume = 1f;
} }
@ -1701,9 +1701,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
helper.setVolume(volume); helper.setVolume(volume);
muteButton.setVisibility(View.VISIBLE); muteButton.setVisibility(View.VISIBLE);
if (volume != 0f) { if (volume != 0f) {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_24dp));
} else { } else {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_24dp));
} }
break; break;
} }

View File

@ -2820,12 +2820,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
muteButton.setOnClickListener(view -> { muteButton.setOnClickListener(view -> {
if (helper != null) { if (helper != null) {
if (helper.getVolume() != 0) { if (helper.getVolume() != 0) {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_24dp));
helper.setVolume(0f); helper.setVolume(0f);
volume = 0f; volume = 0f;
mFragment.videoAutoplayChangeMutingOption(true); mFragment.videoAutoplayChangeMutingOption(true);
} else { } else {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_24dp));
helper.setVolume(1f); helper.setVolume(1f);
volume = 1f; volume = 1f;
mFragment.videoAutoplayChangeMutingOption(false); mFragment.videoAutoplayChangeMutingOption(false);
@ -2918,9 +2918,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
helper.setVolume(volume); helper.setVolume(volume);
muteButton.setVisibility(View.VISIBLE); muteButton.setVisibility(View.VISIBLE);
if (volume != 0f) { if (volume != 0f) {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_24dp));
} else { } else {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_24dp));
} }
break; break;
} }
@ -4039,12 +4039,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
muteButton.setOnClickListener(view -> { muteButton.setOnClickListener(view -> {
if (helper != null) { if (helper != null) {
if (helper.getVolume() != 0) { if (helper.getVolume() != 0) {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_24dp));
helper.setVolume(0f); helper.setVolume(0f);
volume = 0f; volume = 0f;
mFragment.videoAutoplayChangeMutingOption(true); mFragment.videoAutoplayChangeMutingOption(true);
} else { } else {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_24dp));
helper.setVolume(1f); helper.setVolume(1f);
volume = 1f; volume = 1f;
mFragment.videoAutoplayChangeMutingOption(false); mFragment.videoAutoplayChangeMutingOption(false);
@ -4137,9 +4137,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
helper.setVolume(volume); helper.setVolume(volume);
muteButton.setVisibility(View.VISIBLE); muteButton.setVisibility(View.VISIBLE);
if (volume != 0f) { if (volume != 0f) {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_24dp));
} else { } else {
muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_24dp));
} }
break; break;
} }

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid
android:color="#80000000" />
<corners
android:topLeftRadius="16dp"
android:topRightRadius="16dp" />
</shape>

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp" android:width="24dp"
android:height="18dp" android:height="24dp"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M6,14c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L7,17v-2c0,-0.55 -0.45,-1 -1,-1zM6,10c0.55,0 1,-0.45 1,-1L7,7h2c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L6,5c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1zM17,17h-2c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h3c0.55,0 1,-0.45 1,-1v-3c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1v2zM14,6c0,0.55 0.45,1 1,1h2v2c0,0.55 0.45,1 1,1s1,-0.45 1,-1L19,6c0,-0.55 -0.45,-1 -1,-1h-3c-0.55,0 -1,0.45 -1,1z" android:fillColor="@android:color/white"
android:fillColor="#FFFFFF"/> android:pathData="M6,14c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L7,17v-2c0,-0.55 -0.45,-1 -1,-1zM6,10c0.55,0 1,-0.45 1,-1L7,7h2c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L6,5c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1zM17,17h-2c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h3c0.55,0 1,-0.45 1,-1v-3c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1v2zM14,6c0,0.55 0.45,1 1,1h2v2c0,0.55 0.45,1 1,1s1,-0.45 1,-1L19,6c0,-0.55 -0.45,-1 -1,-1h-3c-0.55,0 -1,0.45 -1,1z"/>
</vector> </vector>

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp" android:width="24dp"
android:height="18dp" android:height="24dp"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M3.63,3.63c-0.39,0.39 -0.39,1.02 0,1.41L7.29,8.7 7,9L4,9c-0.55,0 -1,0.45 -1,1v4c0,0.55 0.45,1 1,1h3l3.29,3.29c0.63,0.63 1.71,0.18 1.71,-0.71v-4.17l4.18,4.18c-0.49,0.37 -1.02,0.68 -1.6,0.91 -0.36,0.15 -0.58,0.53 -0.58,0.92 0,0.72 0.73,1.18 1.39,0.91 0.8,-0.33 1.55,-0.77 2.22,-1.31l1.34,1.34c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L5.05,3.63c-0.39,-0.39 -1.02,-0.39 -1.42,0zM19,12c0,0.82 -0.15,1.61 -0.41,2.34l1.53,1.53c0.56,-1.17 0.88,-2.48 0.88,-3.87 0,-3.83 -2.4,-7.11 -5.78,-8.4 -0.59,-0.23 -1.22,0.23 -1.22,0.86v0.19c0,0.38 0.25,0.71 0.61,0.85C17.18,6.54 19,9.06 19,12zM10.29,5.71l-0.17,0.17L12,7.76L12,6.41c0,-0.89 -1.08,-1.33 -1.71,-0.7zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v1.79l2.48,2.48c0.01,-0.08 0.02,-0.16 0.02,-0.24z" android:fillColor="@android:color/white"
android:fillColor="#ffffff"/> android:pathData="M3.63,3.63c-0.39,0.39 -0.39,1.02 0,1.41L7.29,8.7 7,9L4,9c-0.55,0 -1,0.45 -1,1v4c0,0.55 0.45,1 1,1h3l3.29,3.29c0.63,0.63 1.71,0.18 1.71,-0.71v-4.17l4.18,4.18c-0.49,0.37 -1.02,0.68 -1.6,0.91 -0.36,0.15 -0.58,0.53 -0.58,0.92 0,0.72 0.73,1.18 1.39,0.91 0.8,-0.33 1.55,-0.77 2.22,-1.31l1.34,1.34c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L5.05,3.63c-0.39,-0.39 -1.02,-0.39 -1.42,0zM19,12c0,0.82 -0.15,1.61 -0.41,2.34l1.53,1.53c0.56,-1.17 0.88,-2.48 0.88,-3.87 0,-3.83 -2.4,-7.11 -5.78,-8.4 -0.59,-0.23 -1.22,0.23 -1.22,0.86v0.19c0,0.38 0.25,0.71 0.61,0.85C17.18,6.54 19,9.06 19,12zM10.29,5.71l-0.17,0.17L12,7.76L12,6.41c0,-0.89 -1.08,-1.33 -1.71,-0.7zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v1.79l2.48,2.48c0.01,-0.08 0.02,-0.16 0.02,-0.24z"/>
</vector> </vector>

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp" android:width="24dp"
android:height="18dp" android:height="24dp"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M8,19c1.1,0 2,-0.9 2,-2L10,7c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2v10c0,1.1 0.9,2 2,2zM14,7v10c0,1.1 0.9,2 2,2s2,-0.9 2,-2L18,7c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2z" android:fillColor="@android:color/white"
android:fillColor="#ffffff"/> android:pathData="M8,19c1.1,0 2,-0.9 2,-2L10,7c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2v10c0,1.1 0.9,2 2,2zM14,7v10c0,1.1 0.9,2 2,2s2,-0.9 2,-2L18,7c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2z"/>
</vector> </vector>

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp" android:width="24dp"
android:height="18dp" android:height="24dp"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M8,6.82v10.36c0,0.79 0.87,1.27 1.54,0.84l8.14,-5.18c0.62,-0.39 0.62,-1.29 0,-1.69L9.54,5.98C8.87,5.55 8,6.03 8,6.82z" android:fillColor="@android:color/white"
android:fillColor="#ffffff"/> android:pathData="M8,6.82v10.36c0,0.79 0.87,1.27 1.54,0.84l8.14,-5.18c0.62,-0.39 0.62,-1.29 0,-1.69L9.54,5.98C8.87,5.55 8,6.03 8,6.82z"/>
</vector> </vector>

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp" android:width="24dp"
android:height="18dp" android:height="24dp"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M3,10v4c0,0.55 0.45,1 1,1h3l3.29,3.29c0.63,0.63 1.71,0.18 1.71,-0.71L12,6.41c0,-0.89 -1.08,-1.34 -1.71,-0.71L7,9L4,9c-0.55,0 -1,0.45 -1,1zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,4.45v0.2c0,0.38 0.25,0.71 0.6,0.85C17.18,6.53 19,9.06 19,12s-1.82,5.47 -4.4,6.5c-0.36,0.14 -0.6,0.47 -0.6,0.85v0.2c0,0.63 0.63,1.07 1.21,0.85C18.6,19.11 21,15.84 21,12s-2.4,-7.11 -5.79,-8.4c-0.58,-0.23 -1.21,0.22 -1.21,0.85z" android:fillColor="@android:color/white"
android:fillColor="#ffffff"/> android:pathData="M3,10v4c0,0.55 0.45,1 1,1h3l3.29,3.29c0.63,0.63 1.71,0.18 1.71,-0.71L12,6.41c0,-0.89 -1.08,-1.34 -1.71,-0.71L7,9L4,9c-0.55,0 -1,0.45 -1,1zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,4.45v0.2c0,0.38 0.25,0.71 0.6,0.85C17.18,6.53 19,9.06 19,12s-1.82,5.47 -4.4,6.5c-0.36,0.14 -0.6,0.47 -0.6,0.85v0.2c0,0.63 0.63,1.07 1.21,0.85C18.6,19.11 21,15.84 21,12s-2.4,-7.11 -5.79,-8.4c-0.58,-0.23 -1.21,0.22 -1.21,0.85z"/>
</vector> </vector>

View File

@ -1,92 +1,105 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linear_layout_exo_playback_control_view" android:id="@+id/linear_layout_exo_playback_control_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:orientation="vertical" android:orientation="vertical"
android:background="@drawable/background_autoplay"> android:background="#80000000">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@id/exo_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:includeFontPadding="false"
android:layout_marginStart="8dp"
android:textColor="#FFFFFF"
android:textSize="12sp"
android:textStyle="bold"
android:fontFamily="?attr/font_family" />
<TextView
android:id="@+id/slash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/exo_position"
android:layout_centerVertical="true"
android:text="/"
android:textColor="#FFFFFF"
android:textSize="12sp"
android:textStyle="bold"
android:fontFamily="?attr/font_family" />
<TextView android:id="@id/exo_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/slash"
android:layout_centerVertical="true"
android:includeFontPadding="false"
android:textColor="#FFFFFF"
android:textSize="12sp"
android:textStyle="bold"
android:fontFamily="?attr/font_family" />
<ImageView android:id="@id/exo_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_play_arrow_white_rounded_18dp" />
<ImageView android:id="@id/exo_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_pause_white_rounded_18dp" />
<ImageView <ImageView
android:id="@+id/mute_exo_playback_control_view" android:id="@+id/mute_exo_playback_control_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="16dp"
android:layout_toStartOf="@id/fullscreen_exo_playback_control_view" android:layout_toStartOf="@id/fullscreen_exo_playback_control_view"
android:src="@drawable/ic_mute_white_rounded_18dp" android:src="@drawable/ic_mute_white_rounded_24dp"
android:visibility="gone" /> android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@id/fullscreen_exo_playback_control_view" />
<ImageView <ImageView
android:id="@+id/fullscreen_exo_playback_control_view" android:id="@+id/fullscreen_exo_playback_control_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="16dp"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:src="@drawable/ic_fullscreen_white_rounded_18dp" /> android:src="@drawable/ic_fullscreen_white_rounded_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</RelativeLayout> <ImageView android:id="@id/exo_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_play_arrow_white_rounded_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView android:id="@id/exo_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_pause_white_rounded_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@id/exo_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:layout_marginStart="16dp"
android:textColor="#FFFFFF"
android:textSize="?attr/font_default"
android:textStyle="bold"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toTopOf="@id/exo_progress"
app:layout_constraintStart_toStartOf="parent" />
<TextView android:id="@id/exo_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:layout_marginEnd="16dp"
android:textColor="#FFFFFF"
android:textSize="?attr/font_default"
android:textStyle="bold"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toTopOf="@id/exo_progress"
app:layout_constraintEnd_toEndOf="parent" />
<com.google.android.exoplayer2.ui.DefaultTimeBar <com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress" android:id="@id/exo_progress"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:bar_height="2dp" /> app:bar_height="2dp" />
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>