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;
|
package com.simplemobiletools.gallery.activities;
|
||||||
|
|
||||||
|
import android.app.WallpaperManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.media.MediaScannerConnection;
|
import android.media.MediaScannerConnection;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -27,6 +30,7 @@ import com.simplemobiletools.gallery.fragments.ViewPagerFragment;
|
||||||
import com.simplemobiletools.gallery.models.Medium;
|
import com.simplemobiletools.gallery.models.Medium;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -143,6 +147,7 @@ public class ViewPagerActivity extends SimpleActivity
|
||||||
deleteFile();
|
deleteFile();
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_set_as_wallpaper:
|
case R.id.menu_set_as_wallpaper:
|
||||||
|
setAsWallpaper();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_share:
|
case R.id.menu_share:
|
||||||
shareMedium();
|
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() {
|
private void shareMedium() {
|
||||||
final Medium medium = getCurrentMedium();
|
final Medium medium = getCurrentMedium();
|
||||||
Utils.shareMedium(medium, this);
|
Utils.shareMedium(medium, this);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="set_as_wallpaper">Set as Wallpaper</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 folder deleted</item>
|
<item quantity="one">1 folder deleted</item>
|
||||||
|
|
Loading…
Reference in New Issue