From e0dd023da232c2d76efb72c8938cdfa8bc7b5805 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Fri, 13 Apr 2012 16:27:10 +0800 Subject: [PATCH 1/3] Auto-hide actionbar. --- src/net/micode/fileexplorer/Util.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/net/micode/fileexplorer/Util.java b/src/net/micode/fileexplorer/Util.java index 7c3575c..41f764f 100644 --- a/src/net/micode/fileexplorer/Util.java +++ b/src/net/micode/fileexplorer/Util.java @@ -400,6 +400,9 @@ public static String formatDateString(Context context, long time) { public static void updateActionModeTitle(ActionMode mode, Context context, int selectedNum) { if (mode != null) { mode.setTitle(context.getString(R.string.multi_select_title,selectedNum)); + if(selectedNum == 0){ + mode.finish(); + } } } From 6e5af08b7d163f5efe9b470281b8a55bcec69b21 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Fri, 13 Apr 2012 16:48:42 +0800 Subject: [PATCH 2/3] Fixed action bar. --- src/net/micode/fileexplorer/FileListItem.java | 5 ++++- src/net/micode/fileexplorer/FileViewInteractionHub.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/net/micode/fileexplorer/FileListItem.java b/src/net/micode/fileexplorer/FileListItem.java index 9ee85ca..d261e7e 100644 --- a/src/net/micode/fileexplorer/FileListItem.java +++ b/src/net/micode/fileexplorer/FileListItem.java @@ -101,9 +101,12 @@ public void onClick(View v) { } else { tag.Selected = !tag.Selected; } - Util.updateActionModeTitle(actionMode, mContext, mFileViewInteractionHub.getSelectedFileList().size()); + + Menu mMenu = actionMode.getMenu(); + mMenu.findItem(R.id.action_cancel).setVisible(mFileViewInteractionHub.isSelected()); + mMenu.findItem(R.id.action_select_all).setVisible(!mFileViewInteractionHub.isSelectedAll()); } } diff --git a/src/net/micode/fileexplorer/FileViewInteractionHub.java b/src/net/micode/fileexplorer/FileViewInteractionHub.java index f5cbffa..8073715 100644 --- a/src/net/micode/fileexplorer/FileViewInteractionHub.java +++ b/src/net/micode/fileexplorer/FileViewInteractionHub.java @@ -1029,6 +1029,10 @@ private boolean isSelectingFiles() { public boolean isSelectedAll() { return mFileViewListener.getItemCount() != 0 && mCheckedFileNameList.size() == mFileViewListener.getItemCount(); } + + public boolean isSelected() { + return mCheckedFileNameList.size() != 0; + } public void clearSelection() { if (mCheckedFileNameList.size() > 0) { From b9f00b3950b804cfe54c6226aed8d0aec6f85910 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Mon, 16 Apr 2012 23:53:16 +0800 Subject: [PATCH 3/3] Use onPrepareActionMode() to refresh ActionMode's selectall & cancel button whenever it's invalidated. --- src/net/micode/fileexplorer/FileListItem.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net/micode/fileexplorer/FileListItem.java b/src/net/micode/fileexplorer/FileListItem.java index d261e7e..2542925 100644 --- a/src/net/micode/fileexplorer/FileListItem.java +++ b/src/net/micode/fileexplorer/FileListItem.java @@ -103,10 +103,6 @@ public void onClick(View v) { } Util.updateActionModeTitle(actionMode, mContext, mFileViewInteractionHub.getSelectedFileList().size()); - - Menu mMenu = actionMode.getMenu(); - mMenu.findItem(R.id.action_cancel).setVisible(mFileViewInteractionHub.isSelected()); - mMenu.findItem(R.id.action_select_all).setVisible(!mFileViewInteractionHub.isSelectedAll()); } } @@ -147,6 +143,10 @@ public boolean onCreateActionMode(ActionMode mode, Menu menu) { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { mMenu.findItem(R.id.action_copy_path).setVisible( mFileViewInteractionHub.getSelectedFileList().size() == 1); + mMenu.findItem(R.id.action_cancel).setVisible( + mFileViewInteractionHub.isSelected()); + mMenu.findItem(R.id.action_select_all).setVisible( + !mFileViewInteractionHub.isSelectedAll()); return true; }