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:
Andy Scherzinger 2021-06-02 09:27:39 +02:00
parent 9f1c79494b
commit 1fdea011a7
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
16 changed files with 472 additions and 577 deletions

View file

@ -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,12 +307,11 @@ 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:
if (id == R.id.playBtn) {
doPauseResume();
} else if (id == R.id.rewindBtn) {
pos = playerControl.getCurrentPosition();
pos -= 5000;
playerControl.seekTo(pos);
@ -324,9 +319,7 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
playerControl.pause(); // necessary in some 2.3.x devices
}
setProgress();
break;
case R.id.forwardBtn:
} else if (id == R.id.forwardBtn) {
pos = playerControl.getCurrentPosition();
pos += 15000;
playerControl.seekTo(pos);
@ -334,15 +327,9 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
playerControl.pause(); // necessary in some 2.3.x devices
}
setProgress();
break;
default:
// do nothing
break;
}
}
@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.
*/

View file

@ -418,8 +418,9 @@ public abstract class DrawerActivity extends ToolbarActivity
private void onNavigationItemClicked(final MenuItem menuItem) {
setDrawerMenuItemChecked(menuItem.getItemId());
switch (menuItem.getItemId()) {
case R.id.nav_all_files:
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)) {
@ -433,64 +434,49 @@ public abstract class DrawerActivity extends ToolbarActivity
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
startActivity(intent);
}
break;
case R.id.nav_favorites:
} else if (itemId == R.id.nav_favorites) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH),
menuItem.getItemId());
break;
case R.id.nav_gallery:
} else if (itemId == R.id.nav_gallery) {
startPhotoSearch(menuItem);
break;
case R.id.nav_on_device:
} else if (itemId == R.id.nav_on_device) {
EventBus.getDefault().post(new ChangeMenuEvent());
showFiles(true);
break;
case R.id.nav_uploads:
} else if (itemId == R.id.nav_uploads) {
startActivity(UploadListActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
case R.id.nav_trashbin:
} else if (itemId == R.id.nav_trashbin) {
startActivity(TrashbinActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
case R.id.nav_activity:
} else if (itemId == R.id.nav_activity) {
startActivity(ActivitiesActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
case R.id.nav_notifications:
} else if (itemId == R.id.nav_notifications) {
startActivity(NotificationsActivity.class);
break;
case R.id.nav_contacts:
} else if (itemId == R.id.nav_contacts) {
ContactsPreferenceActivity.startActivity(this);
break;
case R.id.nav_settings:
} else if (itemId == R.id.nav_settings) {
startActivity(SettingsActivity.class);
break;
case R.id.nav_community:
} else if (itemId == R.id.nav_community) {
startActivity(CommunityActivity.class);
break;
case R.id.nav_logout:
} 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());
}
break;
case R.id.nav_shared:
} else if (itemId == R.id.nav_shared) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER),
menuItem.getItemId());
break;
case R.id.nav_recently_modified:
} else if (itemId == R.id.nav_recently_modified) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH),
menuItem.getItemId());
break;
default:
} else {
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());
Log_OC.w(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
}
break;
}
}

View file

@ -826,8 +826,9 @@ public class FileDisplayActivity extends FileActivity
@Override
public boolean onOptionsItemSelected(MenuItem item) {
boolean retval = true;
switch (item.getItemId()) {
case android.R.id.home: {
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
FileFragment second = getSecondFragment();
OCFile currentDir = getCurrentDir();
if (isDrawerOpen()) {
@ -844,19 +845,16 @@ public class FileDisplayActivity extends FileActivity
openDrawer();
}
break;
}
case R.id.action_select_all: {
} else if (itemId == R.id.action_select_all) {
OCFileListFragment fragment = getListOfFilesFragment();
if (fragment != null) {
fragment.selectAllFiles(true);
}
break;
}
default:
} else {
retval = super.onOptionsItemSelected(item);
break;
}
return retval;
}

View file

@ -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: {
int itemId = item.getItemId();
if (itemId == R.id.action_create_dir) {
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(getCurrentFolder());
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
break;
}
case android.R.id.home: {
} else if (itemId == android.R.id.home) {
OCFile currentDir = getCurrentFolder();
if (currentDir != null && currentDir.getParentId() != 0) {
onBackPressed();
}
break;
}
default:
} else {
retval = super.onOptionsItemSelected(item);
break;
}
return retval;

