mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
local folder picker mode implementation
This commit is contained in:
parent
aff8a86b37
commit
b152e32952
5 changed files with 52 additions and 19 deletions
|
@ -302,6 +302,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
|||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -408,6 +408,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
|
|||
result = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
<string name="uploader_upload_files_behaviour_upload_and_delete_from_source">Delete file from source folder</string>
|
||||
<string name="file_list_seconds_ago">seconds ago</string>
|
||||
<string name="file_list_empty_headline">No files here</string>
|
||||
<string name="folder_list_empty_headline">No folders here</string>
|
||||
<string name="file_list_empty">Upload some content or sync with your devices.</string>
|
||||
<string name="file_list_empty_favorites">Favorite some files or sync with your devices.</string>
|
||||
<string name="file_list_empty_favorites_filter_list">Files and folders you mark as favorites will show up here</string>
|
||||
|
@ -106,6 +107,7 @@
|
|||
<string name="file_list_loading">Loading…</string>
|
||||
<string name="file_list_no_app_for_file_type">No app set up to handle this file type.</string>
|
||||
<string name="local_file_list_empty">There are no files in this folder.</string>
|
||||
<string name="local_folder_list_empty">There are no further folders.</string>
|
||||
<string name="file_list_empty_headline_search">No results in this folder</string>
|
||||
<string name="file_list_empty_headline_server_search">No results</string>
|
||||
<string name="file_list_empty_favorite_headline">Nothing favorited yet</string>
|
||||
|
|
Loading…
Reference in a new issue