diff --git a/src/net/micode/fileexplorer/FileExplorerPreferenceActivity.java b/src/net/micode/fileexplorer/FileExplorerPreferenceActivity.java index e2a3215..e7070a3 100644 --- a/src/net/micode/fileexplorer/FileExplorerPreferenceActivity.java +++ b/src/net/micode/fileexplorer/FileExplorerPreferenceActivity.java @@ -25,22 +25,25 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; +import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.text.TextUtils; /** - * + * * @author ShunLi */ -public class FileExplorerPreferenceActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { +public class FileExplorerPreferenceActivity extends PreferenceActivity + implements OnSharedPreferenceChangeListener { private static final String PRIMARY_FOLDER = "pref_key_primary_folder"; private static final String READ_ROOT = "pref_key_read_root"; private static final String SHOW_REAL_PATH = "pref_key_show_real_path"; private static final String SYSTEM_SEPARATOR = File.separator; private EditTextPreference mEditTextPreference; + private CheckBoxPreference mCheckBoxPreferenceShowRealPath; @Override protected void onCreate(Bundle savedInstanceState) { @@ -48,6 +51,9 @@ protected void onCreate(Bundle savedInstanceState) { addPreferencesFromResource(R.xml.preferences); mEditTextPreference = (EditTextPreference) findPreference(PRIMARY_FOLDER); + mCheckBoxPreferenceShowRealPath = (CheckBoxPreference) findPreference(SHOW_REAL_PATH); + mCheckBoxPreferenceShowRealPath.setEnabled(getPreferenceScreen() + .getSharedPreferences().getBoolean(READ_ROOT, false)); } @Override @@ -55,11 +61,12 @@ protected void onResume() { super.onResume(); // Setup the initial values - SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); + SharedPreferences sharedPreferences = getPreferenceScreen() + .getSharedPreferences(); mEditTextPreference.setSummary(this.getString( - R.string.pref_primary_folder_summary, - sharedPreferences.getString(PRIMARY_FOLDER, GlobalConsts.ROOT_PATH))); + R.string.pref_primary_folder_summary, sharedPreferences + .getString(PRIMARY_FOLDER, GlobalConsts.ROOT_PATH))); // Set up a listener whenever a key changes sharedPreferences.registerOnSharedPreferenceChangeListener(this); @@ -70,30 +77,48 @@ protected void onPause() { super.onPause(); // Unregister the listener whenever a key changes - getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); + getPreferenceScreen().getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(this); } @Override - public void onSharedPreferenceChanged(SharedPreferences sharedpreferences, String key) { + public void onSharedPreferenceChanged(SharedPreferences sharedpreferences, + String key) { if (PRIMARY_FOLDER.equals(key)) { - mEditTextPreference.setSummary(this.getString( - R.string.pref_primary_folder_summary, - sharedpreferences.getString(PRIMARY_FOLDER, GlobalConsts.ROOT_PATH))); + mEditTextPreference + .setSummary(this.getString( + R.string.pref_primary_folder_summary, + sharedpreferences.getString(PRIMARY_FOLDER, + GlobalConsts.ROOT_PATH))); + } else if (READ_ROOT.equals(key)) { + // sharedpreferences.getBoolean(READ_ROOT, false) + mCheckBoxPreferenceShowRealPath.setEnabled(sharedpreferences + .getBoolean(READ_ROOT, false)); } } public static String getPrimaryFolder(Context context) { - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); - String primaryFolder = settings.getString(PRIMARY_FOLDER, context.getString(R.string.default_primary_folder, GlobalConsts.ROOT_PATH)); - - if (TextUtils.isEmpty(primaryFolder)) { // setting primary folder = empty("") + SharedPreferences settings = PreferenceManager + .getDefaultSharedPreferences(context); + String primaryFolder = settings.getString(PRIMARY_FOLDER, context + .getString(R.string.default_primary_folder, + GlobalConsts.ROOT_PATH)); + + if (TextUtils.isEmpty(primaryFolder)) { // setting primary folder = + // empty("") primaryFolder = GlobalConsts.ROOT_PATH; } - // it's remove the end char of the home folder setting when it with the '/' at the end. - // if has the backslash at end of the home folder, it's has minor bug at "UpLevel" function. + // it's remove the end char of the home folder setting when it with the + // '/' at the end. + // if has the backslash at end of the home folder, it's has minor bug at + // "UpLevel" function. int length = primaryFolder.length(); - if (length > 1 && SYSTEM_SEPARATOR.equals(primaryFolder.substring(length - 1))) { // length = 1, ROOT_PATH + if (length > 1 + && SYSTEM_SEPARATOR.equals(primaryFolder.substring(length - 1))) { // length + // = + // 1, + // ROOT_PATH return primaryFolder.substring(0, length - 1); } else { return primaryFolder; @@ -101,17 +126,22 @@ public static String getPrimaryFolder(Context context) { } public static boolean isReadRoot(Context context) { - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences settings = PreferenceManager + .getDefaultSharedPreferences(context); boolean isReadRootFromSetting = settings.getBoolean(READ_ROOT, false); - boolean isReadRootWhenSettingPrimaryFolderWithoutSdCardPrefix = !getPrimaryFolder(context).startsWith(Util.getSdDirectory()); + boolean isReadRootWhenSettingPrimaryFolderWithoutSdCardPrefix = !getPrimaryFolder( + context).startsWith(Util.getSdDirectory()); - return isReadRootFromSetting || isReadRootWhenSettingPrimaryFolderWithoutSdCardPrefix; + return isReadRootFromSetting + || isReadRootWhenSettingPrimaryFolderWithoutSdCardPrefix; } - + public static boolean showRealPath(Context context) { - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); - return settings.getBoolean(SHOW_REAL_PATH, false); + SharedPreferences settings = PreferenceManager + .getDefaultSharedPreferences(context); + return settings.getBoolean(SHOW_REAL_PATH, false) + && isReadRoot(context); } } diff --git a/src/net/micode/fileexplorer/FileOperationHelper.java b/src/net/micode/fileexplorer/FileOperationHelper.java index 287e2fb..c40126a 100644 --- a/src/net/micode/fileexplorer/FileOperationHelper.java +++ b/src/net/micode/fileexplorer/FileOperationHelper.java @@ -264,6 +264,8 @@ private void CopyFile(FileInfo f, String dest) { destFile = new File(destPath); } + destFile.mkdirs();// 修复不能复制空文件夹的bug + for (File child : file.listFiles(mFilter)) { if (!child.isHidden() && Util.isNormalFile(child.getAbsolutePath())) { CopyFile(Util.GetFileInfo(child, mFilter, Settings.instance().getShowDotAndHiddenFiles()), destPath); diff --git a/src/net/micode/fileexplorer/FileViewActivity.java b/src/net/micode/fileexplorer/FileViewActivity.java index 2678bb5..cb48a4f 100644 --- a/src/net/micode/fileexplorer/FileViewActivity.java +++ b/src/net/micode/fileexplorer/FileViewActivity.java @@ -87,7 +87,8 @@ public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Log.v(LOG_TAG, "received broadcast:" + intent.toString()); - if (action.equals(Intent.ACTION_MEDIA_MOUNTED) || action.equals(Intent.ACTION_MEDIA_UNMOUNTED)) { + if (action.equals(Intent.ACTION_MEDIA_MOUNTED) + || action.equals(Intent.ACTION_MEDIA_UNMOUNTED)) { runOnUiThread(new Runnable() { @Override public void run() { @@ -99,20 +100,25 @@ public void run() { }; private boolean mBackspaceExit; + private boolean mShowRealPath; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { mActivity = getActivity(); // getWindow().setFormat(android.graphics.PixelFormat.RGBA_8888); - mRootView = inflater.inflate(R.layout.file_explorer_list, container, false); - ActivitiesManager.getInstance().registerActivity(ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity); + mRootView = inflater.inflate(R.layout.file_explorer_list, container, + false); + ActivitiesManager.getInstance().registerActivity( + ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity); mFileCagetoryHelper = new FileCategoryHelper(mActivity); mFileViewInteractionHub = new FileViewInteractionHub(this); Intent intent = mActivity.getIntent(); String action = intent.getAction(); if (!TextUtils.isEmpty(action) - && (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT))) { + && (action.equals(Intent.ACTION_PICK) || action + .equals(Intent.ACTION_GET_CONTENT))) { mFileViewInteractionHub.setMode(Mode.Pick); boolean pickFolder = intent.getBooleanExtra(PICK_FOLDER, false); @@ -122,26 +128,35 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mFileCagetoryHelper.setCustomCategory(exts); } } else { - mFileCagetoryHelper.setCustomCategory(new String[]{} /*folder only*/); - mRootView.findViewById(R.id.pick_operation_bar).setVisibility(View.VISIBLE); - - mRootView.findViewById(R.id.button_pick_confirm).setOnClickListener(new OnClickListener() { - public void onClick(View v) { - try { - Intent intent = Intent.parseUri(mFileViewInteractionHub.getCurrentPath(), 0); - mActivity.setResult(Activity.RESULT_OK, intent); - mActivity.finish(); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - }); - - mRootView.findViewById(R.id.button_pick_cancel).setOnClickListener(new OnClickListener() { - public void onClick(View v) { - mActivity.finish(); - } - }); + mFileCagetoryHelper.setCustomCategory(new String[] {} /* + * folder + * only + */); + mRootView.findViewById(R.id.pick_operation_bar).setVisibility( + View.VISIBLE); + + mRootView.findViewById(R.id.button_pick_confirm) + .setOnClickListener(new OnClickListener() { + public void onClick(View v) { + try { + Intent intent = Intent.parseUri( + mFileViewInteractionHub + .getCurrentPath(), 0); + mActivity.setResult(Activity.RESULT_OK, + intent); + mActivity.finish(); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + } + }); + + mRootView.findViewById(R.id.button_pick_cancel) + .setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mActivity.finish(); + } + }); } } else { mFileViewInteractionHub.setMode(Mode.View); @@ -149,10 +164,13 @@ public void onClick(View v) { mFileListView = (ListView) mRootView.findViewById(R.id.file_path_list); mFileIconHelper = new FileIconHelper(mActivity); - mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, mFileNameList, mFileViewInteractionHub, - mFileIconHelper); + mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, + mFileNameList, mFileViewInteractionHub, mFileIconHelper); - boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD, !FileExplorerPreferenceActivity.isReadRoot(mActivity)); + mShowRealPath = FileExplorerPreferenceActivity.showRealPath(mActivity); + + boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD, + !FileExplorerPreferenceActivity.isReadRoot(mActivity)); Log.i(LOG_TAG, "baseSd = " + baseSd); String rootDir = intent.getStringExtra(ROOT_DIRECTORY); @@ -165,7 +183,8 @@ public void onClick(View v) { } mFileViewInteractionHub.setRootPath(rootDir); - String currentDir = FileExplorerPreferenceActivity.getPrimaryFolder(mActivity); + String currentDir = FileExplorerPreferenceActivity + .getPrimaryFolder(mActivity); Uri uri = intent.getData(); if (uri != null) { if (baseSd && this.sdDir.startsWith(uri.getPath())) { @@ -178,8 +197,9 @@ public void onClick(View v) { Log.i(LOG_TAG, "CurrentDir = " + currentDir); mBackspaceExit = (uri != null) - && (TextUtils.isEmpty(action) - || (!action.equals(Intent.ACTION_PICK) && !action.equals(Intent.ACTION_GET_CONTENT))); + && (TextUtils.isEmpty(action) || (!action + .equals(Intent.ACTION_PICK) && !action + .equals(Intent.ACTION_GET_CONTENT))); mFileListView.setAdapter(mAdapter); mFileViewInteractionHub.refreshFileList(); @@ -215,7 +235,8 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public boolean onBack() { - if (mBackspaceExit || !Util.isSDCardReady() || mFileViewInteractionHub == null) { + if (mBackspaceExit || !Util.isSDCardReady() + || mFileViewInteractionHub == null) { return false; } return mFileViewInteractionHub.onBackPressed(); @@ -224,6 +245,7 @@ public boolean onBack() { private class PathScrollPositionItem { String path; int pos; + PathScrollPositionItem(String s, int p) { path = s; pos = p; @@ -233,18 +255,23 @@ private class PathScrollPositionItem { // execute before change, return the memorized scroll position private int computeScrollPosition(String path) { int pos = 0; - if(mPreviousPath!=null) { + if (mPreviousPath != null) { if (path.startsWith(mPreviousPath)) { - int firstVisiblePosition = mFileListView.getFirstVisiblePosition(); + int firstVisiblePosition = mFileListView + .getFirstVisiblePosition(); if (mScrollPositionList.size() != 0 - && mPreviousPath.equals(mScrollPositionList.get(mScrollPositionList.size() - 1).path)) { + && mPreviousPath.equals(mScrollPositionList + .get(mScrollPositionList.size() - 1).path)) { mScrollPositionList.get(mScrollPositionList.size() - 1).pos = firstVisiblePosition; - Log.i(LOG_TAG, "computeScrollPosition: update item: " + mPreviousPath + " " + firstVisiblePosition + Log.i(LOG_TAG, "computeScrollPosition: update item: " + + mPreviousPath + " " + firstVisiblePosition + " stack count:" + mScrollPositionList.size()); pos = firstVisiblePosition; } else { - mScrollPositionList.add(new PathScrollPositionItem(mPreviousPath, firstVisiblePosition)); - Log.i(LOG_TAG, "computeScrollPosition: add item: " + mPreviousPath + " " + firstVisiblePosition + mScrollPositionList.add(new PathScrollPositionItem( + mPreviousPath, firstVisiblePosition)); + Log.i(LOG_TAG, "computeScrollPosition: add item: " + + mPreviousPath + " " + firstVisiblePosition + " stack count:" + mScrollPositionList.size()); } } else { @@ -260,16 +287,19 @@ private int computeScrollPosition(String path) { pos = mScrollPositionList.get(i - 1).pos; } - for (int j = mScrollPositionList.size() - 1; j >= i-1 && j>=0; j--) { + for (int j = mScrollPositionList.size() - 1; j >= i - 1 + && j >= 0; j--) { mScrollPositionList.remove(j); } } } - Log.i(LOG_TAG, "computeScrollPosition: result pos: " + path + " " + pos + " stack count:" + mScrollPositionList.size()); + Log.i(LOG_TAG, "computeScrollPosition: result pos: " + path + " " + pos + + " stack count:" + mScrollPositionList.size()); mPreviousPath = path; return pos; } + public boolean onRefreshFileList(String path, FileSortHelper sort) { File file = new File(path); if (!file.exists() || !file.isDirectory()) { @@ -285,13 +315,16 @@ public boolean onRefreshFileList(String path, FileSortHelper sort) { for (File child : listFiles) { // do not show selected file if in move state - if (mFileViewInteractionHub.isMoveState() && mFileViewInteractionHub.isFileSelected(child.getPath())) + if (mFileViewInteractionHub.isMoveState() + && mFileViewInteractionHub.isFileSelected(child.getPath())) continue; String absolutePath = child.getAbsolutePath(); - if (Util.isNormalFile(absolutePath) && Util.shouldShowFile(absolutePath)) { + if (Util.isNormalFile(absolutePath) + && Util.shouldShowFile(absolutePath)) { FileInfo lFileInfo = Util.GetFileInfo(child, - mFileCagetoryHelper.getFilter(), Settings.instance().getShowDotAndHiddenFiles()); + mFileCagetoryHelper.getFilter(), Settings.instance() + .getShowDotAndHiddenFiles()); if (lFileInfo != null) { fileList.add(lFileInfo); } @@ -318,7 +351,7 @@ private void updateUI() { navigationBar.setVisibility(sdCardReady ? View.VISIBLE : View.GONE); mFileListView.setVisibility(sdCardReady ? View.VISIBLE : View.GONE); - if(sdCardReady) { + if (sdCardReady) { mFileViewInteractionHub.refreshFileList(); } } @@ -354,7 +387,8 @@ public void run() { @Override public void onPick(FileInfo f) { try { - Intent intent = Intent.parseUri(Uri.fromFile(new File(f.filePath)).toString(), 0); + Intent intent = Intent.parseUri(Uri.fromFile(new File(f.filePath)) + .toString(), 0); mActivity.setResult(Activity.RESULT_OK, intent); mActivity.finish(); return; @@ -373,11 +407,12 @@ public boolean onOperation(int id) { return false; } - //支持显示真实路径 + // 支持显示真实路径 @Override public String getDisplayPath(String path) { - if (path.startsWith(this.sdDir) && !FileExplorerPreferenceActivity.showRealPath(mActivity)) { - return getString(R.string.sd_folder) + path.substring(this.sdDir.length()); + if (path.startsWith(this.sdDir) && !mShowRealPath) { + return getString(R.string.sd_folder) + + path.substring(this.sdDir.length()); } else { return path; } @@ -435,8 +470,7 @@ public boolean setPath(String location) { if (!location.startsWith(mFileViewInteractionHub.getRootPath())) { return false; } - mFileViewInteractionHub.setCurrentPath(location); - mFileViewInteractionHub.refreshFileList(); + mFileViewInteractionHub.jump2Folder(location); return true; } diff --git a/src/net/micode/fileexplorer/FileViewInteractionHub.java b/src/net/micode/fileexplorer/FileViewInteractionHub.java index 8073715..38d17ba 100644 --- a/src/net/micode/fileexplorer/FileViewInteractionHub.java +++ b/src/net/micode/fileexplorer/FileViewInteractionHub.java @@ -21,6 +21,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Stack; import android.R.drawable; import android.app.AlertDialog; @@ -87,6 +88,8 @@ public class FileViewInteractionHub implements IOperationProgressListener { private Context mContext; + private Stack mFolderHistroyStack; + public enum Mode { View, Pick }; @@ -98,6 +101,7 @@ public FileViewInteractionHub(IFileInteractionListener fileViewListener) { mFileOperationHelper = new FileOperationHelper(this); mFileSortHelper = new FileSortHelper(); mContext = mFileViewListener.getContext(); + mFolderHistroyStack = new Stack(); } private void showProgress(String msg) { @@ -168,7 +172,8 @@ public boolean isInSelection() { } public boolean isMoveState() { - return mFileOperationHelper.isMoveState() || mFileOperationHelper.canPaste(); + return mFileOperationHelper.isMoveState() + || mFileOperationHelper.canPaste(); } private void setup() { @@ -179,25 +184,30 @@ private void setup() { private void setupNaivgationBar() { mNavigationBar = mFileViewListener.getViewById(R.id.navigation_bar); - mNavigationBarText = (TextView) mFileViewListener.getViewById(R.id.current_path_view); - mNavigationBarUpDownArrow = (ImageView) mFileViewListener.getViewById(R.id.path_pane_arrow); + mNavigationBarText = (TextView) mFileViewListener + .getViewById(R.id.current_path_view); + mNavigationBarUpDownArrow = (ImageView) mFileViewListener + .getViewById(R.id.path_pane_arrow); View clickable = mFileViewListener.getViewById(R.id.current_path_pane); clickable.setOnClickListener(buttonClick); - mDropdownNavigation = mFileViewListener.getViewById(R.id.dropdown_navigation); + mDropdownNavigation = mFileViewListener + .getViewById(R.id.dropdown_navigation); setupClick(mNavigationBar, R.id.path_pane_up_level); } // buttons private void setupOperationPane() { - mConfirmOperationBar = mFileViewListener.getViewById(R.id.moving_operation_bar); + mConfirmOperationBar = mFileViewListener + .getViewById(R.id.moving_operation_bar); setupClick(mConfirmOperationBar, R.id.button_moving_confirm); setupClick(mConfirmOperationBar, R.id.button_moving_cancel); } private void setupClick(View v, int id) { - View button = (v != null ? v.findViewById(id) : mFileViewListener.getViewById(id)); + View button = (v != null ? v.findViewById(id) : mFileViewListener + .getViewById(id)); if (button != null) button.setOnClickListener(buttonClick); } @@ -206,37 +216,38 @@ private void setupClick(View v, int id) { @Override public void onClick(View v) { switch (v.getId()) { - case R.id.button_operation_copy: - onOperationCopy(); - break; - case R.id.button_operation_move: - onOperationMove(); - break; - case R.id.button_operation_send: - onOperationSend(); - break; - case R.id.button_operation_delete: - onOperationDelete(); - break; - case R.id.button_operation_cancel: - onOperationSelectAllOrCancel(); - break; - case R.id.current_path_pane: - onNavigationBarClick(); - break; - case R.id.button_moving_confirm: - onOperationButtonConfirm(); - break; - case R.id.button_moving_cancel: - onOperationButtonCancel(); - break; - case R.id.path_pane_up_level: - onOperationUpLevel(); - ActionMode mode = ((FileExplorerTabActivity) mContext).getActionMode(); - if (mode != null) { - mode.finish(); - } - break; + case R.id.button_operation_copy: + onOperationCopy(); + break; + case R.id.button_operation_move: + onOperationMove(); + break; + case R.id.button_operation_send: + onOperationSend(); + break; + case R.id.button_operation_delete: + onOperationDelete(); + break; + case R.id.button_operation_cancel: + onOperationSelectAllOrCancel(); + break; + case R.id.current_path_pane: + onNavigationBarClick(); + break; + case R.id.button_moving_confirm: + onOperationButtonConfirm(); + break; + case R.id.button_moving_cancel: + onOperationButtonCancel(); + break; + case R.id.path_pane_up_level: + onOperationUpLevel(false); + ActionMode mode = ((FileExplorerTabActivity) mContext) + .getActionMode(); + if (mode != null) { + mode.finish(); + } + break; } } @@ -257,7 +268,8 @@ private void onOperationFavorite() { } private void onOperationSetting() { - Intent intent = new Intent(mContext, FileExplorerPreferenceActivity.class); + Intent intent = new Intent(mContext, + FileExplorerPreferenceActivity.class); if (intent != null) { try { mContext.startActivity(intent); @@ -268,7 +280,8 @@ private void onOperationSetting() { } private void onOperationFavorite(String path) { - FavoriteDatabaseHelper databaseHelper = FavoriteDatabaseHelper.getInstance(); + FavoriteDatabaseHelper databaseHelper = FavoriteDatabaseHelper + .getInstance(); if (databaseHelper != null) { int stringId = 0; if (databaseHelper.isFavorite(path)) { @@ -284,7 +297,8 @@ private void onOperationFavorite(String path) { } private void onOperationShowSysFiles() { - Settings.instance().setShowDotAndHiddenFiles(!Settings.instance().getShowDotAndHiddenFiles()); + Settings.instance().setShowDotAndHiddenFiles( + !Settings.instance().getShowDotAndHiddenFiles()); refreshFileList(); } @@ -305,13 +319,41 @@ public void onOperationSelectAll() { FileExplorerTabActivity fileExplorerTabActivity = (FileExplorerTabActivity) mContext; ActionMode mode = fileExplorerTabActivity.getActionMode(); if (mode == null) { - mode = fileExplorerTabActivity.startActionMode(new ModeCallback(mContext, this)); + mode = fileExplorerTabActivity.startActionMode(new ModeCallback( + mContext, this)); fileExplorerTabActivity.setActionMode(mode); - Util.updateActionModeTitle(mode, mContext, getSelectedFileList().size()); + Util.updateActionModeTitle(mode, mContext, getSelectedFileList() + .size()); } mFileViewListener.onDataChanged(); } + public void jump2Folder(String path) { + if (mCurrentPath != path) {// 判断是否应该将当前路径添加到历史堆栈中 + mFolderHistroyStack.add(mCurrentPath.isEmpty() ? mRoot + : mCurrentPath); + } + mCurrentPath = path; + refreshFileList(); + } + + /* + * 返回上一个文件夹当存在上一个浏览过的文件夹时返回true,当已经是最初浏览的文件夹时返回false(用以判断是否该退出) + * 新增加了判断是否属于合法路径的判断,用以在变更设置时(是否浏览root目录等)自动过滤掉不该显示的目录 + */ + private boolean folderReturn() { + String path = null; + while (!mFolderHistroyStack.empty()) { + path = mFolderHistroyStack.pop(); + if (path.startsWith(mRoot)) { + mCurrentPath = path; + refreshFileList(); + return true; + } + } + return false; + } + private OnClickListener navigationClick = new OnClickListener() { @Override @@ -322,12 +364,7 @@ public void onClick(View v) { if (mFileViewListener.onNavigation(path)) return; - if(path.isEmpty()){ - mCurrentPath = mRoot; - } else{ - mCurrentPath = path; - } - refreshFileList(); + jump2Folder(path.isEmpty() ? mRoot : path); } }; @@ -336,35 +373,41 @@ protected void onNavigationBarClick() { if (mDropdownNavigation.getVisibility() == View.VISIBLE) { showDropdownNavigation(false); } else { - LinearLayout list = (LinearLayout) mDropdownNavigation.findViewById(R.id.dropdown_navigation_list); + LinearLayout list = (LinearLayout) mDropdownNavigation + .findViewById(R.id.dropdown_navigation_list); list.removeAllViews(); int pos = 0; String displayPath = mFileViewListener.getDisplayPath(mCurrentPath); boolean root = true; int left = 0; - while (pos != -1 && !displayPath.equals("/")) {//如果当前位置在根文件夹则不显示导航条 + while (pos != -1 && !displayPath.equals("/")) {// 如果当前位置在根文件夹则不显示导航条 int end = displayPath.indexOf("/", pos); if (end == -1) break; - View listItem = LayoutInflater.from(mContext).inflate(R.layout.dropdown_item, - null); + View listItem = LayoutInflater.from(mContext).inflate( + R.layout.dropdown_item, null); View listContent = listItem.findViewById(R.id.list_item); listContent.setPadding(left, 0, 0, 0); left += 20; - ImageView img = (ImageView) listItem.findViewById(R.id.item_icon); + ImageView img = (ImageView) listItem + .findViewById(R.id.item_icon); - img.setImageResource(root ? R.drawable.dropdown_icon_root : R.drawable.dropdown_icon_folder); + img.setImageResource(root ? R.drawable.dropdown_icon_root + : R.drawable.dropdown_icon_folder); root = false; - TextView text = (TextView) listItem.findViewById(R.id.path_name); + TextView text = (TextView) listItem + .findViewById(R.id.path_name); String substring = displayPath.substring(pos, end); - if(substring.isEmpty())substring = "/"; + if (substring.isEmpty()) + substring = "/"; text.setText(substring); listItem.setOnClickListener(navigationClick); - listItem.setTag(mFileViewListener.getRealPath(displayPath.substring(0, end))); + listItem.setTag(mFileViewListener.getRealPath(displayPath + .substring(0, end))); pos = end + 1; list.addView(listItem); } @@ -374,26 +417,31 @@ protected void onNavigationBarClick() { } } - public boolean onOperationUpLevel() { + public boolean onOperationUpLevel(boolean isreturn) { showDropdownNavigation(false); if (mFileViewListener.onOperation(GlobalConsts.OPERATION_UP_LEVEL)) { return true; } - if (!mRoot.equals(mCurrentPath)) { - mCurrentPath = new File(mCurrentPath).getParent(); - refreshFileList(); - return true; + if (isreturn) {// 真正的后退动作 + return folderReturn(); + } else {// 返回上一级文件夹 + if (!mRoot.equals(mCurrentPath)) { + jump2Folder(new File(mCurrentPath).getParent()); + return true; + } } return false; } public void onOperationCreateFolder() { - TextInputDialog dialog = new TextInputDialog(mContext, mContext.getString( - R.string.operation_create_folder), mContext.getString(R.string.operation_create_folder_message), - mContext.getString(R.string.new_folder_name), new OnFinishListener() { + TextInputDialog dialog = new TextInputDialog(mContext, + mContext.getString(R.string.operation_create_folder), + mContext.getString(R.string.operation_create_folder_message), + mContext.getString(R.string.new_folder_name), + new OnFinishListener() { @Override public boolean onFinish(String text) { return doCreateFolder(text); @@ -408,10 +456,13 @@ private boolean doCreateFolder(String text) { return false; if (mFileOperationHelper.CreateFolder(mCurrentPath, text)) { - mFileViewListener.addSingleFile(Util.GetFileInfo(Util.makePath(mCurrentPath, text))); + mFileViewListener.addSingleFile(Util.GetFileInfo(Util.makePath( + mCurrentPath, text))); mFileListView.setSelection(mFileListView.getCount() - 1); } else { - new AlertDialog.Builder(mContext).setMessage(mContext.getString(R.string.fail_to_create_folder)) + new AlertDialog.Builder(mContext) + .setMessage( + mContext.getString(R.string.fail_to_create_folder)) .setPositiveButton(R.string.confirm, null).create().show(); return false; } @@ -439,7 +490,8 @@ public void onOperationCopy(ArrayList files) { clearSelection(); showConfirmOperationBar(true); - View confirmButton = mConfirmOperationBar.findViewById(R.id.button_moving_confirm); + View confirmButton = mConfirmOperationBar + .findViewById(R.id.button_moving_confirm); confirmButton.setEnabled(false); // refresh to hide selected files refreshFileList(); @@ -453,8 +505,8 @@ public void onOperationCopyPath() { } private void copy(CharSequence text) { - ClipboardManager cm = (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ClipboardManager cm = (ClipboardManager) mContext + .getSystemService(Context.CLIPBOARD_SERVICE); cm.setText(text); } @@ -468,7 +520,8 @@ public void onOperationMove() { mFileOperationHelper.StartMove(getSelectedFileList()); clearSelection(); showConfirmOperationBar(true); - View confirmButton = mConfirmOperationBar.findViewById(R.id.button_moving_confirm); + View confirmButton = mConfirmOperationBar + .findViewById(R.id.button_moving_confirm); confirmButton.setEnabled(false); // refresh to hide selected files refreshFileList(); @@ -490,13 +543,15 @@ private void updateConfirmButtons() { if (mConfirmOperationBar.getVisibility() == View.GONE) return; - Button confirmButton = (Button) mConfirmOperationBar.findViewById(R.id.button_moving_confirm); + Button confirmButton = (Button) mConfirmOperationBar + .findViewById(R.id.button_moving_confirm); int text = R.string.operation_paste; if (isSelectingFiles()) { confirmButton.setEnabled(mCheckedFileNameList.size() != 0); text = R.string.operation_send; } else if (isMoveState()) { - confirmButton.setEnabled(mFileOperationHelper.canMove(mCurrentPath)); + confirmButton + .setEnabled(mFileOperationHelper.canMove(mCurrentPath)); } confirmButton.setText(text); @@ -504,20 +559,24 @@ private void updateConfirmButtons() { private void updateNavigationPane() { View upLevel = mFileViewListener.getViewById(R.id.path_pane_up_level); - upLevel.setVisibility(mRoot.equals(mCurrentPath) ? View.INVISIBLE : View.VISIBLE); + upLevel.setVisibility(mRoot.equals(mCurrentPath) ? View.INVISIBLE + : View.VISIBLE); View arrow = mFileViewListener.getViewById(R.id.path_pane_arrow); - arrow.setVisibility(mRoot.equals(mCurrentPath) ? View.GONE : View.VISIBLE); + arrow.setVisibility(mRoot.equals(mCurrentPath) ? View.GONE + : View.VISIBLE); - mNavigationBarText.setText(mFileViewListener.getDisplayPath(mCurrentPath)); + mNavigationBarText.setText(mFileViewListener + .getDisplayPath(mCurrentPath)); } public void onOperationSend() { ArrayList selectedFileList = getSelectedFileList(); for (FileInfo f : selectedFileList) { if (f.IsDir) { - AlertDialog dialog = new AlertDialog.Builder(mContext).setMessage( - R.string.error_info_cant_send_folder).setPositiveButton(R.string.confirm, null).create(); + AlertDialog dialog = new AlertDialog.Builder(mContext) + .setMessage(R.string.error_info_cant_send_folder) + .setPositiveButton(R.string.confirm, null).create(); dialog.show(); return; } @@ -545,8 +604,10 @@ public void onOperationRename() { final FileInfo f = getSelectedFileList().get(0); clearSelection(); - TextInputDialog dialog = new TextInputDialog(mContext, mContext.getString(R.string.operation_rename), - mContext.getString(R.string.operation_rename_message), f.fileName, new OnFinishListener() { + TextInputDialog dialog = new TextInputDialog(mContext, + mContext.getString(R.string.operation_rename), + mContext.getString(R.string.operation_rename_message), + f.fileName, new OnFinishListener() { @Override public boolean onFinish(String text) { return doRename(f, text); @@ -565,7 +626,8 @@ private boolean doRename(final FileInfo f, String text) { f.fileName = text; mFileViewListener.onDataChanged(); } else { - new AlertDialog.Builder(mContext).setMessage(mContext.getString(R.string.fail_to_rename)) + new AlertDialog.Builder(mContext) + .setMessage(mContext.getString(R.string.fail_to_rename)) .setPositiveButton(R.string.confirm, null).create().show(); return false; } @@ -580,9 +642,12 @@ private void notifyFileSystemChanged(String path) { final Intent intent; if (f.isDirectory()) { intent = new Intent(Intent.ACTION_MEDIA_MOUNTED); - intent.setClassName("com.android.providers.media", "com.android.providers.media.MediaScannerReceiver"); - intent.setData(Uri.fromFile(Environment.getExternalStorageDirectory())); - Log.v(LOG_TAG, "directory changed, send broadcast:" + intent.toString()); + intent.setClassName("com.android.providers.media", + "com.android.providers.media.MediaScannerReceiver"); + intent.setData(Uri.fromFile(Environment + .getExternalStorageDirectory())); + Log.v(LOG_TAG, + "directory changed, send broadcast:" + intent.toString()); } else { intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(new File(path))); @@ -606,22 +671,30 @@ public void onOperationDelete(int position) { } private void doOperationDelete(final ArrayList selectedFileList) { - final ArrayList selectedFiles = new ArrayList(selectedFileList); + final ArrayList selectedFiles = new ArrayList( + selectedFileList); Dialog dialog = new AlertDialog.Builder(mContext) - .setMessage(mContext.getString(R.string.operation_delete_confirm_message)) - .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - if (mFileOperationHelper.Delete(selectedFiles)) { - showProgress(mContext.getString(R.string.operation_deleting)); - } - clearSelection(); - } - }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - clearSelection(); - } - }).create(); + .setMessage( + mContext.getString(R.string.operation_delete_confirm_message)) + .setPositiveButton(R.string.confirm, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int whichButton) { + if (mFileOperationHelper.Delete(selectedFiles)) { + showProgress(mContext + .getString(R.string.operation_deleting)); + } + clearSelection(); + } + }) + .setNegativeButton(R.string.cancel, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + clearSelection(); + } + }).create(); dialog.show(); } @@ -633,8 +706,8 @@ public void onOperationInfo() { if (file == null) return; - InformationDialog dialog = new InformationDialog(mContext, file, mFileViewListener - .getFileIconHelper()); + InformationDialog dialog = new InformationDialog(mContext, file, + mFileViewListener.getFileIconHelper()); dialog.show(); clearSelection(); } @@ -672,7 +745,8 @@ public void onOperationButtonCancel() { // context menu private OnCreateContextMenuListener mListViewContextMenuListener = new OnCreateContextMenuListener() { @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { + public void onCreateContextMenu(ContextMenu menu, View v, + ContextMenuInfo menuInfo) { if (isInSelection() || isMoveState()) return; @@ -680,7 +754,8 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuIn AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; - FavoriteDatabaseHelper databaseHelper = FavoriteDatabaseHelper.getInstance(); + FavoriteDatabaseHelper databaseHelper = FavoriteDatabaseHelper + .getInstance(); FileInfo file = mFileViewListener.getItem(info.position); if (databaseHelper != null && file != null) { int stringId = databaseHelper.isFavorite(file.filePath) ? R.string.operation_unfavorite @@ -688,11 +763,14 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuIn addMenuItem(menu, GlobalConsts.MENU_FAVORITE, 0, stringId); } - addMenuItem(menu, GlobalConsts.MENU_COPY, 0, R.string.operation_copy); - addMenuItem(menu, GlobalConsts.MENU_COPY_PATH, 0, R.string.operation_copy_path); + addMenuItem(menu, GlobalConsts.MENU_COPY, 0, + R.string.operation_copy); + addMenuItem(menu, GlobalConsts.MENU_COPY_PATH, 0, + R.string.operation_copy_path); // addMenuItem(menu, GlobalConsts.MENU_PASTE, 0, // R.string.operation_paste); - addMenuItem(menu, GlobalConsts.MENU_MOVE, 0, R.string.operation_move); + addMenuItem(menu, GlobalConsts.MENU_MOVE, 0, + R.string.operation_move); addMenuItem(menu, MENU_SEND, 0, R.string.operation_send); addMenuItem(menu, MENU_RENAME, 0, R.string.operation_rename); addMenuItem(menu, MENU_DELETE, 0, R.string.operation_delete); @@ -712,12 +790,15 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuIn private int mListViewContextMenuSelectedItem; private void setupFileListView() { - mFileListView = (ListView) mFileViewListener.getViewById(R.id.file_path_list); + mFileListView = (ListView) mFileViewListener + .getViewById(R.id.file_path_list); mFileListView.setLongClickable(true); - mFileListView.setOnCreateContextMenuListener(mListViewContextMenuListener); + mFileListView + .setOnCreateContextMenuListener(mListViewContextMenuListener); mFileListView.setOnItemClickListener(new OnItemClickListener() { @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { + public void onItemClick(AdapterView parent, View view, + int position, long id) { onListItemClick(parent, view, position, id); } }); @@ -757,8 +838,10 @@ public void onItemClick(AdapterView parent, View view, int position, long id) @Override public boolean onMenuItemClick(MenuItem item) { - AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); - mListViewContextMenuSelectedItem = info != null ? info.position : -1; + AdapterContextMenuInfo info = (AdapterContextMenuInfo) item + .getMenuInfo(); + mListViewContextMenuSelectedItem = info != null ? info.position + : -1; int itemId = item.getItemId(); if (mFileViewListener.onOperation(itemId)) { @@ -768,74 +851,74 @@ public boolean onMenuItemClick(MenuItem item) { addContextMenuSelectedItem(); switch (itemId) { - case MENU_SEARCH: - onOperationSearch(); - break; - case GlobalConsts.MENU_NEW_FOLDER: - onOperationCreateFolder(); - break; - case MENU_REFRESH: - onOperationReferesh(); - break; - case MENU_SELECTALL: - onOperationSelectAllOrCancel(); - break; - case GlobalConsts.MENU_SHOWHIDE: - onOperationShowSysFiles(); - break; - case GlobalConsts.MENU_FAVORITE: - onOperationFavorite(); - break; - case MENU_SETTING: - onOperationSetting(); - break; - case MENU_EXIT: - ((FileExplorerTabActivity) mContext).finish(); - break; - // sort - case MENU_SORT_NAME: - item.setChecked(true); - onSortChanged(SortMethod.name); - break; - case MENU_SORT_SIZE: - item.setChecked(true); - onSortChanged(SortMethod.size); - break; - case MENU_SORT_DATE: - item.setChecked(true); - onSortChanged(SortMethod.date); - break; - case MENU_SORT_TYPE: - item.setChecked(true); - onSortChanged(SortMethod.type); - break; - - case GlobalConsts.MENU_COPY: - onOperationCopy(); - break; - case GlobalConsts.MENU_COPY_PATH: - onOperationCopyPath(); - break; - case GlobalConsts.MENU_PASTE: - onOperationPaste(); - break; - case GlobalConsts.MENU_MOVE: - onOperationMove(); - break; - case MENU_SEND: - onOperationSend(); - break; - case MENU_RENAME: - onOperationRename(); - break; - case MENU_DELETE: - onOperationDelete(); - break; - case MENU_INFO: - onOperationInfo(); - break; - default: - return false; + case MENU_SEARCH: + onOperationSearch(); + break; + case GlobalConsts.MENU_NEW_FOLDER: + onOperationCreateFolder(); + break; + case MENU_REFRESH: + onOperationReferesh(); + break; + case MENU_SELECTALL: + onOperationSelectAllOrCancel(); + break; + case GlobalConsts.MENU_SHOWHIDE: + onOperationShowSysFiles(); + break; + case GlobalConsts.MENU_FAVORITE: + onOperationFavorite(); + break; + case MENU_SETTING: + onOperationSetting(); + break; + case MENU_EXIT: + ((FileExplorerTabActivity) mContext).finish(); + break; + // sort + case MENU_SORT_NAME: + item.setChecked(true); + onSortChanged(SortMethod.name); + break; + case MENU_SORT_SIZE: + item.setChecked(true); + onSortChanged(SortMethod.size); + break; + case MENU_SORT_DATE: + item.setChecked(true); + onSortChanged(SortMethod.date); + break; + case MENU_SORT_TYPE: + item.setChecked(true); + onSortChanged(SortMethod.type); + break; + + case GlobalConsts.MENU_COPY: + onOperationCopy(); + break; + case GlobalConsts.MENU_COPY_PATH: + onOperationCopyPath(); + break; + case GlobalConsts.MENU_PASTE: + onOperationPaste(); + break; + case GlobalConsts.MENU_MOVE: + onOperationMove(); + break; + case MENU_SEND: + onOperationSend(); + break; + case MENU_RENAME: + onOperationRename(); + break; + case MENU_DELETE: + onOperationDelete(); + break; + case MENU_INFO: + onOperationInfo(); + break; + default: + return false; } mListViewContextMenuSelectedItem = -1; @@ -862,8 +945,8 @@ public boolean onCreateOptionsMenu(Menu menu) { addMenuItem(menu, MENU_SELECTALL, 0, R.string.operation_selectall, R.drawable.ic_menu_select_all); - SubMenu sortMenu = menu.addSubMenu(0, MENU_SORT, 1, R.string.menu_item_sort).setIcon( - R.drawable.ic_menu_sort); + SubMenu sortMenu = menu.addSubMenu(0, MENU_SORT, 1, + R.string.menu_item_sort).setIcon(R.drawable.ic_menu_sort); addMenuItem(sortMenu, MENU_SORT_NAME, 0, R.string.menu_item_sort_name); addMenuItem(sortMenu, MENU_SORT_SIZE, 1, R.string.menu_item_sort_size); addMenuItem(sortMenu, MENU_SORT_DATE, 2, R.string.menu_item_sort_date); @@ -873,16 +956,18 @@ public boolean onCreateOptionsMenu(Menu menu) { // addMenuItem(menu, GlobalConsts.MENU_PASTE, 2, // R.string.operation_paste); - addMenuItem(menu, GlobalConsts.MENU_NEW_FOLDER, 3, R.string.operation_create_folder, - R.drawable.ic_menu_new_folder); - addMenuItem(menu, GlobalConsts.MENU_FAVORITE, 4, R.string.operation_favorite, - R.drawable.ic_menu_delete_favorite); - addMenuItem(menu, GlobalConsts.MENU_SHOWHIDE, 5, R.string.operation_show_sys, - R.drawable.ic_menu_show_sys); + addMenuItem(menu, GlobalConsts.MENU_NEW_FOLDER, 3, + R.string.operation_create_folder, R.drawable.ic_menu_new_folder); + addMenuItem(menu, GlobalConsts.MENU_FAVORITE, 4, + R.string.operation_favorite, R.drawable.ic_menu_delete_favorite); + addMenuItem(menu, GlobalConsts.MENU_SHOWHIDE, 5, + R.string.operation_show_sys, R.drawable.ic_menu_show_sys); addMenuItem(menu, MENU_REFRESH, 6, R.string.operation_refresh, R.drawable.ic_menu_refresh); - addMenuItem(menu, MENU_SETTING, 7, R.string.menu_setting, drawable.ic_menu_preferences); - addMenuItem(menu, MENU_EXIT, 8, R.string.menu_exit, drawable.ic_menu_close_clear_cancel); + addMenuItem(menu, MENU_SETTING, 7, R.string.menu_setting, + drawable.ic_menu_preferences); + addMenuItem(menu, MENU_EXIT, 8, R.string.menu_exit, + drawable.ic_menu_close_clear_cancel); return true; } @@ -890,9 +975,11 @@ private void addMenuItem(Menu menu, int itemId, int order, int string) { addMenuItem(menu, itemId, order, string, -1); } - private void addMenuItem(Menu menu, int itemId, int order, int string, int iconRes) { + private void addMenuItem(Menu menu, int itemId, int order, int string, + int iconRes) { if (!mFileViewListener.shouldHideMenu(itemId)) { - MenuItem item = menu.add(0, itemId, order, string).setOnMenuItemClickListener(menuItemClick); + MenuItem item = menu.add(0, itemId, order, string) + .setOnMenuItemClickListener(menuItemClick); if (iconRes > 0) { item.setIcon(iconRes); } @@ -906,7 +993,8 @@ public boolean onPrepareOptionsMenu(Menu menu) { private void updateMenuItems(Menu menu) { menu.findItem(MENU_SELECTALL).setTitle( - isSelectedAll() ? R.string.operation_cancel_selectall : R.string.operation_selectall); + isSelectedAll() ? R.string.operation_cancel_selectall + : R.string.operation_selectall); menu.findItem(MENU_SELECTALL).setEnabled(mCurrentMode != Mode.Pick); MenuItem menuItem = menu.findItem(GlobalConsts.MENU_SHOWHIDE); @@ -915,7 +1003,8 @@ private void updateMenuItems(Menu menu) { : R.string.operation_show_sys); } - FavoriteDatabaseHelper databaseHelper = FavoriteDatabaseHelper.getInstance(); + FavoriteDatabaseHelper databaseHelper = FavoriteDatabaseHelper + .getInstance(); if (databaseHelper != null) { MenuItem item = menu.findItem(GlobalConsts.MENU_FAVORITE); if (item != null) { @@ -938,7 +1027,8 @@ public Mode getMode() { return mCurrentMode; } - public void onListItemClick(AdapterView parent, View view, int position, long id) { + public void onListItemClick(AdapterView parent, View view, int position, + long id) { FileInfo lFileInfo = mFileViewListener.getItem(position); showDropdownNavigation(false); @@ -949,8 +1039,10 @@ public void onListItemClick(AdapterView parent, View view, int position, long if (isInSelection()) { boolean selected = lFileInfo.Selected; - ActionMode actionMode = ((FileExplorerTabActivity) mContext).getActionMode(); - ImageView checkBox = (ImageView) view.findViewById(R.id.file_checkbox); + ActionMode actionMode = ((FileExplorerTabActivity) mContext) + .getActionMode(); + ImageView checkBox = (ImageView) view + .findViewById(R.id.file_checkbox); if (selected) { mCheckedFileNameList.remove(lFileInfo); checkBox.setImageResource(R.drawable.btn_check_off_holo_light); @@ -959,12 +1051,15 @@ public void onListItemClick(AdapterView parent, View view, int position, long checkBox.setImageResource(R.drawable.btn_check_on_holo_light); } if (actionMode != null) { - if (mCheckedFileNameList.size() == 0) actionMode.finish(); - else actionMode.invalidate(); + if (mCheckedFileNameList.size() == 0) + actionMode.finish(); + else + actionMode.invalidate(); } lFileInfo.Selected = !selected; - Util.updateActionModeTitle(actionMode, mContext, mCheckedFileNameList.size()); + Util.updateActionModeTitle(actionMode, mContext, + mCheckedFileNameList.size()); return; } @@ -977,12 +1072,12 @@ public void onListItemClick(AdapterView parent, View view, int position, long return; } - mCurrentPath = getAbsoluteName(mCurrentPath, lFileInfo.fileName); - ActionMode actionMode = ((FileExplorerTabActivity) mContext).getActionMode(); + jump2Folder(getAbsoluteName(mCurrentPath, lFileInfo.fileName)); + ActionMode actionMode = ((FileExplorerTabActivity) mContext) + .getActionMode(); if (actionMode != null) { actionMode.finish(); } - refreshFileList(); } public void setRootPath(String path) { @@ -1003,7 +1098,8 @@ public void setCurrentPath(String path) { } private String getAbsoluteName(String path, String name) { - return path.equals(GlobalConsts.ROOT_PATH) ? path + name : path + File.separator + name; + return path.equals(GlobalConsts.ROOT_PATH) ? path + name : path + + File.separator + name; } // check or uncheck @@ -1011,7 +1107,7 @@ public boolean onCheckItem(FileInfo f, View v) { if (isMoveState()) return false; - if(isSelectingFiles() && f.IsDir) + if (isSelectingFiles() && f.IsDir) return false; if (f.Selected) { @@ -1027,9 +1123,11 @@ private boolean isSelectingFiles() { } public boolean isSelectedAll() { - return mFileViewListener.getItemCount() != 0 && mCheckedFileNameList.size() == mFileViewListener.getItemCount(); + return mFileViewListener.getItemCount() != 0 + && mCheckedFileNameList.size() == mFileViewListener + .getItemCount(); } - + public boolean isSelected() { return mCheckedFileNameList.size() != 0; } @@ -1060,7 +1158,7 @@ public boolean onBackPressed() { mDropdownNavigation.setVisibility(View.GONE); } else if (isInSelection()) { clearSelection(); - } else if (!onOperationUpLevel()) { + } else if (!onOperationUpLevel(true)) { return false; } return true; @@ -1080,9 +1178,9 @@ public void moveFileFrom(ArrayList files) { private void showDropdownNavigation(boolean show) { mDropdownNavigation.setVisibility(show ? View.VISIBLE : View.GONE); - mNavigationBarUpDownArrow - .setImageResource(mDropdownNavigation.getVisibility() == View.VISIBLE ? R.drawable.arrow_up - : R.drawable.arrow_down); + mNavigationBarUpDownArrow.setImageResource(mDropdownNavigation + .getVisibility() == View.VISIBLE ? R.drawable.arrow_up + : R.drawable.arrow_down); } @Override