mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 14:28:00 +01:00
add sorting button to the menu
This commit is contained in:
parent
fddaea76c3
commit
cd567c370b
5 changed files with 33 additions and 1 deletions
|
@ -102,6 +102,8 @@ public class MainActivity extends SimpleActivity
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
case R.id.sort:
|
||||||
|
return true;
|
||||||
case R.id.camera:
|
case R.id.camera:
|
||||||
startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
|
startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -124,6 +124,22 @@ public class MediaActivity extends SimpleActivity
|
||||||
setTitle(dirName);
|
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() {
|
private void deleteDirectoryIfEmpty() {
|
||||||
final File file = new File(mPath);
|
final File file = new File(mPath);
|
||||||
if (file.isDirectory() && file.listFiles().length == 0) {
|
if (file.isDirectory() && file.listFiles().length == 0) {
|
||||||
|
@ -364,7 +380,7 @@ public class MediaActivity extends SimpleActivity
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
final MenuInflater inflater = mode.getMenuInflater();
|
final MenuInflater inflater = mode.getMenuInflater();
|
||||||
inflater.inflate(R.menu.media_menu, menu);
|
inflater.inflate(R.menu.cab_media, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<?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/sort"
|
||||||
|
android:icon="@mipmap/sort"
|
||||||
|
android:title="@string/sort_by"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/camera"
|
android:id="@+id/camera"
|
||||||
android:icon="@mipmap/camera"
|
android:icon="@mipmap/camera"
|
||||||
|
|
9
app/src/main/res/menu/menu_media.xml
Normal file
9
app/src/main/res/menu/menu_media.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/sort"
|
||||||
|
android:icon="@mipmap/sort"
|
||||||
|
android:title="@string/sort_by"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
</menu>
|
Loading…
Reference in a new issue