View file

@ -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:
if (item.getItemId() == android.R.id.home) {
onBackPressed();
break;
default:
} else {
retval = super.onOptionsItemSelected(item);
break;
}
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:
int itemId = item.getItemId();
if (itemId == R.id.action_open_account) {
accountClicked(user.hashCode());
break;
case R.id.action_delete_account:
} else if (itemId == R.id.action_delete_account) {
openAccountRemovalConfirmationDialog(user, getSupportFragmentManager());
break;
default:
} else {
openAccount(user);
break;
}
return true;
});
popup.show();

View file

@ -655,8 +655,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
@Override
public void onClick(View v) {
// click on button
switch (v.getId()) {
case R.id.uploader_choose_folder:
int id = v.getId();
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) {
@ -670,13 +671,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
Log_OC.d(TAG, "Uploading file to dir " + mUploadPath);
uploadFiles();
}
break;
case R.id.uploader_cancel:
} else if (id == R.id.uploader_cancel) {
finish();
break;
default:
} 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:
int itemId = item.getItemId();
if (itemId == R.id.action_create_dir) {
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(mFile);
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
break;
case android.R.id.home:
} else if (itemId == android.R.id.home) {
if (mParents.size() > SINGLE_PARENT) {
onBackPressed();
}
break;
case R.id.action_switch_account:
} else if (itemId == R.id.action_switch_account) {
showAccountChooserDialog();
break;
default:
} else {
retval = super.onOptionsItemSelected(item);
break;
}
return retval;
}

View file

@ -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: {
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
if (mCurrentDir != null && mCurrentDir.getParentFile() != null) {
onBackPressed();
}
break;
}
case R.id.action_select_all: {
} else if (itemId == 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: {
} else if (itemId == R.id.action_choose_storage_path) {
showLocalStoragePathPickerDialog();
break;
}
default:
} else {
retval = super.onOptionsItemSelected(item);
break;
}
return retval;
}

View file

@ -246,20 +246,18 @@ public class UploadListActivity extends FileActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
boolean retval = true;
switch (item.getItemId()) {
case android.R.id.home:
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
if (isDrawerOpen()) {
closeDrawer();
} else {
openDrawer();
}
break;
case R.id.action_clear_failed_uploads:
} else if (itemId == R.id.action_clear_failed_uploads) {
uploadsStorageManager.clearFailedButNotDelayedUploads();
uploadListAdapter.loadUploadItemsFromDb();
break;
default:
} else {
retval = super.onOptionsItemSelected(item);
}

View file

@ -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:
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
onBackPressed();
break;
case R.id.action_open_account:
} else if (itemId == R.id.action_open_account) {
accountClicked(user.hashCode());
break;
case R.id.action_delete_account:
} else if (itemId == R.id.action_delete_account) {
openAccountRemovalConfirmationDialog(user, getSupportFragmentManager());
break;
default:
} else {
retval = super.onOptionsItemSelected(item);
break;
}
return retval;
}

View file

@ -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:
int itemId = i.getItemId();
if (itemId == R.id.action_upload_list_resolve_conflict) {
checkAndOpenConflictResolutionDialog(user, itemViewHolder, item, status);
break;
case R.id.action_upload_list_delete:
default:
} else {
removeUpload(item);
break;
}
return true;
});
popup.show();

View file

