summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorNicolas Araujo <63880378+nicoolasj@users.noreply.github.com>2022-04-24 17:36:37 -0300
committerGitHub <noreply@github.com>2022-04-24 22:36:37 +0200
commit9b78d4c3f39b085184ae54e88b22fb71f3fc13a3 (patch)
treebd1bdd4d03ed614dbae53801948364786c4344a4 /app
parent1b2102d753820f2934a8463e767865212efe2831 (diff)
downloadAntennaPod-9b78d4c3f39b085184ae54e88b22fb71f3fc13a3.zip
Put playback speed in widget (#5774)
Diffstat (limited to 'app')
-rw-r--r--app/src/main/AndroidManifest.xml11
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/PlaybackSpeedDialogActivity.java29
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java9
-rw-r--r--app/src/main/res/layout/activity_widget_config.xml144
4 files changed, 129 insertions, 64 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ff6c917dd..93f1494f2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -43,6 +43,17 @@
android:allowAudioPlaybackCapture="true"
android:networkSecurityConfig="@xml/network_security_config">
+ <activity
+ android:name=".activity.PlaybackSpeedDialogActivity"
+ android:noHistory="true"
+ android:exported="false"
+ android:excludeFromRecents="true"
+ android:theme="@style/Theme.AntennaPod.Light.Translucent">
+ <intent-filter>
+ <action android:name="de.danoeh.antennapod.intents.PLAYBACK_SPEED" />
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ </activity>
<meta-data android:name="android.webkit.WebView.MetricsOptOut"
android:value="true"/>
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());
diff --git a/app/src/main/res/layout/activity_widget_config.xml b/app/src/main/res/layout/activity_widget_config.xml
index 8c540fcc6..6e7bd8eb9 100644
--- a/app/src/main/res/layout/activity_widget_config.xml
+++ b/app/src/main/res/layout/activity_widget_config.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@@ -16,91 +17,108 @@
android:id="@+id/widget_config_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:srcCompat="@drawable/teaser"
- android:scaleType="centerCrop" />
+ android:scaleType="centerCrop"
+ app:srcCompat="@drawable/teaser" />
<include
android:id="@+id/widget_config_preview"
- layout="@layout/player_widget"
android:layout_width="match_parent"
android:layout_height="96dp"
android:layout_gravity="center"
- android:layout_margin="16dp" />
+ android:layout_margin="16dp"
+ layout="@layout/player_widget" />
+
</FrameLayout>
- <LinearLayout
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:padding="16dp">
+ android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal">
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:padding="16dp">
- <TextView
- android:id="@+id/textView"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/widget_opacity"
- android:textSize="16sp"
- android:textColor="?android:attr/textColorPrimary" />
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
- <TextView
- android:id="@+id/widget_opacity_textView"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="end"
- android:text="100%"
- android:textSize="16sp"
- android:textColor="?android:attr/textColorSecondary" />
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/widget_opacity"
+ android:textSize="16sp"
+ android:textColor="?android:attr/textColorPrimary" />
- </LinearLayout>
+ <TextView
+ android:id="@+id/widget_opacity_textView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="end"
+ android:text="100%"
+ android:textSize="16sp"
+ android:textColor="?android:attr/textColorSecondary" />
- <SeekBar
- android:id="@+id/widget_opacity_seekBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:layout_marginBottom="16dp"
- android:max="100"
- android:progress="100" />
+ </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <CheckBox
- android:id="@+id/ckRewind"
- android:layout_width="wrap_content"
+ <SeekBar
+ android:id="@+id/widget_opacity_seekBar"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Rewind" />
+ android:layout_marginTop="16dp"
+ android:layout_marginBottom="16dp"
+ android:max="100"
+ android:progress="100" />
- <CheckBox
- android:id="@+id/ckFastForward"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Forward" />
+ android:orientation="vertical">
+
+ <CheckBox
+ android:id="@+id/ckPlaybackSpeed"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Playback Speed" />
- <CheckBox
- android:id="@+id/ckSkip"
- android:layout_width="wrap_content"
+ <CheckBox
+ android:id="@+id/ckRewind"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Rewind" />
+
+ <CheckBox
+ android:id="@+id/ckFastForward"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Forward" />
+
+ <CheckBox
+ android:id="@+id/ckSkip"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Skip" />
+
+ </LinearLayout>
+
+ <Button
+ android:id="@+id/butConfirm"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Skip" />
+ android:layout_gravity="center"
+ android:text="@string/widget_create_button" />
+
</LinearLayout>
- <Button
- android:id="@+id/butConfirm"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="@string/widget_create_button" />
- </LinearLayout>
+
+ </androidx.core.widget.NestedScrollView>
</LinearLayout>