Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2737021b authored by Mangesh Ghiware's avatar Mangesh Ghiware Committed by Android Git Automerger
Browse files

am d180bb94: Use existing crop activity as fallback.

* commit 'd180bb94':
  Use existing crop activity as fallback.
parents d7fd034b d180bb94
Loading
Loading
Loading
Loading
+26 −19
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.gallery3d.app;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.WallpaperManager;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Point;
import android.net.Uri;
@@ -99,14 +100,21 @@ public class Wallpaper extends Activity {
                Intent cropAndSetWallpaperIntent;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    WallpaperManager wpm = WallpaperManager.getInstance(getApplicationContext());
                    try {
                        cropAndSetWallpaperIntent = wpm.getCropAndSetWallpaperIntent(mPickedItem);
                } else {
                        startActivity(cropAndSetWallpaperIntent);
                    } catch (ActivityNotFoundException anfe) {
                        // ignored; fallthru to existing crop activity
                    }
                }

                int width = getWallpaperDesiredMinimumWidth();
                int height = getWallpaperDesiredMinimumHeight();
                Point size = getDefaultDisplaySize(new Point());
                float spotlightX = (float) size.x / width;
                float spotlightY = (float) size.y / height;
                cropAndSetWallpaperIntent = new Intent(CropActivity.CROP_ACTION)
                    .setClass(this, CropActivity.class)
                    .setDataAndType(mPickedItem, IMAGE_TYPE)
                    .addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
                    .putExtra(CropExtras.KEY_OUTPUT_X, width)
@@ -118,7 +126,6 @@ public class Wallpaper extends Activity {
                    .putExtra(CropExtras.KEY_SCALE, true)
                    .putExtra(CropExtras.KEY_SCALE_UP_IF_NEEDED, true)
                    .putExtra(CropExtras.KEY_SET_AS_WALLPAPER, true);
                }
                startActivity(cropAndSetWallpaperIntent);
                finish();
            }