@ -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: {
int itemId = item.getItemId();
if (itemId == R.id.action_send_file) {
containerActivity.getFileOperationsHelper().sendShareFile(getFile(), true);
return true;
}
case R.id.action_open_file_with: {
} else if (itemId == R.id.action_open_file_with) {
containerActivity.getFileOperationsHelper().openFile(getFile());
return true;
}
case R.id.action_remove_file: {
} else if (itemId == R.id.action_remove_file) {
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
dialog.show(getFragmentManager(), FTAG_CONFIRMATION);
return true;
}
case R.id.action_rename_file: {
} else if (itemId == R.id.action_rename_file) {
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(getFile());
dialog.show(getFragmentManager(), FTAG_RENAME_FILE);
return true;
}
case R.id.action_cancel_sync: {
} else if (itemId == R.id.action_cancel_sync) {
((FileDisplayActivity) containerActivity).cancelTransference(getFile());
return true;
}
case R.id.action_download_file:
case R.id.action_sync_file: {
} else if (itemId == R.id.action_download_file || itemId == R.id.action_sync_file) {
containerActivity.getFileOperationsHelper().syncFile(getFile());
return true;
}
case R.id.action_set_as_wallpaper: {
} else if (itemId == R.id.action_set_as_wallpaper) {
containerActivity.getFileOperationsHelper().setPictureAs(getFile(), getView());
return true;
}
case R.id.action_encrypted: {
// TODO implement or remove
} 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;
}
case R.id.action_unset_encrypted: {
// TODO implement or remove
return true;
}
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cancelBtn: {
int id = v.getId();
if (id == 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);
}
} else if (id == R.id.favorite) {
containerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), !getFile().isFavorite());
setFavoriteIconStatus(!getFile().isFavorite());
break;
}
case R.id.overflow_menu: {
} else if (id == R.id.overflow_menu) {
onOverflowIconClicked(v);
break;
}
case R.id.last_modification_timestamp: {
} else if (id == R.id.last_modification_timestamp) {
boolean showDetailedTimestamp = !preferences.isShowDetailedTimestampEnabled();
preferences.setShowDetailedTimestampEnabled(showDetailedTimestamp);
setFileModificationTimestamp(getFile(), showDetailedTimestamp);
}
default:
Log_OC.e(TAG, "Incorrect view clicked!");
} else {
Log_OC.e(TAG, "Incorrect view clicked!");
break;
}
}

View file

