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

View file

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

View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> 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 <item
android:id="@+id/menu_edit" android:id="@+id/menu_edit"
android:icon="@mipmap/edit" android:icon="@mipmap/edit"

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string> <string name="descending">Descending</string>
<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>
<plurals name="folders_deleted"> <plurals name="folders_deleted">
<item quantity="one">1 cartella eliminata</item> <item quantity="one">1 cartella eliminata</item>

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string> <string name="descending">Descending</string>
<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>
<plurals name="folders_deleted"> <plurals name="folders_deleted">
<item quantity="one">1 フォルダーを削除しました</item> <item quantity="one">1 フォルダーを削除しました</item>

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string> <string name="descending">Descending</string>
<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>
<plurals name="folders_deleted"> <plurals name="folders_deleted">
<item quantity="one">1 mapp borttagen</item> <item quantity="one">1 mapp borttagen</item>

View file

@ -28,6 +28,7 @@
<string name="descending">Descending</string> <string name="descending">Descending</string>
<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>
<plurals name="folders_deleted"> <plurals name="folders_deleted">
<item quantity="one">1 folder deleted</item> <item quantity="one">1 folder deleted</item>