Showing wallpaper on widget config page
This commit is contained in:
parent
b513608032
commit
cb1c403d15
|
@ -1,6 +1,13 @@
|
||||||
package de.danoeh.antennapod.activity;
|
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.util.Log;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
|
@ -13,6 +20,7 @@ import android.widget.RemoteViews;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.core.receiver.PlayerWidget;
|
import de.danoeh.antennapod.core.receiver.PlayerWidget;
|
||||||
|
@ -47,6 +55,7 @@ public class WidgetConfigActivity extends AppCompatActivity {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayDeviceBackground();
|
||||||
opacityTextView = findViewById(R.id.widget_opacity_textView);
|
opacityTextView = findViewById(R.id.widget_opacity_textView);
|
||||||
opacitySeekBar = findViewById(R.id.widget_opacity_seekBar);
|
opacitySeekBar = findViewById(R.id.widget_opacity_seekBar);
|
||||||
widgetPreview = findViewById(R.id.widgetLayout);
|
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) {
|
public void confirmCreateWidget(View v) {
|
||||||
int backgroundColor = getColorWithAlpha(DEFAULT_COLOR,opacitySeekBar.getProgress());
|
int backgroundColor = getColorWithAlpha(DEFAULT_COLOR,opacitySeekBar.getProgress());
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,22 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="200dp"
|
android:layout_height="200dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center">
|
||||||
android:background="@drawable/bg_splash"
|
|
||||||
android:padding="16dp">
|
<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
|
<include
|
||||||
android:id="@+id/widget_config_preview"
|
android:id="@+id/widget_config_preview"
|
||||||
layout="@layout/player_widget"
|
layout="@layout/player_widget"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center"
|
||||||
|
android:layout_margin="16dp" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
Loading…
Reference in New Issue