@ -436,11 +436,9 @@ 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: {
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(),
@ -448,8 +446,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
menu.findItem(R.id.allow_creating).isChecked(),
menu.findItem(R.id.allow_deleting).isChecked()));
return true;
}
case R.id.action_unshare: {
} else if (itemId == R.id.action_unshare) {
unshareWith(share);
ShareeListAdapter adapter = (ShareeListAdapter) binding.sharesList.getAdapter();
if (adapter == null) {
@ -459,30 +456,29 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
adapter.remove(share);
return true;
}
case R.id.action_expiration_date: {
} 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;
}
case R.id.action_share_send_note:
} else if (itemId == R.id.action_share_send_note) {
NoteDialogFragment dialog = NoteDialogFragment.newInstance(share);
dialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
return true;
default:
return true;
}
return true;
}
public boolean linkOptionsItemSelected(MenuItem item, OCShare publicShare) {
switch (item.getItemId()) {
case R.id.link_share_read_only:
int itemId = item.getItemId();
if (itemId == 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:
} else if (itemId == R.id.link_share_allow_upload_and_editing) {
item.setChecked(true);
if (publicShare.isFolder()) {
fileOperationsHelper.setPermissionsToShare(publicShare, MAXIMUM_PERMISSIONS_FOR_FOLDER);
@ -490,59 +486,55 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
fileOperationsHelper.setPermissionsToShare(publicShare, MAXIMUM_PERMISSIONS_FOR_FILE);
}
return true;
case R.id.link_share_file_drop: {
} else if (itemId == R.id.link_share_file_drop) {
item.setChecked(true);
fileOperationsHelper.setPermissionsToShare(publicShare, CREATE_PERMISSION_FLAG);
return true;
}
case R.id.allow_editing:
} else if (itemId == 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:
} else if (itemId == R.id.action_hide_file_download) {
item.setChecked(!item.isChecked());
fileOperationsHelper.setHideFileDownloadPermissionsToPublicShare(publicShare, item.isChecked());
return true;
case R.id.action_password: {
} else if (itemId == R.id.action_password) {
requestPasswordForShare(publicShare,
capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
return true;
}
case R.id.action_share_expiration_date: {
} 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;
}
case R.id.action_share_send_link: {
} 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);
}
return true;
}
case R.id.action_share_send_note:
} else if (itemId == 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:
} else if (itemId == 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:
} else if (itemId == R.id.action_unshare) {
fileOperationsHelper.unshareShare(file, publicShare);
return true;
case R.id.action_add_another_public_share_link:
} else if (itemId == R.id.action_add_another_public_share_link) {
createPublicShareLink();
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
/**

View file

@ -1072,20 +1072,18 @@ 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: {
int itemId = item.getItemId();
if (itemId == R.id.action_send_share_file) {
mContainerActivity.getFileOperationsHelper().sendShareFile(singleFile);
return true;
}
case R.id.action_open_file_with: {
} else if (itemId == R.id.action_open_file_with) {
mContainerActivity.getFileOperationsHelper().openFile(singleFile);
return true;
}
case R.id.action_stream_media: {
} else if (itemId == R.id.action_stream_media) {
mContainerActivity.getFileOperationsHelper().streamMediaFile(singleFile);
return true;
}
case R.id.action_edit: {
} 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(),
@ -1096,13 +1094,11 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
return true;
}
case R.id.action_rename_file: {
} else if (itemId == 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: {
} else if (itemId == R.id.action_see_details) {
if (mActiveActionMode != null) {
mActiveActionMode.finish();
}
@ -1110,77 +1106,64 @@ public class OCFileListFragment extends ExtendedListFragment implements
mContainerActivity.showDetails(singleFile);
mContainerActivity.showSortListGroup(false);
return true;
}
case R.id.action_set_as_wallpaper: {
} else if (itemId == R.id.action_set_as_wallpaper) {
mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile, getView());
return true;
}
case R.id.action_encrypted: {
} else if (itemId == R.id.action_encrypted) {
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, true);
return true;
}
case R.id.action_unset_encrypted: {
} 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);
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;
}
case R.id.action_download_file:
case R.id.action_sync_file: {
} else if (itemId == R.id.action_download_file || itemId == R.id.action_sync_file) {
syncAndCheckFiles(checkedFiles);
exitSelectionMode();
return true;
}
case R.id.action_cancel_sync: {
} else if (itemId == R.id.action_cancel_sync) {
((FileDisplayActivity) mContainerActivity).cancelTransference(checkedFiles);
return true;
}
case R.id.action_favorite: {
} else if (itemId == R.id.action_favorite) {
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, true);
return true;
}
case R.id.action_unset_favorite: {
} else if (itemId == R.id.action_unset_favorite) {
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, false);
return true;
}
case R.id.action_move: {
} 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;
}
case R.id.action_copy: {
} 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;
}
case R.id.action_select_all_action_menu: {
} else if (itemId == R.id.action_select_all_action_menu) {
selectAllFiles(true);
return true;
}
case R.id.action_deselect_all_action_menu: {
} else if (itemId == R.id.action_deselect_all_action_menu) {
selectAllFiles(false);
return true;
}
case R.id.action_send_file:
} else if (itemId == R.id.action_send_file) {
mContainerActivity.getFileOperationsHelper().sendFiles(checkedFiles);
return true;
default:
return false;
}
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();

View file

@ -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:
} else if (itemId == R.id.action_select_all) {
item.setChecked(!item.isChecked());
setSelectAllMenuItem(item, item.isChecked());
contactListAdapter.selectAllFiles(item.isChecked());
retval = true;
break;
default:
} else {
retval = super.onOptionsItemSelected(item);
break;
}
return retval;
}

View file

@ -212,15 +212,11 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cancelBtn: {
if (v.getId() == R.id.cancelBtn) {
containerActivity.getFileOperationsHelper().cancelTransference(getFile());
getActivity().finish();
break;
}
default:
} else {
Log_OC.e(TAG, "Incorrect view clicked!");
break;
}
}

View file

@ -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: {
int itemId = item.getItemId();
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;
}
case R.id.action_open_file_with: {
} else if (itemId == R.id.action_open_file_with) {
openFile();
return true;
}
case R.id.action_remove_file: {
} else if (itemId == R.id.action_remove_file) {
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
return true;
}
case R.id.action_see_details: {
} else if (itemId == R.id.action_see_details) {
seeDetails();
return true;
}
case R.id.action_sync_file: {
} else if (itemId == R.id.action_sync_file) {
containerActivity.getFileOperationsHelper().syncFile(getFile());
return true;
}
case R.id.action_edit:
} else if (itemId == R.id.action_edit) {
containerActivity.getFileOperationsHelper().openFileWithTextEditor(getFile(), getContext());
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
/**