From 9b78d4c3f39b085184ae54e88b22fb71f3fc13a3 Mon Sep 17 00:00:00 2001 From: Nicolas Araujo <63880378+nicoolasj@users.noreply.github.com> Date: Sun, 24 Apr 2022 17:36:37 -0300 Subject: Put playback speed in widget (#5774) --- .../activity/PlaybackSpeedDialogActivity.java | 29 ++++++++++++++++++++++ .../antennapod/activity/WidgetConfigActivity.java | 9 ++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/de/danoeh/antennapod/activity/PlaybackSpeedDialogActivity.java (limited to 'app/src/main/java/de/danoeh/antennapod') diff --git a/app/src/main/java/de/danoeh/antennapod/activity/PlaybackSpeedDialogActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/PlaybackSpeedDialogActivity.java new file mode 100644 index 000000000..137724acd --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/activity/PlaybackSpeedDialogActivity.java @@ -0,0 +1,29 @@ +package de.danoeh.antennapod.activity; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.DialogInterface; +import android.os.Bundle; + +import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.dialog.VariableSpeedDialog; + +public class PlaybackSpeedDialogActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + setTheme(UserPreferences.getTranslucentTheme()); + super.onCreate(savedInstanceState); + VariableSpeedDialog speedDialog = new InnerVariableSpeedDialog(); + speedDialog.show(getSupportFragmentManager(), null); + } + + public static class InnerVariableSpeedDialog extends VariableSpeedDialog { + @Override + public void onDismiss(@NonNull DialogInterface dialog) { + super.onDismiss(dialog); + getActivity().finish(); + } + } +} diff --git a/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java index 7245ce675..32789e51a 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java @@ -20,6 +20,7 @@ public class WidgetConfigActivity extends AppCompatActivity { private SeekBar opacitySeekBar; private TextView opacityTextView; private View widgetPreview; + private CheckBox ckPlaybackSpeed; private CheckBox ckRewind; private CheckBox ckFastForward; private CheckBox ckSkip; @@ -75,6 +76,8 @@ public class WidgetConfigActivity extends AppCompatActivity { progress.setVisibility(View.VISIBLE); progress.setText(R.string.position_default_label); + ckPlaybackSpeed = findViewById(R.id.ckPlaybackSpeed); + ckPlaybackSpeed.setOnClickListener(v -> displayPreviewPanel()); ckRewind = findViewById(R.id.ckRewind); ckRewind.setOnClickListener(v -> displayPreviewPanel()); ckFastForward = findViewById(R.id.ckFastForward); @@ -84,10 +87,13 @@ public class WidgetConfigActivity extends AppCompatActivity { } private void displayPreviewPanel() { - boolean showExtendedPreview = ckRewind.isChecked() || ckFastForward.isChecked() || ckSkip.isChecked(); + boolean showExtendedPreview = + ckPlaybackSpeed.isChecked() || ckRewind.isChecked() || ckFastForward.isChecked() || ckSkip.isChecked(); widgetPreview.findViewById(R.id.extendedButtonsContainer) .setVisibility(showExtendedPreview ? View.VISIBLE : View.GONE); widgetPreview.findViewById(R.id.butPlay).setVisibility(showExtendedPreview ? View.GONE : View.VISIBLE); + widgetPreview.findViewById(R.id.butPlaybackSpeed) + .setVisibility(ckPlaybackSpeed.isChecked() ? View.VISIBLE : View.GONE); widgetPreview.findViewById(R.id.butFastForward) .setVisibility(ckFastForward.isChecked() ? View.VISIBLE : View.GONE); widgetPreview.findViewById(R.id.butSkip).setVisibility(ckSkip.isChecked() ? View.VISIBLE : View.GONE); @@ -100,6 +106,7 @@ public class WidgetConfigActivity extends AppCompatActivity { SharedPreferences prefs = getSharedPreferences(PlayerWidget.PREFS_NAME, MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putInt(PlayerWidget.KEY_WIDGET_COLOR + appWidgetId, backgroundColor); + editor.putBoolean(PlayerWidget.KEY_WIDGET_PLAYBACK_SPEED + appWidgetId, ckPlaybackSpeed.isChecked()); editor.putBoolean(PlayerWidget.KEY_WIDGET_SKIP + appWidgetId, ckSkip.isChecked()); editor.putBoolean(PlayerWidget.KEY_WIDGET_REWIND + appWidgetId, ckRewind.isChecked()); editor.putBoolean(PlayerWidget.KEY_WIDGET_FAST_FORWARD + appWidgetId, ckFastForward.isChecked()); -- cgit v1.2.3