From 4bf1b65f4136cc5fae727c1a8227b31ab708d1df Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Mon, 20 Nov 2017 08:42:37 +0100 Subject: [PATCH 1/3] hide item options (share, overflow menu) in move/copy dialog --- .../ui/activity/FolderPickerActivity.java | 92 +++++++++---------- .../ui/adapter/FileListListAdapter.java | 34 +++---- .../ui/fragment/OCFileListFragment.java | 11 +-- 3 files changed, 60 insertions(+), 77 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 ae7982aeed..56e358b6b6 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java @@ -1,4 +1,4 @@ -/** +/* * ownCloud Android client application * * Copyright (C) 2016 ownCloud Inc. @@ -102,13 +102,17 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C // Action bar setup setupToolbar(); - getSupportActionBar().setDisplayShowTitleEnabled(true); + + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayShowTitleEnabled(true); + getSupportActionBar().setTitle(caption); + } + if (getIntent().getStringExtra(EXTRA_ACTION) != null) { caption = getIntent().getStringExtra(EXTRA_ACTION); } else { caption = ThemeUtils.getDefaultDisplayNameForRootFolder(); } - getSupportActionBar().setTitle(caption); setIndeterminate(mSyncInProgress); // always AFTER setContentView(...) ; to work around bug in its implementation @@ -161,6 +165,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C Bundle args = new Bundle(); args.putBoolean(OCFileListFragment.ARG_JUST_FOLDERS, true); args.putBoolean(OCFileListFragment.ARG_HIDE_FAB, true); + args.putBoolean(OCFileListFragment.ARG_HIDE_ITEM_OPTIONS, true); listOfFiles.setArguments(args); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.fragment_container, listOfFiles, TAG_LIST_OF_FOLDERS); @@ -194,7 +199,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C if (listOfFiles != null) { return (OCFileListFragment)listOfFiles; } - Log_OC.e(TAG, "Access to unexisting list of files fragment!!"); + Log_OC.e(TAG, "Access to non existing list of files fragment!!"); return null; } @@ -222,19 +227,12 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C mSyncInProgress = true; // perform folder synchronization - RemoteOperation synchFolderOp = new RefreshFolderOperation( folder, - currentSyncTime, - false, - getFileOperationsHelper().isSharedSupported(), - ignoreETag, - getStorageManager(), - getAccount(), - getApplicationContext() - ); - synchFolderOp.execute(getAccount(), this, null, null); + RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false, + getFileOperationsHelper().isSharedSupported(), ignoreETag, getStorageManager(), getAccount(), + getApplicationContext()); + refreshFolderOperation.execute(getAccount(), this, null, null); setIndeterminate(true); - setBackgroundText(); } @@ -277,6 +275,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); + menu.findItem(R.id.action_switch_view).setVisible(false); + menu.findItem(R.id.action_sync_account).setVisible(false); + menu.findItem(R.id.action_select_all).setVisible(false); menu.findItem(R.id.action_sort).setVisible(false); return true; } @@ -355,16 +356,15 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C } protected void updateNavigationElementsInActionBar() { - ActionBar actionBar = getSupportActionBar(); OCFile currentDir = getCurrentFolder(); - boolean atRoot = (currentDir == null || currentDir.getParentId() == 0); - actionBar.setDisplayHomeAsUpEnabled(!atRoot); - actionBar.setHomeButtonEnabled(!atRoot); - actionBar.setTitle( - atRoot - ? caption - : currentDir.getFileName() - ); + ActionBar actionBar = getSupportActionBar(); + + if (actionBar != null) { + boolean atRoot = (currentDir == null || currentDir.getParentId() == 0); + actionBar.setDisplayHomeAsUpEnabled(!atRoot); + actionBar.setHomeButtonEnabled(!atRoot); + actionBar.setTitle(atRoot ? caption : currentDir.getFileName()); + } } /** @@ -443,39 +443,33 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C String event = intent.getAction(); Log_OC.d(TAG, "Received broadcast " + event); String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME); - String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); - RemoteOperationResult synchResult = (RemoteOperationResult) + String syncFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); + RemoteOperationResult syncResult = (RemoteOperationResult) DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT)); - boolean sameAccount = (getAccount() != null && - accountName.equals(getAccount().name) && getStorageManager() != null); + boolean sameAccount = (getAccount() != null && accountName.equals(getAccount().name) + && getStorageManager() != null); if (sameAccount) { - if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { mSyncInProgress = true; - } else { - OCFile currentFile = (getFile() == null) ? null : - getStorageManager().getFileByPath(getFile().getRemotePath()); + OCFile currentFile = (getFile() == null) ? null : + getStorageManager().getFileByPath(getFile().getRemotePath()); OCFile currentDir = (getCurrentFolder() == null) ? null : getStorageManager().getFileByPath(getCurrentFolder().getRemotePath()); if (currentDir == null) { // current folder was removed from the server - DisplayUtils.showSnackMessage( - getActivity(), - R.string.sync_current_folder_was_removed, - getCurrentFolder().getFileName() - ); + DisplayUtils.showSnackMessage(getActivity(), R.string.sync_current_folder_was_removed, + getCurrentFolder().getFileName()); browseToRoot(); - } else { if (currentFile == null && !getFile().isFolder()) { // currently selected file was removed in the server, and now we know it currentFile = currentDir; } - if (currentDir.getRemotePath().equals(synchFolderRemotePath)) { + if (currentDir.getRemotePath().equals(syncFolderRemotePath)) { OCFileListFragment fileListFragment = getListOfFilesFragment(); if (fileListFragment != null) { fileListFragment.listDirectory(currentDir, false, false); @@ -486,21 +480,17 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event)); - - if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED. - equals(event) && + + if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) && /// TODO refactor and make common - synchResult != null && !synchResult.isSuccess()) { - - if(ResultCode.UNAUTHORIZED.equals(synchResult.getCode()) || - (synchResult.isException() && synchResult.getException() - instanceof AuthenticatorException)) { + syncResult != null && !syncResult.isSuccess()) { + if (ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) || (syncResult.isException() + && syncResult.getException() instanceof AuthenticatorException)) { requestCredentialsUpdate(context); - - } else if(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(synchResult.getCode())) { - - showUntrustedCertDialog(synchResult); + } else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED + .equals(syncResult.getCode())) { + showUntrustedCertDialog(syncResult); } } diff --git a/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java index f753baa0a1..dcbf1b547b 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -84,6 +84,7 @@ public class FileListListAdapter extends BaseAdapter { private Vector mFilesAll = new Vector(); private Vector mFiles = null; private boolean mJustFolders; + private boolean mHideItemOptions; private FileDataStorageManager mStorageManager; private Account mAccount; @@ -96,17 +97,14 @@ public class FileListListAdapter extends BaseAdapter { private ArrayList asyncTasks = new ArrayList<>(); - public FileListListAdapter( - boolean justFolders, - Context context, - ComponentsGetter transferServiceGetter, - OCFileListFragmentInterface OCFileListFragmentInterface - ) { + public FileListListAdapter(boolean justFolders, Context context, ComponentsGetter transferServiceGetter, + OCFileListFragmentInterface OCFileListFragmentInterface, boolean argHideItemOptions) { this.OCFileListFragmentInterface = OCFileListFragmentInterface; mJustFolders = justFolders; mContext = context; mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext); + mHideItemOptions = argHideItemOptions; mTransferServiceGetter = transferServiceGetter; @@ -118,17 +116,6 @@ public class FileListListAdapter extends BaseAdapter { new ThumbnailsCacheManager.InitDiskCacheTask().execute(); } - public FileListListAdapter( - boolean justFolders, - Context context, - ComponentsGetter transferServiceGetter, - OCFileListFragmentInterface OCFileListFragmentInterface, - FileDataStorageManager fileDataStorageManager - ) { - this(justFolders, context, transferServiceGetter, OCFileListFragmentInterface); - mStorageManager = fileDataStorageManager; - } - @Override public boolean areAllItemsEnabled() { return true; @@ -326,8 +313,17 @@ public class FileListListAdapter extends BaseAdapter { hideOverflowMenuIcon(view, viewType); } else { checkBoxV.setVisibility(View.GONE); - showShareIcon(view, file); - showOverflowMenuIcon(view, file, viewType); + + if (mHideItemOptions) { + ImageView sharedIconView = (ImageView) view.findViewById(R.id.sharedIcon); + sharedIconView.setVisibility(View.GONE); + + ImageView overflowIndicatorView = (ImageView) view.findViewById(R.id.overflow_menu); + overflowIndicatorView.setVisibility(View.GONE); + } else { + showShareIcon(view, file); + showOverflowMenuIcon(view, file, viewType); + } } // this if-else is needed even though kept-in-sync icon is visible by default diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index b969ed807d..a8306d3343 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -125,6 +125,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi public final static String ARG_JUST_FOLDERS = MY_PACKAGE + ".JUST_FOLDERS"; public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS = MY_PACKAGE + ".ALLOW_CONTEXTUAL"; public final static String ARG_HIDE_FAB = MY_PACKAGE + ".HIDE_FAB"; + public final static String ARG_HIDE_ITEM_OPTIONS = MY_PACKAGE + ".HIDE_ITEM_OPTIONS"; public static final String DOWNLOAD_BEHAVIOUR = "DOWNLOAD_BEHAVIOUR"; public static final String DOWNLOAD_SEND = "DOWNLOAD_SEND"; @@ -312,13 +313,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi Bundle args = getArguments(); mJustFolders = (args != null) && args.getBoolean(ARG_JUST_FOLDERS, false); - mAdapter = new FileListListAdapter( - mJustFolders, - getActivity(), - mContainerActivity, - this, - mContainerActivity.getStorageManager() - ); + boolean hideItemOptions = (args != null) && args.getBoolean(ARG_HIDE_ITEM_OPTIONS, false); + + mAdapter = new FileListListAdapter(mJustFolders, getActivity(), mContainerActivity, this, hideItemOptions); setListAdapter(mAdapter); mHideFab = (args != null) && args.getBoolean(ARG_HIDE_FAB, false); From f3be3ca91c39bb83ad7a2a7889ba349caa79e3be Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Mon, 20 Nov 2017 11:05:49 +0100 Subject: [PATCH 2/3] move order --- .../android/ui/activity/FolderPickerActivity.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 56e358b6b6..e7a4fe5042 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java @@ -102,11 +102,6 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C // Action bar setup setupToolbar(); - - if (getSupportActionBar() != null) { - getSupportActionBar().setDisplayShowTitleEnabled(true); - getSupportActionBar().setTitle(caption); - } if (getIntent().getStringExtra(EXTRA_ACTION) != null) { caption = getIntent().getStringExtra(EXTRA_ACTION); @@ -114,6 +109,11 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C caption = ThemeUtils.getDefaultDisplayNameForRootFolder(); } + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayShowTitleEnabled(true); + getSupportActionBar().setTitle(caption); + } + setIndeterminate(mSyncInProgress); // always AFTER setContentView(...) ; to work around bug in its implementation From 38fd3688c30b65ec9469dc5e6bcdf22507b0145e Mon Sep 17 00:00:00 2001 From: nextcloud-android-bot <> Date: Mon, 27 Nov 2017 16:14:17 +0000 Subject: [PATCH 3/3] Drone: update Lint results to reflect reduced error/warning count [skip ci] --- scripts/lint/lint-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint/lint-results.txt b/scripts/lint/lint-results.txt index c1eaa881d8..de0f6c1f82 100644 --- a/scripts/lint/lint-results.txt +++ b/scripts/lint/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 367 warnings + Lint Report: 366 warnings