Set correct title for sort mode after changes.

Change-Id: I4f75f5ee68de6ed6f3b07d93b3681aa2307cb2dc
This commit is contained in:
Siqi Liu
2015-04-23 15:16:24 +02:00
parent e49e8ac40a
commit 79dd7b118e
2 changed files with 19 additions and 8 deletions

View File

@@ -18,6 +18,12 @@
<string name="menu_search">Search</string> <string name="menu_search">Search</string>
<string name="list_view">List</string> <string name="list_view">List</string>
<string name="grid_view">Grid</string> <string name="grid_view">Grid</string>
<string name="sort_smallest">Smallest first</string>
<string name="sort_largest">Largest first</string>
<string name="sort_az">A-Z</string>
<string name="sort_za">Z-A</string>
<string name="sort_oldest">Oldest first</string>
<string name="sort_newest">Newest first</string>
<string name="menu_sort_size">Sort By Size</string> <string name="menu_sort_size">Sort By Size</string>
<string name="menu_sort_az">Sort A-Z</string> <string name="menu_sort_az">Sort A-Z</string>
<string name="menu_sort_modified">Sort by Date</string> <string name="menu_sort_modified">Sort by Date</string>

View File

@@ -437,28 +437,33 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
return true; return true;
} }
@SuppressWarnings("unused")//see android:onClick properties in view_menu.xml
public void sortFiles(MenuItem item){ public void sortFiles(MenuItem item){
switch ( item.getItemId() ) { switch (item.getItemId()) {
case R.id.menu_sort_az: case R.id.menu_sort_az:
if( sortMode == FileUtilities.SORT_AZ ){ if (sortMode == FileUtilities.SORT_AZ){
sortMode = FileUtilities.SORT_ZA; sortMode = FileUtilities.SORT_ZA;
}else{ item.setTitle(R.string.sort_az);
} else {
sortMode = FileUtilities.SORT_AZ; sortMode = FileUtilities.SORT_AZ;
item.setTitle(R.string.sort_za);
} }
break; break;
case R.id.menu_sort_modified: case R.id.menu_sort_modified:
if( sortMode == FileUtilities.SORT_NEWEST ){ if (sortMode == FileUtilities.SORT_NEWEST){
sortMode = FileUtilities.SORT_OLDEST; sortMode = FileUtilities.SORT_OLDEST;
}else{ item.setTitle(R.string.sort_newest);
} else {
sortMode = FileUtilities.SORT_NEWEST; sortMode = FileUtilities.SORT_NEWEST;
item.setTitle(R.string.sort_oldest);
} }
break; break;
case R.id.menu_sort_size: case R.id.menu_sort_size:
if( sortMode == FileUtilities.SORT_LARGEST ){ if (sortMode == FileUtilities.SORT_LARGEST){
sortMode = FileUtilities.SORT_SMALLEST; sortMode = FileUtilities.SORT_SMALLEST;
}else{ item.setTitle(R.string.sort_largest);
} else {
sortMode = FileUtilities.SORT_LARGEST; sortMode = FileUtilities.SORT_LARGEST;
item.setTitle(R.string.sort_smallest);
} }
break; break;
default: default: