diff options
author | Nicolas Araujo <63880378+nicoolasj@users.noreply.github.com> | 2022-04-24 17:36:37 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-24 22:36:37 +0200 |
commit | 9b78d4c3f39b085184ae54e88b22fb71f3fc13a3 (patch) | |
tree | bd1bdd4d03ed614dbae53801948364786c4344a4 /core/src/main | |
parent | 1b2102d753820f2934a8463e767865212efe2831 (diff) | |
download | AntennaPod-9b78d4c3f39b085184ae54e88b22fb71f3fc13a3.zip |
Put playback speed in widget (#5774)
Diffstat (limited to 'core/src/main')
4 files changed, 27 insertions, 5 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java index 46faeec50..4e5aff696 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java +++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/PlayerWidget.java @@ -14,6 +14,7 @@ public class PlayerWidget extends AppWidgetProvider { public static final String PREFS_NAME = "PlayerWidgetPrefs"; private static final String KEY_ENABLED = "WidgetEnabled"; public static final String KEY_WIDGET_COLOR = "widget_color"; + public static final String KEY_WIDGET_PLAYBACK_SPEED = "widget_playback_speed"; public static final String KEY_WIDGET_SKIP = "widget_skip"; public static final String KEY_WIDGET_FAST_FORWARD = "widget_fast_forward"; public static final String KEY_WIDGET_REWIND = "widget_rewind"; @@ -47,6 +48,7 @@ public class PlayerWidget extends AppWidgetProvider { for (int appWidgetId : appWidgetIds) { SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); prefs.edit().remove(KEY_WIDGET_COLOR + appWidgetId).apply(); + prefs.edit().remove(KEY_WIDGET_PLAYBACK_SPEED + appWidgetId).apply(); prefs.edit().remove(KEY_WIDGET_REWIND + appWidgetId).apply(); prefs.edit().remove(KEY_WIDGET_FAST_FORWARD + appWidgetId).apply(); prefs.edit().remove(KEY_WIDGET_SKIP + appWidgetId).apply(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java b/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java index 1253c747b..8afba881a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java +++ b/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java @@ -31,6 +31,7 @@ import de.danoeh.antennapod.core.util.TimeSpeedConverter; import de.danoeh.antennapod.model.playback.Playable; import de.danoeh.antennapod.playback.base.PlayerStatus; import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter; +import de.danoeh.antennapod.ui.appstartintent.PlaybackSpeedActivityStarter; import de.danoeh.antennapod.ui.appstartintent.VideoPlayerActivityStarter; /** @@ -73,6 +74,9 @@ public abstract class WidgetUpdater { } else { startMediaPlayer = new MainActivityStarter(context).withOpenPlayer().getPendingIntent(); } + + PendingIntent startPlaybackSpeedDialog = new PlaybackSpeedActivityStarter(context).getPendingIntent(); + RemoteViews views; views = new RemoteViews(context.getPackageName(), R.layout.player_widget); @@ -81,6 +85,7 @@ public abstract class WidgetUpdater { int iconSize = context.getResources().getDimensionPixelSize(android.R.dimen.app_icon_size); views.setOnClickPendingIntent(R.id.layout_left, startMediaPlayer); views.setOnClickPendingIntent(R.id.imgvCover, startMediaPlayer); + views.setOnClickPendingIntent(R.id.butPlaybackSpeed, startPlaybackSpeedDialog); try { icon = Glide.with(context) @@ -165,13 +170,15 @@ public abstract class WidgetUpdater { } else { views.setViewVisibility(R.id.layout_center, View.VISIBLE); } + boolean showPlaybackSpeed = prefs.getBoolean(PlayerWidget.KEY_WIDGET_PLAYBACK_SPEED + id, false); boolean showRewind = prefs.getBoolean(PlayerWidget.KEY_WIDGET_REWIND + id, false); boolean showFastForward = prefs.getBoolean(PlayerWidget.KEY_WIDGET_FAST_FORWARD + id, false); boolean showSkip = prefs.getBoolean(PlayerWidget.KEY_WIDGET_SKIP + id, false); - if (showRewind || showSkip || showFastForward) { + if (showPlaybackSpeed || showRewind || showSkip || showFastForward) { views.setInt(R.id.extendedButtonsContainer, "setVisibility", View.VISIBLE); views.setInt(R.id.butPlay, "setVisibility", View.GONE); + views.setInt(R.id.butPlaybackSpeed, "setVisibility", showPlaybackSpeed ? View.VISIBLE : View.GONE); views.setInt(R.id.butRew, "setVisibility", showRewind ? View.VISIBLE : View.GONE); views.setInt(R.id.butFastForward, "setVisibility", showFastForward ? View.VISIBLE : View.GONE); views.setInt(R.id.butSkip, "setVisibility", showSkip ? View.VISIBLE : View.GONE); diff --git a/core/src/main/res/layout/player_widget.xml b/core/src/main/res/layout/player_widget.xml index 60d40e6b5..6f3842e8b 100644 --- a/core/src/main/res/layout/player_widget.xml +++ b/core/src/main/res/layout/player_widget.xml @@ -89,6 +89,16 @@ android:visibility="gone"> <ImageButton + android:id="@+id/butPlaybackSpeed" + android:layout_width="36dp" + android:layout_height="36dp" + android:background="?android:attr/selectableItemBackground" + android:contentDescription="@string/playback_speed" + android:layout_marginEnd="2dp" + android:scaleType="fitXY" + android:src="@drawable/ic_widget_playback_speed" /> + + <ImageButton android:id="@+id/butRew" android:layout_width="36dp" android:layout_height="36dp" diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index 2b0529f85..e597f8222 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -110,32 +110,35 @@ </style> <style name="Theme.AntennaPod.Light.Translucent" parent="Theme.AntennaPod.Light.NoTitle"> + <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item> + <item name="android:windowLightStatusBar" tools:targetApi="M">false</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:windowAnimationStyle">@style/AnimationFade</item> - <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> <item name="android:fitsSystemWindows">true</item> </style> <style name="Theme.AntennaPod.Dark.Translucent" parent="Theme.AntennaPod.Dark.NoTitle"> + <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item> + <item name="android:windowLightStatusBar" tools:targetApi="M">false</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:windowAnimationStyle">@style/AnimationFade</item> - <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> <item name="android:fitsSystemWindows">true</item> </style> - <style name="Theme.AntennaPod.TrueBlack.Translucent" parent="Theme.AntennaPod.TrueBlack"> + <style name="Theme.AntennaPod.TrueBlack.Translucent" parent="Theme.AntennaPod.TrueBlack.NoTitle"> + <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item> + <item name="android:windowLightStatusBar" tools:targetApi="M">false</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:windowAnimationStyle">@style/AnimationFade</item> - <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> <item name="android:fitsSystemWindows">true</item> </style> |