mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-27 01:03:15 +01:00
Showing wallpaper on widget config page
This commit is contained in:
parent
b513608032
commit
cb1c403d15
@ -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());
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user