diff options
author | aleksandar-stefanovic <theonewithideas@gmail.com> | 2017-02-25 11:09:22 +0100 |
---|---|---|
committer | Aleksandar Stefanović <theonewithideas@gmail.com> | 2017-03-12 22:32:40 +0000 |
commit | 243476399e76fb5ad2ce8c7fbef9e224b330c706 (patch) | |
tree | 91b93ebfe0768a5ba3f9829cf90221cf5a410f11 /android | |
parent | 7f09093b8bbc119f50763e1b629424cc2669628a (diff) |
Made sort menu use radio buttons
This makes it MUCH easier to see what sort option is currently
selected. Removed the mechanism of switching between labels when
the option is toggled, and instead put all the options into a menu.
Change-Id: I44142dc842d983d5438faeb06b67046bad235308
Reviewed-on: https://gerrit.libreoffice.org/34640
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Aleksandar Stefanović <theonewithideas@gmail.com>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/res/menu/view_menu.xml | 25 | ||||
-rw-r--r-- | android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java | 121 |
2 files changed, 83 insertions, 63 deletions
diff --git a/android/source/res/menu/view_menu.xml b/android/source/res/menu/view_menu.xml index 2b99ad15e1ab..67f059647989 100644 --- a/android/source/res/menu/view_menu.xml +++ b/android/source/res/menu/view_menu.xml @@ -35,12 +35,25 @@ android:icon="@drawable/ic_sort_black_24dp" app:showAsAction="ifRoom"> <menu> - <item android:id="@+id/menu_sort_size" - android:title="@string/menu_sort_size" /> - <item android:id="@+id/menu_sort_az" - android:title="@string/menu_sort_az"/> - <item android:id="@+id/menu_sort_modified" - android:title="@string/menu_sort_modified"/> + <group android:checkableBehavior="single"> + <item android:id="@+id/menu_sort_size_asc" + android:title="@string/sort_smallest" /> + + <item android:id="@+id/menu_sort_size_desc" + android:title="@string/sort_largest" /> + + <item android:id="@+id/menu_sort_az" + android:title="@string/sort_az"/> + + <item android:id="@+id/menu_sort_za" + android:title="@string/sort_za"/> + + <item android:id="@+id/menu_sort_modified_newest" + android:title="@string/sort_newest"/> + + <item android:id="@+id/menu_sort_modified_oldest" + android:title="@string/sort_oldest"/> + </group> </menu> </item> <item android:id="@+id/action_settings" diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java index a4daa454a346..4861a8e7468e 100644 --- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -526,25 +526,36 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.view_menu, menu); - MenuItem item = menu.findItem(R.id.menu_sort_size); - if (sortMode == FileUtilities.SORT_LARGEST) { - item.setTitle(R.string.sort_smallest); - } else { - item.setTitle(R.string.sort_largest); - } + switch (sortMode) { + case FileUtilities.SORT_SMALLEST: { + menu.findItem(R.id.menu_sort_size_asc).setChecked(true); + } + break; - item = menu.findItem(R.id.menu_sort_az); - if (sortMode == FileUtilities.SORT_AZ) { - item.setTitle(R.string.sort_za); - } else { - item.setTitle(R.string.sort_az); - } + case FileUtilities.SORT_LARGEST: { + menu.findItem(R.id.menu_sort_size_desc).setChecked(true); + } + break; - item = menu.findItem(R.id.menu_sort_modified); - if (sortMode == FileUtilities.SORT_NEWEST) { - item.setTitle(R.string.sort_oldest); - } else { - item.setTitle(R.string.sort_newest); + case FileUtilities.SORT_AZ: { + menu.findItem(R.id.menu_sort_az).setChecked(true); + } + break; + + case FileUtilities.SORT_ZA: { + menu.findItem(R.id.menu_sort_za).setChecked(true); + } + break; + + case FileUtilities.SORT_NEWEST: { + menu.findItem(R.id.menu_sort_modified_newest).setChecked(true); + } + break; + + case FileUtilities.SORT_OLDEST: { + menu.findItem(R.id.menu_sort_modified_oldest).setChecked(true); + } + break; } switch (filterMode) { @@ -616,11 +627,42 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings openDirectory(currentDirectory); break; - case R.id.menu_sort_size: - case R.id.menu_sort_az: - case R.id.menu_sort_modified: - sortFiles(item); - break; + case R.id.menu_sort_size_asc: { + sortMode = FileUtilities.SORT_SMALLEST; + this.onResume(); + } + break; + + case R.id.menu_sort_size_desc: { + sortMode = FileUtilities.SORT_LARGEST; + this.onResume(); + } + break; + + case R.id.menu_sort_az: { + sortMode = FileUtilities.SORT_AZ; + this.onResume(); + } + break; + + case R.id.menu_sort_za: { + sortMode = FileUtilities.SORT_ZA; + this.onResume(); + } + break; + + case R.id.menu_sort_modified_newest: { + sortMode = FileUtilities.SORT_NEWEST; + this.onResume(); + } + break; + + case R.id.menu_sort_modified_oldest: { + sortMode = FileUtilities.SORT_OLDEST; + this.onResume(); + } + break; + case R.id.action_about: { AboutDialogFragment aboutDialogFragment = new AboutDialogFragment(); aboutDialogFragment.show(getSupportFragmentManager(), "AboutDialogFragment"); @@ -636,41 +678,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings return true; } - public void sortFiles(MenuItem item){ - switch (item.getItemId()) { - case R.id.menu_sort_az: - if (sortMode == FileUtilities.SORT_AZ){ - sortMode = FileUtilities.SORT_ZA; - item.setTitle(R.string.sort_az); - } else { - sortMode = FileUtilities.SORT_AZ; - item.setTitle(R.string.sort_za); - } - break; - case R.id.menu_sort_modified: - if (sortMode == FileUtilities.SORT_NEWEST){ - sortMode = FileUtilities.SORT_OLDEST; - item.setTitle(R.string.sort_newest); - } else { - sortMode = FileUtilities.SORT_NEWEST; - item.setTitle(R.string.sort_oldest); - } - break; - case R.id.menu_sort_size: - if (sortMode == FileUtilities.SORT_LARGEST){ - sortMode = FileUtilities.SORT_SMALLEST; - item.setTitle(R.string.sort_largest); - } else { - sortMode = FileUtilities.SORT_LARGEST; - item.setTitle(R.string.sort_smallest); - } - break; - default: - break; - } - this.onResume(); - } - public void readPreferences(){ prefs = getSharedPreferences(EXPLORER_PREFS_KEY, MODE_PRIVATE); sortMode = prefs.getInt(SORT_MODE_KEY, FileUtilities.SORT_AZ); |