コード例 #1
0
 @Override
 public void onSave(WallpaperPickerActivity a) {
   try {
     WallpaperManager.getInstance(a).clear();
     a.setResult(RESULT_OK);
   } catch (IOException e) {
     Log.w("Setting wallpaper to default threw exception", e);
   }
   a.finish();
 }
コード例 #2
0
 @Override
 public void onClick(final WallpaperPickerActivity a) {
   final Runnable onLoad;
   if (!mFirstClick) {
     onLoad = null;
   } else {
     mFirstClick = false;
     a.mSetWallpaperButton.setEnabled(false);
     onLoad =
         new Runnable() {
           public void run() {
             if (mBitmapSource != null
                 && mBitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
               a.selectTile(mView);
               a.mSetWallpaperButton.setEnabled(true);
             } else {
               ViewGroup parent = (ViewGroup) mView.getParent();
               if (parent != null) {
                 parent.removeView(mView);
                 Toast.makeText(a, a.getString(R.string.image_load_fail), Toast.LENGTH_SHORT)
                     .show();
               }
             }
           }
         };
   }
   mBitmapSource =
       new BitmapRegionTileSource.UriBitmapSource(
           a, mUri, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
   a.setCropViewTileSource(mBitmapSource, true, false, onLoad);
 }
コード例 #3
0
    @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);
    }
コード例 #4
0
 @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);
 }
コード例 #5
0
 @Override
 public void onSave(final WallpaperPickerActivity a) {
   boolean finishActivityWhenDone = true;
   OnBitmapCroppedHandler h =
       new OnBitmapCroppedHandler() {
         public void onBitmapCropped(byte[] imageBytes) {
           Point thumbSize = getDefaultThumbnailSize(a.getResources());
           // rotation is set to 0 since imageBytes has already been correctly rotated
           Bitmap thumb = createThumbnail(thumbSize, null, null, imageBytes, null, 0, 0, true);
           a.getSavedImages().writeImage(thumb, imageBytes);
         }
       };
   a.cropImageAndSetWallpaper(mUri, h, finishActivityWhenDone);
 }
コード例 #6
0
 @Override
 public void onSave(WallpaperPickerActivity a) {
   boolean finishActivityWhenDone = true;
   a.cropImageAndSetWallpaper(mResources, mResId, finishActivityWhenDone);
 }
コード例 #7
0
 @Override
 public void onClick(WallpaperPickerActivity a) {
   Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
   intent.setType("image/*");
   a.startActivityForResultSafely(intent, IMAGE_PICK);
 }