display an empty properties dialog on info click

This commit is contained in:
tibbi 2016-09-05 23:19:31 +02:00
parent 1be4ccb92e
commit 3b9c6971fe
8 changed files with 55 additions and 17 deletions

View File

@ -313,7 +313,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
MenuItem menuItem = menu.findItem(R.id.cab_rename); MenuItem menuItem = menu.findItem(R.id.cab_rename);
menuItem.setVisible(mSelectedItemsCnt == 1); menuItem.setVisible(mSelectedItemsCnt == 1);
menuItem = menu.findItem(R.id.cab_info); menuItem = menu.findItem(R.id.cab_properties);
menuItem.setVisible(mSelectedItemsCnt == 1); menuItem.setVisible(mSelectedItemsCnt == 1);
return true; return true;
@ -325,8 +325,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment
case R.id.cab_rename: case R.id.cab_rename:
displayRenameDialog(); displayRenameDialog();
break; break;
case R.id.cab_info: case R.id.cab_properties:
displayInfoDialog(); displayPropertiesDialog();
break; break;
case R.id.cab_share: case R.id.cab_share:
shareFiles(); shareFiles();
@ -369,24 +369,33 @@ public class ItemsFragment extends android.support.v4.app.Fragment
startActivity(Intent.createChooser(sendIntent, shareTitle)); 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() { private void displayRenameDialog() {
final List<Integer> itemIndexes = getSelectedItemIndexes(); final FileDirItem item = getSelectedItem();
if (itemIndexes.isEmpty()) if (item == null)
return; 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 View renameView = getActivity().getLayoutInflater().inflate(R.layout.rename_item, null);
final EditText itemName = (EditText) renameView.findViewById(R.id.item_name); final EditText itemName = (EditText) renameView.findViewById(R.id.item_name);
itemName.setText(item.getName()); 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()); final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getResources().getString(renameString)); builder.setTitle(getResources().getString(title));
builder.setView(renameView); builder.setView(renameView);
builder.setPositiveButton(R.string.ok, null); builder.setPositiveButton(R.string.ok, null);
builder.setNegativeButton(R.string.cancel, 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<Integer> itemIndexes = getSelectedItemIndexes();
if (itemIndexes.isEmpty())
return null;
final int itemIndex = itemIndexes.get(0);
return mItems.get(itemIndex);
}
private List<Integer> getSelectedItemIndexes() { private List<Integer> getSelectedItemIndexes() {
final List<Integer> selectedItems = new ArrayList<>(); final List<Integer> selectedItems = new ArrayList<>();
final SparseBooleanArray items = mListView.getCheckedItemPositions(); final SparseBooleanArray items = mListView.getCheckedItemPositions();

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/dialog_holder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
</LinearLayout>

View File

@ -2,9 +2,9 @@
<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 <item
android:id="@+id/cab_info" android:id="@+id/cab_properties"
android:icon="@mipmap/info" android:icon="@mipmap/info"
android:title="@string/info" android:title="@string/properties"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item <item
android:id="@+id/cab_rename" android:id="@+id/cab_rename"

View File

@ -15,7 +15,7 @@
<string name="delete">Löschen</string> <string name="delete">Löschen</string>
<string name="undo">Rückgängig</string> <string name="undo">Rückgängig</string>
<string name="rename">Umbenennen</string> <string name="rename">Umbenennen</string>
<string name="info">Info</string> <string name="properties">Properties</string>
<string name="copy">Kopieren</string> <string name="copy">Kopieren</string>
<string name="copy_move">Copy/Move</string> <string name="copy_move">Copy/Move</string>
<string name="share">Teilen</string> <string name="share">Teilen</string>
@ -34,6 +34,8 @@
<string name="initial_breadcrumb">home</string> <string name="initial_breadcrumb">home</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="cancel">Abbrechen</string> <string name="cancel">Abbrechen</string>
<string name="file_properties">File properties</string>
<string name="directory_properties">Directory properties</string>
<plurals name="items_deleted"> <plurals name="items_deleted">
<item quantity="one">1 Datei/Ordner gelöscht</item> <item quantity="one">1 Datei/Ordner gelöscht</item>

View File

@ -15,7 +15,7 @@
<string name="delete">Elimina</string> <string name="delete">Elimina</string>
<string name="undo">Annulla</string> <string name="undo">Annulla</string>
<string name="rename">Rinomina</string> <string name="rename">Rinomina</string>
<string name="info">Info</string> <string name="properties">Properties</string>
<string name="copy">Copia</string> <string name="copy">Copia</string>
<string name="copy_move">Copy/Move</string> <string name="copy_move">Copy/Move</string>
<string name="share">Condividi</string> <string name="share">Condividi</string>
@ -34,6 +34,8 @@
<string name="initial_breadcrumb">home</string> <string name="initial_breadcrumb">home</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="file_properties">File properties</string>
<string name="directory_properties">Directory properties</string>
<plurals name="items_deleted"> <plurals name="items_deleted">
<item quantity="one">1 elemento eliminato</item> <item quantity="one">1 elemento eliminato</item>

View File

@ -15,7 +15,7 @@
<string name="delete">削除</string> <string name="delete">削除</string>
<string name="undo">元に戻す</string> <string name="undo">元に戻す</string>
<string name="rename">名前を変更</string> <string name="rename">名前を変更</string>
<string name="info">Info</string> <string name="properties">Properties</string>
<string name="copy">コピー</string> <string name="copy">コピー</string>
<string name="copy_move">Copy/Move</string> <string name="copy_move">Copy/Move</string>
<string name="share">Dela</string> <string name="share">Dela</string>
@ -34,6 +34,8 @@
<string name="initial_breadcrumb">ホーム</string> <string name="initial_breadcrumb">ホーム</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="file_properties">File properties</string>
<string name="directory_properties">Directory properties</string>
<plurals name="items_deleted"> <plurals name="items_deleted">
<item quantity="one">1 アイテムを削除しました</item> <item quantity="one">1 アイテムを削除しました</item>

View File

@ -15,7 +15,7 @@
<string name="delete">Ta bort</string> <string name="delete">Ta bort</string>
<string name="undo">Ångra</string> <string name="undo">Ångra</string>
<string name="rename">Döp om</string> <string name="rename">Döp om</string>
<string name="info">Info</string> <string name="properties">Properties</string>
<string name="copy">Kopiera</string> <string name="copy">Kopiera</string>
<string name="copy_move">Copy/Move</string> <string name="copy_move">Copy/Move</string>
<string name="share">Dela</string> <string name="share">Dela</string>
@ -34,6 +34,8 @@
<string name="initial_breadcrumb">home</string> <string name="initial_breadcrumb">home</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="file_properties">File properties</string>
<string name="directory_properties">Directory properties</string>
<plurals name="items_deleted"> <plurals name="items_deleted">
<item quantity="one">1 objekt borttagen</item> <item quantity="one">1 objekt borttagen</item>

View File

@ -15,7 +15,7 @@
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="undo">Undo</string> <string name="undo">Undo</string>
<string name="rename">Rename</string> <string name="rename">Rename</string>
<string name="info">Info</string> <string name="properties">Properties</string>
<string name="copy">Copy</string> <string name="copy">Copy</string>
<string name="copy_move">Copy/Move</string> <string name="copy_move">Copy/Move</string>
<string name="share">Share</string> <string name="share">Share</string>
@ -34,6 +34,8 @@
<string name="initial_breadcrumb">home</string> <string name="initial_breadcrumb">home</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="file_properties">File properties</string>
<string name="directory_properties">Directory properties</string>
<plurals name="items_deleted"> <plurals name="items_deleted">
<item quantity="one">1 item deleted</item> <item quantity="one">1 item deleted</item>