protected void init() {
    setContentView(R.layout.wallpaper_cropper);

    mCropView = (CropView) findViewById(R.id.cropView);

    Intent cropIntent = getIntent();
    final Uri imageUri = cropIntent.getData();

    if (imageUri == null) {
      Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
      finish();
      return;
    }

    int rotation = getRotationFromExif(this, imageUri);
    mCropView.setTileSource(new BitmapRegionTileSource(this, imageUri, 1024, rotation), null);
    mCropView.setTouchEnabled(true);
    // Action bar
    // Show the custom action bar view
    final ActionBar actionBar = getActionBar();
    actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
    actionBar
        .getCustomView()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                boolean finishActivityWhenDone = true;
                cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
              }
            });
  }
    @Override
    public void onClick(WallpaperPickerActivity a) {
      CropView c = a.getCropView();

      Drawable defaultWallpaper =
          WallpaperManager.getInstance(a)
              .getBuiltInDrawable(c.getWidth(), c.getHeight(), false, 0.5f, 0.5f);

      if (defaultWallpaper == null) {
        Log.w(TAG, "Null default wallpaper encountered.");
        c.setTileSource(null, null);
        return;
      }

      c.setTileSource(
          new DrawableTileSource(a, defaultWallpaper, DrawableTileSource.MAX_PREVIEW_SIZE), null);
      c.setScale(1f);
      c.setTouchEnabled(false);
      a.setSystemWallpaperVisiblity(false);
    }
 @Override
 public void onClick(WallpaperPickerActivity a) {
   BitmapRegionTileSource.ResourceBitmapSource bitmapSource =
       new BitmapRegionTileSource.ResourceBitmapSource(
           mResources, mResId, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
   bitmapSource.loadInBackground();
   BitmapRegionTileSource source = new BitmapRegionTileSource(a, bitmapSource);
   CropView v = a.getCropView();
   v.setTileSource(source, null);
   Point wallpaperSize =
       WallpaperCropActivity.getDefaultWallpaperSize(a.getResources(), a.getWindowManager());
   RectF crop =
       WallpaperCropActivity.getMaxCropRect(
           source.getImageWidth(),
           source.getImageHeight(),
           wallpaperSize.x,
           wallpaperSize.y,
           false);
   v.setScale(wallpaperSize.x / crop.width());
   v.setTouchEnabled(false);
   a.setSystemWallpaperVisiblity(false);
 }