From 2b834916314a4f2f1d23e7754d222ae90cb36276 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 24 Aug 2016 23:32:01 +0200 Subject: [PATCH] show a "Set as Wallpaper" menu item at images --- .../gallery/activities/ViewPagerActivity.java | 4 ++++ .../java/com/simplemobiletools/gallery/models/Medium.java | 4 ++++ app/src/main/res/menu/viewpager_menu.xml | 4 ++++ app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 7 files changed, 16 insertions(+) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index 22e0cd1a2..77f4831f5 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -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 diff --git a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java index b951a93d3..c4e69063b 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java +++ b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java @@ -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; diff --git a/app/src/main/res/menu/viewpager_menu.xml b/app/src/main/res/menu/viewpager_menu.xml index 243dc202a..608b1091c 100644 --- a/app/src/main/res/menu/viewpager_menu.xml +++ b/app/src/main/res/menu/viewpager_menu.xml @@ -1,6 +1,10 @@ + Descending OK Cancel + Set as Wallpaper 1 cartella eliminata diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 0836afd0d..987ffc6b2 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -28,6 +28,7 @@ Descending OK Cancel + Set as Wallpaper 1 フォルダーを削除しました diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 8007406df..068481f73 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -28,6 +28,7 @@ Descending OK Cancel + Set as Wallpaper 1 mapp borttagen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 09a38bfa3..e23efc869 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,6 +28,7 @@ Descending OK Cancel + Set as Wallpaper 1 folder deleted