From 1bbef62f23a65e68e25920c18661ea031ef567d5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 14 Jul 2016 23:36:36 +0200 Subject: [PATCH] start working on Copy/move functionality --- .../filemanager/fragments/ItemsFragment.java | 87 ++++++++++++++++-- app/src/main/res/layout/copy_item.xml | 65 +++++++++++++ app/src/main/res/layout/directory_picker.xml | 6 ++ app/src/main/res/menu/cab.xml | 5 + app/src/main/res/mipmap-hdpi/copy.png | Bin 0 -> 360 bytes app/src/main/res/mipmap-mdpi/copy.png | Bin 0 -> 230 bytes app/src/main/res/mipmap-xhdpi/copy.png | Bin 0 -> 362 bytes app/src/main/res/mipmap-xxhdpi/copy.png | Bin 0 -> 610 bytes app/src/main/res/mipmap-xxxhdpi/copy.png | Bin 0 -> 329 bytes app/src/main/res/values/strings.xml | 7 ++ 10 files changed, 160 insertions(+), 10 deletions(-) create mode 100644 app/src/main/res/layout/copy_item.xml create mode 100644 app/src/main/res/layout/directory_picker.xml create mode 100644 app/src/main/res/mipmap-hdpi/copy.png create mode 100644 app/src/main/res/mipmap-mdpi/copy.png create mode 100644 app/src/main/res/mipmap-xhdpi/copy.png create mode 100644 app/src/main/res/mipmap-xxhdpi/copy.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/copy.png 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 7536feec..8d05323f 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java @@ -25,6 +25,7 @@ import android.widget.AdapterView; import android.widget.EditText; import android.widget.ListView; import android.widget.RadioGroup; +import android.widget.TextView; import com.simplemobiletools.filemanager.Config; import com.simplemobiletools.filemanager.Constants; @@ -304,6 +305,10 @@ public class ItemsFragment extends android.support.v4.app.Fragment displayRenameDialog(); mode.finish(); return true; + case R.id.cab_copy: + displayCopyDialog(); + mode.finish(); + return true; case R.id.cab_delete: prepareForDeleting(); mode.finish(); @@ -314,20 +319,18 @@ public class ItemsFragment extends android.support.v4.app.Fragment } private void displayRenameDialog() { - final int itemIndex = getSelectedItemIndex(); - if (itemIndex == -1) + final List itemIndexes = getSelectedItemIndexes(); + if (itemIndexes.isEmpty()) 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 AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - int renameString = R.string.rename_file; - if (item.getIsDirectory()) - renameString = R.string.rename_directory; - builder.setTitle(getResources().getString(renameString)); builder.setView(renameView); builder.setPositiveButton("OK", null); @@ -362,15 +365,46 @@ public class ItemsFragment extends android.support.v4.app.Fragment }); } - private int getSelectedItemIndex() { + private void displayCopyDialog() { + final List itemIndexes = getSelectedItemIndexes(); + if (itemIndexes.isEmpty()) + return; + + final View copyView = getActivity().getLayoutInflater().inflate(R.layout.copy_item, null); + + final TextView source = (TextView) copyView.findViewById(R.id.source); + source.setText(mPath); + + final TextView destination = (TextView) copyView.findViewById(R.id.destination); + destination.setOnClickListener(destinationPicker); + + final int copyString = (itemIndexes.size() == 1) ? R.string.copy_item : R.string.copy_items; + final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(getResources().getString(copyString)); + builder.setView(copyView); + builder.setPositiveButton("OK", null); + builder.setNegativeButton("Cancel", null); + + final AlertDialog alertDialog = builder.create(); + alertDialog.show(); + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + } + + private List getSelectedItemIndexes() { + final List selectedItems = new ArrayList<>(); final SparseBooleanArray items = mListView.getCheckedItemPositions(); int cnt = items.size(); for (int i = 0; i < cnt; i++) { if (items.valueAt(i)) { - return items.keyAt(i); + selectedItems.add(items.keyAt(i)); } } - return -1; + return selectedItems; } private void prepareForDeleting() { @@ -400,6 +434,40 @@ public class ItemsFragment extends android.support.v4.app.Fragment fillItems(); } + private View.OnClickListener destinationPicker = new View.OnClickListener() { + @Override + public void onClick(View v) { + final View pickerView = getActivity().getLayoutInflater().inflate(R.layout.directory_picker, null); + final ListView pickerList = (ListView) pickerView.findViewById(R.id.directory_picker_list); + final ItemsAdapter adapter = new ItemsAdapter(getContext(), mItems); + pickerList.setAdapter(adapter); + pickerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + final FileDirItem item = mItems.get(position); + if (item.getIsDirectory()) { + + } + } + }); + + final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(getResources().getString(R.string.select_destination)); + builder.setView(pickerView); + builder.setPositiveButton("OK", null); + builder.setNegativeButton("Cancel", null); + + final AlertDialog alertDialog = builder.create(); + alertDialog.show(); + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + } + }; + @Override public boolean onTouch(View v, MotionEvent event) { if (mSnackbar != null && mSnackbar.isShown()) { @@ -417,7 +485,6 @@ public class ItemsFragment extends android.support.v4.app.Fragment mSnackbar.dismiss(); } - final List updatedFiles = new ArrayList<>(); for (String delPath : mToBeDeleted) { final File file = new File(delPath); if (file.exists()) { diff --git a/app/src/main/res/layout/copy_item.xml b/app/src/main/res/layout/copy_item.xml new file mode 100644 index 00000000..5fcca674 --- /dev/null +++ b/app/src/main/res/layout/copy_item.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/directory_picker.xml b/app/src/main/res/layout/directory_picker.xml new file mode 100644 index 00000000..996550cc --- /dev/null +++ b/app/src/main/res/layout/directory_picker.xml @@ -0,0 +1,6 @@ + + diff --git a/app/src/main/res/menu/cab.xml b/app/src/main/res/menu/cab.xml index d8d59597..31d422e6 100644 --- a/app/src/main/res/menu/cab.xml +++ b/app/src/main/res/menu/cab.xml @@ -6,6 +6,11 @@ android:icon="@mipmap/edit" android:title="@string/rename" app:showAsAction="ifRoom"/> + |k1|%Oc%$NbBSc;uILpXq-h9ji|$mcBZh%9Dc z;5!1sj8nDwq!}0(xjbDQLn2z=&e+I%$UwmLKckSYvqR?*wiYoiH>R{k))zOFSfdZH zh&;J0A>t#X{*6)Z&k~P~OMlF(EzDu>;Mu6{;m4rE*b~Ck@n(;_+D?VarAl+H6F8qT zq}{V!#ij6RVyhZkSY_0%`)s!>68Zx^u6cdSShwmw$E}vRo1#S0@5>&LJmBe)w{C&! z)i*y5z0vlN^Wdv(EpnZ?>B_CLjM+wKZ%&`-?X%lme&O}g@?V~^Ca~EXAFaz>5aHpZ zH)%q*$`d8donR(+^;Z6gTe~DWM4fA*qSm literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-mdpi/copy.png b/app/src/main/res/mipmap-mdpi/copy.png new file mode 100644 index 0000000000000000000000000000000000000000..c7a634aaa4f208d3a6f0ea5e62de4c39f5d94221 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m=ruPZ!4!kIuJK1GyR$1YFV=Ti;mwN-Qqc->}wYOY4&CM3=ME4_R$~ z$IKel`NYNO!iqWTS2Qpjh?EuO=u<5X=vX$A&H9#0p?kc`H+GadPw31bXk-d3)o2Lf|->5gA zH6w_3%B6*c_xjAX{9oGY8FgTWf{M9HzlwCbwD5&v2&P(f z`@Jhupo6Gr~bp@7a=`x6A_u7K5j&pUXO@geCwox{NCT literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xxhdpi/copy.png b/app/src/main/res/mipmap-xxhdpi/copy.png new file mode 100644 index 0000000000000000000000000000000000000000..1d5f1e61e4d17d62e0be55da3897fe4601d4cac7 GIT binary patch literal 610 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!EX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(hLktES@foAr*7p-gfl6?I6+i@Von)TlX0BF6do$4q3G;DcJ9F^cSuT z3@fLs4w=&+ZL-GU=k9_4?I|D4eUG18@>8yp*DURinwi`bM&sE5J-KJjF!(hTKj5k0 z-ZLvP=Bm=8j8l*0r<<*Ltka->z}@A{|Im+1j6aL~;HpVbd9u#+$P)cKH#+ARA9z0} zJ^A{3Np?B*WBMECA9yW!eACpG`WrVotUmN@amR_5ZC9r6|0i7OQJB!}(0;6ug)F`%F%XdZ_^lZ;M-n+@*s>a#cBL8Q3 z^$~7Iq_+m2cDQ@)E?4sDS^wSq{>f~4ZK1p>kG(EHM8=~);UL5 z#u2;TmTBDnayK@JB>vU>E~lGami3cwmv)W4)z7Mz?q@x>@|3WC+4bhZQkHeuWjT^B zn0Bzvlaedu@;^}ipy=EEIfsLe&wf+w`E2`{m@D&wFS8c>tPXsi-o~2!UPA2ayQ+nE nCq0~3%o}4Cc_lkd_YYIRj4s!Gw;9WUiG;z^)z4*}Q$iB}emn-U literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xxxhdpi/copy.png b/app/src/main/res/mipmap-xxxhdpi/copy.png new file mode 100644 index 0000000000000000000000000000000000000000..4ddee9ef09f13f7c27faac1c159d37c8c8f3bbe7 GIT binary patch literal 329 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7z$oD9;uuoF`1Y1z*P#Frw}&Oi zj`ApGhZ?$GGdiK;WT@>qtDG&`)BJk*^MjW4)88>W>g_pq=38<~QsU#wrS-S}Jy$jk zRAuP<<8Zn`GK#I|f>}bA?1n9TH=@}0Tz~4{z`)4#?=DNtzqlI}MX4MNOYU*EcG@va zsL(&qYbRz9ygOSZVM$%9BA>y;i>iDZCR|kJ+c5E>6#I&=?%(5V96;JxI0O`MG2VbJ zfUEctJs9)C2^5xEoo968i2f7UcR|Gyh)2Ju) v;nsmxcJ29DPtRrk-!9L5VmDelete Undo Rename + Copy + Copy item + Copy items + Move + Source + Destination + Select destination 1 item deleted