mirror of
https://github.com/Docile-Alligator/Infinity-For-Reddit.git
synced 2026-02-18 20:05:43 +00:00
Use MaterialButtonGroup in exo_playback_control_view.xml. Theme the play pause button in ViewVideoActivity.
This commit is contained in:
@ -14,6 +14,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Matrix;
|
||||
@ -75,7 +76,6 @@ import androidx.media3.ui.PlayerControlView;
|
||||
import androidx.media3.ui.PlayerView;
|
||||
import androidx.media3.ui.TrackSelectionDialogBuilder;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.otaliastudios.zoom.ZoomEngine;
|
||||
import com.otaliastudios.zoom.ZoomSurfaceView;
|
||||
@ -285,6 +285,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
setContentView(binding.getRoot());
|
||||
}
|
||||
|
||||
applyCustomTheme();
|
||||
|
||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
|
||||
setTitle(" ");
|
||||
@ -517,10 +519,9 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
setPlaybackSpeed(savedInstanceState.getInt(PLAYBACK_SPEED_STATE, 100));
|
||||
}
|
||||
|
||||
MaterialButton playPauseButton = findViewById(R.id.exo_play_pause_button_exo_playback_control_view);
|
||||
Drawable playDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_play_arrow_24dp, null);
|
||||
Drawable pauseDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_pause_24dp, null);
|
||||
playPauseButton.setOnClickListener(view -> {
|
||||
binding.getPlayPauseButton().setOnClickListener(view -> {
|
||||
Util.handlePlayPauseButtonAction(player);
|
||||
});
|
||||
|
||||
@ -531,7 +532,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
Player.EVENT_PLAY_WHEN_READY_CHANGED,
|
||||
Player.EVENT_PLAYBACK_STATE_CHANGED,
|
||||
Player.EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED)) {
|
||||
playPauseButton.setIcon(Util.shouldShowPlayButton(player) ? playDrawable : pauseDrawable);
|
||||
binding.getPlayPauseButton().setIcon(Util.shouldShowPlayButton(player) ? playDrawable : pauseDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -810,6 +811,11 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
||||
});
|
||||
}
|
||||
|
||||
private void applyCustomTheme() {
|
||||
binding.getPlayPauseButton().setBackgroundColor(mCustomThemeWrapper.getColorAccent());
|
||||
binding.getPlayPauseButton().setIconTint(ColorStateList.valueOf(mCustomThemeWrapper.getFABIconColor()));
|
||||
}
|
||||
|
||||
private void preparePlayer(Bundle savedInstanceState) {
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
|
||||
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
||||
|
||||
@ -21,16 +21,22 @@ public class ViewVideoActivityBindingAdapter {
|
||||
@Nullable
|
||||
private ActivityViewVideoZoomableBinding zoomableBinding;
|
||||
|
||||
private MaterialButton muteButton;
|
||||
private MaterialButton hdButton;
|
||||
private BottomAppBar bottomAppBar;
|
||||
private TextView titleTextView;
|
||||
private MaterialButton backButton;
|
||||
private MaterialButton downloadButton;
|
||||
private MaterialButton playbackSpeedButton;
|
||||
private final MaterialButton playPauseButton;
|
||||
private final MaterialButton forwardButton;
|
||||
private final MaterialButton rewindButton;
|
||||
private final MaterialButton muteButton;
|
||||
private final MaterialButton hdButton;
|
||||
private final BottomAppBar bottomAppBar;
|
||||
private final TextView titleTextView;
|
||||
private final MaterialButton backButton;
|
||||
private final MaterialButton downloadButton;
|
||||
private final MaterialButton playbackSpeedButton;
|
||||
|
||||
public ViewVideoActivityBindingAdapter(ActivityViewVideoBinding binding) {
|
||||
this.binding = binding;
|
||||
playPauseButton = binding.getRoot().findViewById(R.id.exo_play_pause_button_exo_playback_control_view);
|
||||
forwardButton = binding.getRoot().findViewById(R.id.exo_ffwd);
|
||||
rewindButton = binding.getRoot().findViewById(R.id.exo_rew);
|
||||
muteButton = binding.getRoot().findViewById(R.id.mute_exo_playback_control_view);
|
||||
hdButton = binding.getRoot().findViewById(R.id.hd_exo_playback_control_view);
|
||||
bottomAppBar = binding.getRoot().findViewById(R.id.bottom_navigation_exo_playback_control_view);
|
||||
@ -42,6 +48,9 @@ public class ViewVideoActivityBindingAdapter {
|
||||
|
||||
public ViewVideoActivityBindingAdapter(ActivityViewVideoZoomableBinding binding) {
|
||||
zoomableBinding = binding;
|
||||
playPauseButton = binding.getRoot().findViewById(R.id.exo_play_pause_button_exo_playback_control_view);
|
||||
forwardButton = binding.getRoot().findViewById(R.id.exo_ffwd);
|
||||
rewindButton = binding.getRoot().findViewById(R.id.exo_rew);
|
||||
muteButton = binding.getRoot().findViewById(R.id.mute_exo_playback_control_view);
|
||||
hdButton = binding.getRoot().findViewById(R.id.hd_exo_playback_control_view);
|
||||
bottomAppBar = binding.getRoot().findViewById(R.id.bottom_navigation_exo_playback_control_view);
|
||||
@ -63,8 +72,20 @@ public class ViewVideoActivityBindingAdapter {
|
||||
return binding == null ? zoomableBinding.progressBarViewVideoActivity : binding.progressBarViewVideoActivity;
|
||||
}
|
||||
|
||||
public MaterialButton getPlayPauseButton() {
|
||||
return playPauseButton;
|
||||
}
|
||||
|
||||
public MaterialButton getForwardButton() {
|
||||
return forwardButton;
|
||||
}
|
||||
|
||||
public MaterialButton getRewindButton() {
|
||||
return rewindButton;
|
||||
}
|
||||
|
||||
public MaterialButton getMuteButton() {
|
||||
return getRoot().findViewById(R.id.mute_exo_playback_control_view);
|
||||
return muteButton;
|
||||
}
|
||||
|
||||
public MaterialButton getHdButton() {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -32,81 +33,83 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/mute_exo_playback_control_view"
|
||||
style="?attr/materialIconButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:strokeWidth="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@null"
|
||||
app:backgroundTint="#444141"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
style="?attr/materialIconButtonOutlinedStyle" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@id/exo_rew"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:strokeWidth="0dp"
|
||||
app:icon="@drawable/ic_fast_rewind_24dp"
|
||||
app:backgroundTint="#444141"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@null"
|
||||
app:backgroundTint="#444141"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/exo_play_pause_button_exo_playback_control_view"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintEnd_toStartOf="@id/button_group_exo_playback_control_view"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
style="?attr/materialIconButtonOutlinedStyle" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:strokeWidth="0dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/exo_play_pause_button_exo_playback_control_view"
|
||||
<com.google.android.material.button.MaterialButtonGroup
|
||||
android:id="@+id/button_group_exo_playback_control_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:strokeWidth="0dp"
|
||||
app:icon="@drawable/ic_play_arrow_24dp"
|
||||
app:iconSize="36dp"
|
||||
app:iconTint="@null"
|
||||
app:backgroundTint="@color/colorAccent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:spacing="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/exo_ffwd"
|
||||
app:layout_constraintEnd_toStartOf="@+id/hd_exo_playback_control_view"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/exo_rew"
|
||||
style="?attr/materialIconButtonOutlinedStyle" />
|
||||
app:layout_constraintStart_toEndOf="@id/mute_exo_playback_control_view"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@id/exo_ffwd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:strokeWidth="0dp"
|
||||
app:icon="@drawable/ic_fast_forward_24dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@null"
|
||||
app:backgroundTint="#444141"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/exo_play_pause_button_exo_playback_control_view"
|
||||
style="?attr/materialIconButtonOutlinedStyle" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@id/exo_rew"
|
||||
style="?attr/materialIconButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:backgroundTint="#444141"
|
||||
app:icon="@drawable/ic_fast_rewind_24dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@null"
|
||||
app:strokeWidth="0dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/exo_play_pause_button_exo_playback_control_view"
|
||||
style="?attr/materialIconButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:backgroundTint="@color/colorAccent"
|
||||
app:icon="@drawable/ic_play_arrow_24dp"
|
||||
app:iconSize="36dp"
|
||||
app:iconTint="@null"
|
||||
app:strokeWidth="0dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@id/exo_ffwd"
|
||||
style="?attr/materialIconButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:backgroundTint="#444141"
|
||||
app:icon="@drawable/ic_fast_forward_24dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@null"
|
||||
app:strokeWidth="0dp" />
|
||||
|
||||
</com.google.android.material.button.MaterialButtonGroup>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/hd_exo_playback_control_view"
|
||||
style="?attr/materialIconButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:strokeWidth="0dp"
|
||||
app:backgroundTint="#444141"
|
||||
app:icon="@drawable/ic_video_quality_24dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@null"
|
||||
app:backgroundTint="#444141"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
style="?attr/materialIconButtonOutlinedStyle" />
|
||||
app:layout_constraintStart_toEndOf="@id/button_group_exo_playback_control_view"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:strokeWidth="0dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user