From b152e329525c133541ab1582104687aff513034d Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Fri, 9 Jun 2017 15:56:46 +0200 Subject: [PATCH] local folder picker mode implementation --- .../ui/activity/FolderPickerActivity.java | 1 + .../ui/activity/FolderSyncActivity.java | 1 + .../ui/activity/UploadFilesActivity.java | 32 +++++++++++++---- .../ui/fragment/LocalFileListFragment.java | 35 ++++++++++++------- src/main/res/values/strings.xml | 2 ++ 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java index 719128a13b..54bc874867 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java @@ -302,6 +302,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C retval = super.onOptionsItemSelected(item); break; } + return retval; } diff --git a/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java b/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java index f51fcc8fca..05cc24b7fc 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java @@ -408,6 +408,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte result = super.onOptionsItemSelected(item); break; } + return result; } diff --git a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index 2e90246094..0b2c980422 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -205,10 +205,18 @@ public class UploadFilesActivity extends FileActivity implements public boolean onCreateOptionsMenu(Menu menu) { mOptionsMenu = menu; getMenuInflater().inflate(R.menu.upload_files_picker, menu); - MenuItem selectAll = menu.findItem(R.id.action_select_all); - setSelectAllMenuItem(selectAll, mSelectAll); + + if(mLocalFolderPickerMode) { + menu.removeItem(R.id.action_select_all); + menu.removeItem(R.id.action_search); + } else { + MenuItem selectAll = menu.findItem(R.id.action_select_all); + setSelectAllMenuItem(selectAll, mSelectAll); + } + MenuItem switchView = menu.findItem(R.id.action_switch_view); switchView.setTitle(isGridView() ? R.string.action_switch_list_view : R.string.action_switch_grid_view); + return super.onCreateOptionsMenu(menu); } @@ -323,7 +331,9 @@ public class UploadFilesActivity extends FileActivity implements } // invalidate checked state when navigating directories - setSelectAllMenuItem(mOptionsMenu.findItem(R.id.action_select_all), false); + if(!mLocalFolderPickerMode) { + setSelectAllMenuItem(mOptionsMenu.findItem(R.id.action_select_all), false); + } } @@ -409,9 +419,11 @@ public class UploadFilesActivity extends FileActivity implements */ @Override public void onDirectoryClick(File directory) { - // invalidate checked state when navigating directories - MenuItem selectAll = mOptionsMenu.findItem(R.id.action_select_all); - setSelectAllMenuItem(selectAll, false); + if(!mLocalFolderPickerMode) { + // invalidate checked state when navigating directories + MenuItem selectAll = mOptionsMenu.findItem(R.id.action_select_all); + setSelectAllMenuItem(selectAll, false); + } pushDirname(directory); ActionBar actionBar = getSupportActionBar(); @@ -434,6 +446,14 @@ public class UploadFilesActivity extends FileActivity implements return mCurrentDir; } + /** + * {@inheritDoc} + */ + @Override + public boolean isFolderPickerMode() { + return mLocalFolderPickerMode; + } + /** * Performs corresponding action when user presses 'Cancel' or 'Upload' button * diff --git a/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java index d9f04d218f..9adb7b151a 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java @@ -52,8 +52,6 @@ public class LocalFileListFragment extends ExtendedListFragment { private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ? OCFileListFragment.class.getPackage().getName() : "com.owncloud.android.ui.fragment"; - - public final static String ARG_LOCAL_FOLDER_PICKER_MODE = MY_PACKAGE + ".LOCAL_FOLDER_PICKER_MODE"; /** Reference to the Activity which this fragment is attached to. For callbacks */ private LocalFileListFragment.ContainerActivity mContainerActivity; @@ -64,8 +62,6 @@ public class LocalFileListFragment extends ExtendedListFragment { /** Adapter to connect the data from the directory with the View object */ private LocalFileListAdapter mAdapter = null; - private boolean mLocalFolderPicker; - private static final String SCREEN_NAME = "Local file browser"; @Override @@ -96,7 +92,6 @@ public class LocalFileListFragment extends ExtendedListFragment { } } - /** * {@inheritDoc} */ @@ -104,13 +99,19 @@ public class LocalFileListFragment extends ExtendedListFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.i(TAG, "onCreateView() start"); View v = super.onCreateView(inflater, container, savedInstanceState); - if(!mLocalFolderPicker) { + + if(!mContainerActivity.isFolderPickerMode()) { setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); + setMessageForEmptyList(R.string.file_list_empty_headline, R.string.local_file_list_empty, + R.drawable.ic_list_empty_folder, true); + } else { + setMessageForEmptyList(R.string.folder_list_empty_headline, R.string.local_folder_list_empty, + R.drawable.ic_list_empty_folder, true); } + setSwipeEnabled(false); // Disable pull-to-refresh setFabEnabled(false); // Disable FAB - setMessageForEmptyList(R.string.file_list_empty_headline, R.string.local_file_list_empty, - R.drawable.ic_list_empty_folder, true); + Log_OC.i(TAG, "onCreateView() end"); return v; } @@ -125,9 +126,11 @@ public class LocalFileListFragment extends ExtendedListFragment { super.onActivityCreated(savedInstanceState); - Bundle args = getArguments(); - mLocalFolderPicker = (args != null) && args.getBoolean(ARG_LOCAL_FOLDER_PICKER_MODE, false); - mAdapter = new LocalFileListAdapter(mLocalFolderPicker, mContainerActivity.getInitialDirectory(), getActivity()); + mAdapter = new LocalFileListAdapter( + mContainerActivity.isFolderPickerMode(), + mContainerActivity.getInitialDirectory(), + getActivity() + ); setListAdapter(mAdapter); Log_OC.i(TAG, "onActivityCreated() stop"); @@ -315,8 +318,7 @@ public class LocalFileListFragment extends ExtendedListFragment { * @param file */ void onFileClick(File file); - - + /** * Callback method invoked when the parent activity * is fully created to get the directory to list firstly. @@ -325,6 +327,13 @@ public class LocalFileListFragment extends ExtendedListFragment { */ File getInitialDirectory(); + /** + * config check if the list should behave in + * folder picker mode only displaying folders but no files. + * + * @return true if folder picker mode, else false + */ + boolean isFolderPickerMode(); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 86a3e45d6b..33c072d320 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -99,6 +99,7 @@ Delete file from source folder seconds ago No files here + No folders here Upload some content or sync with your devices. Favorite some files or sync with your devices. Files and folders you mark as favorites will show up here @@ -106,6 +107,7 @@ Loading… No app set up to handle this file type. There are no files in this folder. + There are no further folders. No results in this folder No results Nothing favorited yet