aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Zacharia <george.zcharia@gmail.com>2021-08-25 17:05:14 +0530
committerGeorge Zacharia <george.zcharia@gmail.com>2021-08-25 18:46:45 +0530
commit159921f8077ab35903aafd9102b9549f876485a4 (patch)
tree2d704aa9f676e9eb4d8f9971f7830af25829b6e5
parent2e5d1e587d20d8ca0d3ed35c3895a9106ab1bc8e (diff)
OmniStyle: Switch to a simpler flow
Use themepicker's preview activity to set wallpaper Change-Id: Ideff82f0c3ea7f1409cb2899d23ab0d9b0d84235
-rw-r--r--src/org/omnirom/omnistyle/BrowseWallsActivity.java47
1 files changed, 19 insertions, 28 deletions
diff --git a/src/org/omnirom/omnistyle/BrowseWallsActivity.java b/src/org/omnirom/omnistyle/BrowseWallsActivity.java
index 144eab0..fe548f3 100644
--- a/src/org/omnirom/omnistyle/BrowseWallsActivity.java
+++ b/src/org/omnirom/omnistyle/BrowseWallsActivity.java
@@ -457,6 +457,14 @@ public class BrowseWallsActivity extends Activity {
return viewIntent;
}
+ private Intent getPreviewActivity() {
+ final Intent cropAndSetWallpaperIntent = new Intent();
+ cropAndSetWallpaperIntent.setComponent(new ComponentName("com.android.wallpaper",
+ "com.android.wallpaper.picker.StandalonePreviewActivity"));
+ cropAndSetWallpaperIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ return cropAndSetWallpaperIntent;
+ }
+
private void openFileInGalleryApp(String wallpaperFile) {
Intent viewIntent = getViewActivity(new File(wallpaperFile));
if (viewIntent.resolveActivity(getPackageManager()) != null) {
@@ -511,6 +519,16 @@ public class BrowseWallsActivity extends Activity {
d.show();
}
+ private void doCallPreviewActivity(Uri imageUri) {
+
+ final Intent cropAndSetWallpaperIntent = getPreviewActivity()
+ .setDataAndType(imageUri, IMAGE_TYPE)
+ .putExtra(CropExtras.KEY_SCALE, true)
+ .putExtra(CropExtras.KEY_SCALE_UP_IF_NEEDED, true);
+
+ startActivityForResult(cropAndSetWallpaperIntent, IMAGE_CROP_AND_SET);
+ }
+
private List<RemoteWallpaperInfo> getWallpaperList() {
String wallData = NetworkUtils.downloadUrlMemoryAsString(WALLPAPER_LIST_URI);
if (TextUtils.isEmpty(wallData)) {
@@ -689,34 +707,7 @@ public class BrowseWallsActivity extends Activity {
final Uri uri = Uri.fromFile(new File(wallpaperFile));
if (DEBUG) Log.d(TAG, "crop uri = " + uri);
- // if that image ratio is close to the display size ratio
- // assume this wall is meant to be fullscreen without scrolling
- float displayRatio = (float) Math.round(((float) dispSize.x / dispSize.y) * 10) / 10;
- float imageRatio = (float) Math.round(((float) image.getWidth() / image.getHeight()) * 10) / 10;
- if (displayRatio != imageRatio) {
- // ask if scrolling wallpaper should be used original size
- // or if it should be cropped to image size
- AlertDialog.Builder scrollingWallDialog = new AlertDialog.Builder(BrowseWallsActivity.this);
- scrollingWallDialog.setMessage(getResources().getString(R.string.scrolling_wall_dialog_text));
- scrollingWallDialog.setTitle(getResources().getString(R.string.scrolling_wall_dialog_title));
- scrollingWallDialog.setCancelable(false);
- scrollingWallDialog.setPositiveButton(R.string.scrolling_wall_yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- doCallCropActivity(uri, dispSize, wpWidth, wpHeight);
- }
- });
- scrollingWallDialog.setNegativeButton(R.string.scrolling_wall_no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- doCallCropActivity(uri, dispSize, dispSize.x, dispSize.y);
- }
- });
- AlertDialog d = scrollingWallDialog.create();
- d.show();
- } else {
- doCallCropActivity(uri, dispSize, dispSize.x, dispSize.y);
- }
+ doCallPreviewActivity(uri);
}
private void doSetLocalWallpaper(final int position) {