mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
replace switch statements with if/else since resource ids will be non-final in Android Gradle Plugin version 7.0
...so avoid using them in switch case statements. Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
9f1c79494b
commit
1fdea011a7
16 changed files with 472 additions and 577 deletions
|
@ -104,7 +104,6 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
|||
handler.removeMessages(SHOW_PROGRESS);
|
||||
}
|
||||
|
||||
|
||||
private void initControllerView(View v) {
|
||||
pauseButton = v.findViewById(R.id.playBtn);
|
||||
if (pauseButton != null) {
|
||||
|
@ -162,7 +161,6 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
@ -218,7 +216,6 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
|||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
int keyCode = event.getKeyCode();
|
||||
|
@ -277,7 +274,6 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
|||
} else {
|
||||
rewindButton.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void doPauseResume() {
|
||||
|
@ -311,38 +307,29 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
|||
public void onClick(View v) {
|
||||
int pos;
|
||||
boolean playing = playerControl.isPlaying();
|
||||
switch (v.getId()) {
|
||||
case R.id.playBtn:
|
||||
doPauseResume();
|
||||
break;
|
||||
int id = v.getId();
|
||||
|
||||
case R.id.rewindBtn:
|
||||
pos = playerControl.getCurrentPosition();
|
||||
pos -= 5000;
|
||||
playerControl.seekTo(pos);
|
||||
if (!playing) {
|
||||
playerControl.pause(); // necessary in some 2.3.x devices
|
||||
}
|
||||
setProgress();
|
||||
break;
|
||||
|
||||
case R.id.forwardBtn:
|
||||
pos = playerControl.getCurrentPosition();
|
||||
pos += 15000;
|
||||
playerControl.seekTo(pos);
|
||||
if (!playing) {
|
||||
playerControl.pause(); // necessary in some 2.3.x devices
|
||||
}
|
||||
setProgress();
|
||||
break;
|
||||
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
if (id == R.id.playBtn) {
|
||||
doPauseResume();
|
||||
} else if (id == R.id.rewindBtn) {
|
||||
pos = playerControl.getCurrentPosition();
|
||||
pos -= 5000;
|
||||
playerControl.seekTo(pos);
|
||||
if (!playing) {
|
||||
playerControl.pause(); // necessary in some 2.3.x devices
|
||||
}
|
||||
setProgress();
|
||||
} else if (id == R.id.forwardBtn) {
|
||||
pos = playerControl.getCurrentPosition();
|
||||
pos += 15000;
|
||||
playerControl.seekTo(pos);
|
||||
if (!playing) {
|
||||
playerControl.pause(); // necessary in some 2.3.x devices
|
||||
}
|
||||
setProgress();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (!fromUser) {
|
||||
|
@ -370,7 +357,6 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
|||
handler.removeMessages(SHOW_PROGRESS); // grants no more updates with media player progress while dragging
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called in devices with touchpad when the user finishes the adjusting of the seekbar.
|
||||
*/
|
||||
|
|
|
@ -418,79 +418,65 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
private void onNavigationItemClicked(final MenuItem menuItem) {
|
||||
setDrawerMenuItemChecked(menuItem.getItemId());
|
||||
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.nav_all_files:
|
||||
if (this instanceof FileDisplayActivity &&
|
||||
!(((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) &&
|
||||
!(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
|
||||
showFiles(false);
|
||||
((FileDisplayActivity) this).browseToRoot();
|
||||
EventBus.getDefault().post(new ChangeMenuEvent());
|
||||
} else {
|
||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.setAction(FileDisplayActivity.ALL_FILES);
|
||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
|
||||
startActivity(intent);
|
||||
}
|
||||
break;
|
||||
case R.id.nav_favorites:
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH),
|
||||
menuItem.getItemId());
|
||||
break;
|
||||
case R.id.nav_gallery:
|
||||
startPhotoSearch(menuItem);
|
||||
break;
|
||||
case R.id.nav_on_device:
|
||||
int itemId = menuItem.getItemId();
|
||||
|
||||
if (itemId == R.id.nav_all_files) {
|
||||
if (this instanceof FileDisplayActivity &&
|
||||
!(((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) &&
|
||||
!(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
|
||||
showFiles(false);
|
||||
((FileDisplayActivity) this).browseToRoot();
|
||||
EventBus.getDefault().post(new ChangeMenuEvent());
|
||||
showFiles(true);
|
||||
break;
|
||||
case R.id.nav_uploads:
|
||||
startActivity(UploadListActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
break;
|
||||
case R.id.nav_trashbin:
|
||||
startActivity(TrashbinActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
break;
|
||||
case R.id.nav_activity:
|
||||
startActivity(ActivitiesActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
break;
|
||||
case R.id.nav_notifications:
|
||||
startActivity(NotificationsActivity.class);
|
||||
break;
|
||||
case R.id.nav_contacts:
|
||||
ContactsPreferenceActivity.startActivity(this);
|
||||
break;
|
||||
case R.id.nav_settings:
|
||||
startActivity(SettingsActivity.class);
|
||||
break;
|
||||
case R.id.nav_community:
|
||||
startActivity(CommunityActivity.class);
|
||||
break;
|
||||
case R.id.nav_logout:
|
||||
mCheckedMenuItem = -1;
|
||||
menuItem.setChecked(false);
|
||||
final Optional<User> optionalUser = getUser();
|
||||
if (optionalUser.isPresent()) {
|
||||
UserInfoActivity.openAccountRemovalConfirmationDialog(optionalUser.get(), getSupportFragmentManager());
|
||||
}
|
||||
break;
|
||||
case R.id.nav_shared:
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER),
|
||||
menuItem.getItemId());
|
||||
break;
|
||||
case R.id.nav_recently_modified:
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH),
|
||||
menuItem.getItemId());
|
||||
break;
|
||||
default:
|
||||
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK &&
|
||||
menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
|
||||
// external link clicked
|
||||
externalLinkClicked(menuItem);
|
||||
} else {
|
||||
Log_OC.i(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.setAction(FileDisplayActivity.ALL_FILES);
|
||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
|
||||
startActivity(intent);
|
||||
}
|
||||
} else if (itemId == R.id.nav_favorites) {
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH),
|
||||
menuItem.getItemId());
|
||||
} else if (itemId == R.id.nav_gallery) {
|
||||
startPhotoSearch(menuItem);
|
||||
} else if (itemId == R.id.nav_on_device) {
|
||||
EventBus.getDefault().post(new ChangeMenuEvent());
|
||||
showFiles(true);
|
||||
} else if (itemId == R.id.nav_uploads) {
|
||||
startActivity(UploadListActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
} else if (itemId == R.id.nav_trashbin) {
|
||||
startActivity(TrashbinActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
} else if (itemId == R.id.nav_activity) {
|
||||
startActivity(ActivitiesActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
} else if (itemId == R.id.nav_notifications) {
|
||||
startActivity(NotificationsActivity.class);
|
||||
} else if (itemId == R.id.nav_contacts) {
|
||||
ContactsPreferenceActivity.startActivity(this);
|
||||
} else if (itemId == R.id.nav_settings) {
|
||||
startActivity(SettingsActivity.class);
|
||||
} else if (itemId == R.id.nav_community) {
|
||||
startActivity(CommunityActivity.class);
|
||||
} else if (itemId == R.id.nav_logout) {
|
||||
mCheckedMenuItem = -1;
|
||||
menuItem.setChecked(false);
|
||||
final Optional<User> optionalUser = getUser();
|
||||
if (optionalUser.isPresent()) {
|
||||
UserInfoActivity.openAccountRemovalConfirmationDialog(optionalUser.get(), getSupportFragmentManager());
|
||||
}
|
||||
} else if (itemId == R.id.nav_shared) {
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER),
|
||||
menuItem.getItemId());
|
||||
} else if (itemId == R.id.nav_recently_modified) {
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH),
|
||||
menuItem.getItemId());
|
||||
} else {
|
||||
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK &&
|
||||
menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
|
||||
// external link clicked
|
||||
externalLinkClicked(menuItem);
|
||||
} else {
|
||||
Log_OC.w(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -826,37 +826,35 @@ public class FileDisplayActivity extends FileActivity
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home: {
|
||||
FileFragment second = getSecondFragment();
|
||||
OCFile currentDir = getCurrentDir();
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else if (
|
||||
currentDir != null && currentDir.getParentId() != 0 ||
|
||||
second != null && second.getFile() != null ||
|
||||
isSearchOpen()) {
|
||||
onBackPressed();
|
||||
} else if (getLeftFragment() instanceof FileDetailFragment ||
|
||||
getLeftFragment() instanceof PreviewMediaFragment) {
|
||||
onBackPressed();
|
||||
} else {
|
||||
openDrawer();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.action_select_all: {
|
||||
OCFileListFragment fragment = getListOfFilesFragment();
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (fragment != null) {
|
||||
fragment.selectAllFiles(true);
|
||||
}
|
||||
break;
|
||||
if (itemId == android.R.id.home) {
|
||||
FileFragment second = getSecondFragment();
|
||||
OCFile currentDir = getCurrentDir();
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else if (
|
||||
currentDir != null && currentDir.getParentId() != 0 ||
|
||||
second != null && second.getFile() != null ||
|
||||
isSearchOpen()) {
|
||||
onBackPressed();
|
||||
} else if (getLeftFragment() instanceof FileDetailFragment ||
|
||||
getLeftFragment() instanceof PreviewMediaFragment) {
|
||||
onBackPressed();
|
||||
} else {
|
||||
openDrawer();
|
||||
}
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
break;
|
||||
} else if (itemId == R.id.action_select_all) {
|
||||
OCFileListFragment fragment = getListOfFilesFragment();
|
||||
|
||||
if (fragment != null) {
|
||||
fragment.selectAllFiles(true);
|
||||
}
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -308,22 +308,18 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_create_dir: {
|
||||
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(getCurrentFolder());
|
||||
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
|
||||
break;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == R.id.action_create_dir) {
|
||||
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(getCurrentFolder());
|
||||
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
|
||||
} else if (itemId == android.R.id.home) {
|
||||
OCFile currentDir = getCurrentFolder();
|
||||
if (currentDir != null && currentDir.getParentId() != 0) {
|
||||
onBackPressed();
|
||||
}
|
||||
case android.R.id.home: {
|
||||
OCFile currentDir = getCurrentFolder();
|
||||
if (currentDir != null && currentDir.getParentId() != 0) {
|
||||
onBackPressed();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -260,14 +260,13 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -479,17 +478,16 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
|||
popup.getMenu().findItem(R.id.action_open_account).setVisible(false);
|
||||
}
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_open_account:
|
||||
accountClicked(user.hashCode());
|
||||
break;
|
||||
case R.id.action_delete_account:
|
||||
openAccountRemovalConfirmationDialog(user, getSupportFragmentManager());
|
||||
break;
|
||||
default:
|
||||
openAccount(user);
|
||||
break;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == R.id.action_open_account) {
|
||||
accountClicked(user.hashCode());
|
||||
} else if (itemId == R.id.action_delete_account) {
|
||||
openAccountRemovalConfirmationDialog(user, getSupportFragmentManager());
|
||||
} else {
|
||||
openAccount(user);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
popup.show();
|
||||
|
|
|
@ -655,29 +655,26 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
// click on button
|
||||
switch (v.getId()) {
|
||||
case R.id.uploader_choose_folder:
|
||||
mUploadPath = ""; // first element in mParents is root dir, represented by "";
|
||||
// init mUploadPath with "/" results in a "//" prefix
|
||||
for (String p : mParents) {
|
||||
mUploadPath += p + OCFile.PATH_SEPARATOR;
|
||||
}
|
||||
int id = v.getId();
|
||||
|
||||
if (mUploadFromTmpFile) {
|
||||
DialogInputUploadFilename dialog = DialogInputUploadFilename.newInstance(mSubjectText, mExtraText);
|
||||
dialog.show(getSupportFragmentManager(), null);
|
||||
} else {
|
||||
Log_OC.d(TAG, "Uploading file to dir " + mUploadPath);
|
||||
uploadFiles();
|
||||
}
|
||||
break;
|
||||
if (id == R.id.uploader_choose_folder) {
|
||||
mUploadPath = ""; // first element in mParents is root dir, represented by "";
|
||||
// init mUploadPath with "/" results in a "//" prefix
|
||||
for (String p : mParents) {
|
||||
mUploadPath += p + OCFile.PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
case R.id.uploader_cancel:
|
||||
finish();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Wrong element clicked");
|
||||
if (mUploadFromTmpFile) {
|
||||
DialogInputUploadFilename dialog = DialogInputUploadFilename.newInstance(mSubjectText, mExtraText);
|
||||
dialog.show(getSupportFragmentManager(), null);
|
||||
} else {
|
||||
Log_OC.d(TAG, "Uploading file to dir " + mUploadPath);
|
||||
uploadFiles();
|
||||
}
|
||||
} else if (id == R.id.uploader_cancel) {
|
||||
finish();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Wrong element clicked");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1048,23 +1045,21 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_create_dir:
|
||||
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(mFile);
|
||||
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
|
||||
break;
|
||||
case android.R.id.home:
|
||||
if (mParents.size() > SINGLE_PARENT) {
|
||||
onBackPressed();
|
||||
}
|
||||
break;
|
||||
case R.id.action_switch_account:
|
||||
showAccountChooserDialog();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == R.id.action_create_dir) {
|
||||
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(mFile);
|
||||
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
|
||||
} else if (itemId == android.R.id.home) {
|
||||
if (mParents.size() > SINGLE_PARENT) {
|
||||
onBackPressed();
|
||||
}
|
||||
} else if (itemId == R.id.action_switch_account) {
|
||||
showAccountChooserDialog();
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -289,28 +289,23 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home: {
|
||||
if (mCurrentDir != null && mCurrentDir.getParentFile() != null) {
|
||||
onBackPressed();
|
||||
}
|
||||
break;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == android.R.id.home) {
|
||||
if (mCurrentDir != null && mCurrentDir.getParentFile() != null) {
|
||||
onBackPressed();
|
||||
}
|
||||
case R.id.action_select_all: {
|
||||
item.setChecked(!item.isChecked());
|
||||
mSelectAll = item.isChecked();
|
||||
setSelectAllMenuItem(item, mSelectAll);
|
||||
mFileListFragment.selectAllFiles(item.isChecked());
|
||||
break;
|
||||
}
|
||||
case R.id.action_choose_storage_path: {
|
||||
showLocalStoragePathPickerDialog();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
} else if (itemId == R.id.action_select_all) {
|
||||
item.setChecked(!item.isChecked());
|
||||
mSelectAll = item.isChecked();
|
||||
setSelectAllMenuItem(item, mSelectAll);
|
||||
mFileListFragment.selectAllFiles(item.isChecked());
|
||||
} else if (itemId == R.id.action_choose_storage_path) {
|
||||
showLocalStoragePathPickerDialog();
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -246,21 +246,19 @@ public class UploadListActivity extends FileActivity {
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else {
|
||||
openDrawer();
|
||||
}
|
||||
break;
|
||||
case R.id.action_clear_failed_uploads:
|
||||
uploadsStorageManager.clearFailedButNotDelayedUploads();
|
||||
uploadListAdapter.loadUploadItemsFromDb();
|
||||
break;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
if (itemId == android.R.id.home) {
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else {
|
||||
openDrawer();
|
||||
}
|
||||
} else if (itemId == R.id.action_clear_failed_uploads) {
|
||||
uploadsStorageManager.clearFailedButNotDelayedUploads();
|
||||
uploadListAdapter.loadUploadItemsFromDb();
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -174,20 +174,18 @@ public class UserInfoActivity extends DrawerActivity implements Injectable {
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
break;
|
||||
case R.id.action_open_account:
|
||||
accountClicked(user.hashCode());
|
||||
break;
|
||||
case R.id.action_delete_account:
|
||||
openAccountRemovalConfirmationDialog(user, getSupportFragmentManager());
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == android.R.id.home) {
|
||||
onBackPressed();
|
||||
} else if (itemId == R.id.action_open_account) {
|
||||
accountClicked(user.hashCode());
|
||||
} else if (itemId == R.id.action_delete_account) {
|
||||
openAccountRemovalConfirmationDialog(user, getSupportFragmentManager());
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -531,15 +531,14 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
PopupMenu popup = new PopupMenu(MainApp.getAppContext(), view);
|
||||
popup.inflate(R.menu.upload_list_item_file_conflict);
|
||||
popup.setOnMenuItemClickListener(i -> {
|
||||
switch (i.getItemId()) {
|
||||
case R.id.action_upload_list_resolve_conflict:
|
||||
checkAndOpenConflictResolutionDialog(user, itemViewHolder, item, status);
|
||||
break;
|
||||
case R.id.action_upload_list_delete:
|
||||
default:
|
||||
removeUpload(item);
|
||||
break;
|
||||
int itemId = i.getItemId();
|
||||
|
||||
if (itemId == R.id.action_upload_list_resolve_conflict) {
|
||||
checkAndOpenConflictResolutionDialog(user, itemViewHolder, item, status);
|
||||
} else {
|
||||
removeUpload(item);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
popup.show();
|
||||
|
|
|
@ -362,79 +362,59 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|||
}
|
||||
|
||||
private boolean optionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_send_file: {
|
||||
containerActivity.getFileOperationsHelper().sendShareFile(getFile(), true);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_open_file_with: {
|
||||
containerActivity.getFileOperationsHelper().openFile(getFile());
|
||||
return true;
|
||||
}
|
||||
case R.id.action_remove_file: {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
|
||||
dialog.show(getFragmentManager(), FTAG_CONFIRMATION);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_rename_file: {
|
||||
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(getFile());
|
||||
dialog.show(getFragmentManager(), FTAG_RENAME_FILE);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_cancel_sync: {
|
||||
((FileDisplayActivity) containerActivity).cancelTransference(getFile());
|
||||
return true;
|
||||
}
|
||||
case R.id.action_download_file:
|
||||
case R.id.action_sync_file: {
|
||||
containerActivity.getFileOperationsHelper().syncFile(getFile());
|
||||
return true;
|
||||
}
|
||||
case R.id.action_set_as_wallpaper: {
|
||||
containerActivity.getFileOperationsHelper().setPictureAs(getFile(), getView());
|
||||
return true;
|
||||
}
|
||||
case R.id.action_encrypted: {
|
||||
// TODO implement or remove
|
||||
return true;
|
||||
}
|
||||
case R.id.action_unset_encrypted: {
|
||||
// TODO implement or remove
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == R.id.action_send_file) {
|
||||
containerActivity.getFileOperationsHelper().sendShareFile(getFile(), true);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_open_file_with) {
|
||||
containerActivity.getFileOperationsHelper().openFile(getFile());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_remove_file) {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
|
||||
dialog.show(getFragmentManager(), FTAG_CONFIRMATION);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_rename_file) {
|
||||
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(getFile());
|
||||
dialog.show(getFragmentManager(), FTAG_RENAME_FILE);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_cancel_sync) {
|
||||
((FileDisplayActivity) containerActivity).cancelTransference(getFile());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_download_file || itemId == R.id.action_sync_file) {
|
||||
containerActivity.getFileOperationsHelper().syncFile(getFile());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_set_as_wallpaper) {
|
||||
containerActivity.getFileOperationsHelper().setPictureAs(getFile(), getView());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_encrypted) {// TODO implement or remove
|
||||
return true;
|
||||
} else if (itemId == R.id.action_unset_encrypted) {// TODO implement or remove
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.cancelBtn: {
|
||||
((FileDisplayActivity) containerActivity).cancelTransference(getFile());
|
||||
break;
|
||||
}
|
||||
case R.id.favorite: {
|
||||
if (getFile().isFavorite()) {
|
||||
containerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), false);
|
||||
} else {
|
||||
containerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), true);
|
||||
}
|
||||
setFavoriteIconStatus(!getFile().isFavorite());
|
||||
break;
|
||||
}
|
||||
case R.id.overflow_menu: {
|
||||
onOverflowIconClicked(v);
|
||||
break;
|
||||
}
|
||||
case R.id.last_modification_timestamp: {
|
||||
boolean showDetailedTimestamp = !preferences.isShowDetailedTimestampEnabled();
|
||||
preferences.setShowDetailedTimestampEnabled(showDetailedTimestamp);
|
||||
setFileModificationTimestamp(getFile(), showDetailedTimestamp);
|
||||
}
|
||||
default:
|
||||
Log_OC.e(TAG, "Incorrect view clicked!");
|
||||
break;
|
||||
int id = v.getId();
|
||||
|
||||
if (id == R.id.cancelBtn) {
|
||||
((FileDisplayActivity) containerActivity).cancelTransference(getFile());
|
||||
} else if (id == R.id.favorite) {
|
||||
containerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), !getFile().isFavorite());
|
||||
setFavoriteIconStatus(!getFile().isFavorite());
|
||||
} else if (id == R.id.overflow_menu) {
|
||||
onOverflowIconClicked(v);
|
||||
} else if (id == R.id.last_modification_timestamp) {
|
||||
boolean showDetailedTimestamp = !preferences.isShowDetailedTimestampEnabled();
|
||||
preferences.setShowDetailedTimestampEnabled(showDetailedTimestamp);
|
||||
setFileModificationTimestamp(getFile(), showDetailedTimestamp);
|
||||
|
||||
Log_OC.e(TAG, "Incorrect view clicked!");
|
||||
} else {
|
||||
Log_OC.e(TAG, "Incorrect view clicked!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -436,113 +436,105 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
}
|
||||
|
||||
private boolean userOptionsItemSelected(Menu menu, MenuItem item, OCShare share) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.allow_editing:
|
||||
case R.id.allow_creating:
|
||||
case R.id.allow_deleting:
|
||||
case R.id.allow_resharing: {
|
||||
item.setChecked(!item.isChecked());
|
||||
share.setPermissions(updatePermissionsToShare(share,
|
||||
menu.findItem(R.id.allow_resharing).isChecked(),
|
||||
menu.findItem(R.id.allow_editing).isChecked(),
|
||||
menu.findItem(R.id.allow_creating).isChecked(),
|
||||
menu.findItem(R.id.allow_deleting).isChecked()));
|
||||
return true;
|
||||
}
|
||||
case R.id.action_unshare: {
|
||||
unshareWith(share);
|
||||
ShareeListAdapter adapter = (ShareeListAdapter) binding.sharesList.getAdapter();
|
||||
if (adapter == null) {
|
||||
DisplayUtils.showSnackMessage(getView(), getString(R.string.failed_update_ui));
|
||||
return true;
|
||||
}
|
||||
adapter.remove(share);
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == R.id.allow_editing || itemId == R.id.allow_creating || itemId == R.id.allow_deleting || itemId == R.id.allow_resharing) {
|
||||
item.setChecked(!item.isChecked());
|
||||
share.setPermissions(updatePermissionsToShare(share,
|
||||
menu.findItem(R.id.allow_resharing).isChecked(),
|
||||
menu.findItem(R.id.allow_editing).isChecked(),
|
||||
menu.findItem(R.id.allow_creating).isChecked(),
|
||||
menu.findItem(R.id.allow_deleting).isChecked()));
|
||||
return true;
|
||||
} else if (itemId == R.id.action_unshare) {
|
||||
unshareWith(share);
|
||||
ShareeListAdapter adapter = (ShareeListAdapter) binding.sharesList.getAdapter();
|
||||
if (adapter == null) {
|
||||
DisplayUtils.showSnackMessage(getView(), getString(R.string.failed_update_ui));
|
||||
return true;
|
||||
}
|
||||
case R.id.action_expiration_date: {
|
||||
ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment
|
||||
.newInstance(share, share.getExpirationDate());
|
||||
dialog.show(fileActivity.getSupportFragmentManager(),
|
||||
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_share_send_note:
|
||||
NoteDialogFragment dialog = NoteDialogFragment.newInstance(share);
|
||||
dialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
adapter.remove(share);
|
||||
|
||||
return true;
|
||||
} else if (itemId == R.id.action_expiration_date) {
|
||||
ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment
|
||||
.newInstance(share, share.getExpirationDate());
|
||||
dialog.show(fileActivity.getSupportFragmentManager(),
|
||||
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_share_send_note) {
|
||||
NoteDialogFragment dialog = NoteDialogFragment.newInstance(share);
|
||||
dialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean linkOptionsItemSelected(MenuItem item, OCShare publicShare) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.link_share_read_only:
|
||||
item.setChecked(true);
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, READ_PERMISSION_FLAG);
|
||||
return true;
|
||||
case R.id.link_share_allow_upload_and_editing:
|
||||
item.setChecked(true);
|
||||
if (publicShare.isFolder()) {
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, MAXIMUM_PERMISSIONS_FOR_FOLDER);
|
||||
} else {
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, MAXIMUM_PERMISSIONS_FOR_FILE);
|
||||
}
|
||||
return true;
|
||||
case R.id.link_share_file_drop: {
|
||||
item.setChecked(true);
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, CREATE_PERMISSION_FLAG);
|
||||
return true;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == R.id.link_share_read_only) {
|
||||
item.setChecked(true);
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, READ_PERMISSION_FLAG);
|
||||
return true;
|
||||
} else if (itemId == R.id.link_share_allow_upload_and_editing) {
|
||||
item.setChecked(true);
|
||||
if (publicShare.isFolder()) {
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, MAXIMUM_PERMISSIONS_FOR_FOLDER);
|
||||
} else {
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, MAXIMUM_PERMISSIONS_FOR_FILE);
|
||||
}
|
||||
case R.id.allow_editing:
|
||||
if (file.isSharedViaLink()) {
|
||||
item.setChecked(!item.isChecked());
|
||||
fileOperationsHelper.setUploadPermissionsToPublicShare(publicShare, item.isChecked());
|
||||
}
|
||||
return true;
|
||||
case R.id.action_hide_file_download:
|
||||
return true;
|
||||
} else if (itemId == R.id.link_share_file_drop) {
|
||||
item.setChecked(true);
|
||||
fileOperationsHelper.setPermissionsToShare(publicShare, CREATE_PERMISSION_FLAG);
|
||||
return true;
|
||||
} else if (itemId == R.id.allow_editing) {
|
||||
if (file.isSharedViaLink()) {
|
||||
item.setChecked(!item.isChecked());
|
||||
fileOperationsHelper.setHideFileDownloadPermissionsToPublicShare(publicShare, item.isChecked());
|
||||
return true;
|
||||
case R.id.action_password: {
|
||||
requestPasswordForShare(publicShare,
|
||||
capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
|
||||
return true;
|
||||
fileOperationsHelper.setUploadPermissionsToPublicShare(publicShare, item.isChecked());
|
||||
}
|
||||
case R.id.action_share_expiration_date: {
|
||||
ExpirationDatePickerDialogFragment expirationDialog = ExpirationDatePickerDialogFragment
|
||||
.newInstance(publicShare, publicShare.getExpirationDate());
|
||||
expirationDialog.show(fileActivity.getSupportFragmentManager(),
|
||||
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG);
|
||||
return true;
|
||||
return true;
|
||||
} else if (itemId == R.id.action_hide_file_download) {
|
||||
item.setChecked(!item.isChecked());
|
||||
fileOperationsHelper.setHideFileDownloadPermissionsToPublicShare(publicShare, item.isChecked());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_password) {
|
||||
requestPasswordForShare(publicShare,
|
||||
capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_share_expiration_date) {
|
||||
ExpirationDatePickerDialogFragment expirationDialog = ExpirationDatePickerDialogFragment
|
||||
.newInstance(publicShare, publicShare.getExpirationDate());
|
||||
expirationDialog.show(fileActivity.getSupportFragmentManager(),
|
||||
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_share_send_link) {
|
||||
if (file.isSharedViaLink() && !TextUtils.isEmpty(publicShare.getShareLink())) {
|
||||
FileDisplayActivity.showShareLinkDialog(fileActivity, file, publicShare.getShareLink());
|
||||
} else {
|
||||
showSendLinkTo(publicShare);
|
||||
}
|
||||
case R.id.action_share_send_link: {
|
||||
if (file.isSharedViaLink() && !TextUtils.isEmpty(publicShare.getShareLink())) {
|
||||
FileDisplayActivity.showShareLinkDialog(fileActivity, file, publicShare.getShareLink());
|
||||
} else {
|
||||
showSendLinkTo(publicShare);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case R.id.action_share_send_note:
|
||||
NoteDialogFragment noteDialog = NoteDialogFragment.newInstance(publicShare);
|
||||
noteDialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
|
||||
return true;
|
||||
case R.id.action_edit_label:
|
||||
RenamePublicShareDialogFragment renameDialog = RenamePublicShareDialogFragment.newInstance(publicShare);
|
||||
renameDialog.show(fileActivity.getSupportFragmentManager(),
|
||||
RenamePublicShareDialogFragment.RENAME_PUBLIC_SHARE_FRAGMENT);
|
||||
return true;
|
||||
case R.id.action_unshare:
|
||||
fileOperationsHelper.unshareShare(file, publicShare);
|
||||
return true;
|
||||
case R.id.action_add_another_public_share_link:
|
||||
createPublicShareLink();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_share_send_note) {
|
||||
NoteDialogFragment noteDialog = NoteDialogFragment.newInstance(publicShare);
|
||||
noteDialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_edit_label) {
|
||||
RenamePublicShareDialogFragment renameDialog = RenamePublicShareDialogFragment.newInstance(publicShare);
|
||||
renameDialog.show(fileActivity.getSupportFragmentManager(),
|
||||
RenamePublicShareDialogFragment.RENAME_PUBLIC_SHARE_FRAGMENT);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_unshare) {
|
||||
fileOperationsHelper.unshareShare(file, publicShare);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_add_another_public_share_link) {
|
||||
createPublicShareLink();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1072,115 +1072,98 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
if (checkedFiles.size() == SINGLE_SELECTION) {
|
||||
/// action only possible on a single file
|
||||
OCFile singleFile = checkedFiles.iterator().next();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_send_share_file: {
|
||||
mContainerActivity.getFileOperationsHelper().sendShareFile(singleFile);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_open_file_with: {
|
||||
mContainerActivity.getFileOperationsHelper().openFile(singleFile);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_stream_media: {
|
||||
mContainerActivity.getFileOperationsHelper().streamMediaFile(singleFile);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_edit: {
|
||||
// should not be necessary, as menu item is filtered, but better play safe
|
||||
if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
|
||||
accountManager.getUser(),
|
||||
singleFile.getMimeType())) {
|
||||
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile, getContext());
|
||||
} else {
|
||||
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile, getContext());
|
||||
}
|
||||
int itemId = item.getItemId();
|
||||
|
||||
return true;
|
||||
if (itemId == R.id.action_send_share_file) {
|
||||
mContainerActivity.getFileOperationsHelper().sendShareFile(singleFile);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_open_file_with) {
|
||||
mContainerActivity.getFileOperationsHelper().openFile(singleFile);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_stream_media) {
|
||||
mContainerActivity.getFileOperationsHelper().streamMediaFile(singleFile);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_edit) {
|
||||
// should not be necessary, as menu item is filtered, but better play safe
|
||||
if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
|
||||
accountManager.getUser(),
|
||||
singleFile.getMimeType())) {
|
||||
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile, getContext());
|
||||
} else {
|
||||
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile, getContext());
|
||||
}
|
||||
case R.id.action_rename_file: {
|
||||
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(singleFile);
|
||||
dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_see_details: {
|
||||
if (mActiveActionMode != null) {
|
||||
mActiveActionMode.finish();
|
||||
}
|
||||
|
||||
mContainerActivity.showDetails(singleFile);
|
||||
mContainerActivity.showSortListGroup(false);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_set_as_wallpaper: {
|
||||
mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile, getView());
|
||||
return true;
|
||||
}
|
||||
case R.id.action_encrypted: {
|
||||
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, true);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_unset_encrypted: {
|
||||
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, false);
|
||||
return true;
|
||||
return true;
|
||||
} else if (itemId == R.id.action_rename_file) {
|
||||
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(singleFile);
|
||||
dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_see_details) {
|
||||
if (mActiveActionMode != null) {
|
||||
mActiveActionMode.finish();
|
||||
}
|
||||
|
||||
mContainerActivity.showDetails(singleFile);
|
||||
mContainerActivity.showSortListGroup(false);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_set_as_wallpaper) {
|
||||
mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile, getView());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_encrypted) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, true);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_unset_encrypted) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// actions possible on a batch of files
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_remove_file: {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(new ArrayList<>(checkedFiles), mActiveActionMode);
|
||||
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_download_file:
|
||||
case R.id.action_sync_file: {
|
||||
syncAndCheckFiles(checkedFiles);
|
||||
exitSelectionMode();
|
||||
return true;
|
||||
}
|
||||
case R.id.action_cancel_sync: {
|
||||
((FileDisplayActivity) mContainerActivity).cancelTransference(checkedFiles);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_favorite: {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, true);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_unset_favorite: {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, false);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_move: {
|
||||
Intent action = new Intent(getActivity(), FolderPickerActivity.class);
|
||||
action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, new ArrayList<>(checkedFiles));
|
||||
action.putExtra(FolderPickerActivity.EXTRA_CURRENT_FOLDER, mFile);
|
||||
action.putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.MOVE);
|
||||
getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__MOVE_FILES);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_copy: {
|
||||
Intent action = new Intent(getActivity(), FolderPickerActivity.class);
|
||||
action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, new ArrayList<>(checkedFiles));
|
||||
action.putExtra(FolderPickerActivity.EXTRA_CURRENT_FOLDER, mFile);
|
||||
action.putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.COPY);
|
||||
getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__COPY_FILES);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_select_all_action_menu: {
|
||||
selectAllFiles(true);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_deselect_all_action_menu: {
|
||||
selectAllFiles(false);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_send_file:
|
||||
mContainerActivity.getFileOperationsHelper().sendFiles(checkedFiles);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_remove_file) {
|
||||
RemoveFilesDialogFragment dialog =
|
||||
RemoveFilesDialogFragment.newInstance(new ArrayList<>(checkedFiles), mActiveActionMode);
|
||||
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_download_file || itemId == R.id.action_sync_file) {
|
||||
syncAndCheckFiles(checkedFiles);
|
||||
exitSelectionMode();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_cancel_sync) {
|
||||
((FileDisplayActivity) mContainerActivity).cancelTransference(checkedFiles);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_favorite) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, true);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_unset_favorite) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, false);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_move) {
|
||||
Intent action = new Intent(getActivity(), FolderPickerActivity.class);
|
||||
action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, new ArrayList<>(checkedFiles));
|
||||
action.putExtra(FolderPickerActivity.EXTRA_CURRENT_FOLDER, mFile);
|
||||
action.putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.MOVE);
|
||||
getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__MOVE_FILES);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_copy) {
|
||||
Intent action = new Intent(getActivity(), FolderPickerActivity.class);
|
||||
action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, new ArrayList<>(checkedFiles));
|
||||
action.putExtra(FolderPickerActivity.EXTRA_CURRENT_FOLDER, mFile);
|
||||
action.putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.COPY);
|
||||
getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__COPY_FILES);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_select_all_action_menu) {
|
||||
selectAllFiles(true);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_deselect_all_action_menu) {
|
||||
selectAllFiles(false);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_send_file) {
|
||||
mContainerActivity.getFileOperationsHelper().sendFiles(checkedFiles);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1249,7 +1232,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
|
||||
fileDisplayActivity.hideSearchView(fileDisplayActivity.getCurrentDir());
|
||||
if (getCurrentFile() != null) {
|
||||
fileDisplayActivity.setDrawerIndicatorEnabled(fileDisplayActivity.isRoot(getCurrentFile()));
|
||||
fileDisplayActivity
|
||||
.setDrawerIndicatorEnabled(fileDisplayActivity.isRoot(getCurrentFile()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1819,7 +1803,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
/**
|
||||
* Remove this, if HideBottomViewOnScrollBehavior is fix by Google
|
||||
*
|
||||
* @param visible
|
||||
* @param visible flag if FAB should be shown or hidden
|
||||
*/
|
||||
private void showFabWithBehavior(boolean visible) {
|
||||
ViewGroup.LayoutParams layoutParams = mFabMain.getLayoutParams();
|
||||
|
|
|
@ -267,23 +267,23 @@ public class ContactListFragment extends FileFragment implements Injectable {
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval;
|
||||
ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
|
||||
int itemId = item.getItemId();
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
if (itemId == android.R.id.home) {
|
||||
ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
|
||||
if (contactsPreferenceActivity != null) {
|
||||
contactsPreferenceActivity.onBackPressed();
|
||||
retval = true;
|
||||
break;
|
||||
case R.id.action_select_all:
|
||||
item.setChecked(!item.isChecked());
|
||||
setSelectAllMenuItem(item, item.isChecked());
|
||||
contactListAdapter.selectAllFiles(item.isChecked());
|
||||
retval = true;
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
}
|
||||
retval = true;
|
||||
} else if (itemId == R.id.action_select_all) {
|
||||
item.setChecked(!item.isChecked());
|
||||
setSelectAllMenuItem(item, item.isChecked());
|
||||
contactListAdapter.selectAllFiles(item.isChecked());
|
||||
retval = true;
|
||||
} else {
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -212,15 +212,11 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.cancelBtn: {
|
||||
containerActivity.getFileOperationsHelper().cancelTransference(getFile());
|
||||
getActivity().finish();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log_OC.e(TAG, "Incorrect view clicked!");
|
||||
break;
|
||||
if (v.getId() == R.id.cancelBtn) {
|
||||
containerActivity.getFileOperationsHelper().cancelTransference(getFile());
|
||||
getActivity().finish();
|
||||
} else {
|
||||
Log_OC.e(TAG, "Incorrect view clicked!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -297,40 +297,34 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
|
|||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_send_share_file: {
|
||||
if (getFile().isSharedWithMe() && !getFile().canReshare()) {
|
||||
DisplayUtils.showSnackMessage(getView(), R.string.resharing_is_not_allowed);
|
||||
} else {
|
||||
containerActivity.getFileOperationsHelper().sendShareFile(getFile());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case R.id.action_open_file_with: {
|
||||
openFile();
|
||||
return true;
|
||||
}
|
||||
case R.id.action_remove_file: {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
|
||||
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_see_details: {
|
||||
seeDetails();
|
||||
return true;
|
||||
}
|
||||
case R.id.action_sync_file: {
|
||||
containerActivity.getFileOperationsHelper().syncFile(getFile());
|
||||
return true;
|
||||
}
|
||||
int itemId = item.getItemId();
|
||||
|
||||
case R.id.action_edit:
|
||||
containerActivity.getFileOperationsHelper().openFileWithTextEditor(getFile(), getContext());
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
if (itemId == R.id.action_send_share_file) {
|
||||
if (getFile().isSharedWithMe() && !getFile().canReshare()) {
|
||||
DisplayUtils.showSnackMessage(getView(), R.string.resharing_is_not_allowed);
|
||||
} else {
|
||||
containerActivity.getFileOperationsHelper().sendShareFile(getFile());
|
||||
}
|
||||
return true;
|
||||
} else if (itemId == R.id.action_open_file_with) {
|
||||
openFile();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_remove_file) {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
|
||||
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_see_details) {
|
||||
seeDetails();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_sync_file) {
|
||||
containerActivity.getFileOperationsHelper().syncFile(getFile());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_edit) {
|
||||
containerActivity.getFileOperationsHelper().openFileWithTextEditor(getFile(), getContext());
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue