From 3b9c6971fec5ab905431ad3205605c1fc2f2ad38 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 5 Sep 2016 23:19:31 +0200 Subject: [PATCH] display an empty properties dialog on info click --- .../filemanager/fragments/ItemsFragment.java | 38 ++++++++++++++----- app/src/main/res/layout/item_info.xml | 10 +++++ app/src/main/res/menu/cab.xml | 4 +- app/src/main/res/values-de/strings.xml | 4 +- app/src/main/res/values-it/strings.xml | 4 +- app/src/main/res/values-ja/strings.xml | 4 +- app/src/main/res/values-sv/strings.xml | 4 +- app/src/main/res/values/strings.xml | 4 +- 8 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 app/src/main/res/layout/item_info.xml diff --git a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java index 1a9bc7fe..e7a28e01 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java @@ -313,7 +313,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment MenuItem menuItem = menu.findItem(R.id.cab_rename); menuItem.setVisible(mSelectedItemsCnt == 1); - menuItem = menu.findItem(R.id.cab_info); + menuItem = menu.findItem(R.id.cab_properties); menuItem.setVisible(mSelectedItemsCnt == 1); return true; @@ -325,8 +325,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment case R.id.cab_rename: displayRenameDialog(); break; - case R.id.cab_info: - displayInfoDialog(); + case R.id.cab_properties: + displayPropertiesDialog(); break; case R.id.cab_share: shareFiles(); @@ -369,24 +369,33 @@ public class ItemsFragment extends android.support.v4.app.Fragment startActivity(Intent.createChooser(sendIntent, shareTitle)); } - private void displayInfoDialog() { + private void displayPropertiesDialog() { + final FileDirItem item = getSelectedItem(); + if (item == null) + return; + final int title = (item.getIsDirectory()) ? R.string.directory_properties : R.string.file_properties; + + final View infoView = getActivity().getLayoutInflater().inflate(R.layout.item_info, null); + final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(getResources().getString(title)); + builder.setView(infoView); + builder.setPositiveButton(R.string.ok, null); + builder.create().show(); } private void displayRenameDialog() { - final List itemIndexes = getSelectedItemIndexes(); - if (itemIndexes.isEmpty()) + final FileDirItem item = getSelectedItem(); + if (item == null) return; - final int itemIndex = itemIndexes.get(0); - final FileDirItem item = mItems.get(itemIndex); final View renameView = getActivity().getLayoutInflater().inflate(R.layout.rename_item, null); final EditText itemName = (EditText) renameView.findViewById(R.id.item_name); itemName.setText(item.getName()); - final int renameString = (item.getIsDirectory()) ? R.string.rename_directory : R.string.rename_file; + final int title = (item.getIsDirectory()) ? R.string.rename_directory : R.string.rename_file; final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setTitle(getResources().getString(renameString)); + builder.setTitle(getResources().getString(title)); builder.setView(renameView); builder.setPositiveButton(R.string.ok, null); builder.setNegativeButton(R.string.cancel, null); @@ -487,6 +496,15 @@ public class ItemsFragment extends android.support.v4.app.Fragment }); } + private FileDirItem getSelectedItem() { + final List itemIndexes = getSelectedItemIndexes(); + if (itemIndexes.isEmpty()) + return null; + + final int itemIndex = itemIndexes.get(0); + return mItems.get(itemIndex); + } + private List getSelectedItemIndexes() { final List selectedItems = new ArrayList<>(); final SparseBooleanArray items = mListView.getCheckedItemPositions(); diff --git a/app/src/main/res/layout/item_info.xml b/app/src/main/res/layout/item_info.xml new file mode 100644 index 00000000..cca1fc94 --- /dev/null +++ b/app/src/main/res/layout/item_info.xml @@ -0,0 +1,10 @@ + + + + diff --git a/app/src/main/res/menu/cab.xml b/app/src/main/res/menu/cab.xml index 72602096..d1255446 100644 --- a/app/src/main/res/menu/cab.xml +++ b/app/src/main/res/menu/cab.xml @@ -2,9 +2,9 @@ Löschen Rückgängig Umbenennen - Info + Properties Kopieren Copy/Move Teilen @@ -34,6 +34,8 @@ home OK Abbrechen + File properties + Directory properties 1 Datei/Ordner gelöscht diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 2c072019..4582af9b 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -15,7 +15,7 @@ Elimina Annulla Rinomina - Info + Properties Copia Copy/Move Condividi @@ -34,6 +34,8 @@ home OK Cancel + File properties + Directory properties 1 elemento eliminato diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 86e75b23..6142481d 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -15,7 +15,7 @@ 削除 元に戻す 名前を変更 - Info + Properties コピー Copy/Move Dela @@ -34,6 +34,8 @@ ホーム OK Cancel + File properties + Directory properties 1 アイテムを削除しました diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index b2e99df8..4635bca9 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -15,7 +15,7 @@ Ta bort Ångra Döp om - Info + Properties Kopiera Copy/Move Dela @@ -34,6 +34,8 @@ home OK Cancel + File properties + Directory properties 1 objekt borttagen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index be385ece..55769901 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,7 +15,7 @@ Delete Undo Rename - Info + Properties Copy Copy/Move Share @@ -34,6 +34,8 @@ home OK Cancel + File properties + Directory properties 1 item deleted