mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-23 22:50:59 +01:00
apply the image as wallpaper if picked so
This commit is contained in:
parent
2b83491631
commit
ea9e43c00b
@ -1,8 +1,11 @@
|
||||
package com.simplemobiletools.gallery.activities;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -27,6 +30,7 @@ import com.simplemobiletools.gallery.fragments.ViewPagerFragment;
|
||||
import com.simplemobiletools.gallery.models.Medium;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -143,6 +147,7 @@ public class ViewPagerActivity extends SimpleActivity
|
||||
deleteFile();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_set_as_wallpaper:
|
||||
setAsWallpaper();
|
||||
return true;
|
||||
case R.id.menu_share:
|
||||
shareMedium();
|
||||
@ -158,6 +163,16 @@ public class ViewPagerActivity extends SimpleActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void setAsWallpaper() {
|
||||
final Bitmap bitmap = BitmapFactory.decodeFile(getCurrentFile().getAbsolutePath());
|
||||
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
|
||||
try {
|
||||
wallpaperManager.setBitmap(bitmap);
|
||||
} catch (IOException e) {
|
||||
Utils.showToast(getApplicationContext(), R.string.set_as_wallpaper_failed);
|
||||
}
|
||||
}
|
||||
|
||||
private void shareMedium() {
|
||||
final Medium medium = getCurrentMedium();
|
||||
Utils.shareMedium(medium, this);
|
||||
|
@ -29,6 +29,7 @@
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
||||
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 folder deleted</item>
|
||||
|
Loading…
Reference in New Issue
Block a user