Make widget configurable by long-pressing (#6410)
This commit is contained in:
parent
038847177e
commit
3e101cca2a
|
@ -3,6 +3,8 @@ package de.danoeh.antennapod.activity;
|
|||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
|
@ -84,6 +86,23 @@ public class WidgetConfigActivity extends AppCompatActivity {
|
|||
ckFastForward.setOnClickListener(v -> displayPreviewPanel());
|
||||
ckSkip = findViewById(R.id.ckSkip);
|
||||
ckSkip.setOnClickListener(v -> displayPreviewPanel());
|
||||
|
||||
setInitialState();
|
||||
}
|
||||
|
||||
private void setInitialState() {
|
||||
SharedPreferences prefs = getSharedPreferences(PlayerWidget.PREFS_NAME, MODE_PRIVATE);
|
||||
ckPlaybackSpeed.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_PLAYBACK_SPEED + appWidgetId, false));
|
||||
ckRewind.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_REWIND + appWidgetId, false));
|
||||
ckFastForward.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_FAST_FORWARD + appWidgetId, false));
|
||||
ckSkip.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_SKIP + appWidgetId, false));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
int color = prefs.getInt(PlayerWidget.KEY_WIDGET_COLOR + appWidgetId, 0);
|
||||
int opacity = Color.alpha(color) * 100 / 0xFF;
|
||||
|
||||
opacitySeekBar.setProgress(opacity, false);
|
||||
}
|
||||
displayPreviewPanel();
|
||||
}
|
||||
|
||||
private void displayPreviewPanel() {
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
android:minHeight="40dp"
|
||||
android:minWidth="250dp"
|
||||
android:minResizeWidth="40dp"
|
||||
android:widgetFeatures="reconfigurable"
|
||||
android:configure="de.danoeh.antennapod.activity.WidgetConfigActivity">
|
||||
</appwidget-provider>
|
||||
|
|
|
@ -176,6 +176,9 @@ public abstract class WidgetUpdater {
|
|||
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);
|
||||
} else {
|
||||
views.setInt(R.id.extendedButtonsContainer, "setVisibility", View.GONE);
|
||||
views.setInt(R.id.butPlay, "setVisibility", View.VISIBLE);
|
||||
}
|
||||
|
||||
int backgroundColor = prefs.getInt(PlayerWidget.KEY_WIDGET_COLOR + id, PlayerWidget.DEFAULT_COLOR);
|
||||
|
|
Loading…
Reference in New Issue