From cd567c370bdc0fdf37659a6d5f74a0dd3b373cf3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 24 Jul 2016 16:40:10 +0200 Subject: [PATCH] add sorting button to the menu --- .../gallery/activities/MainActivity.java | 2 ++ .../gallery/activities/MediaActivity.java | 18 +++++++++++++++++- .../res/menu/{media_menu.xml => cab_media.xml} | 0 app/src/main/res/menu/menu_main.xml | 5 +++++ app/src/main/res/menu/menu_media.xml | 9 +++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) rename app/src/main/res/menu/{media_menu.xml => cab_media.xml} (100%) create mode 100644 app/src/main/res/menu/menu_media.xml diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 17d64ed10..8d4bd8031 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -102,6 +102,8 @@ public class MainActivity extends SimpleActivity @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case R.id.sort: + return true; case R.id.camera: startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA)); return true; diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java index 67d0e3359..19215de76 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java @@ -124,6 +124,22 @@ public class MediaActivity extends SimpleActivity setTitle(dirName); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_media, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.sort: + return true; + default: + return super.onOptionsItemSelected(item); + } + } + private void deleteDirectoryIfEmpty() { final File file = new File(mPath); if (file.isDirectory() && file.listFiles().length == 0) { @@ -364,7 +380,7 @@ public class MediaActivity extends SimpleActivity @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); - inflater.inflate(R.menu.media_menu, menu); + inflater.inflate(R.menu.cab_media, menu); return true; } diff --git a/app/src/main/res/menu/media_menu.xml b/app/src/main/res/menu/cab_media.xml similarity index 100% rename from app/src/main/res/menu/media_menu.xml rename to app/src/main/res/menu/cab_media.xml diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 4aed68f4b..62fa39ada 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -1,6 +1,11 @@ + + + +