show a "Set as Wallpaper" menu item at images

This commit is contained in:
tibbi 2016-08-24 23:32:01 +02:00
parent 131f0647a9
commit 2b83491631
7 changed files with 16 additions and 0 deletions

View file

@ -134,6 +134,7 @@ public class ViewPagerActivity extends SimpleActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.viewpager_menu, menu);
menu.findItem(R.id.menu_set_as_wallpaper).setVisible(getCurrentMedium().isImage());
return true;
}
@ -141,6 +142,8 @@ public class ViewPagerActivity extends SimpleActivity
public boolean onOptionsItemSelected(MenuItem item) {
deleteFile();
switch (item.getItemId()) {
case R.id.menu_set_as_wallpaper:
return true;
case R.id.menu_share:
shareMedium();
return true;
@ -385,6 +388,7 @@ public class ViewPagerActivity extends SimpleActivity
public void onPageSelected(int position) {
updateActionbarTitle();
mPos = position;
supportInvalidateOptionsMenu();
}
@Override

View file

@ -39,6 +39,10 @@ public class Medium implements Serializable, Comparable {
return getPath().endsWith(".gif");
}
public boolean isImage() {
return !isGif() && !getIsVideo();
}
@Override
public int compareTo(Object object) {
final Medium medium = (Medium) object;

View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_set_as_wallpaper"
android:title="@string/set_as_wallpaper"
app:showAsAction="never"/>
<item
android:id="@+id/menu_edit"
android:icon="@mipmap/edit"

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="set_as_wallpaper">Set as Wallpaper</string>
<plurals name="folders_deleted">
<item quantity="one">1 cartella eliminata</item>

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="set_as_wallpaper">Set as Wallpaper</string>
<plurals name="folders_deleted">
<item quantity="one">1 フォルダーを削除しました</item>

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="set_as_wallpaper">Set as Wallpaper</string>
<plurals name="folders_deleted">
<item quantity="one">1 mapp borttagen</item>

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="set_as_wallpaper">Set as Wallpaper</string>
<plurals name="folders_deleted">
<item quantity="one">1 folder deleted</item>