diff options
author | ByteHamster <info@bytehamster.com> | 2019-10-23 19:53:21 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2019-10-23 23:08:07 +0200 |
commit | cb1c403d15df7e89373cfeb1cae36d17380d6f00 (patch) | |
tree | 09bf23e68e57bb35cce1c5d6e15a3115379f03f1 /app | |
parent | b513608032f557cedadd14763eb18c0438bd9404 (diff) | |
download | AntennaPod-cb1c403d15df7e89373cfeb1cae36d17380d6f00.zip |
Showing wallpaper on widget config page
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java | 19 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_widget_config.xml | 14 |
2 files changed, 29 insertions, 4 deletions
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 9bdcbbbe4..8fee1ab31 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java @@ -1,6 +1,13 @@ package de.danoeh.antennapod.activity; +import android.Manifest; +import android.app.WallpaperManager; +import android.content.pm.PackageManager; +import android.graphics.drawable.Drawable; +import android.os.Build; import android.util.Log; +import android.widget.FrameLayout; +import android.widget.ImageView; import androidx.appcompat.app.AppCompatActivity; import android.appwidget.AppWidgetManager; @@ -13,6 +20,7 @@ import android.widget.RemoteViews; import android.widget.SeekBar; import android.widget.TextView; +import androidx.core.content.ContextCompat; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.receiver.PlayerWidget; @@ -47,6 +55,7 @@ public class WidgetConfigActivity extends AppCompatActivity { finish(); } + displayDeviceBackground(); opacityTextView = findViewById(R.id.widget_opacity_textView); opacitySeekBar = findViewById(R.id.widget_opacity_seekBar); widgetPreview = findViewById(R.id.widgetLayout); @@ -69,6 +78,16 @@ public class WidgetConfigActivity extends AppCompatActivity { }); } + private void displayDeviceBackground() { + int permission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE); + if (Build.VERSION.SDK_INT < 27 || permission == PackageManager.PERMISSION_GRANTED) { + final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); + final Drawable wallpaperDrawable = wallpaperManager.getDrawable(); + ImageView background = findViewById(R.id.widget_config_background); + background.setImageDrawable(wallpaperDrawable); + } + } + public void confirmCreateWidget(View v) { int backgroundColor = getColorWithAlpha(DEFAULT_COLOR,opacitySeekBar.getProgress()); diff --git a/app/src/main/res/layout/activity_widget_config.xml b/app/src/main/res/layout/activity_widget_config.xml index e8847abe8..b1e40dac0 100644 --- a/app/src/main/res/layout/activity_widget_config.xml +++ b/app/src/main/res/layout/activity_widget_config.xml @@ -10,16 +10,22 @@ <FrameLayout android:layout_width="match_parent" android:layout_height="200dp" - android:layout_gravity="center" - android:background="@drawable/bg_splash" - android:padding="16dp"> + android:layout_gravity="center"> + + <ImageView + android:id="@+id/widget_config_background" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:src="@drawable/bg_splash" + android:scaleType="centerCrop" /> <include android:id="@+id/widget_config_preview" layout="@layout/player_widget" android:layout_width="match_parent" android:layout_height="80dp" - android:layout_gravity="center" /> + android:layout_gravity="center" + android:layout_margin="16dp" /> </FrameLayout> <LinearLayout |