From 57fd78e326e0eb8187fe87d001cdb81eb4504188 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 28 Feb 2019 09:02:33 +0100 Subject: [PATCH] apply code changes to project --- .drone.yml | 22 +- .travis.yml | 8 +- .../android/test/ui/actions/Actions.java | 442 +++++----- .../test/ui/groups/FailingTestCategory.java | 34 +- .../test/ui/groups/FlexibleCategories.java | 240 +++--- .../test/ui/groups/IgnoreTestCategory.java | 34 +- .../test/ui/groups/InProgressCategory.java | 2 +- .../test/ui/groups/NoIgnoreTestCategory.java | 31 +- .../test/ui/groups/OtherTestCategory.java | 34 +- .../groups/PatternClasspathClassesFinder.java | 217 +++-- .../test/ui/groups/SmokeTestCategory.java | 31 +- .../ui/groups/UnfinishedTestCategory.java | 33 +- .../test/ui/models/CertificatePopUp.java | 66 +- .../test/ui/models/ElementMenuOptions.java | 155 ++-- .../test/ui/models/FileDetailsView.java | 90 +- .../android/test/ui/models/FileListView.java | 373 ++++---- .../test/ui/models/GmailEmailListView.java | 83 +- .../test/ui/models/GmailEmailView.java | 67 +- .../test/ui/models/GmailSendMailView.java | 94 +- .../android/test/ui/models/ImageView.java | 106 ++- .../android/test/ui/models/LoginForm.java | 201 +++-- .../android/test/ui/models/MenuList.java | 64 +- .../android/test/ui/models/MoveView.java | 81 +- .../test/ui/models/NewFolderPopUp.java | 86 +- .../test/ui/models/NotificationView.java | 83 +- .../test/ui/models/PassCodeRequestView.java | 90 +- .../android/test/ui/models/PassCodeView.java | 111 ++- .../ui/models/RemoveConfirmationView.java | 62 +- .../android/test/ui/models/SettingsView.java | 168 ++-- .../android/test/ui/models/ShareView.java | 63 +- .../test/ui/models/UploadFilesView.java | 101 ++- .../android/test/ui/models/UploadView.java | 60 +- .../test/ui/models/WaitAMomentPopUp.java | 60 +- .../android/test/ui/testSuites/Common.java | 369 ++++---- .../android/test/ui/testSuites/Config.java | 87 +- .../ui/testSuites/CreateFolderTestSuite.java | 138 ++- .../ui/testSuites/DeleteFileTestSuite.java | 128 ++- .../ui/testSuites/DeleteFolderTestSuite.java | 135 ++- .../test/ui/testSuites/LoginTestSuite.java | 321 ++++--- .../test/ui/testSuites/LogoutTestSuite.java | 114 ++- .../test/ui/testSuites/MoveFileTestSuite.java | 197 +++-- .../ui/testSuites/MoveFolderTestSuite.java | 205 +++-- .../test/ui/testSuites/PasscodeTestSuite.java | 151 ++-- .../ui/testSuites/RefreshFolderTestSuite.java | 106 ++- .../ui/testSuites/RenameFileTestSuite.java | 172 ++-- .../ui/testSuites/RenameFolderTestSuite.java | 185 ++-- .../test/ui/testSuites/RunFailingTests.java | 42 +- .../test/ui/testSuites/RunInProgressTest.java | 7 +- .../test/ui/testSuites/RunNoIgnoreTests.java | 43 +- .../test/ui/testSuites/RunSmokeTests.java | 43 +- .../ui/testSuites/ShareLinkFileTestSuite.java | 234 ++--- .../test/ui/testSuites/UploadTestSuite.java | 509 ++++++----- doc/icon.svg | 1 - doc/workaround_icon.svg | 1 - .../src/androidTest/AndroidManifest.xml | 3 +- .../AuthenticatorActivityTest.java | 86 +- .../SAMLAuthenticatorActivityTest.java | 51 +- .../android/datamodel/OCFileUnitTest.java | 47 +- .../ui/activity/PublicShareActivityTest.java | 110 ++- .../android/uiautomator/InitialTest.java | 11 +- .../android/utils/AccountsManager.java | 71 +- .../owncloud/android/utils/FileManager.java | 39 +- .../owncloud/android/utils/ServerType.java | 101 ++- owncloudApp/src/main/AndroidManifest.xml | 15 +- .../src/main/assets/available_offline.svg | 137 ++- owncloudApp/src/main/assets/download_pin.svg | 153 ++-- .../assets/ic_file_download_white_24px.svg | 4 +- owncloudApp/src/main/assets/offline_pin.svg | 157 ++-- owncloudApp/src/main/assets/uncheck_av.svg | 149 ++-- .../java/com/owncloud/android/AppRater.java | 39 +- .../java/com/owncloud/android/MainApp.java | 70 +- .../authentication/AccountAuthenticator.java | 129 +-- .../AccountAuthenticatorActivity.java | 23 +- .../AccountAuthenticatorService.java | 33 +- .../android/authentication/AccountUtils.java | 66 +- .../authentication/AuthenticatorActivity.java | 70 +- .../AuthenticatorAsyncTask.java | 61 +- .../authentication/BaseWebViewClient.java | 96 ++- .../authentication/FingerprintManager.java | 47 +- .../authentication/FingerprintUIHelper.java | 2 +- .../authentication/PassCodeManager.java | 44 +- .../authentication/PatternManager.java | 6 +- .../authentication/SAMLWebViewClient.java | 41 +- .../ConnectivityActionReceiver.java | 163 ++-- .../CameraUploadsSyncStorageManager.java | 30 +- .../datamodel/FileDataStorageManager.java | 284 +++--- .../android/datamodel/OCCameraUploadSync.java | 6 +- .../owncloud/android/datamodel/OCFile.java | 62 +- .../owncloud/android/datamodel/OCUpload.java | 53 +- .../datamodel/ThumbnailsCacheManager.java | 124 ++- .../datamodel/UploadsStorageManager.java | 12 +- .../android/datamodel/UserProfile.java | 33 +- .../datamodel/UserProfilesRepository.java | 109 ++- .../android/db/PreferenceManager.java | 3 +- .../com/owncloud/android/db/ProviderMeta.java | 45 +- .../com/owncloud/android/db/UploadResult.java | 36 +- .../android/features/FeatureList.java | 87 +- .../android/files/FileMenuFilter.java | 91 +- .../services/AvailableOfflineHandler.java | 8 +- .../AvailableOfflineSyncJobService.java | 8 +- .../files/services/CameraUploadsHandler.java | 10 +- .../services/CameraUploadsSyncJobService.java | 11 +- .../files/services/FileDownloader.java | 137 ++- .../android/files/services/FileUploader.java | 158 ++-- .../android/files/services/IndexedForest.java | 45 +- .../services/RetryDownloadJobService.java | 59 +- .../files/services/RetryUploadJobService.java | 47 +- .../files/services/TransferRequester.java | 18 +- .../android/media/MediaControlView.java | 121 +-- .../owncloud/android/media/MediaService.java | 249 +++--- .../android/media/MediaServiceBinder.java | 57 +- .../operations/AuthenticationMethod.java | 31 +- .../CheckCurrentCredentialsOperation.java | 39 +- .../ChunkedUploadFileOperation.java | 43 +- .../android/operations/CopyFileOperation.java | 3 - .../CreateChunksFolderOperation.java | 33 +- .../operations/CreateFolderOperation.java | 60 +- .../CreateShareViaLinkOperation.java | 8 +- .../CreateShareWithShareeOperation.java | 50 +- .../DetectAuthenticationMethodOperation.java | 15 +- .../operations/DownloadFileOperation.java | 104 ++- .../operations/GetServerInfoOperation.java | 15 +- .../operations/GetSharesForFileOperation.java | 41 +- .../operations/GetUserProfileOperation.java | 56 +- .../operations/MoveChunksFileOperation.java | 31 +- .../android/operations/MoveFileOperation.java | 68 +- .../operations/RefreshFolderOperation.java | 92 +- .../RemoveChunksFolderOperation.java | 31 +- .../operations/RemoveFileOperation.java | 57 +- .../operations/RemoveShareOperation.java | 50 +- .../operations/RenameFileOperation.java | 86 +- .../operations/SyncCapabilitiesOperation.java | 41 +- .../operations/SynchronizeFileOperation.java | 55 +- .../SynchronizeFolderOperation.java | 118 ++- .../UpdateSharePermissionsOperation.java | 36 +- .../UpdateShareViaLinkOperation.java | 41 +- .../operations/UploadFileOperation.java | 108 +-- .../operations/common/SyncOperation.java | 65 +- .../providers/DocumentsStorageProvider.java | 63 +- .../providers/FileContentProvider.java | 19 +- .../UsersAndGroupsSearchProvider.java | 40 +- .../android/providers/cursors/FileCursor.java | 39 +- .../android/providers/cursors/RootCursor.java | 36 +- .../android/services/OperationsService.java | 148 ++-- .../android/services/SyncFolderHandler.java | 47 +- .../AbstractOwnCloudSyncAdapter.java | 57 +- .../android/syncadapter/FileSyncAdapter.java | 262 +++--- .../android/syncadapter/FileSyncService.java | 45 +- .../com/owncloud/android/ui/ActionItem.java | 33 +- .../ui/CheckBoxPreferenceWithLongTitle.java | 36 +- .../com/owncloud/android/ui/CustomPopup.java | 35 +- .../android/ui/DefaultAvatarTextDrawable.java | 8 +- .../owncloud/android/ui/ExtendedListView.java | 35 +- .../android/ui/PreferenceWithLongSummary.java | 36 +- .../owncloud/android/ui/SquareImageView.java | 34 +- .../android/ui/SquareLinearLayout.java | 31 +- .../android/ui/activity/BaseActivity.java | 16 +- .../android/ui/activity/ComponentsGetter.java | 51 +- .../ui/activity/ConflictsResolveActivity.java | 35 +- .../ui/activity/CopyToClipboardActivity.java | 43 +- .../android/ui/activity/DrawerActivity.java | 101 ++- .../ErrorsWhileCopyingHandlerActivity.java | 110 ++- .../android/ui/activity/FileActivity.java | 80 +- .../ui/activity/FileDisplayActivity.java | 41 +- .../ui/activity/FingerprintActivity.java | 42 +- .../ui/activity/FolderPickerActivity.java | 199 +++-- .../activity/GenericExplanationActivity.java | 53 +- .../activity/LocalFolderPickerActivity.java | 62 +- .../ui/activity/LogHistoryActivity.java | 14 +- .../ui/activity/ManageAccountsActivity.java | 35 +- .../ui/activity/ManageSpaceActivity.java | 63 +- .../OnEnforceableRefreshListener.java | 40 +- .../android/ui/activity/PassCodeActivity.java | 87 +- .../ui/activity/PatternLockActivity.java | 26 +- .../android/ui/activity/Preferences.java | 14 +- .../ui/activity/PrivacyPolicyActivity.java | 42 +- .../ReceiveExternalFilesActivity.java | 39 +- .../android/ui/activity/ShareActivity.java | 25 +- .../android/ui/activity/ToolbarActivity.java | 36 +- .../ui/activity/UploadFilesActivity.java | 71 +- .../ui/activity/UploadListActivity.java | 77 +- .../ui/activity/UploadPathActivity.java | 32 +- .../android/ui/activity/WhatsNewActivity.java | 86 +- .../ui/adapter/AccountListAdapter.java | 17 +- .../android/ui/adapter/AccountListItem.java | 30 +- ...rtificateCombinedExceptionViewAdapter.java | 51 +- .../android/ui/adapter/DiskLruImageCache.java | 132 ++- .../adapter/ExpandableUploadListAdapter.java | 124 ++- .../ui/adapter/FileListListAdapter.java | 33 +- .../ui/adapter/LocalFileListAdapter.java | 29 +- .../android/ui/adapter/LogListAdapter.java | 4 +- .../adapter/ReceiveExternalFilesAdapter.java | 51 +- .../adapter/SharePublicLinkListAdapter.java | 15 +- .../ui/adapter/ShareUserListAdapter.java | 40 +- .../ui/adapter/SslCertificateViewAdapter.java | 73 +- .../ui/adapter/SslErrorViewAdapter.java | 51 +- .../adapter/X509CertificateViewAdapter.java | 99 ++- .../CopyAndUploadContentUrisTask.java | 103 ++- .../asynctasks/GetSharesForFileAsyncTask.java | 39 +- .../TransferProgressController.java | 65 +- .../ui/dialog/ConfirmationDialogFragment.java | 88 +- .../ui/dialog/ConflictsResolveDialog.java | 95 +- .../ui/dialog/CreateFolderDialogFragment.java | 90 +- .../ui/dialog/CredentialsDialogFragment.java | 74 +- .../ExpirationDatePickerDialogFragment.java | 16 +- .../dialog/FingerprintAuthDialogFragment.java | 2 +- .../android/ui/dialog/LoadingDialog.java | 48 +- .../android/ui/dialog/LoginWebViewDialog.java | 125 ++- .../ui/dialog/OwnCloudListPreference.java | 8 +- .../android/ui/dialog/RateMeDialog.java | 49 +- .../dialog/RemoveAccountDialogFragment.java | 62 +- .../ui/dialog/RemoveFilesDialogFragment.java | 75 +- .../ui/dialog/RemoveShareDialogFragment.java | 60 +- .../ui/dialog/RenameFileDialogFragment.java | 88 +- .../android/ui/dialog/ShareLinkToDialog.java | 133 ++- .../ui/dialog/SslUntrustedCertDialog.java | 122 +-- .../android/ui/dialog/SsoWebView.java | 41 +- .../ui/errorhandling/ErrorMessageAdapter.java | 251 ++++-- .../ui/errorhandling/ErrorShowActivity.java | 8 +- .../ui/errorhandling/ExceptionHandler.java | 129 ++- .../ui/fragment/EditShareFragment.java | 81 +- .../ui/fragment/ExpandableListFragment.java | 20 +- .../ui/fragment/ExtendedListFragment.java | 108 ++- .../ui/fragment/FileDetailFragment.java | 98 +-- .../android/ui/fragment/FileFragment.java | 68 +- .../ui/fragment/LocalFileListFragment.java | 15 +- .../ui/fragment/OCFileListFragment.java | 179 ++-- .../fragment/PublicShareDialogFragment.java | 37 +- .../ui/fragment/SearchShareesFragment.java | 51 +- .../ui/fragment/ShareFileFragment.java | 15 +- .../ui/fragment/ShareFragmentListener.java | 42 +- .../ui/fragment/TaskRetainerFragment.java | 33 +- .../ui/fragment/UploadListFragment.java | 51 +- .../ui/helpers/FileOperationsHelper.java | 128 ++- .../android/ui/helpers/FilesUploadHelper.java | 72 +- .../helpers/SparseBooleanArrayParcelable.java | 75 +- .../android/ui/helpers/UriUploader.java | 33 +- .../ui/notifications/NotificationUtils.java | 57 +- .../preview/CustomHttpDataSourceFactory.java | 25 +- .../ui/preview/FileDownloadFragment.java | 70 +- .../android/ui/preview/ImageViewCustom.java | 20 +- .../preview/PrepareVideoPlayerAsyncTask.java | 8 +- .../ui/preview/PreviewAudioFragment.java | 100 +-- .../ui/preview/PreviewImageActivity.java | 205 +++-- .../ui/preview/PreviewImageFragment.java | 75 +- .../ui/preview/PreviewImagePagerAdapter.java | 27 +- .../ui/preview/PreviewTextFragment.java | 64 +- .../ui/preview/PreviewVideoActivity.java | 9 +- .../android/ui/preview/PreviewVideoError.java | 37 +- .../ui/preview/PreviewVideoErrorAdapter.java | 34 +- .../ui/preview/PreviewVideoFragment.java | 22 +- .../ui/whatsnew/ProgressIndicator.java | 45 +- .../owncloud/android/utils/BitmapUtils.java | 123 ++- .../android/utils/ConnectivityUtils.java | 36 +- .../com/owncloud/android/utils/DateUtils.java | 32 +- .../owncloud/android/utils/DisplayUtils.java | 8 +- .../com/owncloud/android/utils/Extras.java | 34 +- .../android/utils/FileStorageUtils.java | 4 +- .../android/utils/MimetypeIconUtil.java | 132 +-- .../android/utils/OwnCloudSession.java | 33 +- .../android/utils/PermissionUtil.java | 4 +- .../owncloud/android/utils/PowerUtils.java | 34 +- .../android/utils/PreferenceUtils.java | 6 +- .../owncloud/android/utils/SecurityUtils.java | 32 +- .../com/owncloud/android/utils/UriUtils.java | 68 +- .../android/widgets/ActionEditText.java | 57 +- .../daveKoeller/AlphanumComparator.java | 13 +- .../cube/GridViewWithHeaderAndFooter.java | 24 +- owncloudApp/src/main/res/anim/disappear.xml | 11 +- .../src/main/res/anim/grow_from_bottom.xml | 26 +- .../anim/grow_from_bottomleft_to_topright.xml | 26 +- .../anim/grow_from_bottomright_to_topleft.xml | 26 +- .../src/main/res/anim/grow_from_top.xml | 26 +- .../anim/grow_from_topleft_to_bottomright.xml | 26 +- .../anim/grow_from_topright_to_bottomleft.xml | 26 +- owncloudApp/src/main/res/anim/pump_bottom.xml | 26 +- owncloudApp/src/main/res/anim/pump_top.xml | 26 +- .../src/main/res/anim/shrink_from_bottom.xml | 26 +- .../shrink_from_bottomleft_to_topright.xml | 26 +- .../shrink_from_bottomright_to_topleft.xml | 26 +- .../src/main/res/anim/shrink_from_top.xml | 26 +- .../shrink_from_topleft_to_bottomright.xml | 26 +- .../shrink_from_topright_to_bottomleft.xml | 26 +- .../src/main/res/anim/slide_in_left.xml | 10 +- .../src/main/res/anim/slide_in_right.xml | 10 +- .../src/main/res/anim/slide_out_left.xml | 10 +- .../src/main/res/anim/slide_out_right.xml | 10 +- .../src/main/res/drawable/action_item_btn.xml | 20 +- owncloudApp/src/main/res/drawable/btn.xml | 10 +- .../src/main/res/drawable/btn_round.xml | 20 +- .../main/res/drawable/btn_round_pressed.xml | 20 +- .../src/main/res/drawable/btn_small_round.xml | 101 ++- .../res/drawable/fab_label_background.xml | 6 +- .../main/res/drawable/ic_star_black_24dp.xml | 10 +- .../drawable/indicator_dot_not_selected.xml | 12 +- .../res/drawable/indicator_dot_selected.xml | 12 +- .../src/main/res/drawable/list_selector.xml | 4 +- .../src/main/res/drawable/logo_icon.xml | 19 +- .../src/main/res/drawable/progress_small.xml | 4 +- .../src/main/res/drawable/round_button.xml | 2 +- .../src/main/res/drawable/shadow_gradient.xml | 5 +- .../top_progress_bar_indeterminate.xml | 36 +- .../res/drawable/uploader_list_separator.xml | 7 +- .../src/main/res/layout/account_action.xml | 4 +- .../src/main/res/layout/account_item.xml | 13 +- .../src/main/res/layout/account_setup.xml | 26 +- .../src/main/res/layout/accounts_layout.xml | 28 +- .../res/layout/activity_privacy_policy.xml | 3 +- .../src/main/res/layout/activity_row.xml | 52 +- .../res/layout/custom_playback_control.xml | 45 +- .../main/res/layout/dialog_upload_text.xml | 2 +- owncloudApp/src/main/res/layout/drawer.xml | 6 +- .../src/main/res/layout/drawer_header.xml | 12 +- .../src/main/res/layout/edit_box_dialog.xml | 2 +- .../src/main/res/layout/edit_share_layout.xml | 107 +-- .../src/main/res/layout/file_actions.xml | 2 +- .../main/res/layout/file_details_empty.xml | 8 +- .../main/res/layout/file_details_fragment.xml | 20 +- .../res/layout/file_download_fragment.xml | 127 +-- .../main/res/layout/fingerprint_dialog.xml | 20 +- .../main/res/layout/generic_explanation.xml | 58 +- .../src/main/res/layout/grid_image.xml | 4 +- owncloudApp/src/main/res/layout/grid_item.xml | 2 +- .../src/main/res/layout/list_fragment.xml | 1 - .../res/layout/list_fragment_expandable.xml | 28 +- owncloudApp/src/main/res/layout/list_item.xml | 11 +- .../src/main/res/layout/listrow_details.xml | 2 +- .../src/main/res/layout/listrow_group.xml | 3 +- .../src/main/res/layout/loading_dialog.xml | 2 +- .../src/main/res/layout/media_control.xml | 27 +- .../src/main/res/layout/passcodelock.xml | 14 +- .../src/main/res/layout/password_dialog.xml | 2 +- owncloudApp/src/main/res/layout/popup.xml | 53 +- .../res/layout/preview_audio_fragment.xml | 4 +- .../res/layout/preview_image_fragment.xml | 6 +- .../main/res/layout/preview_text_fragment.xml | 4 +- .../src/main/res/layout/rate_me_dialog.xml | 10 +- .../main/res/layout/search_suggestion_row.xml | 48 +- .../main/res/layout/share_public_dialog.xml | 7 +- .../src/main/res/layout/share_user_item.xml | 9 +- .../res/layout/simple_dialog_list_item.xml | 2 +- .../res/layout/ssl_untrusted_cert_layout.xml | 812 +++++++++--------- .../main/res/layout/ssl_validator_layout.xml | 741 ++++++++-------- .../src/main/res/layout/toolbar_standard.xml | 2 +- .../src/main/res/layout/top_progress_bar.xml | 2 +- .../main/res/layout/upload_files_layout.xml | 20 +- .../src/main/res/layout/upload_list_group.xml | 4 +- .../src/main/res/layout/upload_list_item.xml | 30 +- .../main/res/layout/upload_list_layout.xml | 6 +- .../res/layout/uploader_list_item_layout.xml | 6 +- .../src/main/res/layout/video_layout.xml | 20 +- .../src/main/res/layout/video_preview.xml | 8 +- .../src/main/res/layout/webview_dialog.xml | 2 +- .../main/res/layout/whats_new_activity.xml | 10 +- .../src/main/res/layout/whats_new_element.xml | 14 +- .../res/menu/account_picker_long_click.xml | 10 +- owncloudApp/src/main/res/menu/drawer_menu.xml | 19 +- .../src/main/res/menu/file_actions_menu.xml | 9 +- owncloudApp/src/main/res/menu/main_menu.xml | 11 +- .../src/main/res/menu/upload_files_menu.xml | 4 +- .../src/main/res/menu/upload_list_menu.xml | 10 +- owncloudApp/src/main/res/values/attrs.xml | 14 +- owncloudApp/src/main/res/values/colors.xml | 1 - owncloudApp/src/main/res/values/dims.xml | 2 +- owncloudApp/src/main/res/values/setup.xml | 34 +- owncloudApp/src/main/res/values/styles.xml | 12 +- .../src/main/res/xml/authenticator.xml | 8 +- .../src/main/res/xml/exposed_filepaths.xml | 6 +- owncloudApp/src/main/res/xml/preferences.xml | 3 +- .../src/main/res/xml/syncadapter_files.xml | 2 +- .../res/xml/users_and_groups_searchable.xml | 2 +- .../utils/ErrorMessageAdapterUnitTest.java | 44 +- tests/AndroidManifest.xml | 13 +- .../android/test/AccountUtilsTest.java | 42 +- .../android/test/FileContentProviderTest.java | 79 +- 375 files changed, 11298 insertions(+), 11653 deletions(-) diff --git a/.drone.yml b/.drone.yml index bef4eecae9c..9f901377306 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ workspace: path: src branches: - - master +- master clone: git: @@ -23,35 +23,35 @@ pipeline: image: owncloudci/nodejs:11 pull: true commands: - - cd docs/ - - yarn install + - cd docs/ + - yarn install docs-validate: image: owncloudci/nodejs:11 pull: true commands: - - cd docs/ - - yarn validate + - cd docs/ + - yarn validate docs-build: image: owncloudci/nodejs:11 pull: true commands: - - cd docs/ - - yarn antora + - cd docs/ + - yarn antora docs-pdf: image: owncloudci/asciidoctor:latest pull: true commands: - - cd docs/ - - make pdf + - cd docs/ + - make pdf docs-artifacts: image: owncloud/ubuntu:latest pull: true commands: - - tree docs/public/ + - tree docs/public/ cache-rebuild: image: plugins/s3-cache:1 @@ -59,7 +59,7 @@ pipeline: secrets: [ cache_s3_endpoint, cache_s3_access_key, cache_s3_secret_key ] rebuild: true mount: - - docs/cache + - docs/cache when: local: false event: [ push ] diff --git a/.travis.yml b/.travis.yml index 9781c3711c6..87df7d10a66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ sudo: false language: android jdk: - - oraclejdk8 +- oraclejdk8 # INSTRUMENTED TESTS ARE DISABLED - until Google or Travis fix the mess with emulation, only local tests are enabled # - sys-img-armeabi-v7a-android-24 @@ -24,11 +24,11 @@ install: # - ./wait_for_emulator.sh script: # force init of adb way before any Gradle task that uses ADB; prevents a timeout error that skips emulators of android-24 - - adb devices +- adb devices # build app and assemble APK, in debug mode - - ./gradlew :owncloudApp:assembleDebug +- ./gradlew :owncloudApp:assembleDebug # run all the local unit tests of app module - - ./gradlew :owncloudApp:testDebug +- ./gradlew :owncloudApp:testDebug # run all the instrumented tests of app module - DISABLED until we get an stable setup for Espresso in Travis # - ./gradlew :owncloudApp:connectedDebugAndroidTest --info # install app, then assemble and install instrumented tests of app module diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java b/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java index 1adc190e6d3..5bd5a219104 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java @@ -1,244 +1,240 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.actions; -import java.util.HashMap; - -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.ScreenOrientation; -import org.openqa.selenium.remote.RemoteWebElement; -import io.appium.java_client.android.AndroidDriver; -import io.appium.java_client.android.AndroidElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import com.owncloud.android.test.ui.models.CertificatePopUp; import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileListView; import com.owncloud.android.test.ui.models.GmailSendMailView; -import com.owncloud.android.test.ui.models.ShareView; -import com.owncloud.android.test.ui.models.UploadFilesView; import com.owncloud.android.test.ui.models.LoginForm; -import com.owncloud.android.test.ui.models.FileListView; import com.owncloud.android.test.ui.models.MenuList; import com.owncloud.android.test.ui.models.NewFolderPopUp; import com.owncloud.android.test.ui.models.RemoveConfirmationView; import com.owncloud.android.test.ui.models.SettingsView; +import com.owncloud.android.test.ui.models.ShareView; +import com.owncloud.android.test.ui.models.UploadFilesView; import com.owncloud.android.test.ui.models.WaitAMomentPopUp; import com.owncloud.android.test.ui.testSuites.Common; import com.owncloud.android.test.ui.testSuites.Config; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.util.HashMap; public class Actions { - public static FileListView login(String url, String user, String password, - Boolean isTrusted, AndroidDriver driver) - throws InterruptedException { - LoginForm loginForm = new LoginForm(driver); - CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url); - if(!isTrusted){ - WebDriverWait wait = new WebDriverWait(driver, 30); - //sometimes the certificate has been already accept - //and it doesn't appear again - try { - wait.until(ExpectedConditions - .visibilityOf(certificatePopUp.getOkButtonElement())); - //we need to repaint the screen - //because of some element are misplaced - driver.rotate(ScreenOrientation.LANDSCAPE); - driver.rotate(ScreenOrientation.PORTRAIT); - certificatePopUp.clickOnOkButton(); - }catch (NoSuchElementException e) { - - } - - } - loginForm.typeUserName(user); - loginForm.typePassword(password); - //TODO. Assert related to check the connection? - return loginForm.clickOnConnectButton(); - } - - public static WaitAMomentPopUp createFolder(String folderName, - FileListView fileListView){ - NewFolderPopUp newFolderPopUp = fileListView.clickOnNewFolderButton(); - newFolderPopUp.typeNewFolderName(folderName); - WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp - .clickOnNewFolderOkButton(); - //TODO. assert here - return waitAMomentPopUp; - } - - - public static AndroidElement scrollTillFindElement (String elementName, - AndroidElement element, AndroidDriver driver) { - AndroidElement fileElement; - - if(element.getAttribute("scrollable").equals("true")){ - HashMap scrollObject = new HashMap(); - scrollObject.put("text", elementName); - scrollObject.put("element", ( (RemoteWebElement) element).getId()); - driver.executeScript("mobile: scrollTo", scrollObject); - } - try { - fileElement = (AndroidElement) driver - .findElementByName(elementName); - } catch (NoSuchElementException e) { - fileElement = null; - } - return fileElement; - } - - - public static void deleteAccount (int accountPosition,FileListView fileListView) { - MenuList menulist = fileListView.clickOnMenuButton(); - SettingsView settingView = menulist.clickOnSettingsButton(); - deleteAccount(accountPosition,settingView); - } - - public static void deleteAccount (int accountPosition, SettingsView settingsView) { - settingsView.tapOnAccountElement(accountPosition,1, 1000); - settingsView.clickOnDeleteAccountElement(); - } - - public static void clickOnMainLayout(AndroidDriver driver){ - driver.tap(1, 0, 0, 1); - } - - - public static AndroidElement deleteElement(String elementName, - FileListView fileListView, AndroidDriver driver) throws Exception{ - AndroidElement fileElement; - WaitAMomentPopUp waitAMomentPopUp; - try{ - //To open directly the "file list view" and - //we don't need to know in which view we are - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - fileElement = (AndroidElement) driver - .findElementByName(elementName); - ElementMenuOptions menuOptions = fileListView - .longPressOnElement(elementName); - RemoveConfirmationView removeConfirmationView = menuOptions - .clickOnRemove();; - waitAMomentPopUp = removeConfirmationView - .clickOnRemoteAndLocalButton(); - Common.waitTillElementIsNotPresent( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); - }catch(NoSuchElementException e){ - fileElement=null; - } - return fileElement; - } - - public static AndroidElement shareLinkElementByGmail(String elementName, - FileListView fileListView, AndroidDriver driver, Common common) - throws Exception{ - try{ - //To open directly the "file list view" and - //we don't need to know in which view we are - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - ElementMenuOptions menuOptions = fileListView - .longPressOnElement(elementName); - ShareView shareView = menuOptions.clickOnShareLinkElement(); - Actions.scrollTillFindElement("Gmail", shareView - .getListViewLayout(), driver).click(); - GmailSendMailView gmailSendMailView = new GmailSendMailView(driver); - gmailSendMailView.typeToEmailAdress(Config.gmailAccount); - gmailSendMailView.clickOnSendButton(); - Common.waitTillElementIsNotPresentWithoutTimeout(fileListView - .getProgressCircular(), 1000); - common.wait.until(ExpectedConditions.visibilityOf( - fileListView.getFileElementLayout() - .findElement(By.id(FileListView - .getSharedElementIndicator())))); - - }catch(NoSuchElementException e){ - return null; - } - return (AndroidElement) fileListView.getFileElementLayout() - .findElement(By.id(FileListView.getSharedElementIndicator())); - } - - public static AndroidElement shareLinkElementByCopyLink(String elementName, - FileListView fileListView, AndroidDriver driver, Common common) - throws Exception{ - try{ - //To open directly the "file list view" and - //we don't need to know in which view we are - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - ElementMenuOptions menuOptions = fileListView - .longPressOnElement(elementName); - ShareView shareView = menuOptions.clickOnShareLinkElement(); - Actions.scrollTillFindElement("Copy link", shareView.getListViewLayout(), - driver).click(); - WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); - Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp - .getWaitAMomentTextElement(), 100); - common.wait.until(ExpectedConditions.visibilityOf( - fileListView.getFileElementLayout() - .findElement(By.id(FileListView.getSharedElementIndicator())))); - }catch(NoSuchElementException e){ - return null; - } - return (AndroidElement) fileListView.getFileElementLayout() - .findElement(By.id(FileListView.getSharedElementIndicator())); - } - - - public static void unshareLinkElement(String elementName, - FileListView fileListView, AndroidDriver driver, Common common) - throws Exception{ - try{ - //To open directly the "file list view" and - //we don't need to know in which view we are - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - ElementMenuOptions menuOptions = fileListView - .longPressOnElement(elementName); - WaitAMomentPopUp waitAMomentPopUp = menuOptions - .clickOnUnshareLinkElement(); - Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp - .getWaitAMomentTextElement(), 100); - Common.waitTillElementIsNotPresent((AndroidElement) fileListView - .getFileElementLayout() - .findElement(By.id(FileListView.getSharedElementIndicator()) - ),100); - }catch(NoSuchElementException e){ - - } - } - - - public static FileListView uploadFile(String elementName, - FileListView fileListView) throws InterruptedException{ - fileListView.clickOnUploadButton(); - UploadFilesView uploadFilesView = fileListView - .clickOnFilesElementUploadFile(); - uploadFilesView.clickOnFileName(elementName); - FileListView fileListViewAfterUploadFile = uploadFilesView - .clickOnUploadButton(); - //TO DO. detect when the file is successfully uploaded - Thread.sleep(15000); - return fileListViewAfterUploadFile; - } - + public static FileListView login(String url, String user, String password, + Boolean isTrusted, AndroidDriver driver) + throws InterruptedException { + LoginForm loginForm = new LoginForm(driver); + CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url); + if (!isTrusted) { + WebDriverWait wait = new WebDriverWait(driver, 30); + //sometimes the certificate has been already accept + //and it doesn't appear again + try { + wait.until(ExpectedConditions + .visibilityOf(certificatePopUp.getOkButtonElement())); + //we need to repaint the screen + //because of some element are misplaced + driver.rotate(ScreenOrientation.LANDSCAPE); + driver.rotate(ScreenOrientation.PORTRAIT); + certificatePopUp.clickOnOkButton(); + } catch (NoSuchElementException e) { + + } + + } + loginForm.typeUserName(user); + loginForm.typePassword(password); + //TODO. Assert related to check the connection? + return loginForm.clickOnConnectButton(); + } + + public static WaitAMomentPopUp createFolder(String folderName, + FileListView fileListView) { + NewFolderPopUp newFolderPopUp = fileListView.clickOnNewFolderButton(); + newFolderPopUp.typeNewFolderName(folderName); + WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp + .clickOnNewFolderOkButton(); + //TODO. assert here + return waitAMomentPopUp; + } + + public static AndroidElement scrollTillFindElement(String elementName, + AndroidElement element, AndroidDriver driver) { + AndroidElement fileElement; + + if (element.getAttribute("scrollable").equals("true")) { + HashMap scrollObject = new HashMap(); + scrollObject.put("text", elementName); + scrollObject.put("element", ((RemoteWebElement) element).getId()); + driver.executeScript("mobile: scrollTo", scrollObject); + } + try { + fileElement = (AndroidElement) driver + .findElementByName(elementName); + } catch (NoSuchElementException e) { + fileElement = null; + } + return fileElement; + } + + public static void deleteAccount(int accountPosition, FileListView fileListView) { + MenuList menulist = fileListView.clickOnMenuButton(); + SettingsView settingView = menulist.clickOnSettingsButton(); + deleteAccount(accountPosition, settingView); + } + + public static void deleteAccount(int accountPosition, SettingsView settingsView) { + settingsView.tapOnAccountElement(accountPosition, 1, 1000); + settingsView.clickOnDeleteAccountElement(); + } + + public static void clickOnMainLayout(AndroidDriver driver) { + driver.tap(1, 0, 0, 1); + } + + public static AndroidElement deleteElement(String elementName, + FileListView fileListView, AndroidDriver driver) throws Exception { + AndroidElement fileElement; + WaitAMomentPopUp waitAMomentPopUp; + try { + //To open directly the "file list view" and + //we don't need to know in which view we are + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + fileElement = (AndroidElement) driver + .findElementByName(elementName); + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(elementName); + RemoveConfirmationView removeConfirmationView = menuOptions + .clickOnRemove(); + ; + waitAMomentPopUp = removeConfirmationView + .clickOnRemoteAndLocalButton(); + Common.waitTillElementIsNotPresent( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); + } catch (NoSuchElementException e) { + fileElement = null; + } + return fileElement; + } + + public static AndroidElement shareLinkElementByGmail(String elementName, + FileListView fileListView, AndroidDriver driver, Common common) + throws Exception { + try { + //To open directly the "file list view" and + //we don't need to know in which view we are + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(elementName); + ShareView shareView = menuOptions.clickOnShareLinkElement(); + Actions.scrollTillFindElement("Gmail", shareView + .getListViewLayout(), driver).click(); + GmailSendMailView gmailSendMailView = new GmailSendMailView(driver); + gmailSendMailView.typeToEmailAdress(Config.gmailAccount); + gmailSendMailView.clickOnSendButton(); + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView + .getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf( + fileListView.getFileElementLayout() + .findElement(By.id(FileListView + .getSharedElementIndicator())))); + + } catch (NoSuchElementException e) { + return null; + } + return (AndroidElement) fileListView.getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator())); + } + + public static AndroidElement shareLinkElementByCopyLink(String elementName, + FileListView fileListView, AndroidDriver driver, + Common common) + throws Exception { + try { + //To open directly the "file list view" and + //we don't need to know in which view we are + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(elementName); + ShareView shareView = menuOptions.clickOnShareLinkElement(); + Actions.scrollTillFindElement("Copy link", shareView.getListViewLayout(), + driver).click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + common.wait.until(ExpectedConditions.visibilityOf( + fileListView.getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator())))); + } catch (NoSuchElementException e) { + return null; + } + return (AndroidElement) fileListView.getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator())); + } + + public static void unshareLinkElement(String elementName, + FileListView fileListView, AndroidDriver driver, Common common) + throws Exception { + try { + //To open directly the "file list view" and + //we don't need to know in which view we are + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(elementName); + WaitAMomentPopUp waitAMomentPopUp = menuOptions + .clickOnUnshareLinkElement(); + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent((AndroidElement) fileListView + .getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator()) + ), 100); + } catch (NoSuchElementException e) { + + } + } + + public static FileListView uploadFile(String elementName, + FileListView fileListView) throws InterruptedException { + fileListView.clickOnUploadButton(); + UploadFilesView uploadFilesView = fileListView + .clickOnFilesElementUploadFile(); + uploadFilesView.clickOnFileName(elementName); + FileListView fileListViewAfterUploadFile = uploadFilesView + .clickOnUploadButton(); + //TO DO. detect when the file is successfully uploaded + Thread.sleep(15000); + return fileListViewAfterUploadFile; + } + } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java index 74b7406f7df..aea61723539 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java @@ -1,22 +1,22 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.groups; -public interface FailingTestCategory extends IgnoreTestCategory {} +public interface FailingTestCategory extends IgnoreTestCategory { +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java index 94a019afffd..020ea84923a 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java @@ -1,9 +1,5 @@ package com.owncloud.android.test.ui.groups; -import java.lang.annotation.Annotation; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - import org.junit.Test; import org.junit.experimental.categories.Categories.CategoryFilter; import org.junit.experimental.categories.Categories.ExcludeCategory; @@ -15,124 +11,136 @@ import org.junit.runners.model.InitializationError; import org.junit.runners.model.RunnerBuilder; +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + /** * This class is based on org.junit.experimental.categories.Categories from JUnit 4.10. - * + *

* All anotations and inner classes from the original class Categories are removed, * since they will be re-used. * Unfortunately sub-classing Categories did not work. */ public class FlexibleCategories extends Suite { - /** - * Specifies the package which should be scanned for test classes (e.g. @TestScanPackage("my.package")). - * This annotation is required. - */ - @Retention(RetentionPolicy.RUNTIME) - public @interface TestScanPackage { - public String value(); - } - - /** - * Specifies the prefix of matching class names (e.g. @TestClassPrefix("Test")). - * This annotation is optional (default: ""). - */ - @Retention(RetentionPolicy.RUNTIME) - public @interface TestClassPrefix { - public String value(); - } - - /** - * Specifies the suffix of matching class names (e.g. @TestClassSuffix("Test")). - * This annotation is optional (default: "Test"). - */ - @Retention(RetentionPolicy.RUNTIME) - public @interface TestClassSuffix { - public String value(); - } - - /** - * Specifies an annotation for methods which must be present in a matching class (e.g. @TestMethodAnnotationFilter(Test.class)). - * This annotation is optional (default: org.junit.Test.class). - */ - @Retention(RetentionPolicy.RUNTIME) - public @interface TestMethodAnnotation { - public Class value(); - } - - public FlexibleCategories(Class clazz, RunnerBuilder builder) - throws InitializationError { - this(builder, clazz, PatternClasspathClassesFinder.getSuiteClasses( - getTestScanPackage(clazz), getTestClassPrefix(clazz), getTestClassSuffix(clazz), - getTestMethodAnnotation(clazz))); - try { - filter(new CategoryFilter(getIncludedCategory(clazz), - getExcludedCategory(clazz))); - } catch (NoTestsRemainException e) { - // Ignore all classes with no matching tests. - } - assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription()); - } - - public FlexibleCategories(RunnerBuilder builder, Class clazz, - Class[] suiteClasses) throws InitializationError { - super(builder, clazz, suiteClasses); - } - - private static String getTestScanPackage(Class clazz) throws InitializationError { - TestScanPackage annotation = clazz.getAnnotation(TestScanPackage.class); - if (annotation == null) { - throw new InitializationError("No package given to scan for tests!\nUse the annotation @TestScanPackage(\"my.package\") on the test suite " + clazz + "."); - } - return annotation.value(); - } - - private static String getTestClassPrefix(Class clazz) { - TestClassPrefix annotation = clazz.getAnnotation(TestClassPrefix.class); - return annotation == null ? "" : annotation.value(); - } - - private static String getTestClassSuffix(Class clazz) { - TestClassSuffix annotation = clazz.getAnnotation(TestClassSuffix.class); - return annotation == null ? "Test" : annotation.value(); - } - - private static Class getTestMethodAnnotation(Class clazz) { - TestMethodAnnotation annotation = clazz.getAnnotation(TestMethodAnnotation.class); - return annotation == null ? Test.class : annotation.value(); - } - - private Class getIncludedCategory(Class clazz) { - IncludeCategory annotation= clazz.getAnnotation(IncludeCategory.class); - return annotation == null ? null : annotation.value(); - } - - private Class getExcludedCategory(Class clazz) { - ExcludeCategory annotation= clazz.getAnnotation(ExcludeCategory.class); - return annotation == null ? null : annotation.value(); - } - - private void assertNoCategorizedDescendentsOfUncategorizeableParents(Description description) throws InitializationError { - if (!canHaveCategorizedChildren(description)) - assertNoDescendantsHaveCategoryAnnotations(description); - for (Description each : description.getChildren()) - assertNoCategorizedDescendentsOfUncategorizeableParents(each); - } - - private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError { - for (Description each : description.getChildren()) { - if (each.getAnnotation(Category.class) != null) - throw new InitializationError("Category annotations on Parameterized classes are not supported on individual methods."); - assertNoDescendantsHaveCategoryAnnotations(each); - } - } - - // If children have names like [0], our current magical category code can't determine their - // parentage. - private static boolean canHaveCategorizedChildren(Description description) { - for (Description each : description.getChildren()) - if (each.getTestClass() == null) - return false; - return true; - } + /** + * Specifies the package which should be scanned for test classes (e.g. @TestScanPackage("my.package")). + * This annotation is required. + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestScanPackage { + public String value(); + } + + /** + * Specifies the prefix of matching class names (e.g. @TestClassPrefix("Test")). + * This annotation is optional (default: ""). + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestClassPrefix { + public String value(); + } + + /** + * Specifies the suffix of matching class names (e.g. @TestClassSuffix("Test")). + * This annotation is optional (default: "Test"). + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestClassSuffix { + public String value(); + } + + /** + * Specifies an annotation for methods which must be present in a matching class (e.g. @TestMethodAnnotationFilter + * (Test.class)). + * This annotation is optional (default: org.junit.Test.class). + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestMethodAnnotation { + public Class value(); + } + + public FlexibleCategories(Class clazz, RunnerBuilder builder) + throws InitializationError { + this(builder, clazz, PatternClasspathClassesFinder.getSuiteClasses( + getTestScanPackage(clazz), getTestClassPrefix(clazz), getTestClassSuffix(clazz), + getTestMethodAnnotation(clazz))); + try { + filter(new CategoryFilter(getIncludedCategory(clazz), + getExcludedCategory(clazz))); + } catch (NoTestsRemainException e) { + // Ignore all classes with no matching tests. + } + assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription()); + } + + public FlexibleCategories(RunnerBuilder builder, Class clazz, + Class[] suiteClasses) throws InitializationError { + super(builder, clazz, suiteClasses); + } + + private static String getTestScanPackage(Class clazz) throws InitializationError { + TestScanPackage annotation = clazz.getAnnotation(TestScanPackage.class); + if (annotation == null) { + throw new InitializationError("No package given to scan for tests!\nUse the annotation @TestScanPackage" + + "(\"my.package\") on the test suite " + clazz + "."); + } + return annotation.value(); + } + + private static String getTestClassPrefix(Class clazz) { + TestClassPrefix annotation = clazz.getAnnotation(TestClassPrefix.class); + return annotation == null ? "" : annotation.value(); + } + + private static String getTestClassSuffix(Class clazz) { + TestClassSuffix annotation = clazz.getAnnotation(TestClassSuffix.class); + return annotation == null ? "Test" : annotation.value(); + } + + private static Class getTestMethodAnnotation(Class clazz) { + TestMethodAnnotation annotation = clazz.getAnnotation(TestMethodAnnotation.class); + return annotation == null ? Test.class : annotation.value(); + } + + private Class getIncludedCategory(Class clazz) { + IncludeCategory annotation = clazz.getAnnotation(IncludeCategory.class); + return annotation == null ? null : annotation.value(); + } + + private Class getExcludedCategory(Class clazz) { + ExcludeCategory annotation = clazz.getAnnotation(ExcludeCategory.class); + return annotation == null ? null : annotation.value(); + } + + private void assertNoCategorizedDescendentsOfUncategorizeableParents(Description description) throws InitializationError { + if (!canHaveCategorizedChildren(description)) { + assertNoDescendantsHaveCategoryAnnotations(description); + } + for (Description each : description.getChildren()) { + assertNoCategorizedDescendentsOfUncategorizeableParents(each); + } + } + + private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError { + for (Description each : description.getChildren()) { + if (each.getAnnotation(Category.class) != null) { + throw new InitializationError("Category annotations on Parameterized classes are not supported on " + + "individual methods."); + } + assertNoDescendantsHaveCategoryAnnotations(each); + } + } + + // If children have names like [0], our current magical category code can't determine their + // parentage. + private static boolean canHaveCategorizedChildren(Description description) { + for (Description each : description.getChildren()) { + if (each.getTestClass() == null) { + return false; + } + } + return true; + } } \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java index 7c89e936e6a..83e6a77d634 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java @@ -1,24 +1,24 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.groups; -public interface IgnoreTestCategory {} +public interface IgnoreTestCategory { +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java index 850ff45139f..0213d48fbaa 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java @@ -1,5 +1,5 @@ package com.owncloud.android.test.ui.groups; -public interface InProgressCategory extends IgnoreTestCategory{ +public interface InProgressCategory extends IgnoreTestCategory { } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java index d3e6bde688d..f21569d89d6 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.groups; diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java index 5b05d0afed8..ffb5875d69b 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java @@ -1,23 +1,23 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.groups; -public interface OtherTestCategory extends IgnoreTestCategory {} +public interface OtherTestCategory extends IgnoreTestCategory { +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java index b59888309de..22022670e76 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java @@ -10,132 +10,115 @@ import java.util.List; /** - * * Modified version of ClasspathClassesFinder from: * http://linsolas.free.fr/wordpress/index.php/2011/02/how-to-categorize-junit-tests-with-maven/ - * + *

* The difference is, that it does not search for annotated classes but for classes with a certain * class name prefix and suffix. */ public final class PatternClasspathClassesFinder { - /** - * Get the list of classes of a given package name, and that are annotated - * by a given annotation. - * - * @param packageName - * The package name of the classes. - * @param classPrefix - * The prefix of the class name. - * @param classSuffix - * The suffix of the class name. - * @param methodAnnotation - * Only return classes containing methods annotated with methodAnnotation. - * @return The List of classes that matches the requirements. - */ - public static Class[] getSuiteClasses(String packageName, - String classPrefix, String classSuffix, - Class methodAnnotation) { - try { - return getClasses(packageName, classPrefix, classSuffix, methodAnnotation); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } + /** + * Get the list of classes of a given package name, and that are annotated + * by a given annotation. + * + * @param packageName The package name of the classes. + * @param classPrefix The prefix of the class name. + * @param classSuffix The suffix of the class name. + * @param methodAnnotation Only return classes containing methods annotated with methodAnnotation. + * @return The List of classes that matches the requirements. + */ + public static Class[] getSuiteClasses(String packageName, + String classPrefix, String classSuffix, + Class methodAnnotation) { + try { + return getClasses(packageName, classPrefix, classSuffix, methodAnnotation); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } - /** - * Get the list of classes of a given package name, and that are annotated - * by a given annotation. - * - * @param packageName - * The package name of the classes. - * @param classPrefix - * The prefix of the class name. - * @param classSuffix - * The suffix of the class name. - * @param methodAnnotation - * Only return classes containing methods annotated with methodAnnotation. - * @return The List of classes that matches the requirements. - * @throws ClassNotFoundException - * If something goes wrong... - * @throws IOException - * If something goes wrong... - */ - private static Class[] getClasses(String packageName, - String classPrefix, String classSuffix, - Class methodAnnotation) - throws ClassNotFoundException, IOException { - ClassLoader classLoader = Thread.currentThread() - .getContextClassLoader(); - String path = packageName.replace('.', '/'); - // Get classpath - Enumeration resources = classLoader.getResources(path); - List dirs = new ArrayList(); - while (resources.hasMoreElements()) { - URL resource = resources.nextElement(); - dirs.add(new File(resource.getFile())); - } - // For each classpath, get the classes. - ArrayList> classes = new ArrayList>(); - for (File directory : dirs) { - classes.addAll(findClasses(directory, packageName, classPrefix, classSuffix, methodAnnotation)); - } - return classes.toArray(new Class[classes.size()]); - } + /** + * Get the list of classes of a given package name, and that are annotated + * by a given annotation. + * + * @param packageName The package name of the classes. + * @param classPrefix The prefix of the class name. + * @param classSuffix The suffix of the class name. + * @param methodAnnotation Only return classes containing methods annotated with methodAnnotation. + * @return The List of classes that matches the requirements. + * @throws ClassNotFoundException If something goes wrong... + * @throws IOException If something goes wrong... + */ + private static Class[] getClasses(String packageName, + String classPrefix, String classSuffix, + Class methodAnnotation) + throws ClassNotFoundException, IOException { + ClassLoader classLoader = Thread.currentThread() + .getContextClassLoader(); + String path = packageName.replace('.', '/'); + // Get classpath + Enumeration resources = classLoader.getResources(path); + List dirs = new ArrayList(); + while (resources.hasMoreElements()) { + URL resource = resources.nextElement(); + dirs.add(new File(resource.getFile())); + } + // For each classpath, get the classes. + ArrayList> classes = new ArrayList>(); + for (File directory : dirs) { + classes.addAll(findClasses(directory, packageName, classPrefix, classSuffix, methodAnnotation)); + } + return classes.toArray(new Class[classes.size()]); + } - /** - * Find classes, in a given directory (recursively), for a given package - * name, that are annotated by a given annotation. - * - * @param directory - * The directory where to look for. - * @param packageName - * The package name of the classes. - * @param classPrefix - * The prefix of the class name. - * @param classSuffix - * The suffix of the class name. - * @param methodAnnotation - * Only return classes containing methods annotated with methodAnnotation. - * @return The List of classes that matches the requirements. - * @throws ClassNotFoundException - * If something goes wrong... - */ - private static List> findClasses(File directory, - String packageName, String classPrefix, String classSuffix, - Class methodAnnotation) - throws ClassNotFoundException { - List> classes = new ArrayList>(); - if (!directory.exists()) { - return classes; - } - File[] files = directory.listFiles(); - for (File file : files) { - if (file.isDirectory()) { - classes.addAll(findClasses(file, - packageName + "." + file.getName(), classPrefix, classSuffix, methodAnnotation)); - } else if (file.getName().startsWith(classPrefix) && file.getName().endsWith(classSuffix + ".class")) { - // We remove the .class at the end of the filename to get the - // class name... - Class clazz = Class.forName(packageName - + '.' - + file.getName().substring(0, - file.getName().length() - 6)); + /** + * Find classes, in a given directory (recursively), for a given package + * name, that are annotated by a given annotation. + * + * @param directory The directory where to look for. + * @param packageName The package name of the classes. + * @param classPrefix The prefix of the class name. + * @param classSuffix The suffix of the class name. + * @param methodAnnotation Only return classes containing methods annotated with methodAnnotation. + * @return The List of classes that matches the requirements. + * @throws ClassNotFoundException If something goes wrong... + */ + private static List> findClasses(File directory, + String packageName, String classPrefix, String classSuffix, + Class methodAnnotation) + throws ClassNotFoundException { + List> classes = new ArrayList>(); + if (!directory.exists()) { + return classes; + } + File[] files = directory.listFiles(); + for (File file : files) { + if (file.isDirectory()) { + classes.addAll(findClasses(file, + packageName + "." + file.getName(), classPrefix, classSuffix, methodAnnotation)); + } else if (file.getName().startsWith(classPrefix) && file.getName().endsWith(classSuffix + ".class")) { + // We remove the .class at the end of the filename to get the + // class name... + Class clazz = Class.forName(packageName + + '.' + + file.getName().substring(0, + file.getName().length() - 6)); - // Check, if class contains test methods (prevent "No runnable methods" exception): - boolean classHasTest = false; - for (Method method : clazz.getMethods()) { - if (method.getAnnotation(methodAnnotation) != null) { - classHasTest = true; - break; - } - } - if (classHasTest) { - classes.add(clazz); + // Check, if class contains test methods (prevent "No runnable methods" exception): + boolean classHasTest = false; + for (Method method : clazz.getMethods()) { + if (method.getAnnotation(methodAnnotation) != null) { + classHasTest = true; + break; + } + } + if (classHasTest) { + classes.add(clazz); + } + } + } + return classes; } - } - } - return classes; - } } \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java index 29263922467..352b432ec17 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.groups; diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java index f5c5b6a0bfc..8bed04c754f 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java @@ -1,25 +1,24 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.groups; -public interface UnfinishedTestCategory extends IgnoreTestCategory{ +public interface UnfinishedTestCategory extends IgnoreTestCategory { } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java index 18485f7e46b..e6d433d4159 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,26 +23,25 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.PageFactory; public class CertificatePopUp { - final AndroidDriver driver; - - @AndroidFindBy(name = "OK") - private AndroidElement okButton; - - public CertificatePopUp (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public void clickOnOkButton () { - okButton.click(); - } - - public AndroidElement getOkButtonElement () { - return okButton; - } + final AndroidDriver driver; + + @AndroidFindBy(name = "OK") + private AndroidElement okButton; + + public CertificatePopUp(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void clickOnOkButton() { + okButton.click(); + } + + public AndroidElement getOkButtonElement() { + return okButton; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java index 49c1991240f..758588ff7f9 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,71 +23,69 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.PageFactory; public class ElementMenuOptions { - final AndroidDriver driver; - - @AndroidFindBy(name = "Share link") - private AndroidElement shareLinkElement; - - @AndroidFindBy(name = "Unshare link") - private AndroidElement unshareLinkElement; - - @AndroidFindBy(name = "Details") - private AndroidElement detailsFileElement; - - @AndroidFindBy(name = "Rename") - private AndroidElement renameFileElement; - - @AndroidFindBy(name = "Remove") - private AndroidElement removeFileElement; - - @AndroidFindBy(name = "Move") - private AndroidElement moveElement; - - public ElementMenuOptions (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public FileDetailsView clickOnDetails () { - detailsFileElement.click(); - FileDetailsView fileDetailsView = new FileDetailsView(driver); - return fileDetailsView; - } - - public RemoveConfirmationView clickOnRemove () { - removeFileElement.click(); - RemoveConfirmationView removeConfirmationView = - new RemoveConfirmationView(driver); - return removeConfirmationView; - } - - - public MoveView clickOnMove () { - moveElement.click(); - MoveView moveView = new MoveView(driver); - return moveView; - } - - public NewFolderPopUp clickOnRename () { - renameFileElement.click(); - NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); - return newFolderPopUp; - } - - public ShareView clickOnShareLinkElement () { - shareLinkElement.click(); - ShareView shareView = new ShareView(driver); - return shareView; - } - - public WaitAMomentPopUp clickOnUnshareLinkElement () { - unshareLinkElement.click(); - WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); - return waitAMomentPopUp; - } + final AndroidDriver driver; + + @AndroidFindBy(name = "Share link") + private AndroidElement shareLinkElement; + + @AndroidFindBy(name = "Unshare link") + private AndroidElement unshareLinkElement; + + @AndroidFindBy(name = "Details") + private AndroidElement detailsFileElement; + + @AndroidFindBy(name = "Rename") + private AndroidElement renameFileElement; + + @AndroidFindBy(name = "Remove") + private AndroidElement removeFileElement; + + @AndroidFindBy(name = "Move") + private AndroidElement moveElement; + + public ElementMenuOptions(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public FileDetailsView clickOnDetails() { + detailsFileElement.click(); + FileDetailsView fileDetailsView = new FileDetailsView(driver); + return fileDetailsView; + } + + public RemoveConfirmationView clickOnRemove() { + removeFileElement.click(); + RemoveConfirmationView removeConfirmationView = + new RemoveConfirmationView(driver); + return removeConfirmationView; + } + + public MoveView clickOnMove() { + moveElement.click(); + MoveView moveView = new MoveView(driver); + return moveView; + } + + public NewFolderPopUp clickOnRename() { + renameFileElement.click(); + NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); + return newFolderPopUp; + } + + public ShareView clickOnShareLinkElement() { + shareLinkElement.click(); + ShareView shareView = new ShareView(driver); + return shareView; + } + + public WaitAMomentPopUp clickOnUnshareLinkElement() { + unshareLinkElement.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java index 122d9356ce0..7bb2765a0f9 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,38 +23,37 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; public class FileDetailsView { - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(name = "Keep file up to date") - private AndroidElement keepFileUpToDateCheckbox; - - @AndroidFindBy(id = "com.owncloud.android:id/fdProgressBar") - private AndroidElement progressBar; - - public FileDetailsView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public void checkKeepFileUpToDateCheckbox () { - if(keepFileUpToDateCheckbox.getAttribute("checked").equals("false")){ - keepFileUpToDateCheckbox.click(); - } - } - - public void unCheckKeepFileUpToDateCheckbox () { - if(keepFileUpToDateCheckbox.getAttribute("checked").equals("true")){ - keepFileUpToDateCheckbox.click(); - } - } - - public AndroidElement getProgressBar (){ - return progressBar; - } + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(name = "Keep file up to date") + private AndroidElement keepFileUpToDateCheckbox; + + @AndroidFindBy(id = "com.owncloud.android:id/fdProgressBar") + private AndroidElement progressBar; + + public FileDetailsView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void checkKeepFileUpToDateCheckbox() { + if (keepFileUpToDateCheckbox.getAttribute("checked").equals("false")) { + keepFileUpToDateCheckbox.click(); + } + } + + public void unCheckKeepFileUpToDateCheckbox() { + if (keepFileUpToDateCheckbox.getAttribute("checked").equals("true")) { + keepFileUpToDateCheckbox.click(); + } + } + + public AndroidElement getProgressBar() { + return progressBar; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java index 0ec15edaac9..5bf06d17940 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java @@ -1,211 +1,206 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; -import java.util.List; - +import com.owncloud.android.test.ui.actions.Actions; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.android.AndroidKeyCode; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.Point; import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.Point; -import com.owncloud.android.test.ui.actions.Actions; +import java.util.List; public class FileListView { - final AndroidDriver driver; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".description(\"More options\")") - private AndroidElement menuButton; - - @CacheLookup - @AndroidFindBy(id = "com.owncloud.android:id/list_root") - private AndroidElement filesLayout; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".resourceId(\"android:id/action_bar_title\")") - private AndroidElement titleText; - - @AndroidFindBy(id = "android:id/progress_circular") - private AndroidElement progressCircular; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".description(\"New folder\")") - private AndroidElement newFolderButton; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")") - private AndroidElement uploadButton; - - private AndroidElement waitAMomentText; - - @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout") - private List listItemLayout; - - @AndroidFindBy(id = "com.owncloud.android:id/list_root") - private AndroidElement listRootLayout; - - @AndroidFindBy(name = "Files") - private AndroidElement filesElementUploadFile; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".description(\"List Layout\")") - private AndroidElement listLayout; - - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)") - private AndroidElement deviceScreen; - - private AndroidElement fileElement; - - private AndroidElement fileElementLayout; - - private static String localFileIndicator = - "com.owncloud.android:id/localFileIndicator"; - private static String favoriteFileIndicator = - "com.owncloud.android:id/favoriteIcon"; - private static String sharedElementIndicator = - "com.owncloud.android:id/sharedIcon"; - - - public FileListView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public MenuList clickOnMenuButton () { - //if the menu option is not in the actionBar, it is opening again - try { - menuButton.click(); - } catch (NoSuchElementException e){ - driver.sendKeyEvent(AndroidKeyCode.MENU); - } - MenuList menuList = new MenuList (driver); - return menuList; - } - - public SettingsView getSettingsView () { - SettingsView settingsView = new SettingsView(driver); - return settingsView; - } - - public NewFolderPopUp clickOnNewFolderButton () { - newFolderButton.click(); - NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); - return newFolderPopUp; - } - - public void clickOnUploadButton () { - uploadButton.click(); - } - - public UploadFilesView clickOnFilesElementUploadFile () { - filesElementUploadFile.click(); - UploadFilesView uploadFilesView = new UploadFilesView(driver); - return uploadFilesView; - } - - public AndroidElement getTitleTextElement () { - return titleText; - } - - public AndroidElement getUploadButton () { - return uploadButton; - } - - public AndroidElement getWaitAMomentTextElement () { - return waitAMomentText; - } - - public AndroidElement getListRootElement () { - return listRootLayout; - } - - public List getListItemLayout () { - return listItemLayout; - } - - public AndroidElement getFileElement () { - return fileElement; - } - - public ElementMenuOptions longPressOnElement (String elementName) { - scrollTillFindElement(elementName).tap(1, 1000); - //fileElement.tap(1, 1000); - ElementMenuOptions menuOptions = new ElementMenuOptions(driver); - return menuOptions; - } - - public AndroidElement scrollTillFindElement (String elementName) { + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"More options\")") + private AndroidElement menuButton; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement filesLayout; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".resourceId(\"android:id/action_bar_title\")") + private AndroidElement titleText; + + @AndroidFindBy(id = "android:id/progress_circular") + private AndroidElement progressCircular; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"New folder\")") + private AndroidElement newFolderButton; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")") + private AndroidElement uploadButton; + + private AndroidElement waitAMomentText; + + @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout") + private List listItemLayout; + + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement listRootLayout; + + @AndroidFindBy(name = "Files") + private AndroidElement filesElementUploadFile; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"List Layout\")") + private AndroidElement listLayout; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)") + private AndroidElement deviceScreen; + + private AndroidElement fileElement; + + private AndroidElement fileElementLayout; + + private static String localFileIndicator = + "com.owncloud.android:id/localFileIndicator"; + private static String favoriteFileIndicator = + "com.owncloud.android:id/favoriteIcon"; + private static String sharedElementIndicator = + "com.owncloud.android:id/sharedIcon"; + + public FileListView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public MenuList clickOnMenuButton() { + //if the menu option is not in the actionBar, it is opening again + try { + menuButton.click(); + } catch (NoSuchElementException e) { + driver.sendKeyEvent(AndroidKeyCode.MENU); + } + MenuList menuList = new MenuList(driver); + return menuList; + } + + public SettingsView getSettingsView() { + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } + + public NewFolderPopUp clickOnNewFolderButton() { + newFolderButton.click(); + NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); + return newFolderPopUp; + } + + public void clickOnUploadButton() { + uploadButton.click(); + } + + public UploadFilesView clickOnFilesElementUploadFile() { + filesElementUploadFile.click(); + UploadFilesView uploadFilesView = new UploadFilesView(driver); + return uploadFilesView; + } + + public AndroidElement getTitleTextElement() { + return titleText; + } + + public AndroidElement getUploadButton() { + return uploadButton; + } + + public AndroidElement getWaitAMomentTextElement() { + return waitAMomentText; + } + + public AndroidElement getListRootElement() { + return listRootLayout; + } + + public List getListItemLayout() { + return listItemLayout; + } + + public AndroidElement getFileElement() { + return fileElement; + } + + public ElementMenuOptions longPressOnElement(String elementName) { + scrollTillFindElement(elementName).tap(1, 1000); + //fileElement.tap(1, 1000); + ElementMenuOptions menuOptions = new ElementMenuOptions(driver); + return menuOptions; + } + + public AndroidElement scrollTillFindElement(String elementName) { fileElement = Actions - .scrollTillFindElement (elementName,filesLayout,driver); - try { - fileElementLayout = (AndroidElement) driver - .findElementByAndroidUIAutomator("new UiSelector()" - + ".description(\"LinearLayout-"+ elementName +"\")"); + .scrollTillFindElement(elementName, filesLayout, driver); + try { + fileElementLayout = (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".description(\"LinearLayout-" + elementName + "\")"); } catch (NoSuchElementException e) { - fileElementLayout = null; + fileElementLayout = null; } - return fileElement; - } - - public AndroidElement getFileElementLayout () { - return fileElementLayout; - } - - public AndroidElement getProgressCircular () { - return progressCircular; - } - - public static String getLocalFileIndicator() { - return localFileIndicator; - } - - public static String getFavoriteFileIndicator() { - return favoriteFileIndicator; - } - - public static String getSharedElementIndicator() { - return sharedElementIndicator; - } - public void pulldownToRefresh () throws InterruptedException { - Point listLocation = listLayout.getLocation(); - driver.swipe(listLocation.getX(),listLocation.getY(), - listLocation.getX(),listLocation.getY()+1000, 5000); - } - - - - public void pulldownToSeeNotification () throws InterruptedException { - Point listLocation = deviceScreen.getLocation(); - driver.swipe(listLocation.getX(),listLocation.getY(), - listLocation.getX(),listLocation.getY()+1000, 5000); - } + return fileElement; + } + + public AndroidElement getFileElementLayout() { + return fileElementLayout; + } + + public AndroidElement getProgressCircular() { + return progressCircular; + } + + public static String getLocalFileIndicator() { + return localFileIndicator; + } + + public static String getFavoriteFileIndicator() { + return favoriteFileIndicator; + } + + public static String getSharedElementIndicator() { + return sharedElementIndicator; + } + + public void pulldownToRefresh() throws InterruptedException { + Point listLocation = listLayout.getLocation(); + driver.swipe(listLocation.getX(), listLocation.getY(), + listLocation.getX(), listLocation.getY() + 1000, 5000); + } + + public void pulldownToSeeNotification() throws InterruptedException { + Point listLocation = deviceScreen.getLocation(); + driver.swipe(listLocation.getX(), listLocation.getY(), + listLocation.getX(), listLocation.getY() + 1000, 5000); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java index c6838f4558b..a99df27d910 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,35 +23,33 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.support.PageFactory; public class GmailEmailListView { - - final AndroidDriver driver; - - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"" - + "me about UploadFile, on May 11, conversation read\")") - private AndroidElement emailAmericanFormatDate; - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"" - + "me about UploadFile, on 11 May, conversation read\")") - private AndroidElement emailEuropeanFormatDate; - - - public GmailEmailListView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public GmailEmailView clickOnEmail (){ - try{ - emailAmericanFormatDate.click(); - }catch (NoSuchElementException e) { - emailEuropeanFormatDate.click(); - } - GmailEmailView gmailEmailView = new GmailEmailView(driver); - return gmailEmailView; - } - + + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"" + + "me about UploadFile, on May 11, conversation read\")") + private AndroidElement emailAmericanFormatDate; + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"" + + "me about UploadFile, on 11 May, conversation read\")") + private AndroidElement emailEuropeanFormatDate; + + public GmailEmailListView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public GmailEmailView clickOnEmail() { + try { + emailAmericanFormatDate.click(); + } catch (NoSuchElementException e) { + emailEuropeanFormatDate.click(); + } + GmailEmailView gmailEmailView = new GmailEmailView(driver); + return gmailEmailView; + } + } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java index 9fb92d754b8..ec4c493e745 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java @@ -1,50 +1,47 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; +import com.owncloud.android.test.ui.testSuites.Config; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import com.owncloud.android.test.ui.testSuites.Config; - public class GmailEmailView { - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(name = Config.fileToTestSendByEmailName) - private AndroidElement fileButton; - - public GmailEmailView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public ImageView clickOnfileButton (){ - fileButton.click(); - ImageView imageView = new ImageView(driver); - return imageView; - } + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(name = Config.fileToTestSendByEmailName) + private AndroidElement fileButton; + + public GmailEmailView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public ImageView clickOnfileButton() { + fileButton.click(); + ImageView imageView = new ImageView(driver); + return imageView; + } } \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java index 45cd819cb17..9b50744f3f9 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,40 +23,39 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; public class GmailSendMailView { - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"To\")") - private AndroidElement toTextField; - - @CacheLookup - @AndroidFindBy(name = "Subject") - private AndroidElement subjectTextField; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Send\")") - private AndroidElement sendButton; - - public GmailSendMailView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public void typeToEmailAdress (String email) { - toTextField.sendKeys(email + "\n"); - } - - public void clickOnSendButton () { - sendButton.click(); - } - - public void typeSubject (String subject) { - subjectTextField.clear(); - subjectTextField.sendKeys(subject); - } + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"To\")") + private AndroidElement toTextField; + + @CacheLookup + @AndroidFindBy(name = "Subject") + private AndroidElement subjectTextField; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Send\")") + private AndroidElement sendButton; + + public GmailSendMailView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void typeToEmailAdress(String email) { + toTextField.sendKeys(email + "\n"); + } + + public void clickOnSendButton() { + sendButton.click(); + } + + public void typeSubject(String subject) { + subjectTextField.clear(); + subjectTextField.sendKeys(subject); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java index a580f360041..364696524f6 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java @@ -1,25 +1,26 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.testSuites.Common; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; @@ -27,54 +28,51 @@ import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.testSuites.Common; - - public class ImageView { - final AndroidDriver driver; + final AndroidDriver driver; - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".description(\"More options\")") - private AndroidElement optionsButton; + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"More options\")") + private AndroidElement optionsButton; - @AndroidFindBy(name = "Share") - private AndroidElement shareButton; + @AndroidFindBy(name = "Share") + private AndroidElement shareButton; - @AndroidFindBy(name = "ownCloud") - private AndroidElement ownCloudButton; + @AndroidFindBy(name = "ownCloud") + private AndroidElement ownCloudButton; - @AndroidFindBy(name = "Share with ownCloud") - private AndroidElement shareWithOwnCloudButton; + @AndroidFindBy(name = "Share with ownCloud") + private AndroidElement shareWithOwnCloudButton; - @AndroidFindBy(name = "Just once") - private AndroidElement justOnceButton; + @AndroidFindBy(name = "Just once") + private AndroidElement justOnceButton; - @AndroidFindBy(id = "android:id/resolver_list") - private AndroidElement sharingAppsLayout; + @AndroidFindBy(id = "android:id/resolver_list") + private AndroidElement sharingAppsLayout; - public ImageView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } + public ImageView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } - public void clickOnOptionsButton(){ - optionsButton.click(); - } + public void clickOnOptionsButton() { + optionsButton.click(); + } - public void clickOnShareButton(){ - shareButton.click(); - } + public void clickOnShareButton() { + shareButton.click(); + } - public void clickOnOwnCloudButton(){ - if(Common.isElementPresent(ownCloudButton)){ - Actions.scrollTillFindElement("ownCloud",sharingAppsLayout,driver); - ownCloudButton.click(); - }else if(Common.isElementPresent(shareWithOwnCloudButton)){} - } + public void clickOnOwnCloudButton() { + if (Common.isElementPresent(ownCloudButton)) { + Actions.scrollTillFindElement("ownCloud", sharingAppsLayout, driver); + ownCloudButton.click(); + } else if (Common.isElementPresent(shareWithOwnCloudButton)) { + } + } - public void clickOnJustOnceButton(){ - justOnceButton.click(); - } + public void clickOnJustOnceButton() { + justOnceButton.click(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java index 8852826b612..80aeca3a0b0 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java @@ -1,115 +1,112 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; -import org.openqa.selenium.support.CacheLookup; -import org.openqa.selenium.support.PageFactory; - import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.PageFactory; public class LoginForm { - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".description(\"Server address\")") - private AndroidElement hostUrlInput; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Username\")") - private AndroidElement userNameInput; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Password\")") - private AndroidElement passwordInput; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Connect\")") - private AndroidElement connectButton; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".description(\"Testing connection\")") - private AndroidElement serverStatusText; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".description(\"Wrong username or password\")") - private AndroidElement authStatusText; - - public LoginForm (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public CertificatePopUp typeHostUrl (String hostUrl) { - hostUrlInput.clear(); - hostUrlInput.sendKeys(hostUrl + "\n"); - CertificatePopUp certificatePopUp = new CertificatePopUp(driver); - return certificatePopUp; - } - - public void clickOnUserName () { - userNameInput.click(); - } - - public void typeUserName (String userName) { - userNameInput.clear(); - //using the \n , it not need to hide the keyboard - //which sometimes gives problems - userNameInput.sendKeys(userName + "\n"); - //driver.hideKeyboard(); - } - - public void typePassword (String password) { - passwordInput.clear(); - passwordInput.sendKeys(password + "\n"); - //driver.hideKeyboard(); - } - - public FileListView clickOnConnectButton () { - connectButton.click(); - FileListView fileListView = new FileListView(driver); - return fileListView; - } - - public AndroidElement gethostUrlInput () { - return hostUrlInput; - } - - public AndroidElement getUserNameInput () { - return userNameInput; - } - - public AndroidElement getPasswordInput () { - return passwordInput; - } - - - public AndroidElement getServerStatusTextElement () { - return serverStatusText; - } - - public AndroidElement getAuthStatusText () { - return authStatusText; - } + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"Server address\")") + private AndroidElement hostUrlInput; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Username\")") + private AndroidElement userNameInput; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Password\")") + private AndroidElement passwordInput; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Connect\")") + private AndroidElement connectButton; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"Testing connection\")") + private AndroidElement serverStatusText; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"Wrong username or password\")") + private AndroidElement authStatusText; + + public LoginForm(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public CertificatePopUp typeHostUrl(String hostUrl) { + hostUrlInput.clear(); + hostUrlInput.sendKeys(hostUrl + "\n"); + CertificatePopUp certificatePopUp = new CertificatePopUp(driver); + return certificatePopUp; + } + + public void clickOnUserName() { + userNameInput.click(); + } + + public void typeUserName(String userName) { + userNameInput.clear(); + //using the \n , it not need to hide the keyboard + //which sometimes gives problems + userNameInput.sendKeys(userName + "\n"); + //driver.hideKeyboard(); + } + + public void typePassword(String password) { + passwordInput.clear(); + passwordInput.sendKeys(password + "\n"); + //driver.hideKeyboard(); + } + + public FileListView clickOnConnectButton() { + connectButton.click(); + FileListView fileListView = new FileListView(driver); + return fileListView; + } + + public AndroidElement gethostUrlInput() { + return hostUrlInput; + } + + public AndroidElement getUserNameInput() { + return userNameInput; + } + + public AndroidElement getPasswordInput() { + return passwordInput; + } + + public AndroidElement getServerStatusTextElement() { + return serverStatusText; + } + + public AndroidElement getAuthStatusText() { + return authStatusText; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java index aea0d9d1482..97aa1520c5f 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java @@ -1,47 +1,45 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; -import org.openqa.selenium.support.PageFactory; - import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; +import org.openqa.selenium.support.PageFactory; public class MenuList { - final AndroidDriver driver; - - @AndroidFindBy(name = "Settings") - private AndroidElement settingsButton; - - public MenuList (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public SettingsView clickOnSettingsButton () { - settingsButton.click(); - SettingsView settingsView = new SettingsView(driver); - return settingsView; - } + final AndroidDriver driver; + + @AndroidFindBy(name = "Settings") + private AndroidElement settingsButton; + + public MenuList(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public SettingsView clickOnSettingsButton() { + settingsButton.click(); + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java index 1085f173f74..9b7f15c7af5 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java @@ -1,57 +1,54 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; +import com.owncloud.android.test.ui.actions.Actions; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import com.owncloud.android.test.ui.actions.Actions; - public class MoveView { - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(id = "com.owncloud.android:id/list_root") - private AndroidElement filesLayout; - - @AndroidFindBy(name = "Choose") - private AndroidElement chooseButton; - - public MoveView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public WaitAMomentPopUp clickOnChoose () { - chooseButton.click(); - WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); - return waitAMomentPopUp; - } - - public AndroidElement scrollTillFindElement (String elementName) { - return Actions.scrollTillFindElement (elementName,filesLayout,driver); - } + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement filesLayout; + + @AndroidFindBy(name = "Choose") + private AndroidElement chooseButton; + + public MoveView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public WaitAMomentPopUp clickOnChoose() { + chooseButton.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } + + public AndroidElement scrollTillFindElement(String elementName) { + return Actions.scrollTillFindElement(elementName, filesLayout, driver); + } } \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java index 0aa32252a03..73c47d83eeb 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java @@ -1,58 +1,56 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; -import org.openqa.selenium.support.PageFactory; - import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; +import org.openqa.selenium.support.PageFactory; public class NewFolderPopUp { - final AndroidDriver driver; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".resourceId(\"android:id/button1\")") - private AndroidElement newFolderOkButton; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".resourceId(\"com.owncloud.android:id/user_input\")") - private AndroidElement newFolderNameField; - - public NewFolderPopUp (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public void typeNewFolderName (String newFolderName) { - newFolderNameField.clear(); - newFolderNameField.sendKeys(newFolderName + "\n"); - //driver.hideKeyboard(); - } - - public WaitAMomentPopUp clickOnNewFolderOkButton () { - newFolderOkButton.click(); - WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); - return waitAMomentPopUp; - } + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".resourceId(\"android:id/button1\")") + private AndroidElement newFolderOkButton; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".resourceId(\"com.owncloud.android:id/user_input\")") + private AndroidElement newFolderNameField; + + public NewFolderPopUp(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void typeNewFolderName(String newFolderName) { + newFolderNameField.clear(); + newFolderNameField.sendKeys(newFolderName + "\n"); + //driver.hideKeyboard(); + } + + public WaitAMomentPopUp clickOnNewFolderOkButton() { + newFolderOkButton.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/NotificationView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NotificationView.java index 35de73c861b..04ee8caa884 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/NotificationView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NotificationView.java @@ -4,51 +4,48 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.PageFactory; public class NotificationView { -final AndroidDriver driver; - - @AndroidFindBy(name = "Upload succeeded") - private static AndroidElement uploadSucceededNotification; - - @AndroidFindBy(name = "Uploading ?") - private static AndroidElement uploadingNotification; - - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Clear all notifications.\")") - private AndroidElement clearAllNotificationButton; - - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)") - private AndroidElement notificationArea; - - - public NotificationView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - - public AndroidElement getUploadSucceededNotification() { - return uploadSucceededNotification; - } - - public AndroidElement getUploadingNotification() { - return uploadingNotification; - } - - public AndroidElement getClearAllNotificationButton() { - return clearAllNotificationButton; - } - - public void tapOnClearAllNotification () { - clearAllNotificationButton.tap(1, 1000); - } - - public void tapOnBottomNotificationArea(){ - //TODO. it is not working - notificationArea.getSize(); - notificationArea.tap(1, 1000); - } + final AndroidDriver driver; + + @AndroidFindBy(name = "Upload succeeded") + private static AndroidElement uploadSucceededNotification; + + @AndroidFindBy(name = "Uploading ?") + private static AndroidElement uploadingNotification; + + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Clear all notifications.\")") + private AndroidElement clearAllNotificationButton; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)") + private AndroidElement notificationArea; + + public NotificationView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public AndroidElement getUploadSucceededNotification() { + return uploadSucceededNotification; + } + + public AndroidElement getUploadingNotification() { + return uploadingNotification; + } + + public AndroidElement getClearAllNotificationButton() { + return clearAllNotificationButton; + } + + public void tapOnClearAllNotification() { + clearAllNotificationButton.tap(1, 1000); + } + + public void tapOnBottomNotificationArea() { + //TODO. it is not working + notificationArea.getSize(); + notificationArea.tap(1, 1000); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java index 7b0879499e3..8694aa785e9 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java @@ -1,60 +1,58 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; -import org.openqa.selenium.support.PageFactory; - import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; +import org.openqa.selenium.support.PageFactory; public class PassCodeRequestView { -final AndroidDriver driver; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(0)") - private AndroidElement codeElement1; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(1)") - private AndroidElement codeElement2; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(2)") - private AndroidElement codeElement3; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(3)") - private AndroidElement codeElement4; - - public PassCodeRequestView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public void enterPasscode(String codeNumber1, String codeNumber2, - String codeNumber3, String codeNumber4){ - codeElement1 - .sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); - } + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(0)") + private AndroidElement codeElement1; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(1)") + private AndroidElement codeElement2; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(2)") + private AndroidElement codeElement3; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(3)") + private AndroidElement codeElement4; + + public PassCodeRequestView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void enterPasscode(String codeNumber1, String codeNumber2, + String codeNumber3, String codeNumber4) { + codeElement1 + .sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java index 276cff2dca2..cc44ab795f4 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,48 +23,48 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.PageFactory; public class PassCodeView { - final AndroidDriver driver; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(0)") - private AndroidElement codeElement1; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(1)") - private AndroidElement codeElement2; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(2)") - private AndroidElement codeElement3; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.EditText\").index(3)") - private AndroidElement codeElement4; - - @AndroidFindBy(name = "Cancel") - private AndroidElement cancelButton; - - public PassCodeView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public PassCodeView enterPasscode(String codeNumber1, String codeNumber2, - String codeNumber3, String codeNumber4){ - codeElement1 - .sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); - return this; - } - public SettingsView reenterPasscode(String codeNumber1, - String codeNumber2, String codeNumber3, String codeNumber4){ - codeElement1 - .sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); - SettingsView settingsView = new SettingsView(driver); - return settingsView; - } + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(0)") + private AndroidElement codeElement1; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(1)") + private AndroidElement codeElement2; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(2)") + private AndroidElement codeElement3; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(3)") + private AndroidElement codeElement4; + + @AndroidFindBy(name = "Cancel") + private AndroidElement cancelButton; + + public PassCodeView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public PassCodeView enterPasscode(String codeNumber1, String codeNumber2, + String codeNumber3, String codeNumber4) { + codeElement1 + .sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + return this; + } + + public SettingsView reenterPasscode(String codeNumber1, + String codeNumber2, String codeNumber3, String codeNumber4) { + codeElement1 + .sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java index 0889e373e9a..d63dafb1144 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,23 +23,22 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.PageFactory; public class RemoveConfirmationView { - final AndroidDriver driver; - - @AndroidFindBy(name = "Remote and local") - private AndroidElement remoteAndLocalButton; - - public RemoveConfirmationView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public WaitAMomentPopUp clickOnRemoteAndLocalButton () { - remoteAndLocalButton.click(); - WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); - return waitAMomentPopUp; - } + final AndroidDriver driver; + + @AndroidFindBy(name = "Remote and local") + private AndroidElement remoteAndLocalButton; + + public RemoveConfirmationView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public WaitAMomentPopUp clickOnRemoteAndLocalButton() { + remoteAndLocalButton.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java index 71533131ca7..f81c74032f2 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java @@ -1,101 +1,99 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; +import com.owncloud.android.test.ui.testSuites.Config; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import com.owncloud.android.test.ui.testSuites.Config; - public class SettingsView { - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(name = Config.userAccount) - private AndroidElement accountElement; - - @CacheLookup - @AndroidFindBy(name = Config.userAccount2) - private AndroidElement accountElement2; - - @AndroidFindBy(name = "Delete account") - private AndroidElement deleteAccountElement; - - @AndroidFindBy(name = "Change password") - private AndroidElement changePasswordElement; - - @AndroidFindBy(name = "Add account") - private AndroidElement addAccountElement; - - @AndroidFindBy(uiAutomator = "new UiSelector()" - + ".className(\"android.widget.CheckBox\").index(0)") - private AndroidElement passcodeCheckbox; - - public SettingsView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public void tapOnAccountElement (int accountPosition, int fingers, int milliSeconds) { - if(accountPosition==1) - accountElement.tap(fingers, milliSeconds); - else - accountElement2.tap(fingers, milliSeconds); - } - - public void tapOnAddAccount (int fingers, int milliSeconds) { - addAccountElement.tap(fingers, milliSeconds); - } - - public LoginForm clickOnDeleteAccountElement () { - deleteAccountElement.click(); - LoginForm loginForm = new LoginForm(driver); - return loginForm; - } - - public LoginForm clickOnChangePasswordElement () { - changePasswordElement.click(); - LoginForm loginForm = new LoginForm(driver); - return loginForm; - } - - public PassCodeView EnablePassCode(){ - if(!passcodeCheckbox.isSelected()){ - passcodeCheckbox.click(); - } - PassCodeView passcodeview = new PassCodeView(driver); - return passcodeview; - } - - public PassCodeView DisablePassCode(){ - if(passcodeCheckbox.isSelected()){ - passcodeCheckbox.click(); - } - PassCodeView passcodeview = new PassCodeView(driver); - return passcodeview; - } + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(name = Config.userAccount) + private AndroidElement accountElement; + + @CacheLookup + @AndroidFindBy(name = Config.userAccount2) + private AndroidElement accountElement2; + + @AndroidFindBy(name = "Delete account") + private AndroidElement deleteAccountElement; + + @AndroidFindBy(name = "Change password") + private AndroidElement changePasswordElement; + + @AndroidFindBy(name = "Add account") + private AndroidElement addAccountElement; + + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.CheckBox\").index(0)") + private AndroidElement passcodeCheckbox; + + public SettingsView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void tapOnAccountElement(int accountPosition, int fingers, int milliSeconds) { + if (accountPosition == 1) { + accountElement.tap(fingers, milliSeconds); + } else { + accountElement2.tap(fingers, milliSeconds); + } + } + + public void tapOnAddAccount(int fingers, int milliSeconds) { + addAccountElement.tap(fingers, milliSeconds); + } + + public LoginForm clickOnDeleteAccountElement() { + deleteAccountElement.click(); + LoginForm loginForm = new LoginForm(driver); + return loginForm; + } + + public LoginForm clickOnChangePasswordElement() { + changePasswordElement.click(); + LoginForm loginForm = new LoginForm(driver); + return loginForm; + } + + public PassCodeView EnablePassCode() { + if (!passcodeCheckbox.isSelected()) { + passcodeCheckbox.click(); + } + PassCodeView passcodeview = new PassCodeView(driver); + return passcodeview; + } + + public PassCodeView DisablePassCode() { + if (passcodeCheckbox.isSelected()) { + passcodeCheckbox.click(); + } + PassCodeView passcodeview = new PassCodeView(driver); + return passcodeview; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java index a5988e05a8a..b92050b99a2 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -23,26 +22,24 @@ import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; public class ShareView { - final AndroidDriver driver; - - @CacheLookup - @FindBy(id = "android:id/select_dialog_listview") - private AndroidElement listViewLayout; - - public ShareView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public AndroidElement getListViewLayout () { - return listViewLayout; - } - - + final AndroidDriver driver; + + @CacheLookup + @FindBy(id = "android:id/select_dialog_listview") + private AndroidElement listViewLayout; + + public ShareView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public AndroidElement getListViewLayout() { + return listViewLayout; + } + } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java index 44bdfeebbe5..249ccf7cb4e 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java @@ -1,67 +1,64 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; +import com.owncloud.android.test.ui.actions.Actions; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import com.owncloud.android.test.ui.actions.Actions; +public class UploadFilesView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement filesLayout; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload") + private AndroidElement uploadButton; + + private AndroidElement fileElement; + + public UploadFilesView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public FileListView clickOnUploadButton() { + uploadButton.click(); + FileListView fileListView = new FileListView(driver); + return fileListView; + } + + //change to scrollTillFindElement + public void scrollTillFindFile(String fileName) { + fileElement = Actions + .scrollTillFindElement(fileName, filesLayout, driver); + } -public class UploadFilesView{ - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(id = "com.owncloud.android:id/list_root") - private AndroidElement filesLayout; - - @CacheLookup - @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload") - private AndroidElement uploadButton; - - private AndroidElement fileElement; - - public UploadFilesView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public FileListView clickOnUploadButton () { - uploadButton.click(); - FileListView fileListView = new FileListView (driver); - return fileListView; - } - - //change to scrollTillFindElement - public void scrollTillFindFile (String fileName) { - fileElement = Actions - .scrollTillFindElement(fileName,filesLayout,driver); - } - - public void clickOnFileName (String fileName) { - scrollTillFindFile(fileName); - fileElement.click(); - } + public void clickOnFileName(String fileName) { + scrollTillFindFile(fileName); + fileElement.click(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java index e071eac8921..4d8d76ca799 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; @@ -24,23 +23,22 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; public class UploadView { - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(name = "Upload") - private AndroidElement uploadButton; - - public UploadView (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public void clickOUploadButton () { - uploadButton.click(); - } + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(name = "Upload") + private AndroidElement uploadButton; + + public UploadView(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void clickOUploadButton() { + uploadButton.click(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java index 05ad4436bf5..2d0aa7cbcd8 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java @@ -1,44 +1,42 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.models; -import org.openqa.selenium.support.PageFactory; - import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; +import org.openqa.selenium.support.PageFactory; public class WaitAMomentPopUp { - final AndroidDriver driver; - - @AndroidFindBy(name = "Wait a moment") - private AndroidElement waitAMomentText; - - public WaitAMomentPopUp (AndroidDriver driver) { - this.driver = driver; - PageFactory.initElements(new AppiumFieldDecorator(driver), this); - } - - public AndroidElement getWaitAMomentTextElement () { - return waitAMomentText; - } + final AndroidDriver driver; + + @AndroidFindBy(name = "Wait a moment") + private AndroidElement waitAMomentText; + + public WaitAMomentPopUp(AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public AndroidElement getWaitAMomentTextElement() { + return waitAMomentText; + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java index 1b2e78cd819..e10748a3ea0 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java @@ -1,26 +1,33 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TimeoutException; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.ui.WebDriverWait; import java.io.File; import java.io.IOException; @@ -30,174 +37,166 @@ import java.util.Date; import java.util.concurrent.TimeUnit; +import static org.junit.Assert.*; -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.OutputType; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.ui.WebDriverWait; - -import io.appium.java_client.android.AndroidDriver; -import io.appium.java_client.android.AndroidElement; - -public class Common{ - AndroidDriver driver; - static int waitingTime = 30; - - public WebDriverWait wait; - - protected AndroidDriver setUpCommonDriver () throws Exception { - File rootPath = new File(System.getProperty("user.dir")); - File appDir = new File(rootPath,"src/test/resources"); - File app = new File(appDir,"ownCloud.apk"); - DesiredCapabilities capabilities = new DesiredCapabilities(); - capabilities.setCapability("platformName", "Android"); - capabilities.setCapability("deviceName", "test"); - capabilities.setCapability("app", app.getAbsolutePath()); - capabilities.setCapability("appPackage", "com.owncloud.android"); - capabilities.setCapability("appActivity", - ".ui.activity.FileDisplayActivity"); - capabilities.setCapability("appWaitActivity", - ".authentication.AuthenticatorActivity"); - driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), - capabilities); - driver.manage().timeouts().implicitlyWait(waitingTime, - TimeUnit.SECONDS); - wait = new WebDriverWait(driver, waitingTime, 50); - return driver; - - } - - protected boolean waitForTextPresent(String text, AndroidElement element) - throws InterruptedException{ - for (int second = 0;;second++){ - if (second >= waitingTime) - return false; - try{ - if (text.equals(element.getText())) - break; - } catch (Exception e){ - - } - Thread.sleep(1000); - } - return true; - } - - protected boolean isElementPresent(AndroidElement element, By by) { - try { - element.findElement(by); - return true; - } catch (NoSuchElementException e) { - return false; - } - } - - public static boolean isElementPresent(AndroidElement element) { - try{ - element.isDisplayed(); - } catch (NoSuchElementException e){ - return false; - } - return true; - } - - //pollingTime in milliseconds - public static void waitTillElementIsNotPresent (AndroidElement element, - int pollingTime) throws Exception { - for (int time = 0;time <= waitingTime * 1000;time += pollingTime){ - try{ - element.isDisplayed(); - } catch (NoSuchElementException e){ - return; - } - Thread.sleep(pollingTime); - } - throw new TimeoutException(); - } - - public static void waitTillElementIsNotPresentWithoutTimeout ( - AndroidElement element,int pollingTime) - throws InterruptedException { - for (int time = 0;time <= waitingTime * 1000;time += pollingTime){ - try{ - element.isDisplayed(); - } catch (NoSuchElementException e){ - return; - } - Thread.sleep(pollingTime); - } - } - - public static void waitTillElementIsPresent ( - AndroidElement element,int pollingTime) - throws InterruptedException { - for (int time = 0;time <= waitingTime * 1000;time += pollingTime){ - try{ - if(element.isDisplayed()){ - return; - } - } catch (NoSuchElementException e){ - - } - Thread.sleep(pollingTime); - } - } - - protected void takeScreenShotOnFailed (String testName) - throws IOException { - File file = ((RemoteWebDriver) driver) - .getScreenshotAs(OutputType.FILE); - SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); - Date today = Calendar.getInstance().getTime(); - String screenShotName = "ScreenShots/" + dt1.format(today) + "/" - + testName + ".png"; - FileUtils.copyFile(file, new File(screenShotName)); - } - - protected void assertIsInFileListView() throws InterruptedException { - //waitForTextPresent("Wrong username or password", - // changePasswordForm.getAuthStatusText()); - Thread.sleep(2000); - assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver - .findElementByAndroidUIAutomator("new UiSelector()" - + ".resourceId(\"android:id/action_bar_title\")"))); - assertTrue(isElementPresent((AndroidElement) driver - .findElementByAndroidUIAutomator("new UiSelector()" - + ".description(\"Upload\")"))); - } - - protected void assertIsNotInFileListView() throws InterruptedException { - AndroidElement fileElement; - assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver - .findElementByAndroidUIAutomator("new UiSelector()" - + ".resourceId(\"android:id/action_bar_title\")"))); - try { - fileElement = (AndroidElement) driver - .findElementByAndroidUIAutomator("new UiSelector()" - + ".description(\"Upload\")"); - } catch (NoSuchElementException e) { - fileElement = null; - } - assertNull(fileElement); - } - - protected void assertIsPasscodeRequestView() throws InterruptedException { - assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver - .findElementByAndroidUIAutomator("new UiSelector()" - + ".resourceId(\"android:id/action_bar_title\")"))); - assertTrue(((AndroidElement) driver.findElementByAndroidUIAutomator( - "new UiSelector().text(\"Please, insert your pass code\")")) - .isDisplayed()); - - } - - protected void assertIsInSettingsView() throws InterruptedException { - assertTrue(waitForTextPresent("Settings", (AndroidElement) driver - .findElementByAndroidUIAutomator("new UiSelector()" - + ".resourceId(\"android:id/action_bar_title\")"))); - } +public class Common { + AndroidDriver driver; + static int waitingTime = 30; + + public WebDriverWait wait; + + protected AndroidDriver setUpCommonDriver() throws Exception { + File rootPath = new File(System.getProperty("user.dir")); + File appDir = new File(rootPath, "src/test/resources"); + File app = new File(appDir, "ownCloud.apk"); + DesiredCapabilities capabilities = new DesiredCapabilities(); + capabilities.setCapability("platformName", "Android"); + capabilities.setCapability("deviceName", "test"); + capabilities.setCapability("app", app.getAbsolutePath()); + capabilities.setCapability("appPackage", "com.owncloud.android"); + capabilities.setCapability("appActivity", + ".ui.activity.FileDisplayActivity"); + capabilities.setCapability("appWaitActivity", + ".authentication.AuthenticatorActivity"); + driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), + capabilities); + driver.manage().timeouts().implicitlyWait(waitingTime, + TimeUnit.SECONDS); + wait = new WebDriverWait(driver, waitingTime, 50); + return driver; + + } + + protected boolean waitForTextPresent(String text, AndroidElement element) + throws InterruptedException { + for (int second = 0; ; second++) { + if (second >= waitingTime) { + return false; + } + try { + if (text.equals(element.getText())) { + break; + } + } catch (Exception e) { + + } + Thread.sleep(1000); + } + return true; + } + + protected boolean isElementPresent(AndroidElement element, By by) { + try { + element.findElement(by); + return true; + } catch (NoSuchElementException e) { + return false; + } + } + + public static boolean isElementPresent(AndroidElement element) { + try { + element.isDisplayed(); + } catch (NoSuchElementException e) { + return false; + } + return true; + } + + //pollingTime in milliseconds + public static void waitTillElementIsNotPresent(AndroidElement element, + int pollingTime) throws Exception { + for (int time = 0; time <= waitingTime * 1000; time += pollingTime) { + try { + element.isDisplayed(); + } catch (NoSuchElementException e) { + return; + } + Thread.sleep(pollingTime); + } + throw new TimeoutException(); + } + + public static void waitTillElementIsNotPresentWithoutTimeout( + AndroidElement element, int pollingTime) + throws InterruptedException { + for (int time = 0; time <= waitingTime * 1000; time += pollingTime) { + try { + element.isDisplayed(); + } catch (NoSuchElementException e) { + return; + } + Thread.sleep(pollingTime); + } + } + + public static void waitTillElementIsPresent( + AndroidElement element, int pollingTime) + throws InterruptedException { + for (int time = 0; time <= waitingTime * 1000; time += pollingTime) { + try { + if (element.isDisplayed()) { + return; + } + } catch (NoSuchElementException e) { + + } + Thread.sleep(pollingTime); + } + } + + protected void takeScreenShotOnFailed(String testName) + throws IOException { + File file = ((RemoteWebDriver) driver) + .getScreenshotAs(OutputType.FILE); + SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); + Date today = Calendar.getInstance().getTime(); + String screenShotName = "ScreenShots/" + dt1.format(today) + "/" + + testName + ".png"; + FileUtils.copyFile(file, new File(screenShotName)); + } + + protected void assertIsInFileListView() throws InterruptedException { + //waitForTextPresent("Wrong username or password", + // changePasswordForm.getAuthStatusText()); + Thread.sleep(2000); + assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".resourceId(\"android:id/action_bar_title\")"))); + assertTrue(isElementPresent((AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".description(\"Upload\")"))); + } + + protected void assertIsNotInFileListView() throws InterruptedException { + AndroidElement fileElement; + assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".resourceId(\"android:id/action_bar_title\")"))); + try { + fileElement = (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".description(\"Upload\")"); + } catch (NoSuchElementException e) { + fileElement = null; + } + assertNull(fileElement); + } + + protected void assertIsPasscodeRequestView() throws InterruptedException { + assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".resourceId(\"android:id/action_bar_title\")"))); + assertTrue(((AndroidElement) driver.findElementByAndroidUIAutomator( + "new UiSelector().text(\"Please, insert your pass code\")")) + .isDisplayed()); + + } + + protected void assertIsInSettingsView() throws InterruptedException { + assertTrue(waitForTextPresent("Settings", (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".resourceId(\"android:id/action_bar_title\")"))); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java index 6ab78a5b31a..a01fc2e01aa 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java @@ -1,54 +1,53 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; public final class Config { - //without http or https - public static final String URL = "owncloudServerVar"; - public static boolean isTrusted = true; - - //without http or https - public static final String URL2 = "owncloudServer2Var"; - public static boolean isTrusted2 = true; - - public static final String user = "owncloudUserVar"; - public static final String password = "owncloudPasswordVar"; - public static final String user2 = "owncloudUser2Var"; - public static final String password2 = "owncloudPassword2Var"; - public static final String userAccount = user + "@"+ URL; - public static final String userAccount2 = user2 + "@"+ URL2; - - public static final String gmailAccount = "gmailAccountVar"; - - public static final String fileWhichIsInTheServer1 ="test"; - public static final String fileWhichIsInTheServer2 ="test"; - - public static final String fileToTestName = "test"; - public static final String fileToTestSendByEmailName = "test"; - public static final String bigFileToTestName = "test"; - - public static final String passcode1 = "passcode1"; - public static final String passcode2 = "passcode2"; - public static final String passcode3 = "passcode3"; - public static final String passcode4 = "passcode4"; + //without http or https + public static final String URL = "owncloudServerVar"; + public static boolean isTrusted = true; + + //without http or https + public static final String URL2 = "owncloudServer2Var"; + public static boolean isTrusted2 = true; + + public static final String user = "owncloudUserVar"; + public static final String password = "owncloudPasswordVar"; + public static final String user2 = "owncloudUser2Var"; + public static final String password2 = "owncloudPassword2Var"; + public static final String userAccount = user + "@" + URL; + public static final String userAccount2 = user2 + "@" + URL2; + + public static final String gmailAccount = "gmailAccountVar"; + + public static final String fileWhichIsInTheServer1 = "test"; + public static final String fileWhichIsInTheServer2 = "test"; + + public static final String fileToTestName = "test"; + public static final String fileToTestSendByEmailName = "test"; + public static final String bigFileToTestName = "test"; + + public static final String passcode1 = "passcode1"; + public static final String passcode2 = "passcode2"; + public static final String passcode3 = "passcode3"; + public static final String passcode4 = "passcode4"; } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java index c4c13bc9ab8..0f91f83c715 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java @@ -1,94 +1,92 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Rule; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; -import com.owncloud.android.test.ui.models.FileListView; -import com.owncloud.android.test.ui.models.WaitAMomentPopUp; +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class CreateFolderTestSuite{ - - AndroidDriver driver; - Common common; - private Boolean folderHasBeenCreated = false; - private final String FOLDER_NAME = "testCreateFolder"; - private String CurrentCreatedFolder = ""; - - @Rule public TestName name = new TestName(); +public class CreateFolderTestSuite { + + AndroidDriver driver; + Common common; + private Boolean folderHasBeenCreated = false; + private final String FOLDER_NAME = "testCreateFolder"; + private String CurrentCreatedFolder = ""; + + @Rule + public TestName name = new TestName(); - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testCreateNewFolder () throws Exception { - String NEW_FOLDER_NAME = "testCreateFolder"; + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testCreateNewFolder() throws Exception { + String NEW_FOLDER_NAME = "testCreateFolder"; - FileListView fileListView = Actions.login(Config.URL, - Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); + FileListView fileListView = Actions.login(Config.URL, + Config.user, Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); - //check if the folder already exists and if true, delete them - Actions.deleteElement(NEW_FOLDER_NAME, fileListView, driver); + //check if the folder already exists and if true, delete them + Actions.deleteElement(NEW_FOLDER_NAME, fileListView, driver); - WaitAMomentPopUp waitAMomentPopUp = Actions - .createFolder(NEW_FOLDER_NAME, fileListView); - Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp - .getWaitAMomentTextElement(), 100); - fileListView.scrollTillFindElement(FOLDER_NAME); - assertNotNull(fileListView.getFileElement()); - assertTrue( - folderHasBeenCreated=fileListView.getFileElement().isDisplayed()); - CurrentCreatedFolder = FOLDER_NAME; - assertEquals(FOLDER_NAME , fileListView.getFileElement().getText()); - } + WaitAMomentPopUp waitAMomentPopUp = Actions + .createFolder(NEW_FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertNotNull(fileListView.getFileElement()); + assertTrue( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + CurrentCreatedFolder = FOLDER_NAME; + assertEquals(FOLDER_NAME, fileListView.getFileElement().getText()); + } - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - if (folderHasBeenCreated) { - FileListView fileListView = new FileListView(driver); - Actions.deleteElement(CurrentCreatedFolder, fileListView, driver); - } - driver.removeApp("com.owncloud.android"); - driver.quit(); - } + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (folderHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(CurrentCreatedFolder, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java index 1cbf31fa7e3..3222aff101e 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java @@ -1,87 +1,85 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Rule; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.support.ui.ExpectedConditions; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; -import com.owncloud.android.test.ui.models.FileListView; - +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class DeleteFileTestSuite{ - - AndroidDriver driver; - Common common; - private final String FILE_NAME = Config.fileToTestName; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } +public class DeleteFileTestSuite { + + AndroidDriver driver; + Common common; + private final String FILE_NAME = Config.fileToTestName; + + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testDeleteFile() throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + Common.waitTillElementIsNotPresentWithoutTimeout( + fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf( + fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())))); - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testDeleteFile () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //TODO. if the file already exists, do not upload - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - Common.waitTillElementIsNotPresentWithoutTimeout( - fileListViewAfterUploadFile.getProgressCircular(), 1000); - common.wait.until(ExpectedConditions.visibilityOf( - fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getLocalFileIndicator())))); - - Actions.deleteElement(FILE_NAME,fileListViewAfterUploadFile, driver); - assertFalse(fileListViewAfterUploadFile.getFileElement().isDisplayed()); - } + Actions.deleteElement(FILE_NAME, fileListViewAfterUploadFile, driver); + assertFalse(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + } - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java index 25ba04dbb9d..db788b40893 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java @@ -1,92 +1,89 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Rule; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; -import com.owncloud.android.test.ui.models.FileListView; -import com.owncloud.android.test.ui.models.WaitAMomentPopUp; +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class DeleteFolderTestSuite{ - AndroidDriver driver; - Common common; - private Boolean folderHasBeenCreated = false; - private final String FOLDER_NAME = "testCreateFolder"; - - @Rule public TestName name = new TestName(); +public class DeleteFolderTestSuite { + AndroidDriver driver; + Common common; + private Boolean folderHasBeenCreated = false; + private final String FOLDER_NAME = "testCreateFolder"; + + @Rule + public TestName name = new TestName(); + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testDeleteFolder() throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testDeleteFolder () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //TODO. if the folder already exists, do no created - //create the folder - WaitAMomentPopUp waitAMomentPopUp = Actions - .createFolder(FOLDER_NAME, fileListView); - Common.waitTillElementIsNotPresentWithoutTimeout( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); - fileListView.scrollTillFindElement(FOLDER_NAME); - assertTrue( - folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + //TODO. if the folder already exists, do no created + //create the folder + WaitAMomentPopUp waitAMomentPopUp = Actions + .createFolder(FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresentWithoutTimeout( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertTrue( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); - //delete the folder - Actions.deleteElement(FOLDER_NAME, fileListView, driver); - assertFalse( - folderHasBeenCreated =fileListView.getFileElement().isDisplayed()); - } + //delete the folder + Actions.deleteElement(FOLDER_NAME, fileListView, driver); + assertFalse( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + } - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - if(folderHasBeenCreated){ - FileListView fileListView = new FileListView(driver); - Actions.deleteElement(FOLDER_NAME, fileListView, driver); - } - driver.removeApp("com.owncloud.android"); - driver.quit(); - } + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (folderHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(FOLDER_NAME, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java index 98df8885786..a588691d35b 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java @@ -1,181 +1,176 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.*; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.LoginForm; +import com.owncloud.android.test.ui.models.MenuList; +import com.owncloud.android.test.ui.models.SettingsView; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Rule; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; import org.openqa.selenium.ScreenOrientation; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.*; -import com.owncloud.android.test.ui.models.LoginForm; -import com.owncloud.android.test.ui.models.FileListView; -import com.owncloud.android.test.ui.models.MenuList; -import com.owncloud.android.test.ui.models.SettingsView; +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class LoginTestSuite{ - AndroidDriver driver; - Common common; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test1LoginPortrait () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - - Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test2LoginLandscape () throws Exception { - driver.rotate(ScreenOrientation.LANDSCAPE); - Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testLoginAndShowFiles () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer1); - assertTrue(fileListView.getFileElement().isDisplayed()); - } - - - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void test3MultiAccountRotate () throws Exception { - driver.rotate(ScreenOrientation.LANDSCAPE); - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - driver.rotate(ScreenOrientation.PORTRAIT); - MenuList menu = fileListView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - - settingsView.tapOnAddAccount(1, 1000); - fileListView = Actions.login(Config.URL2, Config.user2, - Config.password2, Config.isTrusted2, driver); - common.assertIsInSettingsView(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testMultiAccountAndShowFiles () throws Exception { - driver.rotate(ScreenOrientation.LANDSCAPE); - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer1); - assertTrue(fileListView.getFileElement().isDisplayed()); - - driver.rotate(ScreenOrientation.PORTRAIT); - MenuList menu = fileListView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - - settingsView.tapOnAddAccount(1, 1000); - fileListView = Actions.login(Config.URL2, Config.user2, - Config.password2, Config.isTrusted2, driver); - common.assertIsInSettingsView(); - settingsView.tapOnAccountElement(2,1, 100); - common.assertIsInFileListView(); - - fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer2); - assertTrue(fileListView.getFileElement().isDisplayed()); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test4ExistingAccountRotate () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - driver.rotate(ScreenOrientation.LANDSCAPE); - MenuList menu = fileListView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - settingsView.tapOnAddAccount(1, 1000); - - LoginForm loginForm = new LoginForm(driver); - fileListView = Actions.login(Config.URL, Config.user,Config.password, - Config.isTrusted, driver); - assertTrue(common.waitForTextPresent("An account for the same user and" - + " server already exists in the device", - loginForm.getAuthStatusText())); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test5ChangePasswordWrong () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - MenuList menu = fileListView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - settingsView.tapOnAccountElement(1,1, 1000); - LoginForm changePasswordForm = settingsView - .clickOnChangePasswordElement(); - changePasswordForm.typePassword("WrongPassword"); - changePasswordForm.clickOnConnectButton(); - assertTrue(common.waitForTextPresent("Wrong username or password", - changePasswordForm.getAuthStatusText())); - } - - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } - - +public class LoginTestSuite { + AndroidDriver driver; + Common common; + + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test1LoginPortrait() throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + + Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test2LoginLandscape() throws Exception { + driver.rotate(ScreenOrientation.LANDSCAPE); + Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testLoginAndShowFiles() throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer1); + assertTrue(fileListView.getFileElement().isDisplayed()); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void test3MultiAccountRotate() throws Exception { + driver.rotate(ScreenOrientation.LANDSCAPE); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + driver.rotate(ScreenOrientation.PORTRAIT); + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + + settingsView.tapOnAddAccount(1, 1000); + fileListView = Actions.login(Config.URL2, Config.user2, + Config.password2, Config.isTrusted2, driver); + common.assertIsInSettingsView(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testMultiAccountAndShowFiles() throws Exception { + driver.rotate(ScreenOrientation.LANDSCAPE); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer1); + assertTrue(fileListView.getFileElement().isDisplayed()); + + driver.rotate(ScreenOrientation.PORTRAIT); + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + + settingsView.tapOnAddAccount(1, 1000); + fileListView = Actions.login(Config.URL2, Config.user2, + Config.password2, Config.isTrusted2, driver); + common.assertIsInSettingsView(); + settingsView.tapOnAccountElement(2, 1, 100); + common.assertIsInFileListView(); + + fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer2); + assertTrue(fileListView.getFileElement().isDisplayed()); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test4ExistingAccountRotate() throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + driver.rotate(ScreenOrientation.LANDSCAPE); + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + settingsView.tapOnAddAccount(1, 1000); + + LoginForm loginForm = new LoginForm(driver); + fileListView = Actions.login(Config.URL, Config.user, Config.password, + Config.isTrusted, driver); + assertTrue(common.waitForTextPresent("An account for the same user and" + + " server already exists in the device", + loginForm.getAuthStatusText())); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test5ChangePasswordWrong() throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + settingsView.tapOnAccountElement(1, 1, 1000); + LoginForm changePasswordForm = settingsView + .clickOnChangePasswordElement(); + changePasswordForm.typePassword("WrongPassword"); + changePasswordForm.clickOnConnectButton(); + assertTrue(common.waitForTextPresent("Wrong username or password", + changePasswordForm.getAuthStatusText())); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java index 97f7473351f..890139dd115 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java @@ -1,29 +1,32 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; - -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.LoginForm; +import com.owncloud.android.test.ui.models.MenuList; +import com.owncloud.android.test.ui.models.SettingsView; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -31,47 +34,42 @@ import org.junit.experimental.categories.Category; import org.junit.rules.TestName; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; -import com.owncloud.android.test.ui.models.LoginForm; -import com.owncloud.android.test.ui.models.FileListView; -import com.owncloud.android.test.ui.models.MenuList; -import com.owncloud.android.test.ui.models.SettingsView; +import static org.junit.Assert.*; + +public class LogoutTestSuite { + + AndroidDriver driver; + Common common; -public class LogoutTestSuite{ - - AndroidDriver driver; - Common common; + @Rule + public TestName name = new TestName(); - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testLogout () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - MenuList menulist = fileListView.clickOnMenuButton(); - SettingsView settingsView = menulist.clickOnSettingsButton(); - settingsView.tapOnAccountElement(1,1, 1000); - LoginForm loginForm = settingsView.clickOnDeleteAccountElement(); - assertEquals("Server address https://…", - loginForm.gethostUrlInput().getText()); - assertEquals("Username", loginForm.getUserNameInput().getText()); - assertEquals("", loginForm.getPasswordInput().getText()); - } + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testLogout() throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + MenuList menulist = fileListView.clickOnMenuButton(); + SettingsView settingsView = menulist.clickOnSettingsButton(); + settingsView.tapOnAccountElement(1, 1, 1000); + LoginForm loginForm = settingsView.clickOnDeleteAccountElement(); + assertEquals("Server address https://…", + loginForm.gethostUrlInput().getText()); + assertEquals("Username", loginForm.getUserNameInput().getText()); + assertEquals("", loginForm.getPasswordInput().getText()); + } - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - //driver.removeApp("com.owncloud.android"); - driver.quit(); - } + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + //driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java index dc3a76c323a..807900f2f65 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java @@ -1,28 +1,32 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MoveView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; import org.junit.FixMethodOrder; @@ -32,89 +36,82 @@ import org.junit.rules.TestName; import org.junit.runners.MethodSorters; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; -import com.owncloud.android.test.ui.models.ElementMenuOptions; -import com.owncloud.android.test.ui.models.FileListView; -import com.owncloud.android.test.ui.models.MoveView; -import com.owncloud.android.test.ui.models.WaitAMomentPopUp; - - +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class MoveFileTestSuite{ - AndroidDriver driver; - Common common; - private String FOLDER_WHERE_MOVE = "folderWhereMove"; - private String FILE_NAME = Config.fileToTestName; - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testMoveFile () throws Exception { - WaitAMomentPopUp waitAMomentPopUp; - - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //Common.waitTillElementIsNotPresentWithoutTimeout( - //fileListView.getProgressCircular(), 1000); - - //check if the folder already exists and if true, delete them - Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); - Actions.deleteElement(FILE_NAME, fileListView, driver); - - //Create the folder where the other is gone to be moved - waitAMomentPopUp = Actions - .createFolder(FOLDER_WHERE_MOVE, fileListView); - Common.waitTillElementIsNotPresentWithoutTimeout( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); - fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); - assertTrue(fileListView.getFileElement().isDisplayed()); - - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); - - //select to move the file - ElementMenuOptions menuOptions = fileListView - .longPressOnElement(FILE_NAME); - MoveView moveView = menuOptions.clickOnMove(); - - //to move to a folder - moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - waitAMomentPopUp = moveView.clickOnChoose(); - Common.waitTillElementIsNotPresentWithoutTimeout( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); - - //check that the folder moved is inside the other - fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), - 1000); - Thread.sleep(1000); - fileListView.scrollTillFindElement(FILE_NAME); - assertEquals(FILE_NAME , fileListView.getFileElement().getText()); - - } - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - FileListView fileListView = new FileListView(driver); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); - Actions.deleteElement(FILE_NAME, fileListView, driver); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } +public class MoveFileTestSuite { + AndroidDriver driver; + Common common; + private String FOLDER_WHERE_MOVE = "folderWhereMove"; + private String FILE_NAME = Config.fileToTestName; + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testMoveFile() throws Exception { + WaitAMomentPopUp waitAMomentPopUp; + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //Common.waitTillElementIsNotPresentWithoutTimeout( + //fileListView.getProgressCircular(), 1000); + + //check if the folder already exists and if true, delete them + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FILE_NAME, fileListView, driver); + + //Create the folder where the other is gone to be moved + waitAMomentPopUp = Actions + .createFolder(FOLDER_WHERE_MOVE, fileListView); + Common.waitTillElementIsNotPresentWithoutTimeout( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); + + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + + //select to move the file + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(FILE_NAME); + MoveView moveView = menuOptions.clickOnMove(); + + //to move to a folder + moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1, 1); + waitAMomentPopUp = moveView.clickOnChoose(); + Common.waitTillElementIsNotPresentWithoutTimeout( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); + + //check that the folder moved is inside the other + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1, 1); + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), + 1000); + Thread.sleep(1000); + fileListView.scrollTillFindElement(FILE_NAME); + assertEquals(FILE_NAME, fileListView.getFileElement().getText()); + + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + FileListView fileListView = new FileListView(driver); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FILE_NAME, fileListView, driver); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java index 7e269d600b2..cb6c082cecf 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java @@ -1,37 +1,24 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - import com.owncloud.android.test.ui.actions.Actions; import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.SmokeTestCategory; @@ -39,84 +26,94 @@ import com.owncloud.android.test.ui.models.FileListView; import com.owncloud.android.test.ui.models.MoveView; import com.owncloud.android.test.ui.models.WaitAMomentPopUp; +import io.appium.java_client.android.AndroidDriver; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class MoveFolderTestSuite{ - AndroidDriver driver; - Common common; - private String FOLDER_TO_MOVE = "folderToMove"; - private String FOLDER_WHERE_MOVE = "folderWhereMove"; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testMoveFolder () throws Exception { - WaitAMomentPopUp waitAMomentPopUp; - - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //Common.waitTillElementIsNotPresentWithoutTimeout( - //fileListView.getProgressCircular(), 1000); - - //check if the folder already exists and if true, delete them - Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); - Actions.deleteElement(FOLDER_TO_MOVE, fileListView, driver); - - //Create the folder where the other is gone to be moved - waitAMomentPopUp = Actions - .createFolder(FOLDER_WHERE_MOVE, fileListView); - Common.waitTillElementIsNotPresentWithoutTimeout( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); - fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); - assertTrue(fileListView.getFileElement().isDisplayed()); - - //Create the folder which is going to be moved - waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, fileListView); - Common.waitTillElementIsNotPresent( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); - fileListView.scrollTillFindElement(FOLDER_TO_MOVE); - assertTrue(fileListView.getFileElement().isDisplayed()); - - //select to move the folder - ElementMenuOptions menuOptions = fileListView - .longPressOnElement(FOLDER_TO_MOVE); - MoveView moveView = menuOptions.clickOnMove(); - - //to move to a folder - moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - waitAMomentPopUp = moveView.clickOnChoose(); - Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp - .getWaitAMomentTextElement(), 100); - - //check that the folder moved is inside the other - fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), - 1000); - Thread.sleep(1000); - fileListView.scrollTillFindElement(FOLDER_TO_MOVE); - assertEquals(FOLDER_TO_MOVE , fileListView.getFileElement().getText()); - } - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - FileListView fileListView = new FileListView(driver); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); - Actions.deleteElement(FOLDER_TO_MOVE, fileListView, driver); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } - +public class MoveFolderTestSuite { + AndroidDriver driver; + Common common; + private String FOLDER_TO_MOVE = "folderToMove"; + private String FOLDER_WHERE_MOVE = "folderWhereMove"; + + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testMoveFolder() throws Exception { + WaitAMomentPopUp waitAMomentPopUp; + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //Common.waitTillElementIsNotPresentWithoutTimeout( + //fileListView.getProgressCircular(), 1000); + + //check if the folder already exists and if true, delete them + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FOLDER_TO_MOVE, fileListView, driver); + + //Create the folder where the other is gone to be moved + waitAMomentPopUp = Actions + .createFolder(FOLDER_WHERE_MOVE, fileListView); + Common.waitTillElementIsNotPresentWithoutTimeout( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); + + //Create the folder which is going to be moved + waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, fileListView); + Common.waitTillElementIsNotPresent( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_TO_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); + + //select to move the folder + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(FOLDER_TO_MOVE); + MoveView moveView = menuOptions.clickOnMove(); + + //to move to a folder + moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1, 1); + waitAMomentPopUp = moveView.clickOnChoose(); + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + + //check that the folder moved is inside the other + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1, 1); + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), + 1000); + Thread.sleep(1000); + fileListView.scrollTillFindElement(FOLDER_TO_MOVE); + assertEquals(FOLDER_TO_MOVE, fileListView.getFileElement().getText()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + FileListView fileListView = new FileListView(driver); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FOLDER_TO_MOVE, fileListView, driver); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java index 263a6c70c20..3dfd54753db 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java @@ -1,27 +1,32 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MenuList; +import com.owncloud.android.test.ui.models.PassCodeRequestView; +import com.owncloud.android.test.ui.models.PassCodeView; +import com.owncloud.android.test.ui.models.SettingsView; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; import org.junit.FixMethodOrder; @@ -32,67 +37,59 @@ import org.junit.runners.MethodSorters; import org.openqa.selenium.ScreenOrientation; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.models.FileListView; -import com.owncloud.android.test.ui.models.MenuList; -import com.owncloud.android.test.ui.models.PassCodeRequestView; -import com.owncloud.android.test.ui.models.PassCodeView; -import com.owncloud.android.test.ui.models.SettingsView; - @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class PasscodeTestSuite { - AndroidDriver driver; - Common common; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void testPincodeEnable () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - MenuList menu = fileListView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - - PassCodeView passCodeview = settingsView.EnablePassCode(); - PassCodeView passCodeview2 = passCodeview.enterPasscode( - Config.passcode1, Config.passcode2, Config.passcode3, - Config.passcode4); - passCodeview2.reenterPasscode(Config.passcode1, Config.passcode2, - Config.passcode3, Config.passcode4); - - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); - //TO DO. Open the app instead of start an activity - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - //here we check that we are not in the fileDisplayActivity, - //because pincode is asked - common.assertIsNotInFileListView(); - common.assertIsPasscodeRequestView(); - - PassCodeRequestView passCodeReequestView = new - PassCodeRequestView(driver); - passCodeReequestView.enterPasscode(Config.passcode1, Config.passcode2, - Config.passcode3, Config.passcode4); - common.assertIsInFileListView(); - } - - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } + AndroidDriver driver; + Common common; + + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void testPincodeEnable() throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + + PassCodeView passCodeview = settingsView.EnablePassCode(); + PassCodeView passCodeview2 = passCodeview.enterPasscode( + Config.passcode1, Config.passcode2, Config.passcode3, + Config.passcode4); + passCodeview2.reenterPasscode(Config.passcode1, Config.passcode2, + Config.passcode3, Config.passcode4); + + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); + //TO DO. Open the app instead of start an activity + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + //here we check that we are not in the fileDisplayActivity, + //because pincode is asked + common.assertIsNotInFileListView(); + common.assertIsPasscodeRequestView(); + + PassCodeRequestView passCodeReequestView = new + PassCodeRequestView(driver); + passCodeReequestView.enterPasscode(Config.passcode1, Config.passcode2, + Config.passcode3, Config.passcode4); + common.assertIsInFileListView(); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java index 6badab4eeac..322080d83b6 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java @@ -1,77 +1,73 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.UnfinishedTestCategory; +import com.owncloud.android.test.ui.models.FileListView; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Rule; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.UnfinishedTestCategory; -import com.owncloud.android.test.ui.models.FileListView; +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class RefreshFolderTestSuite{ - AndroidDriver driver; - Common common; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } +public class RefreshFolderTestSuite { + AndroidDriver driver; + Common common; + @Rule + public TestName name = new TestName(); - @Test - @Category({UnfinishedTestCategory.class}) - public void testPulldownToRefreshFolder () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - //TODO. Remove the sleep and check why is not working the assert - //when using waitTillElementIsNotPresent - Thread.sleep(5000); - //waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); - fileListView.pulldownToRefresh(); - assertTrue(fileListView.getProgressCircular().isDisplayed()); - //TODO insert a file in the web, and check that it's shown here - } + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + @Test + @Category({UnfinishedTestCategory.class}) + public void testPulldownToRefreshFolder() throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + //TODO. Remove the sleep and check why is not working the assert + //when using waitTillElementIsNotPresent + Thread.sleep(5000); + //waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); + fileListView.pulldownToRefresh(); + assertTrue(fileListView.getProgressCircular().isDisplayed()); + //TODO insert a file in the web, and check that it's shown here + } - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java index e8edc48402c..77c430f886c 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java @@ -1,114 +1,112 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.NewFolderPopUp; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; import io.appium.java_client.android.AndroidDriver; - import org.junit.After; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Rule; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.support.ui.ExpectedConditions; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; -import com.owncloud.android.test.ui.models.ElementMenuOptions; -import com.owncloud.android.test.ui.models.FileListView; -import com.owncloud.android.test.ui.models.NewFolderPopUp; -import com.owncloud.android.test.ui.models.WaitAMomentPopUp; - +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class RenameFileTestSuite{ +public class RenameFileTestSuite { + + AndroidDriver driver; + Common common; + private Boolean fileHasBeenCreated = false; + private final String OLD_FILE_NAME = Config.fileToTestName; + private final String FILE_NAME = "newNameFile"; + private String CurrentCreatedFile = ""; - AndroidDriver driver; - Common common; - private Boolean fileHasBeenCreated = false; - private final String OLD_FILE_NAME = Config.fileToTestName; - private final String FILE_NAME = "newNameFile"; - private String CurrentCreatedFile = ""; - - @Rule public TestName name = new TestName(); + @Rule + public TestName name = new TestName(); - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testRenameFile () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testRenameFile() throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); - //TODO. if the file already exists, do not upload - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(OLD_FILE_NAME, fileListView); + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(OLD_FILE_NAME, fileListView); - //check if the file with the new name already exists, if true delete it - Actions.deleteElement(FILE_NAME, fileListView, driver); + //check if the file with the new name already exists, if true delete it + Actions.deleteElement(FILE_NAME, fileListView, driver); - fileListViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME); - assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile - .getFileElement().isDisplayed()); - CurrentCreatedFile = OLD_FILE_NAME; - Common.waitTillElementIsNotPresentWithoutTimeout(fileListViewAfterUploadFile - .getProgressCircular(), 1000); - common.wait.until(ExpectedConditions.visibilityOf( - fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getLocalFileIndicator())))); - ElementMenuOptions menuOptions = fileListViewAfterUploadFile - .longPressOnElement(OLD_FILE_NAME); - NewFolderPopUp newFolderPopUp = menuOptions.clickOnRename(); - newFolderPopUp.typeNewFolderName(FILE_NAME); - WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp - .clickOnNewFolderOkButton(); - Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp - .getWaitAMomentTextElement(), 100); - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertNotNull(fileListViewAfterUploadFile.getFileElement()); - assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); - assertEquals(FILE_NAME , fileListViewAfterUploadFile.getFileElement() - .getText()); - CurrentCreatedFile = FILE_NAME; - } + fileListViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME); + assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); + CurrentCreatedFile = OLD_FILE_NAME; + Common.waitTillElementIsNotPresentWithoutTimeout(fileListViewAfterUploadFile + .getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf( + fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())))); + ElementMenuOptions menuOptions = fileListViewAfterUploadFile + .longPressOnElement(OLD_FILE_NAME); + NewFolderPopUp newFolderPopUp = menuOptions.clickOnRename(); + newFolderPopUp.typeNewFolderName(FILE_NAME); + WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp + .clickOnNewFolderOkButton(); + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertNotNull(fileListViewAfterUploadFile.getFileElement()); + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + assertEquals(FILE_NAME, fileListViewAfterUploadFile.getFileElement() + .getText()); + CurrentCreatedFile = FILE_NAME; + } - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - if (fileHasBeenCreated) { - FileListView fileListView = new FileListView(driver); - Actions.deleteElement(CurrentCreatedFile,fileListView, driver); - } - driver.removeApp("com.owncloud.android"); - driver.quit(); - } + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (fileHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(CurrentCreatedFile, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java index 5967aac9ab0..15dae025f7b 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java @@ -1,37 +1,24 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - import com.owncloud.android.test.ui.actions.Actions; import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.SmokeTestCategory; @@ -39,74 +26,84 @@ import com.owncloud.android.test.ui.models.FileListView; import com.owncloud.android.test.ui.models.NewFolderPopUp; import com.owncloud.android.test.ui.models.WaitAMomentPopUp; +import io.appium.java_client.android.AndroidDriver; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class RenameFolderTestSuite{ - - AndroidDriver driver; - Common common; - private Boolean folderHasBeenCreated = false; - private final String OLD_FOLDER_NAME = "beforeRemoving"; - private final String FOLDER_NAME = "testCreateFolder"; - private String CurrentCreatedFolder = ""; - - @Rule public TestName name = new TestName(); - - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testRenameFolder () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //TODO. if the folder already exists, do no created - //create the folder to rename - WaitAMomentPopUp waitAMomentPopUp = Actions - .createFolder(OLD_FOLDER_NAME, fileListView); - Common.waitTillElementIsNotPresentWithoutTimeout( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); - fileListView.scrollTillFindElement(OLD_FOLDER_NAME); - - assertTrue( - folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); - - //check if the folder with the new name already exists - //and if true, delete them - Actions.deleteElement(FOLDER_NAME, fileListView, driver); - - CurrentCreatedFolder = OLD_FOLDER_NAME; - ElementMenuOptions menuOptions = fileListView - .longPressOnElement(OLD_FOLDER_NAME); - NewFolderPopUp FolderPopUp = menuOptions.clickOnRename(); - FolderPopUp.typeNewFolderName(FOLDER_NAME); - FolderPopUp.clickOnNewFolderOkButton(); - CurrentCreatedFolder = FOLDER_NAME; - Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp - .getWaitAMomentTextElement(), 100); - fileListView.scrollTillFindElement(FOLDER_NAME); - assertNotNull(fileListView.getFileElement()); - assertTrue( - folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); - assertEquals(FOLDER_NAME , fileListView.getFileElement().getText()); - } - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - if(folderHasBeenCreated){ - FileListView fileListView = new FileListView(driver); - Actions.deleteElement(CurrentCreatedFolder, fileListView, driver); - } - driver.removeApp("com.owncloud.android"); - driver.quit(); - } +public class RenameFolderTestSuite { + + AndroidDriver driver; + Common common; + private Boolean folderHasBeenCreated = false; + private final String OLD_FOLDER_NAME = "beforeRemoving"; + private final String FOLDER_NAME = "testCreateFolder"; + private String CurrentCreatedFolder = ""; + + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testRenameFolder() throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the folder already exists, do no created + //create the folder to rename + WaitAMomentPopUp waitAMomentPopUp = Actions + .createFolder(OLD_FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresentWithoutTimeout( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(OLD_FOLDER_NAME); + + assertTrue( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + + //check if the folder with the new name already exists + //and if true, delete them + Actions.deleteElement(FOLDER_NAME, fileListView, driver); + + CurrentCreatedFolder = OLD_FOLDER_NAME; + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(OLD_FOLDER_NAME); + NewFolderPopUp FolderPopUp = menuOptions.clickOnRename(); + FolderPopUp.typeNewFolderName(FOLDER_NAME); + FolderPopUp.clickOnNewFolderOkButton(); + CurrentCreatedFolder = FOLDER_NAME; + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertNotNull(fileListView.getFileElement()); + assertTrue( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + assertEquals(FOLDER_NAME, fileListView.getFileElement().getText()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (folderHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(CurrentCreatedFolder, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java index 0041718d553..0d0719b4aa3 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java @@ -1,37 +1,33 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; - -import org.junit.experimental.categories.Categories.ExcludeCategory; -import org.junit.experimental.categories.Categories.IncludeCategory; -import org.junit.runner.RunWith; - import com.owncloud.android.test.ui.groups.FailingTestCategory; import com.owncloud.android.test.ui.groups.FlexibleCategories; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassPrefix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassSuffix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestScanPackage; - +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import org.junit.experimental.categories.Categories.ExcludeCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; @RunWith(FlexibleCategories.class) @ExcludeCategory(NoIgnoreTestCategory.class) diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java index 9fb14a053f1..fe6fd13b5ee 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java @@ -1,13 +1,12 @@ package com.owncloud.android.test.ui.testSuites; -import org.junit.experimental.categories.Categories.IncludeCategory; -import org.junit.runner.RunWith; import com.owncloud.android.test.ui.groups.FlexibleCategories; -import com.owncloud.android.test.ui.groups.InProgressCategory; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassPrefix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassSuffix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestScanPackage; - +import com.owncloud.android.test.ui.groups.InProgressCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; @RunWith(FlexibleCategories.class) @IncludeCategory(InProgressCategory.class) diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java index dc701255457..9db8536aa63 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java @@ -1,36 +1,33 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import org.junit.experimental.categories.Categories.ExcludeCategory; -import org.junit.experimental.categories.Categories.IncludeCategory; -import org.junit.runner.RunWith; - import com.owncloud.android.test.ui.groups.FlexibleCategories; -import com.owncloud.android.test.ui.groups.IgnoreTestCategory; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassPrefix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassSuffix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestScanPackage; - +import com.owncloud.android.test.ui.groups.IgnoreTestCategory; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import org.junit.experimental.categories.Categories.ExcludeCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; @RunWith(FlexibleCategories.class) @ExcludeCategory(IgnoreTestCategory.class) diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java index bb9b03e3c92..80a27d2b162 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java @@ -1,36 +1,33 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import org.junit.experimental.categories.Categories.ExcludeCategory; -import org.junit.experimental.categories.Categories.IncludeCategory; -import org.junit.runner.RunWith; - import com.owncloud.android.test.ui.groups.FlexibleCategories; -import com.owncloud.android.test.ui.groups.IgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassPrefix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassSuffix; import com.owncloud.android.test.ui.groups.FlexibleCategories.TestScanPackage; - +import com.owncloud.android.test.ui.groups.IgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import org.junit.experimental.categories.Categories.ExcludeCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; @RunWith(FlexibleCategories.class) @ExcludeCategory(IgnoreTestCategory.class) diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java index 1c7b29f05b7..46935f10e6a 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java @@ -1,29 +1,31 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.*; +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.IgnoreTestCategory; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; - import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -31,103 +33,101 @@ import org.junit.experimental.categories.Category; import org.junit.rules.TestName; -import com.owncloud.android.test.ui.actions.Actions; -import com.owncloud.android.test.ui.groups.IgnoreTestCategory; -import com.owncloud.android.test.ui.groups.InProgressCategory; -import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; -import com.owncloud.android.test.ui.groups.SmokeTestCategory; -import com.owncloud.android.test.ui.models.FileListView;; - -public class ShareLinkFileTestSuite{ - - AndroidDriver driver; - Common common; - private final String FILE_NAME = Config.fileToTestName; - private Boolean fileHasBeenCreated = false; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void testShareLinkFileByGmail () throws Exception { - AndroidElement sharedElementIndicator; - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //TODO. if the file already exists, do not upload - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile - .getFileElement().isDisplayed()); - - sharedElementIndicator = Actions.shareLinkElementByGmail(FILE_NAME, - fileListViewAfterUploadFile,driver,common); - assertTrue(sharedElementIndicator.isDisplayed()); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testShareLinkFileByCopyLink () throws Exception { - AndroidElement sharedElementIndicator; - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //TODO. if the file already exists, do not upload - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile - .getFileElement().isDisplayed()); - - sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME, - fileListViewAfterUploadFile,driver,common); - assertTrue(sharedElementIndicator.isDisplayed()); - } - - @Test - @Category({IgnoreTestCategory.class, SmokeTestCategory.class}) - public void testUnshareLinkFile () throws Exception { - AndroidElement sharedElementIndicator; - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //TODO. if the file already exists, do not upload - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile - .getFileElement().isDisplayed()); - - sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME, - fileListViewAfterUploadFile,driver,common); - assertTrue(sharedElementIndicator.isDisplayed()); - Actions.unshareLinkElement(FILE_NAME, - fileListViewAfterUploadFile,driver,common); - assertFalse(sharedElementIndicator.isDisplayed()); - - } - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - if (fileHasBeenCreated) { - FileListView fileListView = new FileListView(driver); - Actions.deleteElement(FILE_NAME,fileListView, driver); - } - driver.removeApp("com.owncloud.android"); - driver.quit(); - } +import static org.junit.Assert.*; + +; + +public class ShareLinkFileTestSuite { + + AndroidDriver driver; + Common common; + private final String FILE_NAME = Config.fileToTestName; + private Boolean fileHasBeenCreated = false; + + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void testShareLinkFileByGmail() throws Exception { + AndroidElement sharedElementIndicator; + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); + + sharedElementIndicator = Actions.shareLinkElementByGmail(FILE_NAME, + fileListViewAfterUploadFile, driver, common); + assertTrue(sharedElementIndicator.isDisplayed()); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testShareLinkFileByCopyLink() throws Exception { + AndroidElement sharedElementIndicator; + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); + + sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME, + fileListViewAfterUploadFile, driver, common); + assertTrue(sharedElementIndicator.isDisplayed()); + } + + @Test + @Category({IgnoreTestCategory.class, SmokeTestCategory.class}) + public void testUnshareLinkFile() throws Exception { + AndroidElement sharedElementIndicator; + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); + + sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME, + fileListViewAfterUploadFile, driver, common); + assertTrue(sharedElementIndicator.isDisplayed()); + Actions.unshareLinkElement(FILE_NAME, + fileListViewAfterUploadFile, driver, common); + assertFalse(sharedElementIndicator.isDisplayed()); + + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (fileHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(FILE_NAME, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java index 74580572b69..f0379e8beb8 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java @@ -1,285 +1,272 @@ /** - * ownCloud Android client application - * - * @author purigarcia - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author purigarcia + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.test.ui.testSuites; - -import static org.junit.Assert.*; -import io.appium.java_client.MobileBy; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.support.ui.ExpectedConditions; - import com.owncloud.android.test.ui.actions.Actions; import com.owncloud.android.test.ui.groups.FailingTestCategory; -import com.owncloud.android.test.ui.groups.InProgressCategory; import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.SmokeTestCategory; import com.owncloud.android.test.ui.groups.UnfinishedTestCategory; -import com.owncloud.android.test.ui.models.FileDetailsView; import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileDetailsView; +import com.owncloud.android.test.ui.models.FileListView; import com.owncloud.android.test.ui.models.GmailEmailListView; import com.owncloud.android.test.ui.models.GmailEmailView; import com.owncloud.android.test.ui.models.ImageView; -import com.owncloud.android.test.ui.models.FileListView; import com.owncloud.android.test.ui.models.NotificationView; -import com.owncloud.android.test.ui.models.SettingsView; import com.owncloud.android.test.ui.models.UploadView; +import io.appium.java_client.MobileBy; +import io.appium.java_client.android.AndroidDriver; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.support.ui.ExpectedConditions; +import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Category({NoIgnoreTestCategory.class}) -public class UploadTestSuite{ - - AndroidDriver driver; - Common common; - String FILE_NAME = Config.fileToTestName; - String BIG_FILE_NAME = Config.bigFileToTestName; - String FILE_GMAIL_NAME = Config.fileToTestSendByEmailName; - private Boolean fileHasBeenUploadedFromGmail = false; - private Boolean fileHasBeenUploaded = false; - - @Rule public TestName name = new TestName(); - - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testUploadFile () throws Exception { - - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //check if the file already exists and if true, delete it - Actions.deleteElement(FILE_NAME, fileListView, driver); - - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); - Common.waitTillElementIsNotPresentWithoutTimeout( - fileListViewAfterUploadFile.getProgressCircular(), 1000); - common.wait.until(ExpectedConditions.visibilityOf( - fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getLocalFileIndicator())))); - assertTrue(fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getLocalFileIndicator())) - .isDisplayed()); - fileListView = new FileListView(driver); - fileListView.scrollTillFindElement(FILE_NAME); - assertTrue( - fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); - } - - - - @Test - @Category({UnfinishedTestCategory.class}) - public void testUploadBigFile () throws Exception { - - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - //check if the file already exists and if true, delete it - Actions.deleteElement(BIG_FILE_NAME, fileListView, driver); - - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(BIG_FILE_NAME, fileListView); - - - driver.openNotifications(); - NotificationView notificationView = new NotificationView(driver); - - try{ - if(notificationView.getUploadingNotification().isDisplayed()){ - Common.waitTillElementIsPresent( - notificationView.getUploadSucceededNotification(),300000); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - - } - } catch (NoSuchElementException e) { - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - } - - fileListViewAfterUploadFile.scrollTillFindElement(BIG_FILE_NAME); - - assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); - - Common.waitTillElementIsNotPresentWithoutTimeout( - fileListViewAfterUploadFile.getProgressCircular(), 1000); - common.wait.until(ExpectedConditions.visibilityOf( - fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getLocalFileIndicator())))); - assertTrue(fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getLocalFileIndicator())) - .isDisplayed()); - fileListView = new FileListView(driver); - fileListView.scrollTillFindElement(BIG_FILE_NAME); - assertTrue( - fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); - } - - - @Test - @Category(UnfinishedTestCategory.class) - public void testUploadFromGmail () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - driver.startActivity("com.google.android.gm", - ".ConversationListActivityGmail"); - GmailEmailListView gmailEmailListView = new GmailEmailListView(driver); - Thread.sleep(3000); - GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail(); - ImageView imageView = gmailEmailView.clickOnfileButton(); - imageView.clickOnOptionsButton(); - imageView.clickOnShareButton(); - imageView.clickOnOwnCloudButton(); - //justonce button do not appear always - try{ - imageView.clickOnJustOnceButton(); - }catch (NoSuchElementException e) { - } - UploadView uploadView = new UploadView(driver); - uploadView.clickOUploadButton(); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); - driver.startActivity("com.owncloud.android", - ".ui.activity.FileDisplayActivity"); - common.wait.until(ExpectedConditions - .visibilityOfAllElementsLocatedBy(By.name(FILE_GMAIL_NAME))); - assertEquals(Config.fileToTestSendByEmailName , - driver.findElementByName(FILE_GMAIL_NAME).getText()); - fileListView = new FileListView(driver); - fileListView.scrollTillFindElement(FILE_GMAIL_NAME); - assertTrue(fileHasBeenUploadedFromGmail = fileListView - .getFileElement().isDisplayed()); - //TODO. correct assert if fileListView is shown in grid mode - } - - - @Test - @Category({FailingTestCategory.class}) - public void testKeepFileUpToDate () throws Exception { - - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), - 1000); - - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileHasBeenUploaded = fileListViewAfterUploadFile - .getFileElement().isDisplayed()); - - ElementMenuOptions menuOptions = fileListViewAfterUploadFile - .longPressOnElement(FILE_NAME); - FileDetailsView fileDetailsView = menuOptions.clickOnDetails(); - fileDetailsView.checkKeepFileUpToDateCheckbox(); - Thread.sleep(3000); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - assertTrue(common.isElementPresent( - fileListViewAfterUploadFile.getFileElementLayout(), - MobileBy.id(FileListView.getFavoriteFileIndicator()))); - assertTrue(fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getFavoriteFileIndicator())) - .isDisplayed()); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void testKeepFileUpToDateAndRefresh () throws Exception { - - FileListView fileListView = Actions.login(Config.URL, Config.user, - Config.password, Config.isTrusted, driver); - common.assertIsInFileListView(); - - Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), - 1000); - - FileListView fileListViewAfterUploadFile = Actions - .uploadFile(FILE_NAME, fileListView); - fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileHasBeenUploaded = fileListViewAfterUploadFile - .getFileElement().isDisplayed()); - - ElementMenuOptions menuOptions = fileListViewAfterUploadFile - .longPressOnElement(FILE_NAME); - FileDetailsView fileDetailsView = menuOptions.clickOnDetails(); - fileDetailsView.checkKeepFileUpToDateCheckbox(); - Thread.sleep(3000); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - - fileListViewAfterUploadFile.pulldownToRefresh(); - //assertTrue(fileListView.getProgressCircular().isDisplayed()); - Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), - 100); - - assertTrue(common.isElementPresent( - fileListViewAfterUploadFile.getFileElementLayout(), - MobileBy.id(FileListView.getFavoriteFileIndicator()))); - assertTrue(fileListViewAfterUploadFile.getFileElementLayout() - .findElement(By.id(FileListView.getFavoriteFileIndicator())) - .isDisplayed()); - } - - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - FileListView fileListView = new FileListView(driver); - if (fileHasBeenUploadedFromGmail) { - Actions.deleteElement(FILE_GMAIL_NAME,fileListView, driver); - } - if(fileHasBeenUploaded){ - Actions.deleteElement(FILE_NAME,fileListView, driver); - Actions.deleteElement(BIG_FILE_NAME,fileListView, driver); - } - - //driver.removeApp("com.owncloud.android"); - driver.quit(); - } - +public class UploadTestSuite { + + AndroidDriver driver; + Common common; + String FILE_NAME = Config.fileToTestName; + String BIG_FILE_NAME = Config.bigFileToTestName; + String FILE_GMAIL_NAME = Config.fileToTestSendByEmailName; + private Boolean fileHasBeenUploadedFromGmail = false; + private Boolean fileHasBeenUploaded = false; + + @Rule + public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common = new Common(); + driver = common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testUploadFile() throws Exception { + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //check if the file already exists and if true, delete it + Actions.deleteElement(FILE_NAME, fileListView, driver); + + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + Common.waitTillElementIsNotPresentWithoutTimeout( + fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf( + fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())) + .isDisplayed()); + fileListView = new FileListView(driver); + fileListView.scrollTillFindElement(FILE_NAME); + assertTrue( + fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); + } + + @Test + @Category({UnfinishedTestCategory.class}) + public void testUploadBigFile() throws Exception { + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //check if the file already exists and if true, delete it + Actions.deleteElement(BIG_FILE_NAME, fileListView, driver); + + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(BIG_FILE_NAME, fileListView); + + driver.openNotifications(); + NotificationView notificationView = new NotificationView(driver); + + try { + if (notificationView.getUploadingNotification().isDisplayed()) { + Common.waitTillElementIsPresent( + notificationView.getUploadSucceededNotification(), 300000); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + + } + } catch (NoSuchElementException e) { + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + } + + fileListViewAfterUploadFile.scrollTillFindElement(BIG_FILE_NAME); + + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + + Common.waitTillElementIsNotPresentWithoutTimeout( + fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf( + fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())) + .isDisplayed()); + fileListView = new FileListView(driver); + fileListView.scrollTillFindElement(BIG_FILE_NAME); + assertTrue( + fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); + } + + @Test + @Category(UnfinishedTestCategory.class) + public void testUploadFromGmail() throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + driver.startActivity("com.google.android.gm", + ".ConversationListActivityGmail"); + GmailEmailListView gmailEmailListView = new GmailEmailListView(driver); + Thread.sleep(3000); + GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail(); + ImageView imageView = gmailEmailView.clickOnfileButton(); + imageView.clickOnOptionsButton(); + imageView.clickOnShareButton(); + imageView.clickOnOwnCloudButton(); + //justonce button do not appear always + try { + imageView.clickOnJustOnceButton(); + } catch (NoSuchElementException e) { + } + UploadView uploadView = new UploadView(driver); + uploadView.clickOUploadButton(); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + common.wait.until(ExpectedConditions + .visibilityOfAllElementsLocatedBy(By.name(FILE_GMAIL_NAME))); + assertEquals(Config.fileToTestSendByEmailName, + driver.findElementByName(FILE_GMAIL_NAME).getText()); + fileListView = new FileListView(driver); + fileListView.scrollTillFindElement(FILE_GMAIL_NAME); + assertTrue(fileHasBeenUploadedFromGmail = fileListView + .getFileElement().isDisplayed()); + //TODO. correct assert if fileListView is shown in grid mode + } + + @Test + @Category({FailingTestCategory.class}) + public void testKeepFileUpToDate() throws Exception { + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), + 1000); + + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileHasBeenUploaded = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); + + ElementMenuOptions menuOptions = fileListViewAfterUploadFile + .longPressOnElement(FILE_NAME); + FileDetailsView fileDetailsView = menuOptions.clickOnDetails(); + fileDetailsView.checkKeepFileUpToDateCheckbox(); + Thread.sleep(3000); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + assertTrue(common.isElementPresent( + fileListViewAfterUploadFile.getFileElementLayout(), + MobileBy.id(FileListView.getFavoriteFileIndicator()))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getFavoriteFileIndicator())) + .isDisplayed()); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void testKeepFileUpToDateAndRefresh() throws Exception { + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), + 1000); + + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileHasBeenUploaded = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); + + ElementMenuOptions menuOptions = fileListViewAfterUploadFile + .longPressOnElement(FILE_NAME); + FileDetailsView fileDetailsView = menuOptions.clickOnDetails(); + fileDetailsView.checkKeepFileUpToDateCheckbox(); + Thread.sleep(3000); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + + fileListViewAfterUploadFile.pulldownToRefresh(); + //assertTrue(fileListView.getProgressCircular().isDisplayed()); + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), + 100); + + assertTrue(common.isElementPresent( + fileListViewAfterUploadFile.getFileElementLayout(), + MobileBy.id(FileListView.getFavoriteFileIndicator()))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getFavoriteFileIndicator())) + .isDisplayed()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + FileListView fileListView = new FileListView(driver); + if (fileHasBeenUploadedFromGmail) { + Actions.deleteElement(FILE_GMAIL_NAME, fileListView, driver); + } + if (fileHasBeenUploaded) { + Actions.deleteElement(FILE_NAME, fileListView, driver); + Actions.deleteElement(BIG_FILE_NAME, fileListView, driver); + } + + //driver.removeApp("com.owncloud.android"); + driver.quit(); + } } diff --git a/doc/icon.svg b/doc/icon.svg index 064b3eaba7a..844660a4409 100644 --- a/doc/icon.svg +++ b/doc/icon.svg @@ -3,7 +3,6 @@ xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" diff --git a/doc/workaround_icon.svg b/doc/workaround_icon.svg index da0b58784ff..1b38221dc30 100644 --- a/doc/workaround_icon.svg +++ b/doc/workaround_icon.svg @@ -3,7 +3,6 @@ xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" diff --git a/owncloudApp/src/androidTest/AndroidManifest.xml b/owncloudApp/src/androidTest/AndroidManifest.xml index 38383579be1..ee3db432e57 100644 --- a/owncloudApp/src/androidTest/AndroidManifest.xml +++ b/owncloudApp/src/androidTest/AndroidManifest.xml @@ -20,5 +20,6 @@ - + + \ No newline at end of file diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/AuthenticatorActivityTest.java b/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/AuthenticatorActivityTest.java index fc0a646e8b9..8eb4fbf418e 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/AuthenticatorActivityTest.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/AuthenticatorActivityTest.java @@ -1,22 +1,22 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2019 ownCloud GmbH. - * @author Jesús Recio (@jesmrec) - * @author Christian Schabesberger - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application + *

+ * Copyright (C) 2019 ownCloud GmbH. * + * @author Jesús Recio (@jesmrec) + * @author Christian Schabesberger + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.authentication; @@ -29,17 +29,16 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.SystemClock; + import androidx.test.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; import androidx.test.rule.ActivityTestRule; -import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.uiautomator.UiDevice; - import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.AccountsManager; import com.owncloud.android.utils.ServerType; - import org.junit.After; import org.junit.Before; import org.junit.FixMethodOrder; @@ -61,7 +60,6 @@ import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertTrue; - @RunWith(AndroidJUnit4.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @LargeTest @@ -153,11 +151,10 @@ public void test1_check_certif_not_secure_no_accept() onView(withId(R.id.account_username)).check(matches(not(isDisplayed()))); onView(withId(R.id.account_password)).check(matches(not(isDisplayed()))); - Log_OC.i(LOG_TAG, "Test not accept not secure start"); if (servertype == ServerType.HTTPS_NON_SECURE || - servertype == ServerType.REDIRECTED_NON_SECURE ) { + servertype == ServerType.REDIRECTED_NON_SECURE) { // Check that login button is not displayed onView(withId(R.id.loginButton)) @@ -196,7 +193,6 @@ public void test1_check_certif_not_secure_no_accept() public void test2_check_certif_not_secure() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException { - Log_OC.i(LOG_TAG, "Test accept not secure start"); // Get values passed @@ -242,9 +238,9 @@ public void test2_check_certif_not_secure() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); int mResultCode = f.getInt(mActivityRule.getActivity()); @@ -256,7 +252,6 @@ public void test2_check_certif_not_secure() } } - /** * Login with correct credentials */ @@ -276,9 +271,9 @@ public void test3_check_login() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); @@ -319,9 +314,9 @@ public void test4_login_orientation_changes() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); int mResultCode = f.getInt(mActivityRule.getActivity()); @@ -347,9 +342,9 @@ public void test5_check_login_special_characters() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); @@ -380,7 +375,6 @@ public void test6_check_login_incorrect() Log_OC.i(LOG_TAG, "Test Check Login Incorrect Passed"); - } /** @@ -429,9 +423,9 @@ public void test8_check_login_trimmed_blanks() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); int mResultCode = f.getInt(mActivityRule.getActivity()); @@ -460,9 +454,9 @@ public void test9_check_url_from_browser() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); int mResultCode = f.getInt(mActivityRule.getActivity()); @@ -493,11 +487,10 @@ public void test_10_check_url_uppercase() } - /* * Fill the fields in login view and check the status message depending on the kind of server */ - private void setFields (String connectionString, String username, String password){ + private void setFields(String connectionString, String username, String password) { // Type server url onView(withId(R.id.hostUrlInput)) @@ -517,18 +510,18 @@ private void setFields (String connectionString, String username, String passwor onView(withId(R.id.loginButton)).perform(click()); } - /* * Depending on the expected status message the assertion is checked */ - private void checkStatusMessage(){ + private void checkStatusMessage() { - switch (servertype){ + switch (servertype) { case HTTP: - if (testServerURL.startsWith(HTTP_SCHEME)) + if (testServerURL.startsWith(HTTP_SCHEME)) { onView(withId(R.id.server_status_text)).check(matches(withText(R.string.auth_connection_established))); - else + } else { onView(withId(R.id.server_status_text)).check(matches(withText(R.string.auth_nossl_plain_ok_title))); + } break; case HTTPS_NON_SECURE: onView(withId(R.id.server_status_text)).check(matches(withText(R.string.auth_secure_connection))); @@ -539,7 +532,8 @@ private void checkStatusMessage(){ case REDIRECTED_NON_SECURE: onView(withId(R.id.server_status_text)).check(matches(withText(R.string.auth_nossl_plain_ok_title))); break; - default: break; + default: + break; } } diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/SAMLAuthenticatorActivityTest.java b/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/SAMLAuthenticatorActivityTest.java index 2a44a263ec8..1b879a97fb7 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/SAMLAuthenticatorActivityTest.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/SAMLAuthenticatorActivityTest.java @@ -1,22 +1,22 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2019 ownCloud GmbH. - * @author Jesús Recio (@jesmrec) - * @author Christian Schabesberger - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application + *

+ * Copyright (C) 2019 ownCloud GmbH. * + * @author Jesús Recio (@jesmrec) + * @author Christian Schabesberger + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.authentication; @@ -29,17 +29,16 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.SystemClock; + import androidx.test.InstrumentationRegistry; import androidx.test.espresso.web.webdriver.Locator; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; import androidx.test.rule.ActivityTestRule; -import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.uiautomator.UiDevice; - import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.AccountsManager; - import org.junit.After; import org.junit.Before; import org.junit.FixMethodOrder; @@ -65,7 +64,6 @@ import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertTrue; - @RunWith(AndroidJUnit4.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @LargeTest @@ -104,7 +102,7 @@ private enum ServerType { private final int status; - ServerType (int status) { + ServerType(int status) { this.status = status; } @@ -173,7 +171,6 @@ public void init() { } } - /** * Login with SAML. Supported with non-secured servers under https */ @@ -217,9 +214,9 @@ public void test1_check_login_saml() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); int mResultCode = f.getInt(mActivityRule.getActivity()); @@ -271,9 +268,9 @@ public void test2_check_login_saml_orientation_changes() // Check that the Activity ends after clicking SystemClock.sleep(WAIT_LOGIN_MS); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { assertTrue(ERROR_MESSAGE, mActivityRule.getActivity().isDestroyed()); - else { + } else { Field f = Activity.class.getDeclaredField(RESULT_CODE); f.setAccessible(true); int mResultCode = f.getInt(mActivityRule.getActivity()); diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/datamodel/OCFileUnitTest.java b/owncloudApp/src/androidTest/java/com/owncloud/android/datamodel/OCFileUnitTest.java index 2394b01a546..bc10e82d464 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/datamodel/OCFileUnitTest.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/datamodel/OCFileUnitTest.java @@ -1,30 +1,28 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ - package com.owncloud.android.datamodel; import android.os.Parcel; -import androidx.test.filters.SmallTest; -import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.SmallTest; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +30,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; - /** * Instrumented unit test, to be run in an Android emulator or device. * @@ -69,7 +66,6 @@ public void createDefaultOCFile() { mFile = new OCFile(PATH); } - @Test public void writeThenReadAsParcelable() { @@ -94,7 +90,6 @@ public void writeThenReadAsParcelable() { mFile.setDownloading(true); mFile.setEtagInConflict(ETAG_IN_CONFLICT); - // Write the file data in a Parcel Parcel parcel = Parcel.obtain(); mFile.writeToParcel(parcel, mFile.describeContents()); @@ -113,14 +108,14 @@ public void writeThenReadAsParcelable() { assertThat(fileReadFromParcel.getCreationTimestamp(), is(CREATION_TIMESTAMP)); assertThat(fileReadFromParcel.getModificationTimestamp(), is(MODIFICATION_TIMESTAMP)); assertThat( - fileReadFromParcel.getModificationTimestampAtLastSyncForData(), - is(MODIFICATION_TIMESTAMP_AT_LAST_SYNC_FOR_DATA) + fileReadFromParcel.getModificationTimestampAtLastSyncForData(), + is(MODIFICATION_TIMESTAMP_AT_LAST_SYNC_FOR_DATA) ); assertThat(fileReadFromParcel.getLastSyncDateForProperties(), is(LAST_SYNC_DATE_FOR_PROPERTIES)); assertThat(fileReadFromParcel.getLastSyncDateForData(), is(LAST_SYNC_DATE_FOR_DATA)); assertThat( - fileReadFromParcel.getAvailableOfflineStatus(), - is(OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE) + fileReadFromParcel.getAvailableOfflineStatus(), + is(OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE) ); assertThat(fileReadFromParcel.getEtag(), is(ETAG)); assertThat(fileReadFromParcel.isSharedViaLink(), is(true)); diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/ui/activity/PublicShareActivityTest.java b/owncloudApp/src/androidTest/java/com/owncloud/android/ui/activity/PublicShareActivityTest.java index e2cf366910f..755855f1947 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/ui/activity/PublicShareActivityTest.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/ui/activity/PublicShareActivityTest.java @@ -1,28 +1,25 @@ /** - * ownCloud Android client application - * - * @author Jesús Recio @jesmrec - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Jesús Recio @jesmrec + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ - package com.owncloud.android.ui.activity; - import android.Manifest; import android.content.ClipData; import android.content.ClipboardManager; @@ -34,18 +31,18 @@ import android.os.Looper; import android.os.RemoteException; import android.os.SystemClock; +import android.view.View; + +import androidx.core.content.ContextCompat; import androidx.test.InstrumentationRegistry; import androidx.test.espresso.FailureHandler; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; import androidx.test.rule.ActivityTestRule; -import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.uiautomator.UiDevice; import androidx.test.uiautomator.UiObjectNotFoundException; import androidx.test.uiautomator.UiSelector; -import androidx.core.content.ContextCompat; -import android.view.View; - import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.CapabilityBooleanType; @@ -53,7 +50,6 @@ import com.owncloud.android.utils.AccountsManager; import com.owncloud.android.utils.FileManager; import com.owncloud.android.utils.ServerType; - import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; @@ -136,7 +132,6 @@ public void beforeActivityLaunched() { } }; - @Before public void init() { @@ -146,8 +141,9 @@ public void init() { UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); try { - if (!uiDevice.isScreenOn()) + if (!uiDevice.isScreenOn()) { uiDevice.wakeUp(); + } } catch (RemoteException e) { e.printStackTrace(); } @@ -179,9 +175,8 @@ public void init() { mActivityRule.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } - @BeforeClass - public static void before(){ + public static void before() { //Needed to use clipboard Looper.prepare(); } @@ -240,7 +235,7 @@ public void test_02_create_public_link_download_view_permission() //Enable the option for Download/View permissions onView(withId(R.id.shareViaLinkEditPermissionReadOnly)).perform(click()); - onView(withId(R.id.saveButton)).perform(scrollTo(),click()); + onView(withId(R.id.saveButton)).perform(scrollTo(), click()); SystemClock.sleep(WAIT_CONNECTION_MS); //Check that the sharing panel is displayed @@ -298,7 +293,7 @@ public void test_03_create_public_link_download_view_upload_permission() //Enable the option for Download/View/Upload permissions onView(withId(R.id.shareViaLinkEditPermissionReadAndWrite)).perform(click()); - onView(withId(R.id.saveButton)).perform(scrollTo(),click()); + onView(withId(R.id.saveButton)).perform(scrollTo(), click()); SystemClock.sleep(WAIT_CONNECTION_MS); //Check that the sharing panel is displayed @@ -306,7 +301,6 @@ public void test_03_create_public_link_download_view_upload_permission() onView(withId(R.id.alertTitle)).check(matches(isDisplayed())); pressBack(); - //Check the name onView(withText(nameShare)).check(matches(isDisplayed())); SystemClock.sleep(WAIT_CONNECTION_MS); @@ -334,7 +328,6 @@ public void test_03_create_public_link_download_view_upload_permission() } - /** * TEST CASE: Share publicly a folder with Upload only permission * PASSED IF: Link created and visible in share view with Upload only option @@ -358,7 +351,7 @@ public void test_04_create_public_link_upload_only() //Enable the option for Upload only permissions onView(withId(R.id.shareViaLinkEditPermissionUploadFiles)).perform(click()); - onView(withId(R.id.saveButton)).perform(scrollTo(),click()); + onView(withId(R.id.saveButton)).perform(scrollTo(), click()); SystemClock.sleep(WAIT_CONNECTION_MS); //Check that the sharing panel is displayed @@ -446,7 +439,7 @@ public void test_06_edit_name() { onView(withId(R.id.shareViaLinkNameValue)).perform(replaceText(nameShareEdited)); SystemClock.sleep(WAIT_CONNECTION_MS); - onView(withId(R.id.saveButton)).perform(scrollTo(),click()); + onView(withId(R.id.saveButton)).perform(scrollTo(), click()); SystemClock.sleep(WAIT_CONNECTION_MS); //Check that the sharing panel is displayed @@ -460,7 +453,6 @@ public void test_06_edit_name() { Log_OC.i(LOG_TAG, "Test Edit Link Name Passed"); } - /** * TEST CASE: Edit the public folder by switching "Password" on * PASSED IF: @@ -543,7 +535,7 @@ public void test_08_edit_link_enable_expiration() onView(withId(R.id.shareViaLinkPasswordSwitch)).check(matches(not(isChecked()))); onView(withId(R.id.shareViaLinkExpirationSwitch)).check(matches(isChecked())); - onView(withId(R.id.cancelButton)).perform(scrollTo(),click()); + onView(withId(R.id.cancelButton)).perform(scrollTo(), click()); Log_OC.i(LOG_TAG, "Test Enable Expiration Passed"); @@ -592,8 +584,8 @@ public void test_10_share_multiple_links() selectShare(folder); onView(withId(R.id.addPublicLinkButton)).check(matches(isDisplayed())); - for (int i = 0; i < MULTIPLE_LINKS ; i++) { - publicShareCreationDefault(nameShareMultiple+i); + for (int i = 0; i < MULTIPLE_LINKS; i++) { + publicShareCreationDefault(nameShareMultiple + i); } Log_OC.i(LOG_TAG, "Test Unshare Public Passed"); @@ -614,8 +606,8 @@ public void test_11_remove_multiple_links() //Select share option selectShare(folder); - for (int i = 0; i < MULTIPLE_LINKS ; i++) { - deleteLink(nameShareMultiple+i); + for (int i = 0; i < MULTIPLE_LINKS; i++) { + deleteLink(nameShareMultiple + i); } Log_OC.i(LOG_TAG, "Test Remove Multiple Public Passed"); @@ -652,13 +644,12 @@ public void test_12_permalink() SystemClock.sleep(WAIT_CLIPBOARD_MS); - assertTrue(ERROR_MESSAGE, text.startsWith(testServerURL+"/f")); + assertTrue(ERROR_MESSAGE, text.startsWith(testServerURL + "/f")); Log_OC.i(LOG_TAG, "Test Permalink Passed"); } - /** * TEST CASE: Capability "Allow public links" disabled * PASSED IF: No option to public in share view @@ -674,7 +665,7 @@ public void test_13_capability_allow_public_links() SystemClock.sleep(WAIT_CONNECTION_MS); - AccountsManager.saveCapabilities(targetContext ,capabilities, testServerURL, testUser); + AccountsManager.saveCapabilities(targetContext, capabilities, testServerURL, testUser); //Select share option selectShare(folder2); @@ -832,9 +823,8 @@ public void test_17_unshare_public_file() } - //To create a new public link with defaults - private void publicShareCreationDefault (String name) { + private void publicShareCreationDefault(String name) { //Creation of the share link. Name only for servers >= 10 onView(withId(R.id.addPublicLinkButton)).perform(click()); @@ -842,7 +832,7 @@ private void publicShareCreationDefault (String name) { onView(withId(R.id.shareViaLinkNameValue)).perform(replaceText(name)); SystemClock.sleep(WAIT_CONNECTION_MS); - onView(withId(R.id.saveButton)).perform(scrollTo(),click()); + onView(withId(R.id.saveButton)).perform(scrollTo(), click()); SystemClock.sleep(WAIT_CONNECTION_MS); //Check that the sharing panel is displayed @@ -854,16 +844,14 @@ private void publicShareCreationDefault (String name) { } - //Returns the permission of writing in device storage - private int grantedPermission () { + private int grantedPermission() { return ContextCompat.checkSelfPermission(targetContext, Manifest.permission.WRITE_EXTERNAL_STORAGE); } - //Get copied link from clipboard - private String getTextFromClipboard(){ + private String getTextFromClipboard() { //Clipboard can not be handled in thread without Looper ClipboardManager clipboard = (ClipboardManager) targetContext.getSystemService(Context.CLIPBOARD_SERVICE); @@ -872,18 +860,18 @@ private String getTextFromClipboard(){ // Gets the first item from the clipboard data ClipData.Item item = clip.getItemAt(0); return item.getText().toString(); - } else + } else { return null; + } } - //True if server supports File Listing option - private boolean isSupportedFileListing (){ - return capabilities.getFilesSharingPublicSupportsUploadOnly() == CapabilityBooleanType.TRUE; + private boolean isSupportedFileListing() { + return capabilities.getFilesSharingPublicSupportsUploadOnly() == CapabilityBooleanType.TRUE; } //Delete a link. For non multiple servers. - private void deleteLink(){ + private void deleteLink() { onView(withId(R.id.deletePublicLinkButton)).perform(click()); SystemClock.sleep(WAIT_CONNECTION_MS); onView(withId(android.R.id.button1)).perform(click()); @@ -891,7 +879,7 @@ private void deleteLink(){ } //Delete a link which name is parameter - private void deleteLink(String linkName){ + private void deleteLink(String linkName) { onView(allOf(withId(R.id.deletePublicLinkButton), hasSibling(withText(linkName)))).perform(click()); SystemClock.sleep(WAIT_CONNECTION_MS); onView(withId(android.R.id.button1)).perform(click()); @@ -899,7 +887,7 @@ private void deleteLink(String linkName){ } //Select "Share" option on a item in file list. Repeats until long click works. - private void selectShare(String item){ + private void selectShare(String item) { boolean longClicked = false; while (!longClicked) { onView(withText(item)).perform(longClick()); @@ -914,13 +902,11 @@ private void selectShare(String item){ } //Check if a view is displayed - public static boolean viewIsDisplayed(int viewId) { + public static boolean viewIsDisplayed(int viewId) { final boolean[] isDisplayed = {true}; - onView(withId(viewId)).withFailureHandler(new FailureHandler() - { + onView(withId(viewId)).withFailureHandler(new FailureHandler() { @Override - public void handle(Throwable error, Matcher viewMatcher) - { + public void handle(Throwable error, Matcher viewMatcher) { isDisplayed[0] = false; } }).check(matches(isDisplayed())); diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java b/owncloudApp/src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java index 4c46abb220d..c8de62b057c 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java @@ -18,24 +18,23 @@ package com.owncloud.android.uiautomator; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; + import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SdkSuppress; import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.SdkSuppress; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiDevice; import androidx.test.uiautomator.UiObject; import androidx.test.uiautomator.UiObjectNotFoundException; import androidx.test.uiautomator.UiSelector; import androidx.test.uiautomator.Until; - +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/AccountsManager.java b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/AccountsManager.java index 6512ed47c27..f353052b118 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/AccountsManager.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/AccountsManager.java @@ -1,22 +1,21 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ *

+ *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; @@ -24,17 +23,11 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; -import android.net.Uri; import android.os.SystemClock; import com.owncloud.android.MainApp; import com.owncloud.android.datamodel.FileDataStorageManager; -import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.accounts.AccountUtils; -import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory; -import com.owncloud.android.lib.common.network.NetworkUtils; -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation; import com.owncloud.android.lib.resources.status.OCCapability; import com.owncloud.android.lib.resources.status.OwnCloudVersion; @@ -52,7 +45,7 @@ public static void addAccount(Context context, String baseUrl, String username, // obtaining an AccountManager instance AccountManager accountManager = AccountManager.get(context); - Account account = new Account(username+"@"+regularURL(baseUrl), accountType); + Account account = new Account(username + "@" + regularURL(baseUrl), accountType); accountManager.addAccountExplicitly(account, password, null); // include account version, user, server version and token with the new account @@ -84,52 +77,52 @@ public static void addAccount(Context context, String baseUrl, String username, public static void deleteAccount(Context context, String accountDel) { AccountManager accountManager = AccountManager.get(context); Account account = new Account(accountDel, accountType); - accountManager.removeAccount(account,null,null); + accountManager.removeAccount(account, null, null); } //Remove all accounts from the device public static void deleteAllAccounts(Context context) { AccountManager accountManager = AccountManager.get(context); Account[] accounts = accountManager.getAccounts(); - for (int i=0;i need mocks or integration with new networking stuff return new OCCapability(); } //Save capabilities (in device DB) - public static void saveCapabilities (Context context, OCCapability capabilities, String server, String user){ - FileDataStorageManager fm = new FileDataStorageManager(context, new Account(buildAccountName(user, server), accountType), + public static void saveCapabilities(Context context, OCCapability capabilities, String server, String user) { + FileDataStorageManager fm = new FileDataStorageManager(context, new Account(buildAccountName(user, server), + accountType), MainApp.getAppContext().getContentResolver()); - fm.saveCapabilities (capabilities); + fm.saveCapabilities(capabilities); } //Build account name - private static String buildAccountName (String user, String server){ - return user+"@"+regularURL(server); + private static String buildAccountName(String user, String server) { + return user + "@" + regularURL(server); } } diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/FileManager.java b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/FileManager.java index a4ea4651a0e..a0d3e7d0b77 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/FileManager.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/FileManager.java @@ -1,8 +1,9 @@ package com.owncloud.android.utils; +import android.content.Context; + import androidx.test.uiautomator.UiObject; import androidx.test.uiautomator.UiSelector; - import com.owncloud.android.R; import static androidx.test.espresso.Espresso.onView; @@ -11,33 +12,30 @@ import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static org.hamcrest.Matchers.allOf; -import android.content.Context; /** - * ownCloud Android client application - * - * @author Jesús Recio @jesmrec - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Jesús Recio @jesmrec + * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ - public class FileManager { //To select an option in files view - public static void selectOptionActionsMenu (Context context, int option) { + public static void selectOptionActionsMenu(Context context, int option) { String optionSelected = context.getResources().getString(option); if (!new UiObject(new UiSelector().description(optionSelected)).exists()) { onView(allOf(withContentDescription("More options"), @@ -61,5 +59,4 @@ public static void selectOptionActionsMenu (Context context, int option) { } } - } diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ServerType.java b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ServerType.java index a347f7c1448..8a587a4152e 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ServerType.java +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ServerType.java @@ -1,67 +1,66 @@ /** - * ownCloud Android client application - * - * @author Jesús Recio @jesmrec - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Jesús Recio @jesmrec + * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; public enum ServerType { - /* - * Server with http - */ - HTTP(1), + /* + * Server with http + */ + HTTP(1), - /* - * Server with https, but non-secure certificate - */ - HTTPS_NON_SECURE(2), + /* + * Server with https, but non-secure certificate + */ + HTTPS_NON_SECURE(2), - /* - * Server with https - */ - HTTPS_SECURE(3), + /* + * Server with https + */ + HTTPS_SECURE(3), - /* - * Server redirected to a non-secure server - */ - REDIRECTED_NON_SECURE(4); + /* + * Server redirected to a non-secure server + */ + REDIRECTED_NON_SECURE(4); - private final int status; + private final int status; - ServerType(int status) { - this.status = status; - } + ServerType(int status) { + this.status = status; + } - public int getStatus() { - return status; - } + public int getStatus() { + return status; + } - public static ServerType fromValue(int value) { - switch (value) { - case 1: - return HTTP; - case 2: - return HTTPS_NON_SECURE; - case 3: - return HTTPS_SECURE; - case 4: - return REDIRECTED_NON_SECURE; - } - return null; + public static ServerType fromValue(int value) { + switch (value) { + case 1: + return HTTP; + case 2: + return HTTPS_NON_SECURE; + case 3: + return HTTPS_SECURE; + case 4: + return REDIRECTED_NON_SECURE; } + return null; + } } diff --git a/owncloudApp/src/main/AndroidManifest.xml b/owncloudApp/src/main/AndroidManifest.xml index a0fc350715d..9a93c75c6ea 100644 --- a/owncloudApp/src/main/AndroidManifest.xml +++ b/owncloudApp/src/main/AndroidManifest.xml @@ -21,7 +21,7 @@ package="com.owncloud.android"> + tools:overrideLibrary="android.support.customtabs" /> android:key for passcode preference @@ -72,7 +71,7 @@ public class PassCodeActivity extends BaseActivity { private TextView mPassCodeHdrExplanation; private EditText[] mPassCodeEditTexts = new EditText[4]; - private String [] mPassCodeDigits = {"","","",""}; + private String[] mPassCodeDigits = {"", "", "", ""}; private static String KEY_PASSCODE_DIGITS = "PASSCODE_DIGITS"; private boolean mConfirmingPassCode = false; private static String KEY_CONFIRMING_PASSCODE = "CONFIRMING_PASSCODE"; @@ -128,10 +127,10 @@ protected void onCreate(Bundle savedInstanceState) { mConfirmingPassCode = savedInstanceState.getBoolean(PassCodeActivity.KEY_CONFIRMING_PASSCODE); mPassCodeDigits = savedInstanceState.getStringArray(PassCodeActivity.KEY_PASSCODE_DIGITS); } - if(mConfirmingPassCode){ + if (mConfirmingPassCode) { //the app was in the passcodeconfirmation requestPassCodeConfirmation(); - }else{ + } else { /// pass code preference has just been activated in Preferences; // will receive and confirm pass code value mPassCodeHdr.setText(R.string.pass_code_configure_your_pass_code); @@ -156,15 +155,14 @@ protected void onCreate(Bundle savedInstanceState) { setTextListeners(); } - /** * Enables or disables the cancel button to allow the user interrupt the ACTION * requested to the activity. * * @param enabled 'True' makes the cancel button available, 'false' hides it. */ - protected void setCancelButtonEnabled(boolean enabled){ - if(enabled){ + protected void setCancelButtonEnabled(boolean enabled) { + if (enabled) { mBCancel.setVisibility(View.VISIBLE); mBCancel.setOnClickListener(new OnClickListener() { @Override @@ -179,7 +177,6 @@ public void onClick(View v) { } } - /** * Binds the appropiate listeners to the input boxes receiving each digit of the pass code. */ @@ -202,8 +199,9 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { // used to control what's exactly happening with DEL, not any custom field... mPassCodeEditTexts[0].setText(""); mPassCodeEditTexts[0].requestFocus(); - if (!mConfirmingPassCode) + if (!mConfirmingPassCode) { mPassCodeDigits[0] = ""; + } mBChange = false; } else if (!mBChange) { @@ -238,8 +236,9 @@ public void onFocusChange(View v, boolean hasFocus) { public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) { mPassCodeEditTexts[1].requestFocus(); - if (!mConfirmingPassCode) + if (!mConfirmingPassCode) { mPassCodeDigits[1] = ""; + } mPassCodeEditTexts[1].setText(""); mBChange = false; @@ -275,8 +274,9 @@ public void onFocusChange(View v, boolean hasFocus) { public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) { mPassCodeEditTexts[2].requestFocus(); - if (!mConfirmingPassCode) + if (!mConfirmingPassCode) { mPassCodeDigits[2] = ""; + } mPassCodeEditTexts[2].setText(""); mBChange = false; @@ -305,7 +305,6 @@ public void onFocusChange(View v, boolean hasFocus) { } // end setTextListener - /** * Processes the pass code entered by the user just after the last digit was in. * @@ -319,7 +318,7 @@ private void processFullPassCode() { hideSoftKeyboard(); finish(); - } else { + } else { showErrorAndRestart(R.string.pass_code_wrong, R.string.pass_code_enter_pass_code, View.INVISIBLE); } @@ -368,12 +367,11 @@ private void showErrorAndRestart(int errorMessage, int headerMessage, clearBoxes(); } - /** * Ask to the user for retyping the pass code just entered before saving it as the current pass * code. */ - protected void requestPassCodeConfirmation(){ + protected void requestPassCodeConfirmation() { clearBoxes(); mPassCodeHdr.setText(R.string.pass_code_reenter_your_pass_code); mPassCodeHdrExplanation.setVisibility(View.INVISIBLE); @@ -385,7 +383,7 @@ protected void requestPassCodeConfirmation(){ * * @return 'True' if entered pass code equals to the saved one. */ - protected boolean checkPassCode(){ + protected boolean checkPassCode() { SharedPreferences appPrefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); @@ -409,7 +407,7 @@ protected boolean checkPassCode(){ * * @return 'True' if retyped pass code equals to the entered before. */ - protected boolean confirmPassCode(){ + protected boolean confirmPassCode() { mConfirmingPassCode = false; boolean result = true; @@ -422,8 +420,8 @@ protected boolean confirmPassCode(){ /** * Sets the input fields to empty strings and puts the focus on the first one. */ - protected void clearBoxes(){ - for (int i=0; i < mPassCodeEditTexts.length; i++) { + protected void clearBoxes() { + for (int i = 0; i < mPassCodeEditTexts.length; i++) { mPassCodeEditTexts[i].setText(""); } mPassCodeEditTexts[0].requestFocus(); @@ -438,8 +436,8 @@ protected void clearBoxes(){ * @return 'True' when the key event was processed by this method. */ @Override - public boolean onKeyDown(int keyCode, KeyEvent event){ - if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount()== 0){ + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction()) || ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { finish(); @@ -462,7 +460,6 @@ protected void savePassCodeAndExit() { finish(); } - @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -485,7 +482,7 @@ private class PassCodeDigitTextWatcher implements TextWatcher { */ public PassCodeDigitTextWatcher(int index, boolean lastOne) { mIndex = index; - mLastOne = lastOne; + mLastOne = lastOne; if (mIndex < 0) { throw new IllegalArgumentException( "Invalid index in " + PassCodeDigitTextWatcher.class.getSimpleName() + diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PatternLockActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PatternLockActivity.java index 5663293aede..c7121d6acb0 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PatternLockActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PatternLockActivity.java @@ -5,16 +5,16 @@ * @author Christian Schabesberger * @author David González Verdugo * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -25,8 +25,6 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; -import com.google.android.material.snackbar.Snackbar; -import androidx.appcompat.app.AppCompatActivity; import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; @@ -34,9 +32,11 @@ import android.widget.RelativeLayout; import android.widget.TextView; +import androidx.appcompat.app.AppCompatActivity; import com.andrognito.patternlockview.PatternLockView; import com.andrognito.patternlockview.listener.PatternLockViewListener; import com.andrognito.patternlockview.utils.PatternLockUtils; +import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.BuildConfig; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; @@ -86,7 +86,8 @@ protected void onCreate(Bundle savedInstanceState) { String mPatternHeaderViewText = ""; /** - * mPatternExpShouldVisible holds the boolean value that signifies weather the patternExpView should be visible or not. + * mPatternExpShouldVisible holds the boolean value that signifies weather the patternExpView should be + * visible or not. * it is set to true when the pattern is set and when the pattern is removed. */ boolean mPatternExpShouldVisible = false; @@ -160,7 +161,8 @@ public void onComplete(List list) { /** * This block gets executed when the pattern has to be set. * count variable holds the number of time the pattern has been input. - * if the value of count is two then the pattern input first (which is stored in patternValue variable) + * if the value of count is two then the pattern input first (which is stored in patternValue + * variable) * is compared with the pattern value input the second time * (which is stored in newPatternValue) if both the variables hold the same value * then the pattern is set. @@ -196,8 +198,7 @@ private void processPattern() { showErrorAndRestart(R.string.pattern_incorrect_pattern, R.string.pattern_enter_pattern, View.INVISIBLE); } - } - else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { + } else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { //This block is executed when the user is removing the pattern lock (i.e disabling the pattern lock) if (checkPattern()) { Intent result = new Intent(); @@ -209,7 +210,7 @@ else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { R.string.pattern_enter_pattern, View.INVISIBLE); } } else if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction())) { - //This block is executed when the user is setting the pattern lock (i.e enabling the pattern lock) + //This block is executed when the user is setting the pattern lock (i.e enabling the pattern lock) if (!mPatternPresent) { requestPatternConfirmation(); } else if (confirmPattern()) { @@ -241,7 +242,6 @@ protected void savePatternAndExit() { finish(); } - /** * Ask to the user to re-enter the pattern just entered before saving it as the current pattern. */ @@ -310,8 +310,8 @@ public void onClick(View v) { * @return 'True' when the key event was processed by this method. */ @Override - public boolean onKeyDown(int keyCode, KeyEvent event){ - if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount()== 0){ + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction()) || ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) { finish(); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/Preferences.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/Preferences.java index 0edac6d4bd3..4ce0ddad53f 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/Preferences.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/Preferences.java @@ -37,16 +37,16 @@ import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import android.preference.PreferenceManager; -import androidx.annotation.LayoutRes; -import com.google.android.material.snackbar.Snackbar; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatDelegate; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.LayoutRes; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatDelegate; +import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.BuildConfig; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -57,14 +57,13 @@ import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.PreferenceUtils; - import org.jetbrains.annotations.NotNull; import java.io.File; /** * An Activity that allows the user to change the application's settings. - * + *

* It proxies the necessary calls via {@link androidx.appcompat.app.AppCompatDelegate} to be used * with AppCompat. */ @@ -979,7 +978,8 @@ private void showSimpleDialog(String message) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(R.string.common_important); alertDialog.setMessage(message); - alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(android.R.string.ok), (dialog, which) -> dialog.dismiss()); + alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(android.R.string.ok), + (dialog, which) -> dialog.dismiss()); alertDialog.show(); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PrivacyPolicyActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PrivacyPolicyActivity.java index 7fa573cb8d4..31794b8b320 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PrivacyPolicyActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/PrivacyPolicyActivity.java @@ -1,29 +1,27 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author David González Verdugo - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author David González Verdugo + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.activity; import android.os.Bundle; -import com.google.android.material.snackbar.Snackbar; import android.view.MenuItem; import android.view.View; import android.webkit.WebChromeClient; @@ -32,6 +30,7 @@ import android.widget.LinearLayout; import android.widget.ProgressBar; +import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.R; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.PreferenceUtils; @@ -75,11 +74,10 @@ protected void onCreate(Bundle savedInstanceState) { webview.getSettings().setDisplayZoomControls(false); webview.setWebChromeClient(new WebChromeClient() { - public void onProgressChanged(WebView view, int progress) - { + public void onProgressChanged(WebView view, int progress) { mProgressBar.setProgress(progress); //Set the web page loading progress - if(progress == 100) { + if (progress == 100) { mProgressBar.setVisibility(View.GONE); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index 8049bb33b6e..cd0fc0dd394 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -41,13 +41,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; -import androidx.fragment.app.FragmentManager; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AlertDialog.Builder; import android.text.Editable; import android.text.TextWatcher; import android.view.Menu; @@ -62,6 +55,13 @@ import android.widget.EditText; import android.widget.ListView; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AlertDialog.Builder; +import androidx.fragment.app.FragmentManager; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; +import com.google.android.material.textfield.TextInputEditText; +import com.google.android.material.textfield.TextInputLayout; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountAuthenticator; @@ -95,7 +95,6 @@ import java.util.Stack; import java.util.Vector; - /** * This can be used to upload things to an ownCloud instance. */ @@ -345,11 +344,14 @@ public void onItemClick(AdapterView parent, View view, int position, long id) Vector tmpfiles = getStorageManager().getFolderContent(mFile /*, false*/); tmpfiles = sortFileList(tmpfiles); - if (tmpfiles.size() <= 0) return; + if (tmpfiles.size() <= 0) { + return; + } // filter on dirtype Vector files = new Vector<>(); - for (OCFile f : tmpfiles) + for (OCFile f : tmpfiles) { files.add(f); + } if (files.size() < position) { throw new IndexOutOfBoundsException("Incorrect item selected"); } @@ -476,17 +478,20 @@ private void startSyncFolderOperation(OCFile folder) { private Vector sortFileList(Vector files) { // Read sorting order, default to sort by name ascending FileStorageUtils.mSortOrderFileDisp = PreferenceManager.getSortOrder(this, FileStorageUtils.FILE_DISPLAY_SORT); - FileStorageUtils.mSortAscendingFileDisp = PreferenceManager.getSortAscending(this, FileStorageUtils.FILE_DISPLAY_SORT); + FileStorageUtils.mSortAscendingFileDisp = PreferenceManager.getSortAscending(this, + FileStorageUtils.FILE_DISPLAY_SORT); - files = FileStorageUtils.sortFolder(files, FileStorageUtils.mSortOrderFileDisp, FileStorageUtils.mSortAscendingFileDisp); + files = FileStorageUtils.sortFolder(files, FileStorageUtils.mSortOrderFileDisp, + FileStorageUtils.mSortAscendingFileDisp); return files; } private String generatePath(Stack dirs) { String full_path = ""; - for (String a : dirs) + for (String a : dirs) { full_path += a + "/"; + } return full_path; } @@ -566,7 +571,6 @@ public void uploadFiles() { public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { super.onRemoteOperationFinish(operation, result); - if (operation instanceof CreateFolderOperation) { onCreateFolderOperationFinish((CreateFolderOperation) operation, result); } @@ -596,7 +600,6 @@ private void onCreateFolderOperationFinish(CreateFolderOperation operation, } } - /** * Loads the target folder initialize shown to the user. *

@@ -615,8 +618,9 @@ private void initTargetFolder() { } else { String[] dir_names = lastPath.split("/"); mParents.clear(); - for (String dir : dir_names) + for (String dir : dir_names) { mParents.add(dir); + } } //Make sure that path still exists, if it doesn't pop the stack and try the previous path while (!getStorageManager().fileExists(generatePath(mParents)) && mParents.size() > 1) { @@ -968,8 +972,9 @@ private void setFileNameFromIntent(AlertDialog alertDialog, EditText input) { if (fileName == null) { // Show soft keyboard Window window = alertDialog.getWindow(); - if (window != null) + if (window != null) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); + } } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java index 8918ba24366..9488b5b6f79 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java @@ -7,17 +7,17 @@ * @author David González Verdugo * @author Christian Schabesberger * Copyright (C) 2019 ownCloud GmbH. - * - * + *

+ *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -28,12 +28,12 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentTransaction; import android.view.MenuItem; import android.widget.LinearLayout; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.operations.RemoteOperation; @@ -58,7 +58,6 @@ import com.owncloud.android.ui.fragment.ShareFragmentListener; import com.owncloud.android.utils.PreferenceUtils; - /** * Activity for sharing files */ @@ -76,7 +75,6 @@ public class ShareActivity extends FileActivity GetSharesForFileAsyncTask mGetSharesForFileAsyncTask; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -116,7 +114,6 @@ protected void onAccountSet(boolean stateWasRecovered) { refreshSharesFromServer(); } - @Override protected void onNewIntent(Intent intent) { // Verify the action and get the query @@ -254,9 +251,9 @@ public void showAddPublicShare(String defaultLinkName) { // Create and show the dialog DialogFragment newFragment = PublicShareDialogFragment.newInstanceToCreate( - getFile(), - getAccount(), - defaultLinkName + getFile(), + getAccount(), + defaultLinkName ); newFragment.show(ft, TAG_PUBLIC_SHARE_DIALOG_FRAGMENT); } @@ -296,7 +293,7 @@ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationRe (operation instanceof GetSharesForFileOperation && result.getCode() == RemoteOperationResult.ResultCode.SHARE_NOT_FOUND ) - ) { + ) { Log_OC.d(TAG, "Refreshing view on successful operation or finished refresh"); refreshSharesFromStorageManager(); if (operation instanceof GetSharesForFileOperation) { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java index 72c60581d21..d32d7b7c1ff 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java @@ -1,30 +1,30 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author Andy Scherzinger - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author Andy Scherzinger + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.activity; import android.os.Bundle; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; import android.view.View; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.widget.Toolbar; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index 5237ec83a96..91577a2ebaf 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -1,23 +1,23 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author David A. Velasco - * @author Shashvat Kedia - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author David A. Velasco + * @author Shashvat Kedia + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.activity; @@ -29,8 +29,6 @@ import android.os.Bundle; import android.os.Environment; import android.preference.PreferenceManager; -import androidx.fragment.app.DialogFragment; -import androidx.appcompat.app.ActionBar; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -42,6 +40,8 @@ import android.widget.RadioButton; import android.widget.TextView; +import androidx.appcompat.app.ActionBar; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.lib.common.utils.Log_OC; @@ -55,7 +55,6 @@ import java.io.File; - /** * Displays local files and let the user choose what of them wants to upload * to the current ownCloud account. @@ -260,15 +259,18 @@ public boolean onOptionsItemSelected(MenuItem item) { break; case R.id.action_sort_by_name: item.setChecked(true); - sortByName(com.owncloud.android.db.PreferenceManager.getSortAscending(this, FileStorageUtils.UPLOAD_SORT)); + sortByName(com.owncloud.android.db.PreferenceManager.getSortAscending(this, + FileStorageUtils.UPLOAD_SORT)); break; case R.id.action_sort_by_size: item.setChecked(true); - sortBySize(com.owncloud.android.db.PreferenceManager.getSortAscending(this, FileStorageUtils.UPLOAD_SORT)); + sortBySize(com.owncloud.android.db.PreferenceManager.getSortAscending(this, + FileStorageUtils.UPLOAD_SORT)); break; case R.id.action_sort_by_date: item.setChecked(true); - sortByDate(com.owncloud.android.db.PreferenceManager.getSortAscending(this, FileStorageUtils.UPLOAD_SORT)); + sortByDate(com.owncloud.android.db.PreferenceManager.getSortAscending(this, + FileStorageUtils.UPLOAD_SORT)); break; default: retval = super.onOptionsItemSelected(item); @@ -300,15 +302,18 @@ private void recoverSortMenuState(Menu menu) { switch (com.owncloud.android.db.PreferenceManager.getSortOrder(this, FileStorageUtils.UPLOAD_SORT)) { case FileStorageUtils.SORT_NAME: menu.findItem(R.id.action_sort_by_name).setChecked(true); - sortByName(com.owncloud.android.db.PreferenceManager.getSortAscending(this, FileStorageUtils.UPLOAD_SORT)); + sortByName(com.owncloud.android.db.PreferenceManager.getSortAscending(this, + FileStorageUtils.UPLOAD_SORT)); break; case FileStorageUtils.SORT_SIZE: menu.findItem(R.id.action_sort_by_size).setChecked(true); - sortBySize(com.owncloud.android.db.PreferenceManager.getSortAscending(this, FileStorageUtils.UPLOAD_SORT)); + sortBySize(com.owncloud.android.db.PreferenceManager.getSortAscending(this, + FileStorageUtils.UPLOAD_SORT)); break; case FileStorageUtils.SORT_DATE: menu.findItem(R.id.action_sort_by_date).setChecked(true); - sortByDate(com.owncloud.android.db.PreferenceManager.getSortAscending(this, FileStorageUtils.UPLOAD_SORT)); + sortByDate(com.owncloud.android.db.PreferenceManager.getSortAscending(this, + FileStorageUtils.UPLOAD_SORT)); break; } } @@ -323,12 +328,12 @@ public boolean onNavigationItemSelected(int itemPosition, long itemId) { // the next operation triggers a new call to this method, but it's necessary to // ensure that the name exposed in the action bar is the current directory when the // user selected it in the navigation list - if (itemPosition != 0) + if (itemPosition != 0) { getSupportActionBar().setSelectedNavigationItem(0); + } return true; } - @Override public void onBackPressed() { if (mDirectories.getCount() <= 1) { @@ -356,7 +361,6 @@ public void onBackPressed() { } } - @Override protected void onSaveInstanceState(Bundle outState) { // responsibility of restore is preferred in onCreate() before than in @@ -367,7 +371,6 @@ protected void onSaveInstanceState(Bundle outState) { Log_OC.d(TAG, "onSaveInstanceState() end"); } - /** * Pushes a directory to the drop down list * @@ -394,7 +397,6 @@ public boolean popDirname() { return !mDirectories.isEmpty(); } - // Custom array adapter to override text colors private class CustomArrayAdapter extends ArrayAdapter { @@ -432,7 +434,6 @@ public void onFolderClicked(File directory) { actionBar.setDisplayHomeAsUpEnabled(true); } - /** * {@inheritDoc} */ @@ -494,7 +495,6 @@ public void onClick(View v) { } } - @Override public void onCheckAvailableSpaceStart() { /// progress dialog and disable 'Move' button @@ -559,20 +559,17 @@ public void onConfirmation(String callerTag) { } } - @Override public void onNeutral(String callerTag) { Log_OC.d(TAG, "Phantom neutral button in dialog was clicked; dialog tag is " + callerTag); } - @Override public void onCancel(String callerTag) { /// nothing to do; don't finish, let the user change the selection Log_OC.d(TAG, "Negative button in dialog was clicked; dialog tag is " + callerTag); } - @Override protected void onAccountSet(boolean stateWasRecovered) { super.onAccountSet(stateWasRecovered); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index f27686d87dd..b9d25c5242c 100755 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -1,24 +1,23 @@ /** - * ownCloud Android client application - * - * @author LukeOwncloud - * @author David A. Velasco - * @author masensio - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author LukeOwncloud + * @author David A. Velasco + * @author masensio + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.activity; @@ -34,17 +33,17 @@ import android.net.Uri; import android.os.Bundle; import android.os.IBinder; -import androidx.fragment.app.FragmentTransaction; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import androidx.fragment.app.FragmentTransaction; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.datamodel.UploadsStorageManager; import com.owncloud.android.datamodel.OCUpload; +import com.owncloud.android.datamodel.UploadsStorageManager; import com.owncloud.android.db.UploadResult; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; @@ -92,7 +91,7 @@ protected void onCreate(Bundle savedInstanceState) { setupDrawer(R.id.nav_uploads); // Add fragment with a transaction for setting a tag - if(savedInstanceState == null) { + if (savedInstanceState == null) { createUploadListFragment(); } // else, the Fragment Manager makes the job on configuration changes @@ -101,14 +100,13 @@ protected void onCreate(Bundle savedInstanceState) { mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); } - private void createUploadListFragment(){ + private void createUploadListFragment() { UploadListFragment uploadList = new UploadListFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.upload_list_fragment, uploadList, TAG_UPLOAD_LIST_FRAGMENT); transaction.commit(); } - @Override protected void onResume() { Log_OC.v(TAG, "onResume() start"); @@ -144,9 +142,9 @@ protected void onPause() { public boolean onUploadItemClick(OCUpload file) { /// TODO is this path still active? File f = new File(file.getLocalPath()); - if(!f.exists()) { + if (!f.exists()) { showSnackMessage( - getString(R.string.local_file_not_found_toast) + getString(R.string.local_file_not_found_toast) ); } else { @@ -170,13 +168,13 @@ private void openFileWithDefault(String localPath) { startActivity(myIntent); } catch (ActivityNotFoundException e) { showSnackMessage( - getString(R.string.file_list_no_app_for_file_type) + getString(R.string.file_list_no_app_for_file_type) ); Log_OC.i(TAG, "Could not find app for sending log history."); - } + } } - + /** * Same as openFileWithDefault() but user cannot save default app. * @param ocFile @@ -241,14 +239,14 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == FileActivity.REQUEST_CODE__UPDATE_CREDENTIALS && resultCode == RESULT_OK) { // Retry uploads of the updated account Account account = AccountUtils.getOwnCloudAccountByName( - this, - data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME) + this, + data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME) ); TransferRequester requester = new TransferRequester(); requester.retryFailedUploads( - this, - account, - UploadResult.CREDENTIAL_ERROR, + this, + account, + UploadResult.CREDENTIAL_ERROR, false ); } @@ -281,7 +279,6 @@ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationRe } } - @Override protected ServiceConnection newTransferenceServiceConnection() { return new UploadListServiceConnection(); @@ -293,8 +290,7 @@ private class UploadListServiceConnection implements ServiceConnection { @Override public void onServiceConnected(ComponentName component, IBinder service) { if (service instanceof FileUploaderBinder) { - if(mUploaderBinder == null) - { + if (mUploaderBinder == null) { mUploaderBinder = (FileUploaderBinder) service; Log_OC.d(TAG, "UploadListActivity connected to Upload service. component: " + component + " service: " @@ -313,7 +309,7 @@ public void onServiceConnected(ComponentName component, IBinder service) { Log_OC.d(TAG, "UploadListActivity not connected to Upload service. component: " + component + " service: " + service); return; - } + } } @Override @@ -335,7 +331,7 @@ private class UploadMessagesReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { UploadListFragment uploadListFragment = - (UploadListFragment) getSupportFragmentManager().findFragmentByTag(TAG_UPLOAD_LIST_FRAGMENT); + (UploadListFragment) getSupportFragmentManager().findFragmentByTag(TAG_UPLOAD_LIST_FRAGMENT); uploadListFragment.updateUploads(); } @@ -345,7 +341,6 @@ protected String getDefaultTitle() { return getString(R.string.uploads_view_title); } - /** * Called when the ownCloud {@link Account} associated to the Activity was just updated. */ diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadPathActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadPathActivity.java index a3f065b0c8e..d0959f9624d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadPathActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/UploadPathActivity.java @@ -1,20 +1,19 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.activity; @@ -32,7 +31,6 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag public static final String KEY_CAMERA_UPLOAD_PATH = "CAMERA_UPLOAD_PATH"; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java index 6d5fe2d03a1..16d0ba2e9db 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author Brtosz Przybylski - * @author Christian Schabesberger - * Copyright (C) 2019 Bartosz Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Brtosz Przybylski + * @author Christian Schabesberger + * Copyright (C) 2019 Bartosz Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.activity; @@ -28,12 +27,6 @@ import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentPagerAdapter; -import androidx.viewpager.widget.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -42,6 +35,12 @@ import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountAuthenticatorActivity; @@ -80,8 +79,8 @@ protected void onCreate(Bundle savedInstanceState) { mForwardFinishButton = findViewById(R.id.forward); mForwardFinishButton.setOnClickListener(view -> { if (mProgress.hasNextStep()) { - mPager.setCurrentItem(mPager.getCurrentItem()+1, true); - mProgress.animateToStep(mPager.getCurrentItem()+1); + mPager.setCurrentItem(mPager.getCurrentItem() + 1, true); + mProgress.animateToStep(mPager.getCurrentItem() + 1); } else { finish(); } @@ -104,7 +103,6 @@ public void onBackPressed() { super.onBackPressed(); } - private void updateNextButtonIfNeeded() { if (!mProgress.hasNextStep()) { mForwardFinishButton.setImageResource(R.drawable.ic_done_white); @@ -129,14 +127,16 @@ static private int getLastSeenVersionCode() { } static private boolean isFirstRun() { - if (getLastSeenVersionCode() != 0) + if (getLastSeenVersionCode() != 0) { return false; + } return AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext()) == null; } static public void runIfNeeded(Context context) { - if (context instanceof WhatsNewActivity) + if (context instanceof WhatsNewActivity) { return; + } if (shouldShow(context)) { context.startActivity(new Intent(context, WhatsNewActivity.class)); @@ -148,11 +148,11 @@ static private boolean shouldShow(Context context) { boolean showWizard = context.getResources().getBoolean(R.bool.wizard_enabled); return showWizard && ((isFirstRun() && context instanceof AccountAuthenticatorActivity) || - ( - !(isFirstRun() && (context instanceof FileDisplayActivity)) && - !(context instanceof PassCodeActivity) && - (FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun(), isBeta).length > 0) - )); + ( + !(isFirstRun() && (context instanceof FileDisplayActivity)) && + !(context instanceof PassCodeActivity) && + (FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun(), isBeta).length > 0) + )); } @Override @@ -161,7 +161,7 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse @Override public void onPageSelected(int position) { - mProgress.animateToStep(position+1); + mProgress.animateToStep(position + 1); updateNextButtonIfNeeded(); } @@ -174,7 +174,7 @@ private final class FeaturesViewAdapter extends FragmentPagerAdapter { FeatureItem[] mFeatures; - public FeaturesViewAdapter(FragmentManager fm, FeatureItem[]features) { + public FeaturesViewAdapter(FragmentManager fm, FeatureItem[] features) { super(fm); mFeatures = features; } @@ -204,25 +204,29 @@ static public FeatureFragment newInstance(FeatureItem item) { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mItem = getArguments() != null ? (FeatureItem)getArguments().getParcelable("feature") : null; + mItem = getArguments() != null ? (FeatureItem) getArguments().getParcelable("feature") : null; } @Nullable @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.whats_new_element, container, false); ImageView iv = v.findViewById(R.id.whatsNewImage); - if (mItem.shouldShowImage()) + if (mItem.shouldShowImage()) { iv.setImageResource(mItem.getImage()); + } TextView tv2 = v.findViewById(R.id.whatsNewTitle); - if (mItem.shouldShowTitleText()) + if (mItem.shouldShowTitleText()) { tv2.setText(mItem.getTitleText()); + } tv2 = v.findViewById(R.id.whatsNewText); - if (mItem.shouldShowContentText()) + if (mItem.shouldShowContentText()) { tv2.setText(mItem.getContentText()); + } return v; } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java index 0bc0ed72892..1a5f00cc1db 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java @@ -82,7 +82,6 @@ public View getView(final int position, View convertView, ViewGroup parent) { AccountListItem accountListItem = mValues.get(position); - if (accountListItem != null) { // create account item if (AccountListItem.TYPE_ACCOUNT == accountListItem.getType()) { @@ -92,25 +91,25 @@ public View getView(final int position, View convertView, ViewGroup parent) { viewHolder.nameViewItem.setText(oca.getDisplayName()); } catch (Exception e) { Log_OC.w( - TAG, - "Account not found right after being read :\\ ; using account name instead of display name" + TAG, + "Account not found right after being read :\\ ; using account name instead of display name" ); viewHolder.nameViewItem.setText( - AccountUtils.getUsernameOfAccount(account.name) + AccountUtils.getUsernameOfAccount(account.name) ); } viewHolder.nameViewItem.setTag(account.name); viewHolder.accountViewItem.setText( - DisplayUtils.convertIdn(account.name, false) + DisplayUtils.convertIdn(account.name, false) ); try { DisplayUtils.showAccountAvatar( - account, - viewHolder.imageViewItem, - mAccountAvatarRadiusDimension, - true + account, + viewHolder.imageViewItem, + mAccountAvatarRadiusDimension, + true ); } catch (Exception e) { Log_OC.e(TAG, "Error calculating RGB value for account list item.", e); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListItem.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListItem.java index cbad54b1cf7..d7ce695878f 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListItem.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/AccountListItem.java @@ -1,20 +1,20 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author Andy Scherzinger - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author Andy Scherzinger + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/CertificateCombinedExceptionViewAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/CertificateCombinedExceptionViewAdapter.java index 34e37b13d47..9f3dc705675 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/CertificateCombinedExceptionViewAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/CertificateCombinedExceptionViewAdapter.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; @@ -34,15 +33,15 @@ * */ public class CertificateCombinedExceptionViewAdapter implements SslUntrustedCertDialog.ErrorViewAdapter { - + //private final static String TAG = CertificateCombinedExceptionViewAdapter.class.getSimpleName(); - + private CertificateCombinedException mSslException = null; - + public CertificateCombinedExceptionViewAdapter(CertificateCombinedException sslException) { mSslException = sslException; } - + @Override public void updateErrorView(View dialogView) { // Allow or disallow touches with other visible windows @@ -53,20 +52,20 @@ public void updateErrorView(View dialogView) { /// clean dialogView.findViewById(R.id.reason_no_info_about_error).setVisibility(View.GONE); - + /// refresh if (mSslException.getCertPathValidatorException() != null) { dialogView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.VISIBLE); } else { dialogView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.GONE); } - + if (mSslException.getCertificateExpiredException() != null) { dialogView.findViewById(R.id.reason_cert_expired).setVisibility(View.VISIBLE); } else { dialogView.findViewById(R.id.reason_cert_expired).setVisibility(View.GONE); } - + if (mSslException.getCertificateNotYetValidException() != null) { dialogView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.VISIBLE); } else { @@ -78,6 +77,6 @@ public void updateErrorView(View dialogView) { } else { dialogView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.GONE); } - + } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/DiskLruImageCache.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/DiskLruImageCache.java index 34f2c731e92..7ab44e79d08 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/DiskLruImageCache.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/DiskLruImageCache.java @@ -1,33 +1,24 @@ /** - * ownCloud Android client application - * - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.BitmapFactory; @@ -36,6 +27,13 @@ import com.owncloud.android.BuildConfig; import com.owncloud.android.lib.common.utils.Log_OC; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + public class DiskLruImageCache { private DiskLruCache mDiskCache; @@ -44,97 +42,97 @@ public class DiskLruImageCache { private static final int CACHE_VERSION = 1; private static final int VALUE_COUNT = 1; private static final int IO_BUFFER_SIZE = 8 * 1024; - + private static final String TAG = DiskLruImageCache.class.getSimpleName(); //public DiskLruImageCache( Context context,String uniqueName, int diskCacheSize, public DiskLruImageCache( - File diskCacheDir, int diskCacheSize, CompressFormat compressFormat, int quality - ) throws IOException { + File diskCacheDir, int diskCacheSize, CompressFormat compressFormat, int quality + ) throws IOException { mDiskCache = DiskLruCache.open( - diskCacheDir, CACHE_VERSION, VALUE_COUNT, diskCacheSize + diskCacheDir, CACHE_VERSION, VALUE_COUNT, diskCacheSize ); mCompressFormat = compressFormat; mCompressQuality = quality; } - private boolean writeBitmapToFile( Bitmap bitmap, DiskLruCache.Editor editor ) - throws IOException { + private boolean writeBitmapToFile(Bitmap bitmap, DiskLruCache.Editor editor) + throws IOException { OutputStream out = null; try { - out = new BufferedOutputStream( editor.newOutputStream( 0 ), IO_BUFFER_SIZE ); - return bitmap.compress( mCompressFormat, mCompressQuality, out ); + out = new BufferedOutputStream(editor.newOutputStream(0), IO_BUFFER_SIZE); + return bitmap.compress(mCompressFormat, mCompressQuality, out); } finally { - if ( out != null ) { + if (out != null) { out.close(); } } } - public void put( String key, Bitmap data ) { + public void put(String key, Bitmap data) { DiskLruCache.Editor editor = null; String validKey = convertToValidKey(key); try { - editor = mDiskCache.edit( validKey ); - if ( editor == null ) { + editor = mDiskCache.edit(validKey); + if (editor == null) { return; } - if( writeBitmapToFile( data, editor ) ) { + if (writeBitmapToFile(data, editor)) { mDiskCache.flush(); editor.commit(); - if ( BuildConfig.DEBUG ) { - Log_OC.d( "cache_test_DISK_", "image put on disk cache " + validKey ); + if (BuildConfig.DEBUG) { + Log_OC.d("cache_test_DISK_", "image put on disk cache " + validKey); } } else { editor.abort(); - if ( BuildConfig.DEBUG ) { - Log_OC.d( "cache_test_DISK_", "ERROR on: image put on disk cache " + validKey ); + if (BuildConfig.DEBUG) { + Log_OC.d("cache_test_DISK_", "ERROR on: image put on disk cache " + validKey); } - } + } } catch (IOException e) { - if ( BuildConfig.DEBUG ) { - Log_OC.d( "cache_test_DISK_", "ERROR on: image put on disk cache " + validKey ); + if (BuildConfig.DEBUG) { + Log_OC.d("cache_test_DISK_", "ERROR on: image put on disk cache " + validKey); } try { - if ( editor != null ) { + if (editor != null) { editor.abort(); } } catch (IOException ignored) { - } + } } } - public Bitmap getBitmap( String key ) { + public Bitmap getBitmap(String key) { Bitmap bitmap = null; DiskLruCache.Snapshot snapshot = null; String validKey = convertToValidKey(key); try { - snapshot = mDiskCache.get( validKey ); - if ( snapshot == null ) { + snapshot = mDiskCache.get(validKey); + if (snapshot == null) { return null; } - final InputStream in = snapshot.getInputStream( 0 ); - if ( in != null ) { - final BufferedInputStream buffIn = - new BufferedInputStream( in, IO_BUFFER_SIZE ); - bitmap = BitmapFactory.decodeStream( buffIn ); - } - } catch ( IOException e ) { + final InputStream in = snapshot.getInputStream(0); + if (in != null) { + final BufferedInputStream buffIn = + new BufferedInputStream(in, IO_BUFFER_SIZE); + bitmap = BitmapFactory.decodeStream(buffIn); + } + } catch (IOException e) { e.printStackTrace(); } finally { - if ( snapshot != null ) { + if (snapshot != null) { snapshot.close(); } } - if ( BuildConfig.DEBUG ) { - Log_OC.d("cache_test_DISK_", bitmap == null ? + if (BuildConfig.DEBUG) { + Log_OC.d("cache_test_DISK_", bitmap == null ? "not found" : "image read from disk " + validKey); } @@ -142,18 +140,18 @@ public Bitmap getBitmap( String key ) { } - public boolean containsKey( String key ) { + public boolean containsKey(String key) { boolean contained = false; DiskLruCache.Snapshot snapshot = null; String validKey = convertToValidKey(key); try { - snapshot = mDiskCache.get( validKey ); + snapshot = mDiskCache.get(validKey); contained = snapshot != null; } catch (IOException e) { e.printStackTrace(); } finally { - if ( snapshot != null ) { + if (snapshot != null) { snapshot.close(); } } @@ -163,12 +161,12 @@ public boolean containsKey( String key ) { } public void clearCache() { - if ( BuildConfig.DEBUG ) { - Log_OC.d( "cache_test_DISK_", "disk cache CLEARED"); + if (BuildConfig.DEBUG) { + Log_OC.d("cache_test_DISK_", "disk cache CLEARED"); } try { mDiskCache.delete(); - } catch ( IOException e ) { + } catch (IOException e) { e.printStackTrace(); } } @@ -176,7 +174,7 @@ public void clearCache() { public File getCacheFolder() { return mDiskCache.getDirectory(); } - + private String convertToValidKey(String key) { return Integer.toString(key.hashCode()); } @@ -185,7 +183,7 @@ private String convertToValidKey(String key) { * Remove passed key from cache * @param key */ - public void removeKey( String key ) { + public void removeKey(String key) { String validKey = convertToValidKey(key); try { mDiskCache.remove(validKey); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java index d127cb2ca0e..7bdd1692749 100755 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java @@ -1,23 +1,23 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author LukeOwncloud - * @author masensio - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author LukeOwncloud + * @author masensio + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; @@ -25,7 +25,6 @@ import android.content.Context; import android.database.DataSetObserver; import android.graphics.Bitmap; -import com.google.android.material.snackbar.Snackbar; import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; @@ -38,13 +37,14 @@ import android.widget.ProgressBar; import android.widget.TextView; +import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.datamodel.OCUpload; import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.datamodel.UploadsStorageManager; import com.owncloud.android.datamodel.UploadsStorageManager.UploadStatus; -import com.owncloud.android.datamodel.OCUpload; import com.owncloud.android.db.UploadResult; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.files.services.TransferRequester; @@ -185,7 +185,6 @@ public int getGroupIcon() { loadUploadItemsFromDb(); } - @Override public void registerDataSetObserver(DataSetObserver observer) { super.registerDataSetObserver(observer); @@ -240,10 +239,10 @@ private View getView(OCUpload[] uploadsItems, int position, View convertView, Vi // file size TextView fileSizeTextView = view.findViewById(R.id.upload_file_size); fileSizeTextView.setText( - DisplayUtils.bytesToHumanReadable( - upload.getFileSize(), - mParentActivity - ) + ", " + DisplayUtils.bytesToHumanReadable( + upload.getFileSize(), + mParentActivity + ) + ", " ); //* upload date @@ -263,8 +262,9 @@ private View getView(OCUpload[] uploadsItems, int position, View convertView, Vi Account account = AccountUtils.getOwnCloudAccountByName(mParentActivity, upload.getAccountName()); OwnCloudAccount oca = new OwnCloudAccount(account, mParentActivity); accountNameTextView.setText( - oca.getDisplayName() + " @ " + - DisplayUtils.convertIdn(account.name.substring(account.name.lastIndexOf("@") + 1), false) + oca.getDisplayName() + " @ " + + DisplayUtils.convertIdn(account.name.substring(account.name.lastIndexOf("@") + 1), + false) ); } catch (Exception e) { Log_OC.w(TAG, "Couldn't get display name for account, using old style"); @@ -297,33 +297,33 @@ private View getView(OCUpload[] uploadsItems, int position, View convertView, Vi /// ... unbind the old progress bar, if any; ... if (mProgressListener != null) { binder.removeDatatransferProgressListener( - mProgressListener, - mProgressListener.getUpload() // the one that was added + mProgressListener, + mProgressListener.getUpload() // the one that was added ); } /// ... then, bind the current progress bar to listen for updates mProgressListener = new ProgressListener(upload, progressBar); binder.addDatatransferProgressListener( - mProgressListener, - upload + mProgressListener, + upload ); } else { /// not really uploading; stop listening progress if view is reused! if (convertView != null && mProgressListener != null && - mProgressListener.isWrapping(progressBar)) { + mProgressListener.isWrapping(progressBar)) { binder.removeDatatransferProgressListener( - mProgressListener, - mProgressListener.getUpload() // the one that was added + mProgressListener, + mProgressListener.getUpload() // the one that was added ); mProgressListener = null; } } } else { Log_OC.w( - TAG, - "FileUploaderBinder not ready yet for upload " + upload.getRemotePath() + TAG, + "FileUploaderBinder not ready yet for upload " + upload.getRemotePath() ); } uploadDateTextView.setVisibility(View.GONE); @@ -381,7 +381,7 @@ public void onClick(View v) { @Override public void onClick(View v) { mParentActivity.getFileOperationsHelper().checkCurrentCredentials( - upload.getAccount(mParentActivity) + upload.getAccount(mParentActivity) ); } }); @@ -398,12 +398,12 @@ public void onClick(View v) { refreshView(); } else { final String message = String.format( - mParentActivity.getString(R.string.local_file_not_found_toast) + mParentActivity.getString(R.string.local_file_not_found_toast) ); Snackbar snackbar = Snackbar.make( - v.getRootView().findViewById(android.R.id.content), - message, - Snackbar.LENGTH_LONG + v.getRootView().findViewById(android.R.id.content), + message, + Snackbar.LENGTH_LONG ); snackbar.show(); } @@ -466,7 +466,6 @@ public void onClick(View v) { .getColor(R.color.background_color)); } - } else if (fakeFileToCheatThumbnailsCacheManagerInterface.isImage()) { File file = new File(upload.getLocalPath()); // Thumbnail in Cache? @@ -515,7 +514,7 @@ public void onClick(View v) { * the given upload. * * @param upload Upload to describe. - * @return Text describing the status of the given upload. + * @return Text describing the status of the given upload. */ private String getStatusText(OCUpload upload) { @@ -539,47 +538,47 @@ private String getStatusText(OCUpload upload) { switch (upload.getLastResult()) { case CREDENTIAL_ERROR: status = mParentActivity.getString( - R.string.uploads_view_upload_status_failed_credentials_error + R.string.uploads_view_upload_status_failed_credentials_error ); break; case FOLDER_ERROR: status = mParentActivity.getString( - R.string.uploads_view_upload_status_failed_folder_error + R.string.uploads_view_upload_status_failed_folder_error ); break; case FILE_NOT_FOUND: status = mParentActivity.getString( - R.string.uploads_view_upload_status_failed_localfile_error + R.string.uploads_view_upload_status_failed_localfile_error ); break; case FILE_ERROR: status = mParentActivity.getString( - R.string.uploads_view_upload_status_failed_file_error + R.string.uploads_view_upload_status_failed_file_error ); break; case PRIVILEDGES_ERROR: status = mParentActivity.getString( - R.string.uploads_view_upload_status_failed_permission_error + R.string.uploads_view_upload_status_failed_permission_error ); break; case NETWORK_CONNECTION: status = mParentActivity.getString( - R.string.uploads_view_upload_status_failed_connection_error + R.string.uploads_view_upload_status_failed_connection_error ); break; case DELAYED_FOR_WIFI: status = mParentActivity.getString( - R.string.uploads_view_upload_status_waiting_for_wifi + R.string.uploads_view_upload_status_waiting_for_wifi ); break; case CONFLICT_ERROR: status = mParentActivity.getString( - R.string.uploads_view_upload_status_conflict + R.string.uploads_view_upload_status_conflict ); break; case SERVICE_INTERRUPTED: - status = mParentActivity.getString( - R.string.uploads_view_upload_status_service_interrupted + status = mParentActivity.getString( + R.string.uploads_view_upload_status_service_interrupted ); break; case SERVICE_UNAVAILABLE: @@ -590,24 +589,24 @@ private String getStatusText(OCUpload upload) { break; case SSL_RECOVERABLE_PEER_UNVERIFIED: status = - mParentActivity.getString( - R.string.ssl_certificate_not_trusted - ); + mParentActivity.getString( + R.string.ssl_certificate_not_trusted + ); break; case UNKNOWN: status = mParentActivity.getString( - R.string.uploads_view_upload_status_unknown_fail + R.string.uploads_view_upload_status_unknown_fail ); break; case CANCELLED: // should not get here ; cancelled uploads should be wiped out status = mParentActivity.getString( - R.string.uploads_view_upload_status_cancelled + R.string.uploads_view_upload_status_cancelled ); break; case UPLOADED: // should not get here ; status should be UPLOAD_SUCCESS - status = mParentActivity.getString(R.string.uploads_view_upload_status_succeeded); + status = mParentActivity.getString(R.string.uploads_view_upload_status_succeeded); break; case SPECIFIC_FORBIDDEN: // We don't know the specific forbidden error message because it is not being @@ -636,13 +635,11 @@ private String getStatusText(OCUpload upload) { return status; } - @Override public boolean hasStableIds() { return false; } - /** * Load upload items from {@link UploadsStorageManager}. */ @@ -662,7 +659,6 @@ public void update(Observable arg0, Object arg1) { loadUploadItemsFromDb(); } - public void refreshView() { Log_OC.d(TAG, "refreshView"); loadUploadItemsFromDb(); @@ -783,8 +779,8 @@ public void onTransferProgress(long progressRate, long totalTransferredSoFar, lo public boolean isWrapping(ProgressBar progressBar) { ProgressBar wrappedProgressBar = mProgressBar.get(); return ( - wrappedProgressBar != null && - wrappedProgressBar == progressBar // on purpose; don't replace with equals + wrappedProgressBar != null && + wrappedProgressBar == progressBar // on purpose; don't replace with equals ); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java index 6dd40f3c184..93b6bb9eb6e 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -10,22 +10,21 @@ * @author Shashvat Kedia * Copyright (C) 2011 Bartek Przybylski * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; - import android.accounts.Account; import android.content.Context; import android.graphics.Bitmap; @@ -61,7 +60,6 @@ import java.util.List; import java.util.Vector; - /** * This Adapter populates a ListView with all files and folders in an ownCloud * instance. @@ -92,8 +90,10 @@ public FileListListAdapter( mTransferServiceGetter = transferServiceGetter; // Read sorting order, default to sort by name ascending - FileStorageUtils.mSortOrderFileDisp = PreferenceManager.getSortOrder(mContext, FileStorageUtils.FILE_DISPLAY_SORT); - FileStorageUtils.mSortAscendingFileDisp = PreferenceManager.getSortAscending(mContext, FileStorageUtils.FILE_DISPLAY_SORT); + FileStorageUtils.mSortOrderFileDisp = PreferenceManager.getSortOrder(mContext, + FileStorageUtils.FILE_DISPLAY_SORT); + FileStorageUtils.mSortAscendingFileDisp = PreferenceManager.getSortAscending(mContext, + FileStorageUtils.FILE_DISPLAY_SORT); // initialise thumbnails cache on background thread new ThumbnailsCacheManager.InitDiskCacheTask().execute(); @@ -116,15 +116,17 @@ public int getCount() { @Override public Object getItem(int position) { - if (mFiles == null || mFiles.size() <= position) + if (mFiles == null || mFiles.size() <= position) { return null; + } return mFiles.get(position); } @Override public long getItemId(int position) { - if (mFiles == null || mFiles.size() <= position) + if (mFiles == null || mFiles.size() <= position) { return 0; + } return mFiles.get(position).getFileId(); } @@ -201,11 +203,9 @@ public View getView(int position, View convertView, ViewGroup parent) { TextView fileSizeSeparatorV = view.findViewById(R.id.file_separator); TextView lastModV = view.findViewById(R.id.last_mod); - lastModV.setVisibility(View.VISIBLE); lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file.getModificationTimestamp())); - fileSizeSeparatorV.setVisibility(View.VISIBLE); fileSizeV.setVisibility(View.VISIBLE); fileSizeV.setText(DisplayUtils.bytesToHumanReadable( @@ -245,7 +245,7 @@ public View getView(int position, View convertView, ViewGroup parent) { AbsListView parentList = (AbsListView) parent; if (parentList.getChoiceMode() != AbsListView.CHOICE_MODE_NONE && parentList.getCheckedItemCount() > 0 - ) { + ) { if (parentList.isItemChecked(position)) { view.setBackgroundColor(mContext.getResources().getColor( R.color.selected_item_background)); @@ -299,13 +299,11 @@ public View getView(int position, View convertView, ViewGroup parent) { .getColor(R.color.background_color)); } - } else { fileIcon.setImageResource(MimetypeIconUtil.getFileTypeIconId(file.getMimetype(), file.getFileName())); } - } } return view; @@ -395,7 +393,8 @@ public void swapDirectory(OCFile folder, FileDataStorageManager updatedStorageMa mFiles = null; } - mFiles = FileStorageUtils.sortFolder(mFiles,FileStorageUtils.mSortOrderFileDisp,FileStorageUtils.mSortAscendingFileDisp); + mFiles = FileStorageUtils.sortFolder(mFiles, FileStorageUtils.mSortOrderFileDisp, + FileStorageUtils.mSortAscendingFileDisp); notifyDataSetChanged(); } @@ -417,7 +416,6 @@ public Vector getFolders(Vector files) { return ret; } - public void setSortOrder(Integer order, boolean ascending) { PreferenceManager.setSortOrder(order, mContext, FileStorageUtils.FILE_DISPLAY_SORT); @@ -426,7 +424,8 @@ public void setSortOrder(Integer order, boolean ascending) { FileStorageUtils.mSortOrderFileDisp = order; FileStorageUtils.mSortAscendingFileDisp = ascending; - mFiles = FileStorageUtils.sortFolder(mFiles,FileStorageUtils.mSortOrderFileDisp,FileStorageUtils.mSortAscendingFileDisp); + mFiles = FileStorageUtils.sortFolder(mFiles, FileStorageUtils.mSortOrderFileDisp, + FileStorageUtils.mSortAscendingFileDisp); notifyDataSetChanged(); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java index 074d8c86f85..3c51e50f3f8 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java @@ -88,8 +88,9 @@ public int getCount() { @Override public Object getItem(int position) { - if (mFiles == null || mFiles.length <= position) + if (mFiles == null || mFiles.length <= position) { return null; + } return mFiles[position]; } @@ -216,8 +217,8 @@ public void uncheckFile(File file) { checkedFiles.remove(file); } - public boolean isAlreadyChecked(File file){ - if(checkedFiles.contains(file)){ + public boolean isAlreadyChecked(File file) { + if (checkedFiles.contains(file)) { return true; } return false; @@ -294,11 +295,11 @@ private int compareNames(File lhs, File rhs) { } }); - if(mFiles.length > 0) { + if (mFiles.length > 0) { mFiles = transformVecOCFilesToFilesArr( FileStorageUtils.sortFolder(transformFilesArrToVecOCFiles(mFiles), - FileStorageUtils.mSortOrderUpload, - FileStorageUtils.mSortAscendingUpload) + FileStorageUtils.mSortOrderUpload, + FileStorageUtils.mSortAscendingUpload) ); } } @@ -314,8 +315,8 @@ public void setSortOrder(Integer order, boolean isAscending) { if (mFiles != null && mFiles.length > 0) { mFiles = transformVecOCFilesToFilesArr( FileStorageUtils.sortFolder(transformFilesArrToVecOCFiles(mFiles), - FileStorageUtils.mSortOrderUpload, - FileStorageUtils.mSortAscendingUpload) + FileStorageUtils.mSortOrderUpload, + FileStorageUtils.mSortAscendingUpload) ); if (parentList != null) { for (int i = 0; i < mFiles.length; i++) { @@ -326,9 +327,9 @@ public void setSortOrder(Integer order, boolean isAscending) { } } - public int getNoOfFilesInDir(){ + public int getNoOfFilesInDir() { int count = 0; - if(mFiles != null) { + if (mFiles != null) { for (int i = 0; i < mFiles.length; i++) { if (!mFiles[i].isDirectory()) { count++; @@ -338,10 +339,10 @@ public int getNoOfFilesInDir(){ return count; } - private Vector transformFilesArrToVecOCFiles(File[] files){ + private Vector transformFilesArrToVecOCFiles(File[] files) { Vector transformedFiles = new Vector(); OCFile transformedFile = null; - for(int i=0;i transformFilesArrToVecOCFiles(File[] files){ return transformedFiles; } - private File[] transformVecOCFilesToFilesArr(Vector files){ + private File[] transformVecOCFilesToFilesArr(Vector files) { File[] transformedFiles = new File[files.size()]; - for(int i=0;i. + * ownCloud Android client application * + * @author Tobias Kaminsky + * @author Christian Schabesberger + * @author Shashvat Kedia + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; @@ -123,12 +122,12 @@ public View getView(int position, View convertView, ViewGroup parent) { fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength(), mContext)); // get Thumbnail if file is image - if (file.isImage() && file.getRemoteId() != null){ - // Thumbnail in Cache? + if (file.isImage() && file.getRemoteId() != null) { + // Thumbnail in Cache? Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( String.valueOf(file.getRemoteId()) ); - if (thumbnail != null && !file.needsUpdateThumbnail()){ + if (thumbnail != null && !file.needsUpdateThumbnail()) { fileIcon.setImageBitmap(thumbnail); } else { // generate new Thumbnail @@ -157,13 +156,13 @@ public View getView(int position, View convertView, ViewGroup parent) { } public void setSortOrder(Integer order, boolean isAscending) { - PreferenceManager.setSortOrder(order, mContext,FileStorageUtils.FILE_DISPLAY_SORT); - PreferenceManager.setSortAscending(isAscending, mContext,FileStorageUtils.FILE_DISPLAY_SORT); + PreferenceManager.setSortOrder(order, mContext, FileStorageUtils.FILE_DISPLAY_SORT); + PreferenceManager.setSortAscending(isAscending, mContext, FileStorageUtils.FILE_DISPLAY_SORT); FileStorageUtils.mSortOrderFileDisp = order; FileStorageUtils.mSortAscendingFileDisp = isAscending; - if(mFiles != null && mFiles.size() > 0){ + if (mFiles != null && mFiles.size() > 0) { FileStorageUtils.sortFolder((Vector) mFiles, - FileStorageUtils.mSortOrderFileDisp,FileStorageUtils.mSortAscendingFileDisp); + FileStorageUtils.mSortOrderFileDisp, FileStorageUtils.mSortAscendingFileDisp); } notifyDataSetChanged(); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SharePublicLinkListAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SharePublicLinkListAdapter.java index 77ac2b40d50..3cf74b932fe 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SharePublicLinkListAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SharePublicLinkListAdapter.java @@ -6,21 +6,20 @@ * @author David González Verdugo * @author Christian Schabesberger * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - import android.content.Context; import android.view.LayoutInflater; import android.view.View; @@ -38,16 +37,16 @@ /** * Adapter to show a list of public links */ -public class SharePublicLinkListAdapter extends ArrayAdapter{ +public class SharePublicLinkListAdapter extends ArrayAdapter { private Context mContext; private ArrayList mPublicLinks; private SharePublicLinkListAdapter.SharePublicLinkAdapterListener mListener; - public SharePublicLinkListAdapter(Context context, int resource, ArrayListshares, + public SharePublicLinkListAdapter(Context context, int resource, ArrayList shares, SharePublicLinkListAdapter.SharePublicLinkAdapterListener listener) { super(context, resource); - mContext= context; + mContext = context; mPublicLinks = shares; mListener = listener; } @@ -121,7 +120,9 @@ public void onClick(View v) { public interface SharePublicLinkAdapterListener { void copyOrSendPublicLink(OCShare share); + void removePublicShare(OCShare share); + void editPublicShare(OCShare share); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ShareUserListAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ShareUserListAdapter.java index 10c08bfa91c..a57ddcae758 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ShareUserListAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ShareUserListAdapter.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; @@ -47,10 +46,10 @@ public class ShareUserListAdapter extends ArrayAdapter { private ArrayList mShares; private ShareUserAdapterListener mListener; - public ShareUserListAdapter(Context context, int resource, ArrayListshares, + public ShareUserListAdapter(Context context, int resource, ArrayList shares, ShareUserAdapterListener listener) { super(context, resource); - mContext= context; + mContext = context; mShares = shares; mListener = listener; } @@ -122,6 +121,7 @@ public void onClick(View v) { public interface ShareUserAdapterListener { void unshareButtonPressed(OCShare share); + void editShare(OCShare share); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java index 113bb3f0a1a..50bed43dba8 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java @@ -1,49 +1,48 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; -import java.text.DateFormat; -import java.util.Date; - -import com.owncloud.android.R; -import com.owncloud.android.ui.dialog.SslUntrustedCertDialog; import android.net.http.SslCertificate; import android.view.View; import android.widget.TextView; +import com.owncloud.android.R; +import com.owncloud.android.ui.dialog.SslUntrustedCertDialog; + +import java.text.DateFormat; +import java.util.Date; + /** * TODO */ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.CertificateViewAdapter { - + //private final static String TAG = SslCertificateViewAdapter.class.getSimpleName(); - + private SslCertificate mCertificate; - /** * Constructor - * - * @param + * + * @param */ public SslCertificateViewAdapter(SslCertificate certificate) { mCertificate = certificate; @@ -58,12 +57,12 @@ public void updateCertificateView(View dialogView) { showIssuer(mCertificate.getIssuedBy(), dialogView); showValidity(mCertificate.getValidNotBeforeDate(), mCertificate.getValidNotAfterDate(), dialogView); hideSignature(dialogView); - + } else { nullCerView.setVisibility(View.VISIBLE); } } - + private void showValidity(Date notBefore, Date notAfter, View dialogView) { TextView fromView = dialogView.findViewById(R.id.value_validity_from); TextView toView = dialogView.findViewById(R.id.value_validity_to); @@ -72,16 +71,15 @@ private void showValidity(Date notBefore, Date notAfter, View dialogView) { toView.setText(dateFormat.format(notAfter)); } - private void showSubject(SslCertificate.DName subject, View dialogView) { TextView cnView = dialogView.findViewById(R.id.value_subject_CN); cnView.setText(subject.getCName()); cnView.setVisibility(View.VISIBLE); - + TextView oView = dialogView.findViewById(R.id.value_subject_O); oView.setText(subject.getOName()); oView.setVisibility(View.VISIBLE); - + TextView ouView = dialogView.findViewById(R.id.value_subject_OU); ouView.setText(subject.getUName()); ouView.setVisibility(View.VISIBLE); @@ -94,13 +92,12 @@ private void showSubject(SslCertificate.DName subject, View dialogView) { dialogView.findViewById(R.id.label_subject_ST).setVisibility(View.GONE); dialogView.findViewById(R.id.label_subject_L).setVisibility(View.GONE); } - - + private void showIssuer(SslCertificate.DName issuer, View dialogView) { TextView cnView = dialogView.findViewById(R.id.value_issuer_CN); cnView.setText(issuer.getCName()); cnView.setVisibility(View.VISIBLE); - + TextView oView = dialogView.findViewById(R.id.value_issuer_O); oView.setText(issuer.getOName()); oView.setVisibility(View.VISIBLE); @@ -108,7 +105,7 @@ private void showIssuer(SslCertificate.DName issuer, View dialogView) { TextView ouView = dialogView.findViewById(R.id.value_issuer_OU); ouView.setText(issuer.getUName()); ouView.setVisibility(View.VISIBLE); - + // SslCertificates don't offer this information dialogView.findViewById(R.id.value_issuer_C).setVisibility(View.GONE); dialogView.findViewById(R.id.value_issuer_ST).setVisibility(View.GONE); @@ -117,7 +114,7 @@ private void showIssuer(SslCertificate.DName issuer, View dialogView) { dialogView.findViewById(R.id.label_issuer_ST).setVisibility(View.GONE); dialogView.findViewById(R.id.label_issuer_L).setVisibility(View.GONE); } - + private void hideSignature(View dialogView) { dialogView.findViewById(R.id.label_signature).setVisibility(View.GONE); dialogView.findViewById(R.id.label_signature_algorithm).setVisibility(View.GONE); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslErrorViewAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslErrorViewAdapter.java index eaf6798a447..6c581822a89 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslErrorViewAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/SslErrorViewAdapter.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; @@ -33,15 +32,15 @@ * Dialog to show an Untrusted Certificate */ public class SslErrorViewAdapter implements SslUntrustedCertDialog.ErrorViewAdapter { - + //private final static String TAG = SslErrorViewAdapter.class.getSimpleName(); - + private SslError mSslError; - + public SslErrorViewAdapter(SslError sslError) { mSslError = sslError; } - + @Override public void updateErrorView(View dialogView) { // Allow or disallow touches with other visible windows @@ -52,26 +51,26 @@ public void updateErrorView(View dialogView) { /// clean dialogView.findViewById(R.id.reason_no_info_about_error).setVisibility(View.GONE); - + /// refresh if (mSslError.hasError(SslError.SSL_UNTRUSTED)) { dialogView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.VISIBLE); } else { dialogView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.GONE); } - + if (mSslError.hasError(SslError.SSL_EXPIRED)) { dialogView.findViewById(R.id.reason_cert_expired).setVisibility(View.VISIBLE); } else { dialogView.findViewById(R.id.reason_cert_expired).setVisibility(View.GONE); } - + if (mSslError.getPrimaryError() == SslError.SSL_NOTYETVALID) { dialogView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.VISIBLE); } else { dialogView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.GONE); } - + if (mSslError.getPrimaryError() == SslError.SSL_IDMISMATCH) { dialogView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.VISIBLE); } else { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/X509CertificateViewAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/X509CertificateViewAdapter.java index 917fb26eff4..31c91d59d7e 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/X509CertificateViewAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/X509CertificateViewAdapter.java @@ -1,26 +1,33 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.adapter; +import android.util.Log; +import android.view.View; +import android.widget.TextView; + +import com.owncloud.android.R; +import com.owncloud.android.ui.dialog.SslUntrustedCertDialog; + +import javax.security.auth.x500.X500Principal; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateEncodingException; @@ -30,22 +37,13 @@ import java.util.HashMap; import java.util.Map; -import javax.security.auth.x500.X500Principal; - -import com.owncloud.android.R; -import com.owncloud.android.ui.dialog.SslUntrustedCertDialog; - -import android.util.Log; -import android.view.View; -import android.widget.TextView; - /** * */ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.CertificateViewAdapter { - + //private final static String TAG = X509CertificateViewAdapter.class.getSimpleName(); - + private X509Certificate mCertificate = null; private static final String TAG = X509CertificateViewAdapter.class.getSimpleName(); @@ -53,18 +51,18 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif public X509CertificateViewAdapter(X509Certificate certificate) { mCertificate = certificate; } - + @Override public void updateCertificateView(View dialogView) { TextView nullCerView = dialogView.findViewById(R.id.null_cert); - + if (mCertificate != null) { nullCerView.setVisibility(View.GONE); showSubject(mCertificate.getSubjectX500Principal(), dialogView); showIssuer(mCertificate.getIssuerX500Principal(), dialogView); showValidity(mCertificate.getNotBefore(), mCertificate.getNotAfter(), dialogView); showSignature(dialogView); - + } else { nullCerView.setVisibility(View.VISIBLE); } @@ -109,30 +107,30 @@ private void showSignature(View dialogView) { Log.e(TAG, "Problem while trying to decode the certificate."); } - } - - private final String getDigestHexBytesWithColonsAndNewLines(View dialogView, final String digestType, final byte [] cert) { + + private final String getDigestHexBytesWithColonsAndNewLines(View dialogView, final String digestType, + final byte[] cert) { final byte[] rawDigest; final String newLine = System.getProperty("line.separator"); rawDigest = getDigest(digestType, cert); - if ( rawDigest == null) { + if (rawDigest == null) { return digestType + ":" + newLine + dialogView.getContext().getString(R.string.digest_algorithm_not_available) + newLine + newLine; } final StringBuilder hex = new StringBuilder(3 * rawDigest.length); for (final byte b : rawDigest) { - final int hiVal = (b & 0xF0) >> 4; - final int loVal = b & 0x0F; - hex.append((char) ('0' + (hiVal + (hiVal / 10 * 7)))); - hex.append((char) ('0' + (loVal + (loVal / 10 * 7)))); - hex.append(":"); + final int hiVal = (b & 0xF0) >> 4; + final int loVal = b & 0x0F; + hex.append((char) ('0' + (hiVal + (hiVal / 10 * 7)))); + hex.append((char) ('0' + (loVal + (loVal / 10 * 7)))); + hex.append(":"); } - return digestType + ":" + newLine + hex.toString().replaceFirst("\\:$","") + newLine + newLine; - } + return digestType + ":" + newLine + hex.toString().replaceFirst("\\:$", "") + newLine + newLine; + } private void showValidity(Date notBefore, Date notAfter, View dialogView) { TextView fromView = dialogView.findViewById(R.id.value_validity_from); @@ -150,7 +148,7 @@ private void showSubject(X500Principal subject, View dialogView) { TextView cView = dialogView.findViewById(R.id.value_subject_C); TextView stView = dialogView.findViewById(R.id.value_subject_ST); TextView lView = dialogView.findViewById(R.id.value_subject_L); - + if (s.get("CN") != null) { cnView.setText(s.get("CN")); cnView.setVisibility(View.VISIBLE); @@ -188,7 +186,7 @@ private void showSubject(X500Principal subject, View dialogView) { lView.setVisibility(View.GONE); } } - + private void showIssuer(X500Principal issuer, View dialogView) { Map s = parsePrincipal(issuer); TextView cnView = dialogView.findViewById(R.id.value_issuer_CN); @@ -197,7 +195,7 @@ private void showIssuer(X500Principal issuer, View dialogView) { TextView cView = dialogView.findViewById(R.id.value_issuer_C); TextView stView = dialogView.findViewById(R.id.value_issuer_ST); TextView lView = dialogView.findViewById(R.id.value_issuer_L); - + if (s.get("CN") != null) { cnView.setText(s.get("CN")); cnView.setVisibility(View.VISIBLE); @@ -235,17 +233,16 @@ private void showIssuer(X500Principal issuer, View dialogView) { lView.setVisibility(View.GONE); } } - private Map parsePrincipal(X500Principal principal) { Map result = new HashMap(); String toParse = principal.getName(); String[] pieces = toParse.split(","); - String[] tokens = {"CN", "O", "OU", "C", "ST", "L"}; - for (int i=0; i < pieces.length ; i++) { - for (int j=0; j. + * ownCloud Android client application * + * @author masensio + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.asynctasks; @@ -89,11 +88,9 @@ protected void onPostExecute(Pair result // a cancelled task shouldn't call the listener, even if the reference exists; // the Activity responsible could be stopped, and its abilities to do things constrained - if (result!= null && !isCancelled()) - { + if (result != null && !isCancelled()) { OnRemoteOperationListener listener = mListener.get(); - if (listener!= null) - { + if (listener != null) { listener.onRemoteOperationFinish(result.first, result.second); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/controller/TransferProgressController.java b/owncloudApp/src/main/java/com/owncloud/android/ui/controller/TransferProgressController.java index 65fc58eb3a5..cd63f382bdd 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/controller/TransferProgressController.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/controller/TransferProgressController.java @@ -1,30 +1,28 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.controller; import android.accounts.Account; -import androidx.annotation.UiThread; -import androidx.annotation.WorkerThread; import android.view.View; import android.widget.ProgressBar; +import androidx.annotation.UiThread; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.files.services.FileUploader; @@ -32,7 +30,6 @@ import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.ComponentsGetter; - /** * Controller updating a progress bar with the progress of a file transfer * reported from upload or download service. @@ -45,7 +42,6 @@ public class TransferProgressController implements OnDatatransferProgressListene private ComponentsGetter mComponentsGetter = null; private int mLastPercent = 0; - public TransferProgressController(ComponentsGetter componentsGetter) { if (componentsGetter == null) { throw new IllegalArgumentException("Received NULL componentsGetter"); @@ -53,7 +49,6 @@ public TransferProgressController(ComponentsGetter componentsGetter) { mComponentsGetter = componentsGetter; } - /** * Sets the progress bar that will updated with file transfer progress * @@ -124,11 +119,11 @@ public void startListeningProgressFor(OCFile file, Account account) { public void stopListeningProgressFor(OCFile file, Account account) { if (mComponentsGetter.getFileDownloaderBinder() != null) { mComponentsGetter.getFileDownloaderBinder(). - removeDatatransferProgressListener(this, account, file); + removeDatatransferProgressListener(this, account, file); } if (mComponentsGetter.getFileUploaderBinder() != null) { mComponentsGetter.getFileUploaderBinder(). - removeDatatransferProgressListener(this, account, file); + removeDatatransferProgressListener(this, account, file); } if (mProgressBar != null) { mProgressBar.setIndeterminate(false); @@ -146,24 +141,24 @@ public void stopListeningProgressFor(OCFile file, Account account) { */ @Override public void onTransferProgress( - long progressRate, - long totalTransferredSoFar, - long totalToTransfer, - String filename + long progressRate, + long totalTransferredSoFar, + long totalToTransfer, + String filename ) { if (mProgressBar != null) { final int percent = (int) (100.0 * ((double) totalTransferredSoFar) / ((double) totalToTransfer)); if (percent != mLastPercent) { mProgressBar.post( - new Runnable() { - @Override - public void run() { - mProgressBar.setVisibility(View.VISIBLE); - mProgressBar.setIndeterminate(false); - mProgressBar.setProgress(percent); - mProgressBar.invalidate(); + new Runnable() { + @Override + public void run() { + mProgressBar.setVisibility(View.VISIBLE); + mProgressBar.setIndeterminate(false); + mProgressBar.setProgress(percent); + mProgressBar.invalidate(); + } } - } ); } mLastPercent = percent; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java index 23679ca0255..ee26d5269ac 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java @@ -1,36 +1,34 @@ /** - * ownCloud Android client application - * - * @author Bartek Przybylski - * @author Christian Schabesberger - * Copyright (C) 2012 Bartek Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Bartek Przybylski + * @author Christian Schabesberger + * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; -import androidx.appcompat.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; +import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; - public class ConfirmationDialogFragment extends DialogFragment { public final static String ARG_MESSAGE_RESOURCE_ID = "resource_id"; @@ -40,14 +38,14 @@ public class ConfirmationDialogFragment extends DialogFragment { public final static String ARG_POSITIVE_BTN_RES = "positive_btn_res"; public final static String ARG_NEUTRAL_BTN_RES = "neutral_btn_res"; public final static String ARG_NEGATIVE_BTN_RES = "negative_btn_res"; - + public static final String FTAG_CONFIRMATION = "CONFIRMATION_FRAGMENT"; private ConfirmationDialogFragmentListener mListener; - + /** * Public factory method to create new ConfirmationDialogFragment instances. - * + * * @param messageResId Resource id for a message to show in the dialog. * @param messageArguments Arguments to complete the message, if it's a format string. May be null. * @param titleResId Resource id for a text to show in the title. @@ -55,15 +53,15 @@ public class ConfirmationDialogFragment extends DialogFragment { * @param posBtn Resource id for the text of the positive button. -1 for no positive button. * @param neuBtn Resource id for the text of the neutral button. -1 for no neutral button. * @param negBtn Resource id for the text of the negative button. -1 for no negative button. - * @return Dialog ready to show. + * @return Dialog ready to show. */ public static ConfirmationDialogFragment newInstance( - int messageResId, - String[] messageArguments, - int titleResId, - int posBtn, - int neuBtn, - int negBtn + int messageResId, + String[] messageArguments, + int titleResId, + int posBtn, + int neuBtn, + int negBtn ) { if (messageResId == -1) { @@ -81,7 +79,7 @@ public static ConfirmationDialogFragment newInstance( frag.setArguments(args); return frag; } - + public void setOnConfirmationListener(ConfirmationDialogFragmentListener listener) { mListener = listener; } @@ -94,15 +92,15 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1); int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1); int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1); - + if (messageArguments == null) { messageArguments = new String[]{}; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) - .setIcon(R.drawable.ic_warning) - .setIconAttribute(android.R.attr.alertDialogIcon) - .setMessage(String.format(getString(messageId), messageArguments)); + .setIcon(R.drawable.ic_warning) + .setIconAttribute(android.R.attr.alertDialogIcon) + .setMessage(String.format(getString(messageId), messageArguments)); if (titleId == 0) { builder.setTitle(android.R.string.dialog_alert_title); @@ -110,7 +108,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { builder.setTitle(titleId); } - if (posBtn != -1) + if (posBtn != -1) { builder.setPositiveButton(posBtn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { @@ -120,7 +118,8 @@ public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); - if (neuBtn != -1) + } + if (neuBtn != -1) { builder.setNeutralButton(neuBtn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { @@ -130,7 +129,8 @@ public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); - if (negBtn != -1) + } + if (negBtn != -1) { builder.setNegativeButton(negBtn, new DialogInterface.OnClickListener() { @Override @@ -141,15 +141,17 @@ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); - return builder.create(); + } + return builder.create(); } - - + public interface ConfirmationDialogFragmentListener { void onConfirmation(String callerTag); + void onNeutral(String callerTag); + void onCancel(String callerTag); } - + } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java index 6636e079d36..58489c8f87b 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java @@ -1,39 +1,37 @@ /** - * ownCloud Android client application - * - * @author Bartek Przybylski - * @author Christian Schabesberger - * Copyright (C) 2012 Bartek Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Bartek Przybylski + * @author Christian Schabesberger + * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; -import androidx.appcompat.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; + +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; -import androidx.appcompat.app.AppCompatActivity; - import com.owncloud.android.R; - /** * Dialog which will be displayed to user upon keep-in-sync file conflict. */ @@ -45,9 +43,9 @@ public enum Decision { OVERWRITE, SERVER } - + OnConflictDecisionMadeListener mListener; - + public static ConflictsResolveDialog newInstance(String path, OnConflictDecisionMadeListener listener) { ConflictsResolveDialog f = new ConflictsResolveDialog(); Bundle args = new Bundle(); @@ -56,32 +54,35 @@ public static ConflictsResolveDialog newInstance(String path, OnConflictDecision f.mListener = listener; return f; } - + @Override public Dialog onCreateDialog(Bundle savedInstanceState) { String remotepath = getArguments().getString("remotepath"); return new AlertDialog.Builder(getActivity()) - .setIcon(R.drawable.ic_warning) - .setTitle(R.string.conflict_title) - .setMessage(String.format(getString(R.string.conflict_message), remotepath)) - .setPositiveButton(R.string.conflict_use_local_version, - (dialog, which) -> { - if (mListener != null) - mListener.conflictDecisionMade(Decision.OVERWRITE); - }) - .setNeutralButton(R.string.conflict_keep_both, - (dialog, which) -> { - if (mListener != null) - mListener.conflictDecisionMade(Decision.KEEP_BOTH); - }) - .setNegativeButton(R.string.conflict_use_server_version, - (dialog, which) -> { - if (mListener != null) - mListener.conflictDecisionMade(Decision.SERVER); - }) - .create(); + .setIcon(R.drawable.ic_warning) + .setTitle(R.string.conflict_title) + .setMessage(String.format(getString(R.string.conflict_message), remotepath)) + .setPositiveButton(R.string.conflict_use_local_version, + (dialog, which) -> { + if (mListener != null) { + mListener.conflictDecisionMade(Decision.OVERWRITE); + } + }) + .setNeutralButton(R.string.conflict_keep_both, + (dialog, which) -> { + if (mListener != null) { + mListener.conflictDecisionMade(Decision.KEEP_BOTH); + } + }) + .setNegativeButton(R.string.conflict_use_server_version, + (dialog, which) -> { + if (mListener != null) { + mListener.conflictDecisionMade(Decision.SERVER); + } + }) + .create(); } - + public void showDialog(AppCompatActivity activity) { Fragment prev = activity.getSupportFragmentManager().findFragmentByTag("dialog"); FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); @@ -101,12 +102,12 @@ public void dismissDialog(AppCompatActivity activity) { ft.commit(); } } - + @Override public void onCancel(DialogInterface dialog) { mListener.conflictDecisionMade(Decision.CANCEL); } - + public interface OnConflictDecisionMadeListener { void conflictDecisionMade(Decision decision); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java index 6617bdbc145..1f494e3281f 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; @@ -31,6 +30,9 @@ import android.widget.EditText; import android.widget.TextView; +import androidx.appcompat.app.AlertDialog; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.fragment.app.DialogFragment; import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; @@ -38,27 +40,23 @@ import com.owncloud.android.ui.activity.ComponentsGetter; import com.owncloud.android.utils.PreferenceUtils; -import androidx.appcompat.app.AlertDialog; -import androidx.coordinatorlayout.widget.CoordinatorLayout; -import androidx.fragment.app.DialogFragment; - /** * Dialog to input the name for a new folder to create. - * + * * Triggers the folder creation when name is confirmed. */ public class CreateFolderDialogFragment extends DialogFragment implements DialogInterface.OnClickListener { private static final String ARG_PARENT_FOLDER = "PARENT_FOLDER"; - + public static final String CREATE_FOLDER_FRAGMENT = "CREATE_FOLDER_FRAGMENT"; /** * Public factory method to create new CreateFolderDialogFragment instances. * * @param parentFolder Folder to create - * @return Dialog ready to show. + * @return Dialog ready to show. */ public static CreateFolderDialogFragment newInstance(OCFile parentFolder) { CreateFolderDialogFragment frag = new CreateFolderDialogFragment(); @@ -69,12 +67,11 @@ public static CreateFolderDialogFragment newInstance(OCFile parentFolder) { } private OCFile mParentFolder; - - + @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mParentFolder = getArguments().getParcelable(ARG_PARENT_FOLDER); - + // Inflate the layout for the dialog LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.edit_box_dialog, null); @@ -89,36 +86,35 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { coordinatorLayout.setFilterTouchesWhenObscured( PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(getContext()) ); - + // Setup layout EditText inputText = v.findViewById(R.id.user_input); inputText.setText(""); inputText.requestFocus(); - + // Build the dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(v) - .setPositiveButton(android.R.string.ok, this) - .setNegativeButton(android.R.string.cancel, this) - .setTitle(R.string.uploader_info_dirname); + .setPositiveButton(android.R.string.ok, this) + .setNegativeButton(android.R.string.cancel, this) + .setTitle(R.string.uploader_info_dirname); Dialog d = builder.create(); d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); return d; - } - - + } + @Override public void onClick(DialogInterface dialog, int which) { if (which == AlertDialog.BUTTON_POSITIVE) { - String newFolderName = - ((TextView)(getDialog().findViewById(R.id.user_input))) - .getText().toString().trim(); - + String newFolderName = + ((TextView) (getDialog().findViewById(R.id.user_input))) + .getText().toString().trim(); + if (newFolderName.length() <= 0) { showSnackMessage(R.string.filename_empty); return; } - boolean serverWithForbiddenChars = ((ComponentsGetter)getActivity()). + boolean serverWithForbiddenChars = ((ComponentsGetter) getActivity()). getFileOperationsHelper().isVersionWithForbiddenCharacters(); if (!FileUtils.isValidName(newFolderName, serverWithForbiddenChars)) { @@ -131,11 +127,11 @@ public void onClick(DialogInterface dialog, int which) { showSnackMessage(messageId); return; } - + String path = mParentFolder.getRemotePath(); path += newFolderName + OCFile.PATH_SEPARATOR; - ((ComponentsGetter)getActivity()). - getFileOperationsHelper().createFolder(path, false); + ((ComponentsGetter) getActivity()). + getFileOperationsHelper().createFolder(path, false); } } @@ -146,9 +142,9 @@ public void onClick(DialogInterface dialog, int which) { */ private void showSnackMessage(int messageResource) { Snackbar snackbar = Snackbar.make( - getActivity().findViewById(R.id.coordinator_layout), - messageResource, - Snackbar.LENGTH_LONG + getActivity().findViewById(R.id.coordinator_layout), + messageResource, + Snackbar.LENGTH_LONG ); snackbar.show(); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java index cf6f7453f10..f8bd0886192 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java @@ -1,33 +1,26 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; -import com.owncloud.android.R; -import com.owncloud.android.authentication.AuthenticatorActivity; - -import androidx.appcompat.app.AlertDialog; import android.app.Dialog; -import androidx.appcompat.app.AlertDialog.Builder; import android.content.DialogInterface; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; import android.text.InputType; import android.view.WindowManager.LayoutParams; import android.webkit.HttpAuthHandler; @@ -35,30 +28,33 @@ import android.widget.EditText; import android.widget.LinearLayout; - +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AlertDialog.Builder; +import androidx.fragment.app.DialogFragment; +import com.owncloud.android.R; +import com.owncloud.android.authentication.AuthenticatorActivity; /** * Dialog to input authentication credentials - * + * */ public class CredentialsDialogFragment extends DialogFragment - implements DialogInterface.OnClickListener { + implements DialogInterface.OnClickListener { private WebView mWebView = null; private HttpAuthHandler mHandler = null; private EditText mUsernameET; private EditText mPasswordET; - + private String mUsernameStr; private String mPasswordStr; - /** * Public factory method to create new CredentialsDialogFragment instances. * @param webView WebView that is being loaded * @param handler HttpAuthHandler - * @return Dialog ready to show + * @return Dialog ready to show */ public static CredentialsDialogFragment newInstanceForCredentials(WebView webView, HttpAuthHandler handler) { @@ -72,7 +68,6 @@ public static CredentialsDialogFragment newInstanceForCredentials(WebView webVie return frag; } - @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -90,9 +85,9 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { ll.setOrientation(LinearLayout.VERTICAL); ll.addView(mUsernameET); ll.addView(mPasswordET); - + ll.requestFocus(); - + setRetainInstance(true); Builder authDialog = new AlertDialog @@ -108,7 +103,6 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { return d; } - @Override public void onPause() { super.onPause(); @@ -118,7 +112,6 @@ public void onPause() { mPasswordStr = mPasswordET.getText().toString(); } - @Override public void onResume() { super.onResume(); @@ -126,10 +119,9 @@ public void onResume() { mPasswordET.setText(mPasswordStr); } - @Override public void onClick(DialogInterface dialog, int which) { - if (which == AlertDialog.BUTTON_POSITIVE) { + if (which == AlertDialog.BUTTON_POSITIVE) { String username = mUsernameET.getText().toString(); String password = mPasswordET.getText().toString(); @@ -139,18 +131,18 @@ public void onClick(DialogInterface dialog, int which) { } else if (which == AlertDialog.BUTTON_NEGATIVE) { mWebView.stopLoading(); - ((AuthenticatorActivity)getActivity()).doNegativeAuthenticatioDialogClick(); + ((AuthenticatorActivity) getActivity()).doNegativeAuthenticatioDialogClick(); } dialog.dismiss(); } - - + @Override public void onDestroyView() { - if (getDialog() != null && getRetainInstance()) - getDialog().setDismissMessage(null); - super.onDestroyView(); + if (getDialog() != null && getRetainInstance()) { + getDialog().setDismissMessage(null); + } + super.onDestroyView(); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java index 5884ce7d7c6..d10d79f4830 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java @@ -4,37 +4,36 @@ * @author David A. Velasco * @author David González Verdugo * Copyright (C) 2016 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; - import android.app.DatePickerDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; import android.text.format.DateUtils; import android.widget.DatePicker; +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; -import java.text.SimpleDateFormat; import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -98,7 +97,8 @@ public static DateFormat getDateFormat() { * * @return A new dialog to let the user choose an expiration date that will be bound to a share link. */ - @Override @NonNull + @Override + @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { // Chosen date received as an argument must be later than tomorrow ; default to tomorrow in other case diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/FingerprintAuthDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/FingerprintAuthDialogFragment.java index dc485de6297..c634f8a4ee7 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/FingerprintAuthDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/FingerprintAuthDialogFragment.java @@ -28,7 +28,6 @@ import android.hardware.fingerprint.FingerprintManager; import android.os.Build; import android.os.Bundle; -import androidx.annotation.RequiresApi; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,6 +35,7 @@ import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.RequiresApi; import com.owncloud.android.R; import com.owncloud.android.authentication.FingerprintUIHelper; import com.owncloud.android.authentication.PassCodeManager; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java index 34d6a818a20..633cb64d355 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.java @@ -1,34 +1,28 @@ /** - * ownCloud Android client application - * - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; -import com.owncloud.android.R; -import com.owncloud.android.utils.PreferenceUtils; - import android.app.Dialog; import android.content.DialogInterface; import android.graphics.PorterDuff; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; -import androidx.core.content.ContextCompat; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; @@ -37,6 +31,11 @@ import android.widget.ProgressBar; import android.widget.TextView; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.DialogFragment; +import com.owncloud.android.R; +import com.owncloud.android.utils.PreferenceUtils; + public class LoadingDialog extends DialogFragment { private static final String ARG_MESSAGE_ID = LoadingDialog.class.getCanonicalName() + ".ARG_MESSAGE_ID"; @@ -54,7 +53,7 @@ public void onCreate(Bundle savedInstanceState) { * * @param messageId Resource id for a message to show in the dialog. * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...) - * @return New dialog instance, ready to show. + * @return New dialog instance, ready to show. */ public static LoadingDialog newInstance(int messageId, boolean cancelable) { LoadingDialog fragment = new LoadingDialog(); @@ -115,8 +114,9 @@ public boolean onKey(DialogInterface dialog, int keyCode, @Override public void onDestroyView() { - if (getDialog() != null && getRetainInstance()) + if (getDialog() != null && getRetainInstance()) { getDialog().setDismissMessage(null); + } super.onDestroyView(); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoginWebViewDialog.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoginWebViewDialog.java index 406b9842d89..83b3dfc9cf0 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoginWebViewDialog.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/LoginWebViewDialog.java @@ -1,24 +1,23 @@ /** - * ownCloud Android client application - * - * @author Maria Asensio - * @author David A. Velasco - * @author David González Verdugo - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Maria Asensio + * @author David A. Velasco + * @author David González Verdugo + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; @@ -30,10 +29,6 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -44,6 +39,10 @@ import android.webkit.WebView; import android.widget.RelativeLayout; +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.BaseWebViewClient; @@ -58,13 +57,12 @@ import static com.owncloud.android.operations.AuthenticationMethod.SAML_WEB_SSO; - /** * Dialog to show the WebView for SAML authentication */ public class LoginWebViewDialog extends DialogFragment { - private final static String TAG = LoginWebViewDialog.class.getSimpleName(); + private final static String TAG = LoginWebViewDialog.class.getSimpleName(); private static final String ARG_INITIAL_URL = "INITIAL_URL"; private static final String ARG_TARGET_URLS = "TARGET_URLS"; @@ -83,16 +81,16 @@ public class LoginWebViewDialog extends DialogFragment { * * @param url Url to open at WebView. * @param targetUrls Url signaling the success of the authentication, when loaded. - * @return New dialog instance, ready to show. + * @return New dialog instance, ready to show. */ public static LoginWebViewDialog newInstance( - String url, - ArrayList targetUrls, - AuthenticationMethod authenticationMethod + String url, + ArrayList targetUrls, + AuthenticationMethod authenticationMethod ) { if (SAML_WEB_SSO != authenticationMethod) { throw new IllegalArgumentException( - "Only SAML_WEB_SSO authentication method is supported" + "Only SAML_WEB_SSO authentication method is supported" ); } LoginWebViewDialog fragment = new LoginWebViewDialog(); @@ -103,47 +101,44 @@ public static LoginWebViewDialog newInstance( fragment.setArguments(args); return fragment; } - - + public LoginWebViewDialog() { super(); } - - + @Override public void onAttach(Activity activity) { Log_OC.v(TAG, "onAttach"); super.onAttach(activity); try { AuthenticationMethod authenticationMethod = AuthenticationMethod.fromValue( - getArguments().getInt(ARG_AUTHENTICATION_METHOD) + getArguments().getInt(ARG_AUTHENTICATION_METHOD) ); if (authenticationMethod == null) { throw new IllegalStateException("Null authentication method got to onAttach"); } Handler handler = new Handler(); - if(SAML_WEB_SSO == authenticationMethod) { + if (SAML_WEB_SSO == authenticationMethod) { mSsoWebViewClientListener = (SsoWebViewClientListener) activity; mWebViewClient = new SAMLWebViewClient(activity, handler, mSsoWebViewClientListener); } else { - throw new IllegalStateException("Invalid authentication method got to onAttach"); + throw new IllegalStateException("Invalid authentication method got to onAttach"); } - } catch (ClassCastException e) { + } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement " + - SsoWebViewClientListener.class.getSimpleName() + SsoWebViewClientListener.class.getSimpleName() ); } } - @SuppressLint("SetJavaScriptEnabled") @Override public void onCreate(Bundle savedInstanceState) { Log_OC.v(TAG, "onCreate, savedInstanceState is " + savedInstanceState); super.onCreate(savedInstanceState); - + setRetainInstance(true); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { @@ -155,14 +150,14 @@ public void onCreate(Bundle savedInstanceState) { setStyle(DialogFragment.STYLE_NO_TITLE, 0); } - + @SuppressWarnings("deprecation") @SuppressLint("SetJavaScriptEnabled") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.v(TAG, "onCreateView, savedInsanceState is " + savedInstanceState); - + // Inflate layout of the dialog RelativeLayout ssoRootView = (RelativeLayout) inflater.inflate(R.layout.webview_dialog, container, false); // null parent view because it will go in the dialog layout @@ -171,14 +166,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, ssoRootView.setFilterTouchesWhenObscured( PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(getContext()) ); - + if (mWebView == null) { // initialize the WebView mWebView = new SsoWebView(getActivity().getApplicationContext()); mWebView.setFocusable(true); mWebView.setFocusableInTouchMode(true); mWebView.setClickable(true); - + WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSavePassword(false); @@ -196,21 +191,21 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.removeAllCookie(); - + mWebView.loadUrl(mInitialUrl); } - + mWebViewClient.addTargetUrls(mTargetUrls); mWebView.setWebViewClient(mWebViewClient); - + // add the webview into the layout RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT - ); + ); ssoRootView.addView(mWebView, layoutParams); ssoRootView.requestLayout(); - + return ssoRootView; } @@ -219,29 +214,29 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.getWindow().setSoftInputMode( - WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return dialog; } @Override public void onDestroyView() { Log_OC.v(TAG, "onDestroyView"); - + if (mWebView.getParent() != null) { ((ViewGroup) mWebView.getParent()).removeView(mWebView); } - + mWebView.setWebViewClient(null); - + // Work around bug: http://code.google.com/p/android/issues/detail?id=17423 Dialog dialog = getDialog(); if ((dialog != null)) { dialog.setOnDismissListener(null); } - + super.onDestroyView(); } - + @Override public void onDestroy() { Log_OC.v(TAG, "onDestroy"); @@ -256,19 +251,19 @@ public void onDetach() { mWebViewClient = null; super.onDetach(); } - + @Override - public void onCancel (DialogInterface dialog) { + public void onCancel(DialogInterface dialog) { Log_OC.d(TAG, "onCancel"); super.onCancel(dialog); } - + @Override - public void onDismiss (DialogInterface dialog) { + public void onDismiss(DialogInterface dialog) { Log_OC.d(TAG, "onDismiss"); super.onDismiss(dialog); } - + @Override public void onStart() { Log_OC.v(TAG, "onStart"); @@ -294,17 +289,17 @@ public void onPause() { mWebView.onPause(); super.onPause(); } - + @Override - public int show (FragmentTransaction transaction, String tag) { + public int show(FragmentTransaction transaction, String tag) { Log_OC.v(TAG, "show (transaction)"); return super.show(transaction, tag); } @Override - public void show (FragmentManager manager, String tag) { + public void show(FragmentManager manager, String tag) { Log_OC.v(TAG, "show (manager)"); super.show(manager, tag); } - + } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/OwnCloudListPreference.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/OwnCloudListPreference.java index eca37720c2f..f6937571637 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/OwnCloudListPreference.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/OwnCloudListPreference.java @@ -7,9 +7,9 @@ import android.os.Bundle; import android.preference.ListPreference; import android.preference.PreferenceManager; -import androidx.appcompat.app.AppCompatDialog; import android.util.AttributeSet; +import androidx.appcompat.app.AppCompatDialog; import com.owncloud.android.lib.common.utils.Log_OC; import java.lang.reflect.Method; @@ -52,9 +52,9 @@ protected void showDialog(Bundle state) { // same thing happens for the Standard ListPreference though androidx.appcompat.app.AlertDialog.Builder builder = new androidx.appcompat.app.AlertDialog.Builder(mContext) - .setTitle(getDialogTitle()) - .setIcon(getDialogIcon()) - .setSingleChoiceItems(getEntries(), preselect, this); + .setTitle(getDialogTitle()) + .setIcon(getDialogIcon()) + .setSingleChoiceItems(getEntries(), preselect, this); PreferenceManager pm = getPreferenceManager(); try { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RateMeDialog.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RateMeDialog.java index 4eac0ef43e5..f87c14d40e6 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RateMeDialog.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RateMeDialog.java @@ -1,32 +1,29 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; import android.app.Dialog; import android.content.ActivityNotFoundException; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; -import android.content.DialogInterface; import android.os.Bundle; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -36,6 +33,8 @@ import android.widget.Button; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.AppRater; import com.owncloud.android.R; import com.owncloud.android.utils.PreferenceUtils; @@ -62,7 +61,7 @@ public void onCreate(Bundle savedInstanceState) { * * @param packageName The package name of the application * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...) - * @return New dialog instance, ready to show. + * @return New dialog instance, ready to show. */ public static RateMeDialog newInstance(String packageName, boolean cancelable) { RateMeDialog fragment = new RateMeDialog(); @@ -101,12 +100,9 @@ public void onClick(View v) { /// to taken back to our application, we need to add following flags to intent. int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT; - } - else - { + } else { flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; } goToMarket.addFlags(flags); @@ -174,8 +170,9 @@ public boolean onKey(DialogInterface dialog, int keyCode, @Override public void onDestroyView() { - if (getDialog() != null && getRetainInstance()) + if (getDialog() != null && getRetainInstance()) { getDialog().setDismissMessage(null); + } super.onDestroyView(); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveAccountDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveAccountDialogFragment.java index 1cbde1c30f7..8f980c523a7 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveAccountDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveAccountDialogFragment.java @@ -1,28 +1,27 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; /** * Dialog requiring confirmation before removing an OC Account. - * + * * Removes the account if the user confirms. * * Container Activity needs to implement AccountManagerCallback. @@ -35,13 +34,13 @@ import android.app.Dialog; import android.os.Bundle; import android.os.Handler; -import androidx.annotation.NonNull; +import androidx.annotation.NonNull; import com.owncloud.android.R; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment.ConfirmationDialogFragmentListener; public class RemoveAccountDialogFragment extends ConfirmationDialogFragment - implements ConfirmationDialogFragmentListener { + implements ConfirmationDialogFragmentListener { private Account mTargetAccount; @@ -49,12 +48,12 @@ public class RemoveAccountDialogFragment extends ConfirmationDialogFragment /** * Public factory method to create new RemoveAccountDialogFragment instances. - * + * * @param account Account to remove. - * @return Dialog ready to show. + * @return Dialog ready to show. */ public static RemoveAccountDialogFragment newInstance(Account account) { - if (account == null ) { + if (account == null) { throw new IllegalArgumentException("Cannot remove a NULL account"); } @@ -67,7 +66,7 @@ public static RemoveAccountDialogFragment newInstance(Account account) { args.putInt(ARG_NEGATIVE_BTN_RES, -1); args.putParcelable(ARG_TARGET_ACCOUNT, account); frag.setArguments(args); - + return frag; } @@ -76,23 +75,24 @@ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // checked here to fail soon in case of wrong usage try { - AccountManagerCallback a = (AccountManagerCallback)getActivity(); + AccountManagerCallback a = (AccountManagerCallback) getActivity(); } catch (ClassCastException c) { throw new IllegalStateException( - "Container Activity needs to implement (AccountManagerCallback)", c + "Container Activity needs to implement (AccountManagerCallback)", c ); } } - @Override @NonNull + @Override + @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); mTargetAccount = getArguments().getParcelable(ARG_TARGET_ACCOUNT); - + setOnConfirmationListener(this); - + return dialog; - } + } /** * Performs the removal of the target account. @@ -101,10 +101,10 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { public void onConfirmation(String callerTag) { Activity parentActivity = getActivity(); AccountManager am = AccountManager.get(parentActivity); - AccountManagerCallback callback = (AccountManagerCallback)parentActivity; + AccountManagerCallback callback = (AccountManagerCallback) parentActivity; am.removeAccount(mTargetAccount, callback, new Handler()); } - + @Override public void onCancel(String callerTag) { // nothing to do here diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveFilesDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveFilesDialogFragment.java index a296c2f664c..1de5a037fdb 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveFilesDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveFilesDialogFragment.java @@ -1,28 +1,27 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; /** * Dialog requiring confirmation before removing a collection of given OCFiles. - * + * * Triggers the removal according to the user response. */ @@ -37,7 +36,7 @@ import java.util.ArrayList; public class RemoveFilesDialogFragment extends ConfirmationDialogFragment -implements ConfirmationDialogFragmentListener { + implements ConfirmationDialogFragmentListener { private ArrayList mTargetFiles; @@ -45,9 +44,9 @@ public class RemoveFilesDialogFragment extends ConfirmationDialogFragment /** * Public factory method to create new RemoveFilesDialogFragment instances. - * + * * @param files Files to remove. - * @return Dialog ready to show. + * @return Dialog ready to show. */ public static RemoveFilesDialogFragment newInstance(ArrayList files) { RemoveFilesDialogFragment frag = new RemoveFilesDialogFragment(); @@ -57,9 +56,13 @@ public static RemoveFilesDialogFragment newInstance(ArrayList files) { boolean containsFolder = false; boolean containsDown = false; boolean containsAvailableOffline = false; - for (OCFile file: files) { - if (file.isFolder()) containsFolder = true; - if (file.isDown()) containsDown = true; + for (OCFile file : files) { + if (file.isFolder()) { + containsFolder = true; + } + if (file.isDown()) { + containsDown = true; + } if (file.getAvailableOfflineStatus() != OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE) { containsAvailableOffline = true; } @@ -70,20 +73,20 @@ public static RemoveFilesDialogFragment newInstance(ArrayList files) { OCFile file = files.get(0); messageStringId = (file.isFolder()) ? - R.string.confirmation_remove_folder_alert : - R.string.confirmation_remove_file_alert; + R.string.confirmation_remove_folder_alert : + R.string.confirmation_remove_file_alert; } else { // choose message for more than one file messageStringId = (containsFolder) ? - R.string.confirmation_remove_folders_alert : - R.string.confirmation_remove_files_alert; + R.string.confirmation_remove_folders_alert : + R.string.confirmation_remove_files_alert; } int localRemoveButton = (!containsAvailableOffline && (containsFolder || containsDown)) ? - R.string.confirmation_remove_local : - -1; + R.string.confirmation_remove_local : + -1; args.putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId); if (files.size() == 1) { @@ -94,16 +97,15 @@ public static RemoveFilesDialogFragment newInstance(ArrayList files) { args.putInt(ARG_NEGATIVE_BTN_RES, localRemoveButton); args.putParcelableArrayList(ARG_TARGET_FILES, files); frag.setArguments(args); - + return frag; } - /** * Convenience factory method to create new RemoveFilesDialogFragment instances for a single file * * @param file File to remove. - * @return Dialog ready to show. + * @return Dialog ready to show. */ public static RemoveFilesDialogFragment newInstance(OCFile file) { ArrayList list = new ArrayList<>(); @@ -111,16 +113,15 @@ public static RemoveFilesDialogFragment newInstance(OCFile file) { return newInstance(list); } - @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); mTargetFiles = getArguments().getParcelableArrayList(ARG_TARGET_FILES); - + setOnConfirmationListener(this); - + return dialog; - } + } /** * Performs the removal of the target file, both locally and in the server. @@ -130,7 +131,7 @@ public void onConfirmation(String callerTag) { ComponentsGetter cg = (ComponentsGetter) getActivity(); cg.getFileOperationsHelper().removeFiles(mTargetFiles, false); } - + /** * Performs the removal of the local copy of the target file */ diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveShareDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveShareDialogFragment.java index 6c1fd213409..dc0b74db6ae 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveShareDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RemoveShareDialogFragment.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; @@ -27,17 +26,16 @@ import android.app.Dialog; import android.os.Bundle; -import androidx.annotation.NonNull; +import androidx.annotation.NonNull; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment.ConfirmationDialogFragmentListener; import com.owncloud.android.ui.fragment.ShareFragmentListener; - public class RemoveShareDialogFragment extends ConfirmationDialogFragment -implements ConfirmationDialogFragmentListener { + implements ConfirmationDialogFragmentListener { private static final String TAG = RemoveShareDialogFragment.class.getName(); @@ -47,9 +45,9 @@ public class RemoveShareDialogFragment extends ConfirmationDialogFragment /** * Public factory method to create new RemoveFilesDialogFragment instances. - * + * * @param share {@link OCShare} to remove. - * @return Dialog ready to show. + * @return Dialog ready to show. */ public static RemoveShareDialogFragment newInstance(OCShare share) { RemoveShareDialogFragment frag = new RemoveShareDialogFragment(); @@ -57,10 +55,10 @@ public static RemoveShareDialogFragment newInstance(OCShare share) { args.putInt(ARG_MESSAGE_RESOURCE_ID, R.string.confirmation_remove_public_share_message); args.putStringArray( - ARG_MESSAGE_ARGUMENTS, - new String[] { - share.getName().length() > 0 ? share.getName() : share.getToken() - } + ARG_MESSAGE_ARGUMENTS, + new String[]{ + share.getName().length() > 0 ? share.getName() : share.getToken() + } ); args.putInt(ARG_TITLE_ID, R.string.confirmation_remove_public_share_title); args.putInt(ARG_POSITIVE_BTN_RES, R.string.common_yes); @@ -72,16 +70,16 @@ public static RemoveShareDialogFragment newInstance(OCShare share) { return frag; } - - @Override @NonNull + @Override + @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); mTargetShare = getArguments().getParcelable(ARG_TARGET_SHARE); - + setOnConfirmationListener(this); - + return dialog; - } + } /** * Performs the removal of the target share, both locally and in the server. @@ -92,7 +90,7 @@ public void onConfirmation(String callerTag) { Log_OC.d(TAG, "Removing public share " + mTargetShare.getName()); listener.removeShare(mTargetShare); } - + @Override public void onCancel(String callerTag) { // nothing to do here diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java index c0fe569ecab..b55aaac2d29 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java @@ -1,54 +1,53 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; /** * Dialog to input a new name for an {@link OCFile} being renamed. - * + * * Triggers the rename operation. */ -import com.google.android.material.snackbar.Snackbar; -import androidx.appcompat.app.AlertDialog; + import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager.LayoutParams; import android.widget.EditText; import android.widget.TextView; +import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; +import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.ui.activity.ComponentsGetter; import com.owncloud.android.utils.PreferenceUtils; - /** * Dialog to input a new name for a file or folder to rename. - * + * * Triggers the rename operation when name is confirmed. */ public class RenameFileDialogFragment @@ -58,9 +57,9 @@ public class RenameFileDialogFragment /** * Public factory method to create new RenameFileDialogFragment instances. - * + * * @param file File to rename. - * @return Dialog ready to show. + * @return Dialog ready to show. */ public static RenameFileDialogFragment newInstance(OCFile file) { RenameFileDialogFragment frag = new RenameFileDialogFragment(); @@ -68,11 +67,11 @@ public static RenameFileDialogFragment newInstance(OCFile file) { args.putParcelable(ARG_TARGET_FILE, file); frag.setArguments(args); return frag; - + } private OCFile mTargetFile; - + @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mTargetFile = getArguments().getParcelable(ARG_TARGET_FILE); @@ -85,7 +84,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { v.setFilterTouchesWhenObscured( PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(getContext()) ); - + // Setup layout String currentName = mTargetFile.getFileName(); EditText inputText = v.findViewById(R.id.user_input); @@ -95,36 +94,35 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length(); if (selectionStart >= 0 && selectionEnd >= 0) { inputText.setSelection( - Math.min(selectionStart, selectionEnd), + Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd)); } inputText.requestFocus(); - + // Build the dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(v) - .setPositiveButton(android.R.string.ok, this) - .setNegativeButton(android.R.string.cancel, this) - .setTitle(R.string.rename_dialog_title); + .setPositiveButton(android.R.string.ok, this) + .setNegativeButton(android.R.string.cancel, this) + .setTitle(R.string.rename_dialog_title); Dialog d = builder.create(); d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); return d; - } + } - @Override public void onClick(DialogInterface dialog, int which) { if (which == AlertDialog.BUTTON_POSITIVE) { - String newFileName = - ((TextView)(getDialog().findViewById(R.id.user_input))) - .getText().toString().trim(); - + String newFileName = + ((TextView) (getDialog().findViewById(R.id.user_input))) + .getText().toString().trim(); + if (newFileName.length() <= 0) { showSnackMessage(R.string.filename_empty); return; } - boolean serverWithForbiddenChars = ((ComponentsGetter)getActivity()). + boolean serverWithForbiddenChars = ((ComponentsGetter) getActivity()). getFileOperationsHelper().isVersionWithForbiddenCharacters(); if (!FileUtils.isValidName(newFileName, serverWithForbiddenChars)) { @@ -138,7 +136,7 @@ public void onClick(DialogInterface dialog, int which) { return; } - ((ComponentsGetter)getActivity()).getFileOperationsHelper(). + ((ComponentsGetter) getActivity()).getFileOperationsHelper(). renameFile(mTargetFile, newFileName); } @@ -151,9 +149,9 @@ public void onClick(DialogInterface dialog, int which) { */ private void showSnackMessage(int messageResource) { Snackbar snackbar = Snackbar.make( - getActivity().findViewById(android.R.id.content), - messageResource, - Snackbar.LENGTH_LONG + getActivity().findViewById(android.R.id.content), + messageResource, + Snackbar.LENGTH_LONG ); snackbar.show(); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ShareLinkToDialog.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ShareLinkToDialog.java index 63ec40cfcf6..723f6e84222 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ShareLinkToDialog.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/ShareLinkToDialog.java @@ -1,32 +1,25 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import androidx.appcompat.app.AlertDialog; import android.app.Dialog; import android.content.ComponentName; import android.content.Context; @@ -36,7 +29,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -44,25 +36,32 @@ import android.widget.ImageView; import android.widget.TextView; +import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.CopyToClipboardActivity; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + /** * Dialog showing a list activities able to resolve a given Intent, * filtering out the activities matching give package names. */ -public class ShareLinkToDialog extends DialogFragment { - - private final static String TAG = ShareLinkToDialog.class.getSimpleName(); - private final static String ARG_INTENT = ShareLinkToDialog.class.getSimpleName() + +public class ShareLinkToDialog extends DialogFragment { + + private final static String TAG = ShareLinkToDialog.class.getSimpleName(); + private final static String ARG_INTENT = ShareLinkToDialog.class.getSimpleName() + ".ARG_INTENT"; - private final static String ARG_PACKAGES_TO_EXCLUDE = ShareLinkToDialog.class.getSimpleName() + + private final static String ARG_PACKAGES_TO_EXCLUDE = ShareLinkToDialog.class.getSimpleName() + ".ARG_PACKAGES_TO_EXCLUDE"; private ActivityAdapter mAdapter; private Intent mIntent; - + public static ShareLinkToDialog newInstance(Intent intent, String[] packagesToExclude) { ShareLinkToDialog f = new ShareLinkToDialog(); Bundle args = new Bundle(); @@ -71,12 +70,12 @@ public static ShareLinkToDialog newInstance(Intent intent, String[] packagesToEx f.setArguments(args); return f; } - + public ShareLinkToDialog() { super(); Log_OC.d(TAG, "constructor"); } - + @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mIntent = getArguments().getParcelable(ARG_INTENT); @@ -84,20 +83,20 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { List packagesToExcludeList = Arrays.asList(packagesToExclude != null ? packagesToExclude : new String[0]); - PackageManager pm= getActivity().getPackageManager(); + PackageManager pm = getActivity().getPackageManager(); List activities = pm.queryIntentActivities(mIntent, PackageManager.MATCH_DEFAULT_ONLY); Iterator it = activities.iterator(); ResolveInfo resolveInfo; while (it.hasNext()) { resolveInfo = it.next(); - if (packagesToExcludeList.contains(resolveInfo.activityInfo.packageName.toLowerCase())){ + if (packagesToExcludeList.contains(resolveInfo.activityInfo.packageName.toLowerCase())) { it.remove(); } } - + boolean sendAction = mIntent.getBooleanExtra(Intent.ACTION_SEND, false); - + if (!sendAction) { // add activity for copy to clipboard Intent copyToClipboardIntent = new Intent(getActivity(), CopyToClipboardActivity.class); @@ -106,52 +105,52 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { activities.add(copyToClipboard.get(0)); } } - - Collections.sort(activities, new ResolveInfo.DisplayNameComparator(pm)); + + Collections.sort(activities, new ResolveInfo.DisplayNameComparator(pm)); mAdapter = new ActivityAdapter(getActivity(), pm, activities); - + return createSelector(sendAction); - + } private AlertDialog createSelector(final boolean sendAction) { - + int titleId; if (sendAction) { titleId = R.string.activity_chooser_send_file_title; } else { titleId = R.string.activity_chooser_title; } - + return new AlertDialog.Builder(getActivity()) - .setTitle(titleId) - .setAdapter(mAdapter, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // Add the information of the chosen activity to the intent to send - ResolveInfo chosen = mAdapter.getItem(which); - ActivityInfo actInfo = chosen.activityInfo; - ComponentName name=new ComponentName( - actInfo.applicationInfo.packageName, - actInfo.name); - mIntent.setComponent(name); - - // Send the file - getActivity().startActivity(mIntent); - } - }) - .create(); + .setTitle(titleId) + .setAdapter(mAdapter, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // Add the information of the chosen activity to the intent to send + ResolveInfo chosen = mAdapter.getItem(which); + ActivityInfo actInfo = chosen.activityInfo; + ComponentName name = new ComponentName( + actInfo.applicationInfo.packageName, + actInfo.name); + mIntent.setComponent(name); + + // Send the file + getActivity().startActivity(mIntent); + } + }) + .create(); } - + class ActivityAdapter extends ArrayAdapter { - + private PackageManager mPackageManager; - + ActivityAdapter(Context context, PackageManager pm, List apps) { super(context, R.layout.activity_row, apps); this.mPackageManager = pm; } - + @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { @@ -160,12 +159,12 @@ public View getView(int position, View convertView, ViewGroup parent) { bindView(position, convertView); return convertView; } - + private View newView(ViewGroup parent) { - return(((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)). + return (((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)). inflate(R.layout.activity_row, parent, false)); } - + private void bindView(int position, View row) { TextView label = row.findViewById(R.id.title); label.setText(getItem(position).loadLabel(mPackageManager)); @@ -173,5 +172,5 @@ private void bindView(int position, View row) { icon.setImageDrawable(getItem(position).loadIcon(mPackageManager)); } } - + } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java index 759e5bd2823..1bb66745cd6 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java @@ -1,43 +1,38 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.security.cert.X509Certificate; - import android.app.Activity; import android.app.Dialog; import android.net.http.SslError; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.Window; -import android.view.View.OnClickListener; import android.webkit.SslErrorHandler; import android.widget.Button; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; import com.owncloud.android.lib.common.network.CertificateCombinedException; import com.owncloud.android.lib.common.network.NetworkUtils; @@ -47,24 +42,28 @@ import com.owncloud.android.ui.adapter.SslErrorViewAdapter; import com.owncloud.android.ui.adapter.X509CertificateViewAdapter; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.cert.X509Certificate; + /** * Dialog to show information about an untrusted certificate and allow the user * to decide trust on it or not. - * + * * Abstract implementation of common functionality for different dialogs that * get the information about the error and the certificate from different classes. */ public class SslUntrustedCertDialog extends DialogFragment { - + private final static String TAG = SslUntrustedCertDialog.class.getSimpleName(); - + protected View mView = null; protected SslErrorHandler mHandler = null; protected X509Certificate m509Certificate = null; private ErrorViewAdapter mErrorViewAdapter = null; private CertificateViewAdapter mCertificateViewAdapter = null; - + public static SslUntrustedCertDialog newInstanceForEmptySslError(SslError error, SslErrorHandler handler) { if (error == null) { throw new IllegalArgumentException("Trying to create instance with parameter error == null"); @@ -78,7 +77,7 @@ public static SslUntrustedCertDialog newInstanceForEmptySslError(SslError error, dialog.mCertificateViewAdapter = new SslCertificateViewAdapter(error.getCertificate()); return dialog; } - + public static SslUntrustedCertDialog newInstanceForFullSslError(CertificateCombinedException sslException) { if (sslException == null) { throw new IllegalArgumentException("Trying to create instance with parameter sslException == null"); @@ -89,8 +88,9 @@ public static SslUntrustedCertDialog newInstanceForFullSslError(CertificateCombi dialog.mCertificateViewAdapter = new X509CertificateViewAdapter(sslException.getServerCertificate()); return dialog; } - - public static SslUntrustedCertDialog newInstanceForFullSslError(X509Certificate cert, SslError error, SslErrorHandler handler) { + + public static SslUntrustedCertDialog newInstanceForFullSslError(X509Certificate cert, SslError error, + SslErrorHandler handler) { if (cert == null) { throw new IllegalArgumentException("Trying to create instance with parameter cert == null"); } @@ -107,8 +107,7 @@ public static SslUntrustedCertDialog newInstanceForFullSslError(X509Certificate dialog.mCertificateViewAdapter = new X509CertificateViewAdapter(cert); return dialog; } - - + @Override public void onAttach(Activity activity) { Log_OC.d(TAG, "onAttach"); @@ -118,34 +117,34 @@ public void onAttach(Activity activity) { } } - @Override public void onCreate(Bundle savedInstanceState) { Log_OC.d(TAG, "onCreate, savedInstanceState is " + savedInstanceState); super.onCreate(savedInstanceState); - setRetainInstance(true); // force to keep the state of the fragment on configuration changes (such as device rotations) + setRetainInstance(true); // force to keep the state of the fragment on configuration changes (such as + // device rotations) setCancelable(false); mView = null; } - + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.d(TAG, "onCreateView, savedInsanceState is " + savedInstanceState); // Create a view by inflating desired layout if (mView == null) { - mView = inflater.inflate(R.layout.ssl_untrusted_cert_layout, container, false); + mView = inflater.inflate(R.layout.ssl_untrusted_cert_layout, container, false); mView.findViewById(R.id.details_scroll).setVisibility(View.GONE); mErrorViewAdapter.updateErrorView(mView); } else { - ((ViewGroup)mView.getParent()).removeView(mView); + ((ViewGroup) mView.getParent()).removeView(mView); } - + Button ok = mView.findViewById(R.id.ok); ok.setOnClickListener(new OnCertificateTrusted()); - + Button cancel = mView.findViewById(R.id.cancel); cancel.setOnClickListener(new OnCertificateNotTrusted()); - + Button details = mView.findViewById(R.id.details_btn); details.setOnClickListener(new OnClickListener() { @@ -164,10 +163,9 @@ public void onClick(View v) { } }); - + return mView; } - @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -180,24 +178,24 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { @Override public void onDestroyView() { Log_OC.d(TAG, "onDestroyView"); - if (getDialog() != null && getRetainInstance()) + if (getDialog() != null && getRetainInstance()) { getDialog().setDismissMessage(null); + } super.onDestroyView(); } - + private class OnCertificateNotTrusted implements OnClickListener { - + @Override public void onClick(View v) { getDialog().cancel(); if (mHandler != null) { mHandler.cancel(); } - ((OnSslUntrustedCertListener)getActivity()).onCancelCertificate(); + ((OnSslUntrustedCertListener) getActivity()).onCancelCertificate(); } } - - + private class OnCertificateTrusted implements OnClickListener { @Override @@ -209,35 +207,37 @@ public void onClick(View v) { if (m509Certificate != null) { Activity activity = getActivity(); try { - NetworkUtils.addCertToKnownServersStore(m509Certificate, activity); // TODO make this asynchronously, it can take some time - ((OnSslUntrustedCertListener)activity).onSavedCertificate(); - + NetworkUtils.addCertToKnownServersStore(m509Certificate, activity); // TODO make this + // asynchronously, it can take some time + ((OnSslUntrustedCertListener) activity).onSavedCertificate(); + } catch (GeneralSecurityException e) { - ((OnSslUntrustedCertListener)activity).onFailedSavingCertificate(); + ((OnSslUntrustedCertListener) activity).onFailedSavingCertificate(); Log_OC.e(TAG, "Server certificate could not be saved in the known-servers trust store ", e); - + } catch (IOException e) { - ((OnSslUntrustedCertListener)activity).onFailedSavingCertificate(); + ((OnSslUntrustedCertListener) activity).onFailedSavingCertificate(); Log_OC.e(TAG, "Server certificate could not be saved in the known-servers trust store ", e); } } } - + } - - + public interface OnSslUntrustedCertListener { void onSavedCertificate(); + void onFailedSavingCertificate(); + void onCancelCertificate(); } - + public interface ErrorViewAdapter { void updateErrorView(View mView); } - + public interface CertificateViewAdapter { void updateCertificateView(View mView); } - + } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SsoWebView.java b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SsoWebView.java index bb34607ce43..f186f319793 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SsoWebView.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/dialog/SsoWebView.java @@ -1,20 +1,19 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.dialog; @@ -24,19 +23,19 @@ import android.webkit.WebView; public class SsoWebView extends WebView { - + public SsoWebView(Context context) { super(context); } - + public SsoWebView(Context context, AttributeSet attr) { super(context, attr); } - + @Override - public boolean onCheckIsTextEditor () { + public boolean onCheckIsTextEditor() { return false; } - + } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorMessageAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorMessageAdapter.java index 900bc66dee1..9ea5de5cb8e 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorMessageAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorMessageAdapter.java @@ -18,12 +18,11 @@ * along with this program. If not, see . */ - package com.owncloud.android.ui.errorhandling; import android.content.res.Resources; -import androidx.annotation.Nullable; +import androidx.annotation.Nullable; import com.owncloud.android.R; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -43,8 +42,6 @@ import com.owncloud.android.operations.UpdateShareViaLinkOperation; import com.owncloud.android.operations.UploadFileOperation; - - import java.io.File; import java.net.SocketTimeoutException; @@ -57,6 +54,7 @@ public class ErrorMessageAdapter { private static class Formatter { final Resources r; + Formatter(Resources r) { this.r = r; } @@ -94,31 +92,35 @@ public ErrorMessageAdapter() { * Return an internationalized user message corresponding to an operation result * and the operation performed. * - * @param result Result of a {@link RemoteOperation} performed. - * @param operation Operation performed. - * @param resources Reference to app resources, for i18n. + * @param result Result of a {@link RemoteOperation} performed. + * @param operation Operation performed. + * @param resources Reference to app resources, for i18n. * @return User message corresponding to 'result' and 'operation' */ public static String getResultMessage(final RemoteOperationResult result, final RemoteOperation operation, final Resources resources) { Formatter f = new Formatter(resources); - if(result.isSuccess()) { - if(operation instanceof UploadFileOperation) - return f.format(R.string.uploader_upload_succeeded_content_single, ((UploadFileOperation) operation).getFileName()); - if(operation instanceof DownloadFileOperation) + if (result.isSuccess()) { + if (operation instanceof UploadFileOperation) { + return f.format(R.string.uploader_upload_succeeded_content_single, + ((UploadFileOperation) operation).getFileName()); + } + if (operation instanceof DownloadFileOperation) { return f.format(R.string.downloader_download_succeeded_content, new File(((DownloadFileOperation) operation).getSavePath()).getName()); - if(operation instanceof RemoveFileOperation) + } + if (operation instanceof RemoveFileOperation) { return f.format(R.string.remove_success_msg); + } } - if(operation instanceof SynchronizeFileOperation && + if (operation instanceof SynchronizeFileOperation && !((SynchronizeFileOperation) operation).transferWasRequested()) { return f.format(R.string.sync_file_nothing_to_do_msg); } - if((operation instanceof CreateShareWithShareeOperation + if ((operation instanceof CreateShareWithShareeOperation || operation instanceof CreateShareViaLinkOperation || operation instanceof RemoveShareOperation || operation instanceof UpdateShareViaLinkOperation @@ -137,62 +139,95 @@ public static String getResultMessage(final RemoteOperationResult result, switch (result.getCode()) { case LOCAL_STORAGE_FULL: return f.format(R.string.error__upload__local_file_not_copied, - ((UploadFileOperation) operation).getFileName(),R.string.app_name); + ((UploadFileOperation) operation).getFileName(), R.string.app_name); case LOCAL_STORAGE_NOT_COPIED: return f.format(R.string.error__upload__local_file_not_copied, - ((UploadFileOperation) operation).getFileName(),R.string.app_name); + ((UploadFileOperation) operation).getFileName(), R.string.app_name); case FORBIDDEN: - if(operation instanceof UploadFileOperation) + if (operation instanceof UploadFileOperation) { return f.format(R.string.forbidden_permissions, R.string.uploader_upload_forbidden_permissions); - if(operation instanceof DownloadFileOperation) + } + if (operation instanceof DownloadFileOperation) { return f.forbidden(R.string.downloader_download_forbidden_permissions); - if(operation instanceof RemoveFileOperation) + } + if (operation instanceof RemoveFileOperation) { return f.forbidden(R.string.forbidden_permissions_delete); - if(operation instanceof RenameFileOperation) + } + if (operation instanceof RenameFileOperation) { return f.forbidden(R.string.forbidden_permissions_rename); - if(operation instanceof CreateFolderOperation) + } + if (operation instanceof CreateFolderOperation) { return f.forbidden(R.string.forbidden_permissions_create); - if(operation instanceof MoveFileOperation) return f.forbidden(R.string.forbidden_permissions_move); - if(operation instanceof CopyFileOperation)return f.forbidden(R.string.forbidden_permissions_copy); + } + if (operation instanceof MoveFileOperation) { + return f.forbidden(R.string.forbidden_permissions_move); + } + if (operation instanceof CopyFileOperation) { + return f.forbidden(R.string.forbidden_permissions_copy); + } case INVALID_CHARACTER_DETECT_IN_SERVER: return f.format(R.string.filename_forbidden_charaters_from_server); - case QUOTA_EXCEEDED: return f.format(R.string.failed_upload_quota_exceeded_text); + case QUOTA_EXCEEDED: + return f.format(R.string.failed_upload_quota_exceeded_text); case FILE_NOT_FOUND: - if(operation instanceof UploadFileOperation) + if (operation instanceof UploadFileOperation) { return f.format(R.string.uploads_view_upload_status_failed_folder_error); - if(operation instanceof DownloadFileOperation) + } + if (operation instanceof DownloadFileOperation) { return f.format(R.string.downloader_download_forbidden_permissions); - if(operation instanceof RenameFileOperation) return f.format(R.string.rename_server_fail_msg); - if(operation instanceof MoveFileOperation) return f.format(R.string.move_file_not_found); - if(operation instanceof SynchronizeFolderOperation) + } + if (operation instanceof RenameFileOperation) { + return f.format(R.string.rename_server_fail_msg); + } + if (operation instanceof MoveFileOperation) { + return f.format(R.string.move_file_not_found); + } + if (operation instanceof SynchronizeFolderOperation) { return f.format(R.string.sync_current_folder_was_removed, - new File(((SynchronizeFolderOperation) operation).getFolderPath()).getName()); - if(operation instanceof CopyFileOperation) return f.format(R.string.copy_file_not_found); - case INVALID_LOCAL_FILE_NAME: return f.format(R.string.rename_local_fail_msg); - case INVALID_CHARACTER_IN_NAME: return f.format(R.string.filename_forbidden_characters); + new File(((SynchronizeFolderOperation) operation).getFolderPath()).getName()); + } + if (operation instanceof CopyFileOperation) { + return f.format(R.string.copy_file_not_found); + } + case INVALID_LOCAL_FILE_NAME: + return f.format(R.string.rename_local_fail_msg); + case INVALID_CHARACTER_IN_NAME: + return f.format(R.string.filename_forbidden_characters); case SHARE_NOT_FOUND: - if(operation instanceof CreateShareViaLinkOperation) - return f.format(R.string.share_link_file_no_exist); - if(operation instanceof RemoveShareOperation) - return f.format(R.string.unshare_link_file_no_exist); - if(operation instanceof UpdateSharePermissionsOperation - || operation instanceof UpdateShareViaLinkOperation) - return f.format(R.string.update_link_file_no_exist); + if (operation instanceof CreateShareViaLinkOperation) { + return f.format(R.string.share_link_file_no_exist); + } + if (operation instanceof RemoveShareOperation) { + return f.format(R.string.unshare_link_file_no_exist); + } + if (operation instanceof UpdateSharePermissionsOperation + || operation instanceof UpdateShareViaLinkOperation) { + return f.format(R.string.update_link_file_no_exist); + } case SHARE_FORBIDDEN: - if(operation instanceof CreateShareViaLinkOperation) + if (operation instanceof CreateShareViaLinkOperation) { return f.forbidden(R.string.share_link_forbidden_permissions); - if(operation instanceof RemoveShareOperation) + } + if (operation instanceof RemoveShareOperation) { return f.forbidden(R.string.unshare_link_forbidden_permissions); - if(operation instanceof UpdateSharePermissionsOperation - || operation instanceof UpdateShareViaLinkOperation) + } + if (operation instanceof UpdateSharePermissionsOperation + || operation instanceof UpdateShareViaLinkOperation) { return f.forbidden(R.string.update_link_forbidden_permissions); + } case INVALID_MOVE_INTO_DESCENDANT: - return f.format(R.string.move_file_invalid_into_descendent); + return f.format(R.string.move_file_invalid_into_descendent); case INVALID_OVERWRITE: - if(operation instanceof MoveFileOperation) return f.format(R.string.move_file_invalid_overwrite); - if(operation instanceof CopyFileOperation) return f.format(R.string.copy_file_invalid_overwrite); - case CONFLICT:return f.format(R.string.move_file_error); - case INVALID_COPY_INTO_DESCENDANT: return f.format(R.string.copy_file_invalid_into_descendent); + if (operation instanceof MoveFileOperation) { + return f.format(R.string.move_file_invalid_overwrite); + } + if (operation instanceof CopyFileOperation) { + return f.format(R.string.copy_file_invalid_overwrite); + } + case CONFLICT: + return f.format(R.string.move_file_error); + case INVALID_COPY_INTO_DESCENDANT: + return f.format(R.string.copy_file_invalid_into_descendent); default: return getCommonMessageForResult(operation, result, resources); } @@ -202,8 +237,8 @@ public static String getResultMessage(final RemoteOperationResult result, * Return a user message corresponding to an operation result with no knowledge about the operation * performed. * - * @param result Result of a {@link RemoteOperation} performed. - * @param res Reference to app resources, for i18n. + * @param result Result of a {@link RemoteOperation} performed. + * @param res Reference to app resources, for i18n. * @return User message corresponding to 'result'. */ @Nullable @@ -213,32 +248,51 @@ private static String getCommonMessageForResult(RemoteOperation operation, final Formatter f = new Formatter(res); - if(result.isSuccess()) return ""; - switch(result.getCode()) { - case WRONG_CONNECTION: return f.format(R.string.network_error_socket_exception); - case NO_NETWORK_CONNECTION: return f.format(R.string.error_no_network_connection); - case TIMEOUT: return (result.getException() instanceof SocketTimeoutException) - ? f.format(R.string.network_error_socket_timeout_exception) - : f.format(R.string.network_error_connect_timeout_exception); - case HOST_NOT_AVAILABLE: return f.format(R.string.network_host_not_available); - case SERVICE_UNAVAILABLE: return f.format(R.string.service_unavailable); - case SSL_RECOVERABLE_PEER_UNVERIFIED: return f.format(R.string.ssl_certificate_not_trusted); - case BAD_OC_VERSION: return f.format(R.string.auth_bad_oc_version_title); - case INCORRECT_ADDRESS: return f.format(R.string.auth_incorrect_address_title); - case SSL_ERROR: return f.format(R.string.auth_ssl_general_error_title); - case UNAUTHORIZED: return f.format(R.string.auth_unauthorized); - case INSTANCE_NOT_CONFIGURED: return f.format(R.string.auth_not_configured_title); - case FILE_NOT_FOUND: return f.format(R.string.auth_incorrect_path_title); - case OAUTH2_ERROR: return f.format(R.string.auth_oauth_error); - case OAUTH2_ERROR_ACCESS_DENIED: return f.format(R.string.auth_oauth_error_access_denied); - case ACCOUNT_NOT_NEW: return f.format(R.string.auth_account_not_new); - case ACCOUNT_NOT_THE_SAME: return f.format(R.string.auth_account_not_the_same); + if (result.isSuccess()) { + return ""; + } + switch (result.getCode()) { + case WRONG_CONNECTION: + return f.format(R.string.network_error_socket_exception); + case NO_NETWORK_CONNECTION: + return f.format(R.string.error_no_network_connection); + case TIMEOUT: + return (result.getException() instanceof SocketTimeoutException) + ? f.format(R.string.network_error_socket_timeout_exception) + : f.format(R.string.network_error_connect_timeout_exception); + case HOST_NOT_AVAILABLE: + return f.format(R.string.network_host_not_available); + case SERVICE_UNAVAILABLE: + return f.format(R.string.service_unavailable); + case SSL_RECOVERABLE_PEER_UNVERIFIED: + return f.format(R.string.ssl_certificate_not_trusted); + case BAD_OC_VERSION: + return f.format(R.string.auth_bad_oc_version_title); + case INCORRECT_ADDRESS: + return f.format(R.string.auth_incorrect_address_title); + case SSL_ERROR: + return f.format(R.string.auth_ssl_general_error_title); + case UNAUTHORIZED: + return f.format(R.string.auth_unauthorized); + case INSTANCE_NOT_CONFIGURED: + return f.format(R.string.auth_not_configured_title); + case FILE_NOT_FOUND: + return f.format(R.string.auth_incorrect_path_title); + case OAUTH2_ERROR: + return f.format(R.string.auth_oauth_error); + case OAUTH2_ERROR_ACCESS_DENIED: + return f.format(R.string.auth_oauth_error_access_denied); + case ACCOUNT_NOT_NEW: + return f.format(R.string.auth_account_not_new); + case ACCOUNT_NOT_THE_SAME: + return f.format(R.string.auth_account_not_the_same); case OK_REDIRECT_TO_NON_SECURE_CONNECTION: return f.format(R.string.auth_redirect_non_secure_connection_title); default: - if(result.getHttpPhrase() != null - && result.getHttpPhrase().length() > 0) + if (result.getHttpPhrase() != null + && result.getHttpPhrase().length() > 0) { return result.getHttpPhrase(); + } } return getGenericErrorMessageForOperation(operation, result, res); @@ -247,8 +301,8 @@ private static String getCommonMessageForResult(RemoteOperation operation, /** * Return a user message corresponding to a generic error for a given operation. * - * @param operation Operation performed. - * @param res Reference to app resources, for i18n. + * @param operation Operation performed. + * @param res Reference to app resources, for i18n. * @return User message corresponding to a generic error of 'operation'. */ @Nullable @@ -257,28 +311,49 @@ private static String getGenericErrorMessageForOperation(RemoteOperation operati Resources res) { final Formatter f = new Formatter(res); - if (operation instanceof UploadFileOperation) + if (operation instanceof UploadFileOperation) { return f.format(R.string.uploader_upload_failed_content_single, ((UploadFileOperation) operation).getFileName()); - if (operation instanceof DownloadFileOperation) return f.format(R.string.downloader_download_failed_content, + } + if (operation instanceof DownloadFileOperation) { + return f.format(R.string.downloader_download_failed_content, new File(((DownloadFileOperation) operation).getSavePath()).getName()); - if (operation instanceof RemoveFileOperation) return f.format(R.string.remove_fail_msg); - if (operation instanceof RenameFileOperation) return f.format(R.string.rename_server_fail_msg); - if (operation instanceof CreateFolderOperation) return f.format(R.string.create_dir_fail_msg); + } + if (operation instanceof RemoveFileOperation) { + return f.format(R.string.remove_fail_msg); + } + if (operation instanceof RenameFileOperation) { + return f.format(R.string.rename_server_fail_msg); + } + if (operation instanceof CreateFolderOperation) { + return f.format(R.string.create_dir_fail_msg); + } if (operation instanceof CreateShareViaLinkOperation || - operation instanceof CreateShareWithShareeOperation) + operation instanceof CreateShareWithShareeOperation) { return f.format(R.string.share_link_file_error); - if (operation instanceof RemoveShareOperation) return f.format(R.string.unshare_link_file_error); + } + if (operation instanceof RemoveShareOperation) { + return f.format(R.string.unshare_link_file_error); + } if (operation instanceof UpdateShareViaLinkOperation || - operation instanceof UpdateSharePermissionsOperation) + operation instanceof UpdateSharePermissionsOperation) { return f.format((R.string.update_link_file_error)); - if (operation instanceof MoveFileOperation) return f.format(R.string.move_file_error); - if (operation instanceof SynchronizeFolderOperation) + } + if (operation instanceof MoveFileOperation) { + return f.format(R.string.move_file_error); + } + if (operation instanceof SynchronizeFolderOperation) { return f.format(R.string.sync_folder_failed_content, new File(((SynchronizeFolderOperation) operation).getFolderPath()).getName()); - if (operation instanceof CopyFileOperation) return f.format(R.string.copy_file_error); + } + if (operation instanceof CopyFileOperation) { + return f.format(R.string.copy_file_error); + } // if everything else failes - if(result.isSuccess()) return f.format(android.R.string.ok); - else return f.format(R.string.common_error_unknown); + if (result.isSuccess()) { + return f.format(android.R.string.ok); + } else { + return f.format(R.string.common_error_unknown); + } } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorShowActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorShowActivity.java index 9a38ab75bbe..40f57c41274 100755 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorShowActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ErrorShowActivity.java @@ -1,20 +1,20 @@ /** - * ownCloud Android client application + * ownCloud Android client application * * @author LukeOwncloud * @author Christian Schabesberger * @author David González Verdugo * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ExceptionHandler.java b/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ExceptionHandler.java index 6ace7010e10..9522a09d961 100755 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ExceptionHandler.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/errorhandling/ExceptionHandler.java @@ -1,85 +1,84 @@ /** - * ownCloud Android client application - * - * @author LukeOwncloud - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author LukeOwncloud + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.errorhandling; -import java.io.PrintWriter; -import java.io.StringWriter; - import android.app.Activity; import android.content.Intent; import android.os.Build; import android.util.Log; +import java.io.PrintWriter; +import java.io.StringWriter; + public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler { - private final Activity mContext; - private final String LINE_SEPARATOR = "\n"; + private final Activity mContext; + private final String LINE_SEPARATOR = "\n"; - private static final String TAG = ExceptionHandler.class.getSimpleName(); + private static final String TAG = ExceptionHandler.class.getSimpleName(); - public ExceptionHandler(Activity context) { - mContext = context; - } + public ExceptionHandler(Activity context) { + mContext = context; + } - public void uncaughtException(Thread thread, Throwable exception) { - Log.e(TAG, "ExceptionHandler caught UncaughtException", exception); - StringWriter stackTrace = new StringWriter(); - exception.printStackTrace(new PrintWriter(stackTrace)); - StringBuilder errorReport = new StringBuilder(); - errorReport.append("************ CAUSE OF ERROR ************\n\n"); - errorReport.append(stackTrace.toString()); + public void uncaughtException(Thread thread, Throwable exception) { + Log.e(TAG, "ExceptionHandler caught UncaughtException", exception); + StringWriter stackTrace = new StringWriter(); + exception.printStackTrace(new PrintWriter(stackTrace)); + StringBuilder errorReport = new StringBuilder(); + errorReport.append("************ CAUSE OF ERROR ************\n\n"); + errorReport.append(stackTrace.toString()); - errorReport.append("\n************ DEVICE INFORMATION ***********\n"); - errorReport.append("Brand: "); - errorReport.append(Build.BRAND); - errorReport.append(LINE_SEPARATOR); - errorReport.append("Device: "); - errorReport.append(Build.DEVICE); - errorReport.append(LINE_SEPARATOR); - errorReport.append("Model: "); - errorReport.append(Build.MODEL); - errorReport.append(LINE_SEPARATOR); - errorReport.append("Id: "); - errorReport.append(Build.ID); - errorReport.append(LINE_SEPARATOR); - errorReport.append("Product: "); - errorReport.append(Build.PRODUCT); - errorReport.append(LINE_SEPARATOR); - errorReport.append("\n************ FIRMWARE ************\n"); - errorReport.append("SDK: "); - errorReport.append(Build.VERSION.SDK_INT); - errorReport.append(LINE_SEPARATOR); - errorReport.append("Release: "); - errorReport.append(Build.VERSION.RELEASE); - errorReport.append(LINE_SEPARATOR); - errorReport.append("Incremental: "); - errorReport.append(Build.VERSION.INCREMENTAL); - errorReport.append(LINE_SEPARATOR); + errorReport.append("\n************ DEVICE INFORMATION ***********\n"); + errorReport.append("Brand: "); + errorReport.append(Build.BRAND); + errorReport.append(LINE_SEPARATOR); + errorReport.append("Device: "); + errorReport.append(Build.DEVICE); + errorReport.append(LINE_SEPARATOR); + errorReport.append("Model: "); + errorReport.append(Build.MODEL); + errorReport.append(LINE_SEPARATOR); + errorReport.append("Id: "); + errorReport.append(Build.ID); + errorReport.append(LINE_SEPARATOR); + errorReport.append("Product: "); + errorReport.append(Build.PRODUCT); + errorReport.append(LINE_SEPARATOR); + errorReport.append("\n************ FIRMWARE ************\n"); + errorReport.append("SDK: "); + errorReport.append(Build.VERSION.SDK_INT); + errorReport.append(LINE_SEPARATOR); + errorReport.append("Release: "); + errorReport.append(Build.VERSION.RELEASE); + errorReport.append(LINE_SEPARATOR); + errorReport.append("Incremental: "); + errorReport.append(Build.VERSION.INCREMENTAL); + errorReport.append(LINE_SEPARATOR); - Log.e(TAG, "An exception was thrown and handled by ExceptionHandler:", exception); + Log.e(TAG, "An exception was thrown and handled by ExceptionHandler:", exception); - Intent intent = new Intent(mContext, ErrorShowActivity.class); - intent.putExtra("error", errorReport.toString()); - mContext.startActivity(intent); + Intent intent = new Intent(mContext, ErrorShowActivity.class); + intent.putExtra("error", errorReport.toString()); + mContext.startActivity(intent); - android.os.Process.killProcess(android.os.Process.myPid()); - System.exit(1000); - } + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(1000); + } } \ No newline at end of file diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java index a148e017066..0e7d7ef7a6d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java @@ -1,32 +1,29 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; import android.accounts.Account; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; -import androidx.appcompat.widget.SwitchCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -34,6 +31,8 @@ import android.widget.CompoundButton; import android.widget.TextView; +import androidx.appcompat.widget.SwitchCompat; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.FileDataStorageManager; @@ -78,7 +77,6 @@ public class EditShareFragment extends DialogFragment { /** Listener for changes on privilege checkboxes */ private CompoundButton.OnCheckedChangeListener mOnPrivilegeChangeListener; - /** * Public factory method to create new EditShareFragment instances. * @@ -103,7 +101,6 @@ public static EditShareFragment newInstance(OCShare shareToEdit, OCFile sharedFi public EditShareFragment() { } - /** * {@inheritDoc} */ @@ -119,21 +116,19 @@ public void onCreate(Bundle savedInstanceState) { } else { mShare = savedInstanceState.getParcelable(ARG_SHARE); } - Log_OC.e(TAG, String.format(Locale.getDefault(), "Share has id %1$d remoteId %2$d", mShare.getId(), mShare.getRemoteId())); + Log_OC.e(TAG, String.format(Locale.getDefault(), "Share has id %1$d remoteId %2$d", mShare.getId(), + mShare.getRemoteId())); } setStyle(DialogFragment.STYLE_NO_TITLE, 0); } - - @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log_OC.d(TAG, "onActivityCreated"); } - /** * {@inheritDoc} */ @@ -159,14 +154,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, return view; } - @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(ARG_SHARE, mShare); } - /** * Updates the UI with the current permissions in the edited {@link OCShare} * @@ -180,13 +173,13 @@ private void refreshUiFromState(View editShareView) { boolean isFederated = ShareType.FEDERATED.equals(mShare.getShareType()); OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mAccount); boolean isNotReshareableFederatedSupported = ( - serverVersion != null && - serverVersion.isNotReshareableFederatedSupported() + serverVersion != null && + serverVersion.isNotReshareableFederatedSupported() ); CompoundButton compound; compound = editShareView.findViewById(R.id.canShareSwitch); - if(isFederated && !isNotReshareableFederatedSupported) { + if (isFederated && !isNotReshareableFederatedSupported) { compound.setVisibility(View.INVISIBLE); } compound.setChecked((sharePermissions & OCShare.SHARE_PERMISSION_FLAG) > 0); @@ -222,7 +215,6 @@ private void refreshUiFromState(View editShareView) { } } - /** * Binds or unbinds listener for user actions to enable or disable a permission on the edited share * to the views receiving the user events. @@ -279,7 +271,7 @@ public void onCheckedChanged(CompoundButton compound, boolean isChecked) { /// else, getView() cannot be NULL CompoundButton subordinate; - switch(compound.getId()) { + switch (compound.getId()) { case R.id.canShareSwitch: Log_OC.v(TAG, "canShareCheckBox toggled to " + isChecked); updatePermissionsToShare(); @@ -293,8 +285,8 @@ public void onCheckedChanged(CompoundButton compound, boolean isChecked) { if (isChecked) { OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mAccount); boolean isNotReshareableFederatedSupported = ( - serverVersion != null && - serverVersion.isNotReshareableFederatedSupported() + serverVersion != null && + serverVersion.isNotReshareableFederatedSupported() ); if (!isFederated || isNotReshareableFederatedSupported) { /// not federated shares -> enable all the subpermisions @@ -305,7 +297,7 @@ public void onCheckedChanged(CompoundButton compound, boolean isChecked) { subordinate.setVisibility(View.VISIBLE); } if (!subordinate.isChecked() && - !mFile.isSharedWithMe()) { // see (1) + !mFile.isSharedWithMe()) { // see (1) toggleDisablingListener(subordinate); } } @@ -330,8 +322,8 @@ public void onCheckedChanged(CompoundButton compound, boolean isChecked) { } } - if(!(mFile.isFolder() && isChecked && mFile.isSharedWithMe()) // see (1) - || isFederated ) { + if (!(mFile.isFolder() && isChecked && mFile.isSharedWithMe()) // see (1) + || isFederated) { updatePermissionsToShare(); } @@ -382,7 +374,7 @@ private void syncCanEditSwitch(View subordinateCheckBoxView, boolean isChecked) } } else { boolean allDisabled = true; - for (int i=0; allDisabled && i * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -69,18 +69,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator)); mList.setDividerHeight(1); -// if (savedInstanceState != null) { -// int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION); -// setReferencePosition(referencePosition); -// } - + // if (savedInstanceState != null) { + // int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION); + // setReferencePosition(referencePosition); + // } + // Pull down refresh mRefreshListLayout = v.findViewById(R.id.swipe_refresh_files); mRefreshEmptyLayout = v.findViewById(R.id.swipe_refresh_files_emptyView); - + onCreateSwipeToRefresh(mRefreshListLayout); onCreateSwipeToRefresh(mRefreshEmptyLayout); - + mList.setEmptyView(mRefreshEmptyLayout); return v; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 4101fbee035..60bcbc88172 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -1,29 +1,26 @@ /** - * ownCloud Android client application - * - * @author Christian Schabesberger - * Copyright (C) 2012 Bartek Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Christian Schabesberger + * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; import android.os.Bundle; -import androidx.fragment.app.Fragment; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -36,6 +33,8 @@ import android.widget.ProgressBar; import android.widget.TextView; +import androidx.fragment.app.Fragment; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.getbase.floatingactionbutton.FloatingActionButton; import com.getbase.floatingactionbutton.FloatingActionsMenu; import com.owncloud.android.R; @@ -43,20 +42,19 @@ import com.owncloud.android.ui.ExtendedListView; import com.owncloud.android.ui.activity.OnEnforceableRefreshListener; import com.owncloud.android.utils.PreferenceUtils; +import third_parties.in.srain.cube.GridViewWithHeaderAndFooter; import java.util.ArrayList; -import third_parties.in.srain.cube.GridViewWithHeaderAndFooter; - public class ExtendedListFragment extends Fragment implements OnItemClickListener, OnEnforceableRefreshListener { protected static final String TAG = ExtendedListFragment.class.getSimpleName(); - protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION"; + protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION"; private static final String KEY_INDEXES = "INDEXES"; - private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS"; + private static final String KEY_FIRST_POSITIONS = "FIRST_POSITIONS"; private static final String KEY_TOPS = "TOPS"; private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL"; private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE"; @@ -139,11 +137,10 @@ public void switchToListView() { } } - public boolean isGridEnabled(){ + public boolean isGridEnabled() { return (mCurrentListView == mGridView); } - - + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -177,7 +174,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mRefreshGridLayout = v.findViewById(R.id.swipe_containing_grid); mRefreshEmptyLayout = v.findViewById(R.id.swipe_containing_empty); mEmptyListMessage = v.findViewById(R.id.empty_list_view); - + onCreateSwipeToRefresh(mRefreshListLayout); onCreateSwipeToRefresh(mRefreshGridLayout); onCreateSwipeToRefresh(mRefreshEmptyLayout); @@ -220,16 +217,15 @@ public void onActivityCreated(Bundle savedInstanceState) { mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS); mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL); setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE)); - + } else { mIndexes = new ArrayList(); mFirstPositions = new ArrayList(); mTops = new ArrayList(); mHeightCell = 0; } - } - - + } + @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); @@ -247,10 +243,10 @@ public void onSaveInstanceState(Bundle savedInstanceState) { * Calculates the position of the item that will be used as a reference to * reposition the visible items in the list when the device is turned to * other position. - * + * * The current policy is take as a reference the visible item in the center * of the screen. - * + * * @return The position in the list of the visible item in the center of the * screen. */ @@ -263,30 +259,29 @@ protected int getReferencePosition() { } } - /* * Restore index and position */ protected void restoreIndexAndTopPosition() { - if (mIndexes.size() > 0) { + if (mIndexes.size() > 0) { // needs to be checked; not every browse-up had a browse-down before - + int index = mIndexes.remove(mIndexes.size() - 1); - final int firstPosition = mFirstPositions.remove(mFirstPositions.size() -1); + final int firstPosition = mFirstPositions.remove(mFirstPositions.size() - 1); int top = mTops.remove(mTops.size() - 1); Log_OC.v(TAG, "Setting selection to position: " + firstPosition + "; top: " + top + "; index: " + index); if (mCurrentListView == mListView) { - if (mHeightCell*index <= mListView.getHeight()) { + if (mHeightCell * index <= mListView.getHeight()) { mListView.setSelectionFromTop(firstPosition, top); } else { mListView.setSelectionFromTop(index, 0); } } else { - if (mHeightCell*index <= mGridView.getHeight()) { + if (mHeightCell * index <= mGridView.getHeight()) { mGridView.setSelection(firstPosition); //mGridView.smoothScrollToPosition(firstPosition); } else { @@ -297,29 +292,28 @@ protected void restoreIndexAndTopPosition() { } } - + /* * Save index and top position */ protected void saveIndexAndTopPosition(int index) { - + mIndexes.add(index); - + int firstPosition = mCurrentListView.getFirstVisiblePosition(); mFirstPositions.add(firstPosition); - + View view = mCurrentListView.getChildAt(0); - int top = (view == null) ? 0 : view.getTop() ; + int top = (view == null) ? 0 : view.getTop(); mTops.add(top); - + // Save the height of a cell mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight(); } - - + @Override - public void onItemClick (AdapterView parent, View view, int position, long id) { + public void onItemClick(AdapterView parent, View view, int position, long id) { // to be @overriden } @@ -333,10 +327,10 @@ public void onRefresh() { mOnRefreshListener.onRefresh(); } } + public void setOnRefreshListener(OnEnforceableRefreshListener listener) { mOnRefreshListener = listener; } - /** * Disables swipe gesture. @@ -361,7 +355,7 @@ public void setSwipeEnabled(boolean enabled) { * @param enabled Desired visibility for the FAB. */ public void setFabEnabled(boolean enabled) { - if(enabled) { + if (enabled) { mFabMain.setVisibility(View.VISIBLE); } else { mFabMain.setVisibility(View.GONE); @@ -379,7 +373,7 @@ public void setMessageForEmptyList(String message) { /** * Get the text of EmptyListMessage TextView - * + * * @return String */ public String getEmptyViewText() { @@ -424,7 +418,7 @@ protected void setMultiChoiceModeListener(AbsListView.MultiChoiceModeListener li protected void setFooterEnabled(boolean enabled) { if (enabled) { if (mGridView.getFooterViewCount() == 0) { - if (mGridFooterView.getParent() != null ) { + if (mGridFooterView.getParent() != null) { ((ViewGroup) mGridFooterView.getParent()).removeView(mGridFooterView); } try { @@ -436,7 +430,7 @@ protected void setFooterEnabled(boolean enabled) { mGridFooterView.invalidate(); if (mListView.getFooterViewsCount() == 0) { - if (mListFooterView.getParent() != null ) { + if (mListFooterView.getParent() != null) { ((ViewGroup) mListFooterView.getParent()).removeView(mListFooterView); } mListView.addFooterView(mListFooterView, null, false); @@ -449,11 +443,11 @@ protected void setFooterEnabled(boolean enabled) { } } - public ProgressBar getProgressBar(){ + public ProgressBar getProgressBar() { return mProgressBar; } - public View getShadowView(){ + public View getShadowView() { return mShadowView; } @@ -463,8 +457,8 @@ public View getShadowView(){ */ protected void setFooterText(String text) { if (text != null && text.length() > 0) { - ((TextView)mListFooterView.findViewById(R.id.footerText)).setText(text); - ((TextView)mGridFooterView.findViewById(R.id.footerText)).setText(text); + ((TextView) mListFooterView.findViewById(R.id.footerText)).setText(text); + ((TextView) mGridFooterView.findViewById(R.id.footerText)).setText(text); setFooterEnabled(true); } else { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index 575dd6456fd..adc720b7954 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -1,25 +1,24 @@ /** - * ownCloud Android client application - * - * @author Bartek Przybylski - * @author David A. Velasco - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2011 Bartek Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Bartek Przybylski + * @author David A. Velasco + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2011 Bartek Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; @@ -33,7 +32,11 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.*; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.TextView; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -54,7 +57,6 @@ import com.owncloud.android.utils.MimetypeIconUtil; import com.owncloud.android.utils.PreferenceUtils; - /** * This Fragment is used to display the details about a file. */ @@ -72,7 +74,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener private static final String ARG_FILE = "FILE"; private static final String ARG_ACCOUNT = "ACCOUNT"; - /** * Public factory method to create new FileDetailFragment instances. * @@ -80,7 +81,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener * * @param fileToDetail An {@link OCFile} to show in the fragment * @param account An ownCloud account; needed to start downloads - * @return New fragment with arguments set + * @return New fragment with arguments set */ public static FileDetailFragment newInstance(OCFile fileToDetail, Account account) { FileDetailFragment frag = new FileDetailFragment(); @@ -93,7 +94,7 @@ public static FileDetailFragment newInstance(OCFile fileToDetail, Account accoun /** * Creates an empty details fragment. - * + * * It's necessary to keep a public constructor without parameters; the system uses it when tries * to reinstantiate a fragment automatically. */ @@ -171,7 +172,6 @@ public void onStop() { super.onStop(); } - @Override public void onTransferServiceConnected() { if (mProgressController != null) { @@ -213,7 +213,6 @@ public View getView() { return super.getView() == null ? mView : super.getView(); } - /** * {@inheritDoc} */ @@ -223,7 +222,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.file_actions_menu, menu); } - /** * {@inheritDoc} */ @@ -233,10 +231,10 @@ public void onPrepareOptionsMenu(Menu menu) { if (mContainerActivity.getStorageManager() != null) { FileMenuFilter mf = new FileMenuFilter( - getFile(), - mContainerActivity.getStorageManager().getAccount(), - mContainerActivity, - getActivity() + getFile(), + mContainerActivity.getStorageManager().getAccount(), + mContainerActivity, + getActivity() ); mf.filter(menu, false, false); } @@ -263,7 +261,7 @@ public void onPrepareOptionsMenu(Menu menu) { } item = menu.findItem(R.id.action_switch_view); - if (item != null){ + if (item != null) { item.setVisible(false); item.setEnabled(false); } @@ -287,7 +285,6 @@ public void onPrepareOptionsMenu(Menu menu) { } } - /** * {@inheritDoc} */ @@ -313,7 +310,7 @@ public boolean onOptionsItemSelected(MenuItem item) { return true; } case R.id.action_cancel_sync: { - ((FileDisplayActivity)mContainerActivity).cancelTransference(getFile()); + ((FileDisplayActivity) mContainerActivity).cancelTransference(getFile()); return true; } case R.id.action_download_file: @@ -326,17 +323,16 @@ public boolean onOptionsItemSelected(MenuItem item) { if (!getFile().isDown()) { // Download the file Log_OC.d(TAG, getFile().getRemotePath() + " : File must be downloaded"); ((FileDisplayActivity) mContainerActivity).startDownloadForSending(getFile()); - } - else { + } else { mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); } return true; } - case R.id.action_set_available_offline:{ + case R.id.action_set_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), true); return true; } - case R.id.action_unset_available_offline:{ + case R.id.action_unset_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), false); return true; } @@ -358,7 +354,8 @@ public void onClick(View v) { } /** - * Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced. + * Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be + * replaced. * * @return True when the fragment was created with the empty layout. */ @@ -366,7 +363,6 @@ public boolean isEmpty() { return (mLayout == R.layout.file_details_empty || getFile() == null || mAccount == null); } - /** * Updates the view with all relevant details about that file. * @@ -389,20 +385,20 @@ private void updateFileDetails(boolean forcedTransferring, boolean refresh) { setFilesize(file.getFileLength()); setTimeModified(file.getModificationTimestamp()); - + // configure UI for depending upon local state of the file FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder(); if (forcedTransferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) || (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) - ) { + ) { setButtonsForTransferring(); } else if (file.isDown()) { - + setButtonsForDown(); - + } else { // TODO load default preview image; when the local file is removed, the preview // remains there @@ -421,7 +417,6 @@ private boolean readyToShow() { return (getFile() != null && mAccount != null && mLayout == R.layout.file_details_fragment); } - /** * Updates the filename in view * @@ -442,7 +437,7 @@ private void setFiletype(OCFile file) { String mimetype = file.getMimetype(); TextView tv = getView().findViewById(R.id.fdType); if (tv != null) { - // mimetype MIME type to set + // mimetype MIME type to set String printableMimetype = DisplayUtils.convertMIMEtoPrettyPrint(mimetype); tv.setText(printableMimetype); } @@ -480,10 +475,10 @@ private void setFiletype(OCFile file) { } } } else { - // Name of the file, to deduce the icon to use in case the MIME type is not precise enough - String filename = file.getFileName(); + // Name of the file, to deduce the icon to use in case the MIME type is not precise enough + String filename = file.getFileName(); iv.setImageResource(MimetypeIconUtil.getFileTypeIconId(mimetype, filename)); - } + } } } @@ -525,8 +520,7 @@ private void setButtonsForTransferring() { //if (getFile().isDownloading()) { if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) { progressText.setText(R.string.downloader_download_in_progress_ticker); - } - else { + } else { if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) { progressText.setText(R.string.uploader_upload_in_progress_ticker); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileFragment.java index 6526e784940..08b84eae892 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileFragment.java @@ -1,71 +1,66 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author Christian Schabesberger - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; import android.content.Context; -import androidx.fragment.app.Fragment; +import androidx.fragment.app.Fragment; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.ui.activity.ComponentsGetter; - /** * Common methods for {@link Fragment}s containing {@link OCFile}s */ public abstract class FileFragment extends Fragment { - + private OCFile mFile; - - protected ContainerActivity mContainerActivity; + protected ContainerActivity mContainerActivity; /** * Creates an empty fragment. - * + * * It's necessary to keep a public constructor without parameters; the system uses it when * tries to reinstantiate a fragment automatically. */ public FileFragment() { mFile = null; } - + /** * Getter for the hold {@link OCFile} - * + * * @return The {@link OCFile} hold */ public OCFile getFile() { return mFile; } - - + protected void setFile(OCFile file) { mFile = file; } - - + /** * {@inheritDoc} */ @@ -74,14 +69,13 @@ public void onAttach(Context context) { super.onAttach(context); try { mContainerActivity = (ContainerActivity) context; - + } catch (ClassCastException e) { throw new ClassCastException(context.toString() + " must implement " + ContainerActivity.class.getSimpleName()); } } - - + /** * {@inheritDoc} */ @@ -91,7 +85,6 @@ public void onDetach() { super.onDetach(); } - public void onSyncEvent(String syncEvent, boolean success, OCFile updatedFile) { if (syncEvent.equals(FileUploader.getUploadStartMessage())) { updateViewForSyncInProgress(); @@ -134,7 +127,6 @@ public void onSyncEvent(String syncEvent, boolean success, OCFile updatedFile) { public abstract void onFileContentChanged(); - /** * Interface to implement by any Activity that includes some instance of FileListFragment * Interface to implement by any Activity that includes some instance of FileFragment @@ -143,18 +135,18 @@ public interface ContainerActivity extends ComponentsGetter { /** * Request the parent activity to show the details of an {@link OCFile}. - * + * * @param file File to show details */ void showDetails(OCFile file); - ///// TO UNIFY IN A SINGLE CALLBACK METHOD - EVENT NOTIFICATIONs -> something happened // inside the fragment, MAYBE activity is interested --> unify in notification method + /** * Callback method invoked when a the user browsed into a different folder through the * list of files - * + * * @param folder */ void onBrowsedDownTo(OCFile folder); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java index 9a4ffd69abd..9e76644569d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java @@ -31,6 +31,7 @@ import android.widget.AdapterView; import android.widget.ImageView; import android.widget.ListView; + import androidx.coordinatorlayout.widget.CoordinatorLayout; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; @@ -41,7 +42,6 @@ import java.io.File; import java.util.ArrayList; - /** * A Fragment that lists all files and folders in a given LOCAL path. */ @@ -83,7 +83,6 @@ public static LocalFileListFragment newInstance(boolean justFolders) { return frag; } - /** * {@inheritDoc} */ @@ -98,7 +97,6 @@ public void onAttach(Context context) { } } - /** * {@inheritDoc} */ @@ -255,7 +253,6 @@ public void onItemClick(AdapterView l, View v, int position, long id) { } } - /** * Browse up to the parent folder of the current one. */ @@ -270,7 +267,6 @@ public void browseUp() { restoreIndexAndTopPosition(); } - /** * Use this to query the {@link File} object for the directory * that is currently being displayed by this fragment @@ -281,7 +277,6 @@ public File getCurrentFolder() { return mDirectory; } - /** * Calls {@link LocalFileListFragment#listFolder(File)} with a null parameter * to refresh the current directory. @@ -306,11 +301,12 @@ public void listFolder(File directory) { } else { directory = Environment.getExternalStorageDirectory(); // TODO be careful with the state of the storage; could not be available - if (directory == null) return; // no files to show + if (directory == null) { + return; // no files to show + } } } - // if that's not a directory -> List its parent if (!directory.isDirectory()) { Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString()); @@ -326,7 +322,6 @@ public void listFolder(File directory) { mDirectory = directory; } - /** * Returns the file paths to the files checked by the user * @@ -348,7 +343,6 @@ public String[] getCheckedFilePaths() { return result.toArray(new String[result.size()]); } - @Override public void onSaveInstanceState(Bundle savedInstanceState) { savedInstanceState.putStringArrayList(OUT_STATE_CHECKED_FILES, mAdapter.getCheckedFiles()); @@ -375,7 +369,6 @@ public interface ContainerActivity { */ void onFileClicked(File file); - /** * Callback method invoked when the parent activity * is fully created to get the directory to list firstly. diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 29412a8c952..34a6d0c1674 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1,27 +1,26 @@ /** - * ownCloud Android client application - * - * @author Bartek Przybylski - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * @author David González Verdugo - * @author Shashvat Kedia - * Copyright (C) 2011 Bartek Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Bartek Przybylski + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * @author David González Verdugo + * @author Shashvat Kedia + * Copyright (C) 2011 Bartek Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; @@ -52,6 +51,10 @@ import android.widget.ListView; import android.widget.TextView; +import androidx.appcompat.widget.SearchView; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.snackbar.Snackbar; @@ -84,11 +87,6 @@ import java.util.ArrayList; import java.util.List; -import androidx.appcompat.widget.SearchView; -import androidx.coordinatorlayout.widget.CoordinatorLayout; -import androidx.drawerlayout.widget.DrawerLayout; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - /** * A Fragment that lists all files and folders in a given path. * @@ -129,19 +127,18 @@ public class OCFileListFragment extends ExtendedListFragment implements private SearchView mSearchView; - /** * Public factory method to create new {@link OCFileListFragment} instances. * * @param justFolders When 'true', only folders will be shown to the user, not files. * @param hideFAB When 'true', floating action button is hidden. * @param allowContextualMode When 'true', contextual action mode is enabled long-pressing an item. - * @return New fragment with arguments set. + * @return New fragment with arguments set. */ public static OCFileListFragment newInstance( - boolean justFolders, - boolean hideFAB, - boolean allowContextualMode + boolean justFolders, + boolean hideFAB, + boolean allowContextualMode ) { OCFileListFragment frag = new OCFileListFragment(); Bundle args = new Bundle(); @@ -152,7 +149,6 @@ public static OCFileListFragment newInstance( return frag; } - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -198,7 +194,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa Log_OC.i(TAG, "onCreateView() end"); return v; } - + @Override public void onDetach() { setOnRefreshListener(null); @@ -293,12 +289,13 @@ private void registerFabUploadListeners() { getFabUpload().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Log_OC.e(TAG,"Clicked" + getContext().toString()); - final View uploadBottomSheet = getLayoutInflater().inflate(R.layout.upload_bottom_sheet_fragment,null); + Log_OC.e(TAG, "Clicked" + getContext().toString()); + final View uploadBottomSheet = getLayoutInflater().inflate(R.layout.upload_bottom_sheet_fragment, null); final BottomSheetDialog dialog = new BottomSheetDialog(getContext()); dialog.setContentView(uploadBottomSheet); final LinearLayout uploadFilesLinearLayout = uploadBottomSheet.findViewById(R.id.files_linear_layout); - LinearLayout uploadFromCameraLinearLayout = uploadBottomSheet.findViewById(R.id.upload_from_camera_linear_layout); + LinearLayout uploadFromCameraLinearLayout = + uploadBottomSheet.findViewById(R.id.upload_from_camera_linear_layout); TextView uploadToTextView = uploadBottomSheet.findViewById(R.id.upload_to_text_view); uploadFilesLinearLayout.setOnTouchListener(new View.OnTouchListener() { @Override @@ -318,8 +315,10 @@ public boolean onTouch(View v, MotionEvent event) { return false; } }); - uploadToTextView.setText(String.format(getResources().getString(R.string.upload_to),getResources().getString(R.string.app_name))); - final BottomSheetBehavior uploadBottomSheetBehavior = BottomSheetBehavior.from((View) uploadBottomSheet.getParent()); + uploadToTextView.setText(String.format(getResources().getString(R.string.upload_to), + getResources().getString(R.string.app_name))); + final BottomSheetBehavior uploadBottomSheetBehavior = + BottomSheetBehavior.from((View) uploadBottomSheet.getParent()); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { @@ -407,7 +406,7 @@ public boolean onLongClick(View v) { */ private void recordMiniFabClick() { // only record if it hasn't been done already at some other time - if(!miniFabClicked) { + if (!miniFabClicked) { final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putLong(KEY_FAB_EVER_CLICKED, 1).commit(); miniFabClicked = true; @@ -449,7 +448,7 @@ public void onFocusChange(View v, boolean hasFocus) { } } - public boolean isSingleItemChecked(){ + public boolean isSingleItemChecked() { return mFileListAdapter.getCheckedItems(getListView()).size() == 1; } @@ -462,7 +461,7 @@ public boolean isSingleItemChecked(){ * and closed. */ private class MultiChoiceModeListener - implements AbsListView.MultiChoiceModeListener, DrawerLayout.DrawerListener { + implements AbsListView.MultiChoiceModeListener, DrawerLayout.DrawerListener { private static final String KEY_ACTION_MODE_CLOSED_BY_DRAWER = "KILLED_ACTION_MODE"; private static final String KEY_SELECTION_WHEN_CLOSED_BY_DRAWER = "CHECKED_ITEMS"; @@ -495,12 +494,12 @@ public void onDrawerOpened(View drawerView) { */ @Override public void onDrawerClosed(View drawerView) { - if (mSelectionWhenActionModeClosedByDrawer !=null && mActionModeClosedByDrawer) { - for (int i = 0; i< mSelectionWhenActionModeClosedByDrawer.size(); i++) { + if (mSelectionWhenActionModeClosedByDrawer != null && mActionModeClosedByDrawer) { + for (int i = 0; i < mSelectionWhenActionModeClosedByDrawer.size(); i++) { if (mSelectionWhenActionModeClosedByDrawer.valueAt(i)) { getListView().setItemChecked( - mSelectionWhenActionModeClosedByDrawer.keyAt(i), - true + mSelectionWhenActionModeClosedByDrawer.keyAt(i), + true ); } } @@ -523,7 +522,6 @@ public void onDrawerStateChanged(int newState) { } } - /** * Update action mode bar when an item is selected / unselected in the list */ @@ -531,10 +529,10 @@ public void onDrawerStateChanged(int newState) { public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { getListView().invalidateViews(); mode.invalidate(); - if(mFileListAdapter.getCheckedItems(getListView()).size() == mFileListAdapter.getCount()){ + if (mFileListAdapter.getCheckedItems(getListView()).size() == mFileListAdapter.getCount()) { mEnableSelectAll = false; - } else{ - if(!checked) { + } else { + if (!checked) { mEnableSelectAll = true; } } @@ -572,16 +570,16 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { List checkedFiles = mFileListAdapter.getCheckedItems(getListView()); final int checkedCount = checkedFiles.size(); String title = getResources().getQuantityString( - R.plurals.items_selected_count, - checkedCount, - checkedCount + R.plurals.items_selected_count, + checkedCount, + checkedCount ); mode.setTitle(title); FileMenuFilter mf = new FileMenuFilter( - checkedFiles, - ((FileActivity) getActivity()).getAccount(), - mContainerActivity, - getActivity() + checkedFiles, + ((FileActivity) getActivity()).getAccount(), + mContainerActivity, + getActivity() ); mf.filter(menu, mEnableSelectAll, true); return true; @@ -608,17 +606,16 @@ public void onDestroyActionMode(ActionMode mode) { } // show FAB on multi selection mode exit - if(!mHideFab) { + if (!mHideFab) { setFabEnabled(true); } } - public void storeStateIn(Bundle outState) { outState.putBoolean(KEY_ACTION_MODE_CLOSED_BY_DRAWER, mActionModeClosedByDrawer); if (mSelectionWhenActionModeClosedByDrawer != null) { SparseBooleanArrayParcelable sbap = new SparseBooleanArrayParcelable( - mSelectionWhenActionModeClosedByDrawer + mSelectionWhenActionModeClosedByDrawer ); outState.putParcelable(KEY_SELECTION_WHEN_CLOSED_BY_DRAWER, sbap); } @@ -626,11 +623,11 @@ public void storeStateIn(Bundle outState) { public void loadStateFrom(Bundle savedInstanceState) { mActionModeClosedByDrawer = savedInstanceState.getBoolean( - KEY_ACTION_MODE_CLOSED_BY_DRAWER, - mActionModeClosedByDrawer + KEY_ACTION_MODE_CLOSED_BY_DRAWER, + mActionModeClosedByDrawer ); SparseBooleanArrayParcelable sbap = savedInstanceState.getParcelable( - KEY_SELECTION_WHEN_CLOSED_BY_DRAWER + KEY_SELECTION_WHEN_CLOSED_BY_DRAWER ); if (sbap != null) { mSelectionWhenActionModeClosedByDrawer = sbap.getSparseBooleanArray(); @@ -656,7 +653,7 @@ private void setChoiceModeAsMultipleModal(Bundle savedInstanceState) { mMultiChoiceModeListener.loadStateFrom(savedInstanceState); } setMultiChoiceModeListener(mMultiChoiceModeListener); - ((FileActivity)getActivity()).addDrawerListener(mMultiChoiceModeListener); + ((FileActivity) getActivity()).addDrawerListener(mMultiChoiceModeListener); } /** @@ -675,7 +672,7 @@ public void onSaveInstanceState(Bundle outState) { } @Override - public void onPrepareOptionsMenu (Menu menu) { + public void onPrepareOptionsMenu(Menu menu) { changeGridIcon(menu); // this is enough if the option stays out of the action bar } @@ -726,7 +723,7 @@ public int onBrowseUp() { } private void listDirectoryWithAnimationDown(final OCFile file) { - if(isInPowerSaveMode()) { + if (isInPowerSaveMode()) { listDirectory(file); } else { Animation fadeOutFront = AnimationUtils.loadAnimation(getContext(), R.anim.dir_fadeout_front); @@ -751,7 +748,7 @@ private boolean isInPowerSaveMode() { } private void listDirectoryWidthAnimationUp(final OCFile file) { - if(isInPowerSaveMode()) { + if (isInPowerSaveMode()) { listDirectory(file); } else { if (getListView().getVisibility() == View.GONE) { @@ -813,7 +810,7 @@ public void onItemClick(AdapterView l, View v, int position, long id) { // If the file is already downloaded sync it, just to update it if there is a // new available file version - if(file.isDown()) { + if (file.isDown()) { mContainerActivity.getFileOperationsHelper().syncFile(file); } } else { @@ -839,13 +836,13 @@ private boolean fileIsDownloading(OCFile file) { ((FileActivity) mContainerActivity).getAccount(), file); } - public void selectAll(){ - for(int i = 0; i < mFileListAdapter.getCount(); i++) { + public void selectAll() { + for (int i = 0; i < mFileListAdapter.getCount(); i++) { getListView().setItemChecked(i, true); } } - public int getNoOfItems(){ + public int getNoOfItems() { return getListView().getCount(); } @@ -857,7 +854,9 @@ public int getNoOfItems(){ */ public boolean onFileActionChosen(int menuId) { final ArrayList checkedFiles = mFileListAdapter.getCheckedItems(getListView()); - if (checkedFiles.size() <= 0) return false; + if (checkedFiles.size() <= 0) { + return false; + } if (checkedFiles.size() == 1) { /// action only possible on a single file @@ -905,11 +904,11 @@ public boolean onFileActionChosen(int menuId) { return true; } case R.id.action_select_inverse: { - for(int i = 0;i < mFileListAdapter.getCount();i++){ - if(getListView().isItemChecked(i)) { + for (int i = 0; i < mFileListAdapter.getCount(); i++) { + if (getListView().isItemChecked(i)) { getListView().setItemChecked(i, false); - } else{ - getListView().setItemChecked(i,true); + } else { + getListView().setItemChecked(i, true); } } return true; @@ -968,7 +967,7 @@ public OCFile getCurrentFile() { /** * Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter */ - public void listDirectory(boolean reloadData){ + public void listDirectory(boolean reloadData) { if (reloadData) { listDirectory(null); } else { @@ -993,11 +992,12 @@ public void listDirectory(OCFile directory/*, boolean onlyOnDevice*/) { directory = mFile; } else { directory = storageManager.getFileByPath("/"); - if (directory == null) return; // no files, wait for sync + if (directory == null) { + return; // no files, wait for sync + } } } - // If that's not a directory -> List its parent if (!directory.isFolder()) { Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString()); @@ -1020,7 +1020,7 @@ private void updateLayout() { int filesCount = 0, foldersCount = 0; int count = mFileListAdapter.getCount(); OCFile file; - for (int i=0; i < count ; i++) { + for (int i = 0; i < count; i++) { file = (OCFile) mFileListAdapter.getItem(i); if (file.isFolder()) { foldersCount++; @@ -1033,7 +1033,7 @@ private void updateLayout() { // decide grid vs list view OwnCloudVersion version = AccountUtils.getServerVersion( - ((FileActivity)mContainerActivity).getAccount()); + ((FileActivity) mContainerActivity).getAccount()); if (version != null && version.supportsRemoteThumbnails() && isGridViewPreferred(mFile)) { switchToGridView(); @@ -1049,7 +1049,7 @@ private void updateLayout() { } private void invalidateActionMode() { - if(mActiveActionMode != null){ + if (mActiveActionMode != null) { mActiveActionMode.invalidate(); } } @@ -1112,7 +1112,7 @@ public void sortBySize(boolean descending) { * @param file Folder to check. * @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred. */ - public boolean isGridViewPreferred(OCFile file){ + public boolean isGridViewPreferred(OCFile file) { if (file != null) { OCFile fileToTest = file; OCFile parentDir; @@ -1160,9 +1160,9 @@ private boolean endWhile(OCFile parentDir, SharedPreferences setting) { } } - private void changeGridIcon(Menu menu){ + private void changeGridIcon(Menu menu) { MenuItem menuItem = menu.findItem(R.id.action_switch_view); - if (isGridViewPreferred(mFile)){ + if (isGridViewPreferred(mFile)) { menuItem.setTitle(getString(R.string.action_switch_list_view)); menuItem.setIcon(R.drawable.ic_view_list); } else { @@ -1181,7 +1181,7 @@ public void setGridAsPreferred() { switchToGridView(); } - private void saveGridAsPreferred(boolean setGrid){ + private void saveGridAsPreferred(boolean setGrid) { SharedPreferences setting = getActivity().getSharedPreferences( GRID_IS_PREFERED_PREFERENCE, Context.MODE_PRIVATE ); @@ -1191,7 +1191,6 @@ private void saveGridAsPreferred(boolean setGrid){ editor.apply(); } - /** * Show a temporary message in a Snackbar bound to the content view of the parent Activity * @@ -1199,9 +1198,9 @@ private void saveGridAsPreferred(boolean setGrid){ */ private void showSnackMessage(int messageResource) { Snackbar snackbar = Snackbar.make( - getActivity().findViewById(R.id.coordinator_layout), - messageResource, - Snackbar.LENGTH_LONG + getActivity().findViewById(R.id.coordinator_layout), + messageResource, + Snackbar.LENGTH_LONG ); snackbar.show(); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/PublicShareDialogFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/PublicShareDialogFragment.java index 9cfece9e798..14adf2be446 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/PublicShareDialogFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/PublicShareDialogFragment.java @@ -5,16 +5,16 @@ * @author David González Verdugo * @author Christian Schabesberger * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -41,6 +41,8 @@ import android.widget.RadioGroup; import android.widget.TextView; +import androidx.appcompat.widget.SwitchCompat; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; @@ -55,9 +57,6 @@ import java.text.SimpleDateFormat; import java.util.Date; -import androidx.appcompat.widget.SwitchCompat; -import androidx.fragment.app.DialogFragment; - public class PublicShareDialogFragment extends DialogFragment { private static final String TAG = PublicShareDialogFragment.class.getSimpleName(); @@ -125,7 +124,6 @@ public class PublicShareDialogFragment extends DialogFragment { private RadioButton mReadWriteButton; private RadioButton mUploadOnlyButton; - /** * Create a new instance of PublicShareDialogFragment, providing fileToShare and account * as an argument. @@ -171,7 +169,6 @@ public static PublicShareDialogFragment newInstanceToUpdate(OCFile fileToShare, return publicShareDialogFragment; } - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -320,9 +317,9 @@ private void onSaveShareSetting() { publicUploadPermission = (mCapabilities.getVersionMayor() >= 10 - && (mCapabilities.getVersionMinor() > 1 + && (mCapabilities.getVersionMinor() > 1 || mCapabilities.getVersionMicro() > 3)) - && publicUploadPermission; + && publicUploadPermission; if (!updating()) { // Creating a new public share ((FileActivity) getActivity()).getFileOperationsHelper(). @@ -382,7 +379,7 @@ private abstract static class RightDrawableOnTouchListener implements View.OnTou public boolean onTouch(View view, MotionEvent event) { Drawable rightDrawable = null; if (view instanceof TextView) { - Drawable[] drawables = ((TextView)view).getCompoundDrawables(); + Drawable[] drawables = ((TextView) view).getCompoundDrawables(); if (drawables.length > 2) { rightDrawable = drawables[2]; } @@ -391,7 +388,7 @@ public boolean onTouch(View view, MotionEvent event) { final int x = (int) event.getX(); final int y = (int) event.getY(); final Rect bounds = rightDrawable.getBounds(); - if ( x >= (view.getRight() - bounds.width() - fuzz) && + if (x >= (view.getRight() - bounds.width() - fuzz) && x <= (view.getRight() - view.getPaddingRight() + fuzz) && y >= (view.getPaddingTop() - fuzz) && y <= (view.getHeight() - view.getPaddingBottom()) + fuzz) { @@ -450,7 +447,7 @@ private void showViewPasswordButton() { private boolean isPasswordVisible() { return (getView() != null) && ((mPasswordValueEdit.getInputType() & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) - == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } private void hidePasswordButton() { @@ -462,9 +459,9 @@ private void hidePasswordButton() { private void showPassword() { if (getView() != null) { mPasswordValueEdit.setInputType( - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | - InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); + InputType.TYPE_CLASS_TEXT | + InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | + InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); showViewPasswordButton(); } } @@ -472,9 +469,9 @@ private void showPassword() { private void hidePassword() { if (getView() != null) { mPasswordValueEdit.setInputType( - InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_PASSWORD | - InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); + InputType.TYPE_CLASS_TEXT | + InputType.TYPE_TEXT_VARIATION_PASSWORD | + InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); showViewPasswordButton(); } } @@ -576,7 +573,7 @@ public void onCheckedChanged(CompoundButton switchView, boolean isChecked) { private void initExpirationListener() { mOnExpirationDateInteractionListener = new OnExpirationDateInteractionListener(); mExpirationDateSwitch.setOnCheckedChangeListener(mOnExpirationDateInteractionListener); - mExpirationDateLabel. setOnClickListener(mOnExpirationDateInteractionListener); + mExpirationDateLabel.setOnClickListener(mOnExpirationDateInteractionListener); mExpirationDateValueLabel.setOnClickListener(mOnExpirationDateInteractionListener); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/SearchShareesFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/SearchShareesFragment.java index dc9123b68b2..96fb37a8e4a 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/SearchShareesFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/SearchShareesFragment.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; @@ -27,8 +26,6 @@ import android.app.SearchManager; import android.content.Context; import android.os.Bundle; -import androidx.fragment.app.Fragment; -import androidx.appcompat.widget.SearchView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,6 +33,8 @@ import android.view.inputmethod.InputMethodManager; import android.widget.ListView; +import androidx.appcompat.widget.SearchView; +import androidx.fragment.app.Fragment; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; @@ -74,7 +73,6 @@ public class SearchShareesFragment extends Fragment implements ShareUserListAdap private ShareUserListAdapter mUserGroupsAdapter = null; private ShareFragmentListener mListener; - /** * Public factory method to create new SearchShareesFragment instances. * @@ -148,7 +146,6 @@ public boolean onQueryTextChange(String newText) { return view; } - @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -159,14 +156,13 @@ public void onActivityCreated(Bundle savedInstanceState) { refreshUsersOrGroupsListFromDB(); } - /** * Get users and groups from the DB to fill in the "share with" list * * Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager} * instance ready to use. If not ready, does nothing. */ - public void refreshUsersOrGroupsListFromDB (){ + public void refreshUsersOrGroupsListFromDB() { // Get Users and Groups if (((FileActivity) mListener).getStorageManager() != null) { mShares = ((FileActivity) mListener).getStorageManager().getPrivateSharesForAFile( @@ -183,8 +179,8 @@ private void updateListOfUserGroups() { // Update list of users/groups mUserGroupsAdapter = new ShareUserListAdapter( - getActivity().getApplicationContext(), - R.layout.share_user_item, mShares, this + getActivity().getApplicationContext(), + R.layout.share_user_item, mShares, this ); // Show data @@ -240,7 +236,8 @@ private void hideSoftKeyboard() { if (getView() != null) { View searchView = getView().findViewById(R.id.searchView); if (searchView != null) { - InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + InputMethodManager imm = + (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java index ae2fcb29a6f..022dcea0c80 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java @@ -7,16 +7,16 @@ * @author David González Verdugo * @author Christian Schabesberger * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -27,8 +27,6 @@ import android.app.Activity; import android.graphics.Bitmap; import android.os.Bundle; -import com.google.android.material.snackbar.Snackbar; -import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -41,6 +39,8 @@ import android.widget.TextView; import android.widget.Toast; +import androidx.fragment.app.Fragment; +import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; @@ -135,7 +135,6 @@ public class ShareFileFragment extends Fragment */ private OCCapability mCapabilities; - /** * Public factory method to create new ShareFileFragment instances. * @@ -391,7 +390,6 @@ public void onDetach() { mListener = null; } - /** * Get known server capabilities from DB * @@ -405,7 +403,6 @@ public void refreshCapabilitiesFromDB() { } } - /** * Get users and groups from the DB to fill in the "share with" list. * @@ -561,7 +558,6 @@ private void updateListOfPublicLinks() { scrollView.scrollTo(0, 0); } - /// BEWARE: next methods will failed with NullPointerException if called before onCreateView() finishes private LinearLayout getShareViaLinkSection() { @@ -603,7 +599,6 @@ public static void setListViewHeightBasedOnChildren(ListView listView) { listView.requestLayout(); } - /** * Hide share features sections that are not enabled * diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFragmentListener.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFragmentListener.java index 99962d0e736..70175c8d83b 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFragmentListener.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ShareFragmentListener.java @@ -1,28 +1,25 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; -import android.accounts.Account; - import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.resources.shares.OCShare; @@ -38,11 +35,18 @@ */ public interface ShareFragmentListener { void copyOrSendPrivateLink(OCFile file); + void showSearchUsersAndGroups(); + void showEditPrivateShare(OCShare share); + void refreshSharesFromServer(); + void removeShare(OCShare share); + void showAddPublicShare(String defaultLinkName); + void showEditPublicShare(OCShare share); + void copyOrSendPublicLink(OCShare share); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/TaskRetainerFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/TaskRetainerFragment.java index 4ad0cfb8f1d..fcb4c140d5a 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/TaskRetainerFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/TaskRetainerFragment.java @@ -1,27 +1,26 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; import android.content.Context; import android.os.Bundle; -import androidx.fragment.app.Fragment; +import androidx.fragment.app.Fragment; import com.owncloud.android.ui.activity.ReceiveExternalFilesActivity; import com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/UploadListFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/UploadListFragment.java index 06ad3fc5da5..97ad90ee11d 100755 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/UploadListFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/UploadListFragment.java @@ -1,22 +1,21 @@ /** - * ownCloud Android client application - * - * @author LukeOwncloud - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author LukeOwncloud + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.fragment; @@ -36,7 +35,7 @@ /** * A Fragment that lists all files and folders in a given LOCAL path. - * + * */ public class UploadListFragment extends ExpandableListFragment { static private String TAG = UploadListFragment.class.getSimpleName(); @@ -55,11 +54,11 @@ public class UploadListFragment extends ExpandableListFragment { public void setBinderReady(boolean ready) { mBinderReady = ready; } - public boolean isBinderReady(){ + + public boolean isBinderReady() { return mBinderReady; } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = super.onCreateView(inflater, container, savedInstanceState); @@ -68,7 +67,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa setOnRefreshListener(this); return v; } - + @Override public void onRefresh() { // remove the progress circle as soon as pull is triggered, like in the list of files @@ -100,7 +99,7 @@ public void onActivityCreated(Bundle savedInstanceState) { public void onStart() { Log_OC.d(TAG, "onStart() start"); super.onStart(); - mAdapter = new ExpandableUploadListAdapter((FileActivity)getActivity()); + mAdapter = new ExpandableUploadListAdapter((FileActivity) getActivity()); setListAdapter(mAdapter); } @@ -120,7 +119,7 @@ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition /** * Interface to implement by any Activity that includes some instance of * UploadListFragment - * + * * @author LukeOwncloud */ public interface ContainerActivity { @@ -128,7 +127,7 @@ public interface ContainerActivity { /** * Callback method invoked when an upload item is clicked by the user on * the upload list - * + * * @param file * @return return true if click was handled. */ @@ -136,7 +135,7 @@ public interface ContainerActivity { } - public void binderReady(){ + public void binderReady() { setBinderReady(true); if (mAdapter != null) { @@ -144,7 +143,7 @@ public void binderReady(){ } } - public void updateUploads(){ + public void updateUploads() { if (mAdapter != null) { mAdapter.refreshView(); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java index a18c2005fe5..e4bd8f4b6a3 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -1,24 +1,23 @@ /** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * @author Juan Carlos González Cabrero - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author masensio + * @author David A. Velasco + * @author Juan Carlos González Cabrero + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.helpers; @@ -28,9 +27,9 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import androidx.fragment.app.DialogFragment; import android.webkit.MimeTypeMap; +import androidx.fragment.app.DialogFragment; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; @@ -70,8 +69,8 @@ public void openFile(OCFile file) { Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW); intentForSavedMimeType.setDataAndType( - file.getExposedFileUri(mFileActivity), - file.getMimetype() + file.getExposedFileUri(mFileActivity), + file.getMimetype() ); intentForSavedMimeType.setFlags( @@ -86,8 +85,8 @@ public void openFile(OCFile file) { if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) { intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW); intentForGuessedMimeType.setDataAndType( - file.getExposedFileUri(mFileActivity), - guessedMimeType + file.getExposedFileUri(mFileActivity), + guessedMimeType ); intentForGuessedMimeType.setFlags( Intent.FLAG_GRANT_READ_URI_PERMISSION | @@ -106,7 +105,7 @@ public void openFile(OCFile file) { List launchables = mFileActivity.getPackageManager(). queryIntentActivities(openFileWithIntent, PackageManager.GET_INTENT_FILTERS); - if(launchables != null && launchables.size() > 0) { + if (launchables != null && launchables.size() > 0) { try { mFileActivity.startActivity( Intent.createChooser( @@ -115,14 +114,14 @@ public void openFile(OCFile file) { ); } catch (ActivityNotFoundException anfe) { mFileActivity.showSnackMessage( - mFileActivity.getString( - R.string.file_list_no_app_for_file_type - ) + mFileActivity.getString( + R.string.file_list_no_app_for_file_type + ) ); } } else { mFileActivity.showSnackMessage( - mFileActivity.getString(R.string.file_list_no_app_for_file_type) + mFileActivity.getString(R.string.file_list_no_app_for_file_type) ); } @@ -165,8 +164,7 @@ public void shareFileViaLink(OCFile file, String password, long expirationTimeInMillis, boolean uploadToFolderPermission, - int permissions) - { + int permissions) { if (isSharedSupported()) { if (file != null) { @@ -223,7 +221,7 @@ public void shareFileViaLink(OCFile file, } else { // Show a Message mFileActivity.showSnackMessage( - mFileActivity.getString(R.string.share_link_no_support_share_api) + mFileActivity.getString(R.string.share_link_no_support_share_api) ); } } @@ -238,7 +236,7 @@ public void copyOrSendPublicLink(OCShare share) { String link = share.getShareLink(); if (link.length() <= 0) { mFileActivity.showSnackMessage( - mFileActivity.getString(R.string.share_no_link_in_this_share) + mFileActivity.getString(R.string.share_no_link_in_this_share) ); return; } @@ -273,7 +271,6 @@ public void shareFileWithSharee(OCFile file, String shareeName, ShareType shareT } } - /** * @return 'True' if the server supports the Share API */ @@ -285,7 +282,6 @@ public boolean isSharedSupported() { return false; } - /** * Helper method to remove an existing share, no matter if public or private. * Starts a request to do it in {@link OperationsService} @@ -302,7 +298,7 @@ public void removeShare(OCShare share) { queueShareIntent(unshareService); } - private void queueShareIntent(Intent shareIntent){ + private void queueShareIntent(Intent shareIntent) { if (isSharedSupported()) { // Unshare the file mWaitingForOpId = mFileActivity.getOperationsServiceBinder(). @@ -313,7 +309,7 @@ private void queueShareIntent(Intent shareIntent){ } else { // Show a Message mFileActivity.showSnackMessage( - mFileActivity.getString(R.string.share_link_no_support_share_api) + mFileActivity.getString(R.string.share_link_no_support_share_api) ); } } @@ -323,7 +319,7 @@ private void queueShareIntent(Intent shareIntent){ * * @param file File to share or unshare. */ - public void showShareFile(OCFile file){ + public void showShareFile(OCFile file) { Intent intent = new Intent(mFileActivity, ShareActivity.class); intent.putExtra(FileActivity.EXTRA_FILE, file); intent.putExtra(FileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount()); @@ -365,12 +361,12 @@ public void setPermissionsToShareWithSharee(OCShare share, int permissions) { * @param permissions Optional permissions to allow or not specific actions in the folder */ public void updateShareViaLink( - OCShare share, - String name, - String password, - long expirationTimeInMillis, - boolean uploadToFolderPermission, - int permissions + OCShare share, + String name, + String password, + long expirationTimeInMillis, + boolean uploadToFolderPermission, + int permissions ) { // Set password updating share Intent updateShareIntent = new Intent(mFileActivity, OperationsService.class); @@ -379,23 +375,23 @@ public void updateShareViaLink( updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId()); updateShareIntent.putExtra( - OperationsService.EXTRA_SHARE_NAME, - (name == null) ? "" : name + OperationsService.EXTRA_SHARE_NAME, + (name == null) ? "" : name ); updateShareIntent.putExtra( - OperationsService.EXTRA_SHARE_PASSWORD, + OperationsService.EXTRA_SHARE_PASSWORD, password ); updateShareIntent.putExtra( - OperationsService.EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, - expirationTimeInMillis + OperationsService.EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, + expirationTimeInMillis ); updateShareIntent.putExtra( - OperationsService.EXTRA_SHARE_PUBLIC_UPLOAD, - uploadToFolderPermission + OperationsService.EXTRA_SHARE_PUBLIC_UPLOAD, + uploadToFolderPermission ); updateShareIntent.putExtra( @@ -406,7 +402,6 @@ public void updateShareViaLink( queueShareIntent(updateShareIntent); } - /** * @return 'True' if the server supports the Search Users API */ @@ -424,8 +419,8 @@ public void sendDownloadedFile(OCFile file) { // set MimeType sendIntent.setType(file.getMimetype()); sendIntent.putExtra( - Intent.EXTRA_STREAM, - file.getExposedFileUri(mFileActivity) + Intent.EXTRA_STREAM, + file.getExposedFileUri(mFileActivity) ); sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action @@ -440,7 +435,7 @@ public void sendDownloadedFile(OCFile file) { } public void syncFiles(Collection files) { - for (OCFile file: files) { + for (OCFile file : files) { syncFile(file); } } @@ -451,7 +446,7 @@ public void syncFiles(Collection files) { * @param file The file or folder to synchronize */ public void syncFile(OCFile file) { - if (!file.isFolder()){ + if (!file.isFolder()) { Intent intent = new Intent(mFileActivity, OperationsService.class); intent.setAction(OperationsService.ACTION_SYNC_FILE); intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); @@ -464,15 +459,15 @@ public void syncFile(OCFile file) { intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath()); intent.putExtra( - OperationsService.EXTRA_SYNC_REGULAR_FILES, - true + OperationsService.EXTRA_SYNC_REGULAR_FILES, + true ); mFileActivity.startService(intent); } } - public void toggleAvailableOffline(Collection files, boolean isAvailableOffline){ - for (OCFile file: files) { + public void toggleAvailableOffline(Collection files, boolean isAvailableOffline) { + for (OCFile file : files) { toggleAvailableOffline(file, isAvailableOffline); } } @@ -481,14 +476,14 @@ public void toggleAvailableOffline(OCFile file, boolean isAvailableOffline) { if (OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE_PARENT == file.getAvailableOfflineStatus()) { /// files descending of an av-offline folder can't be toggled mFileActivity.showSnackMessage( - mFileActivity.getString(R.string.available_offline_inherited_msg) + mFileActivity.getString(R.string.available_offline_inherited_msg) ); } else { /// update local property, for file and all its descendents (if folder) OCFile.AvailableOfflineStatus targetAvailableOfflineStatus = isAvailableOffline ? - OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE : - OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE; + OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE : + OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE; file.setAvailableOfflineStatus(targetAvailableOfflineStatus); boolean success = mFileActivity.getStorageManager().saveLocalAvailableOfflineStatus(file); @@ -509,7 +504,7 @@ public void toggleAvailableOffline(OCFile file, boolean isAvailableOffline) { } else { /// unexpected error mFileActivity.showSnackMessage( - mFileActivity.getString(R.string.common_error_unknown) + mFileActivity.getString(R.string.common_error_unknown) ); } } @@ -527,7 +522,6 @@ public void renameFile(OCFile file, String newFilename) { mFileActivity.showLoadingDialog(R.string.wait_a_moment); } - /** * Start operations to delete one or several files * @@ -549,7 +543,6 @@ public void removeFiles(Collection files, boolean onlyLocalCopy) { mFileActivity.showLoadingDialog(R.string.wait_a_moment); } - public void createFolder(String remotePath, boolean createFullPath) { // Create Folder Intent service = new Intent(mFileActivity, OperationsService.class); @@ -557,7 +550,7 @@ public void createFolder(String remotePath, boolean createFullPath) { service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); service.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath); service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath); - mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service); + mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service); mFileActivity.showLoadingDialog(R.string.wait_a_moment); } @@ -627,7 +620,6 @@ public long getOpIdWaitingFor() { return mWaitingForOpId; } - public void setOpIdWaitingFor(long waitingForOpId) { mWaitingForOpId = waitingForOpId; } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FilesUploadHelper.java b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FilesUploadHelper.java index 5df02672583..017e2440673 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FilesUploadHelper.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FilesUploadHelper.java @@ -1,22 +1,21 @@ /** - * ownCloud Android client application - * - * @author Christian Schabesberger - * @author Shashvat Kedia - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Christian Schabesberger + * @author Shashvat Kedia + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.helpers; @@ -29,8 +28,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.provider.MediaStore; -import androidx.core.content.FileProvider; +import androidx.core.content.FileProvider; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.FileStorageUtils; @@ -39,7 +38,6 @@ import java.io.IOException; import java.util.Calendar; - public class FilesUploadHelper implements Parcelable { private static final String TAG = FilesUploadHelper.class.toString(); @@ -65,9 +63,9 @@ public void init(Activity activity, String accountName) { this.accountName = accountName; } - public interface OnCheckAvailableSpaceListener { void onCheckAvailableSpaceStart(); + void onCheckAvailableSpaceFinished(boolean hasEnoughSpace, String[] capturedFilePaths); } @@ -97,7 +95,6 @@ protected void onPreExecute() { callback.onCheckAvailableSpaceStart(); } - /** * Checks the available space * @@ -133,7 +130,7 @@ public void checkIfAvailableSpace(String[] checkedFilePaths, new CheckAvailableSpaceTask(checkedFilePaths, listener).execute(); } - public static String getCapturedImageName(){ + public static String getCapturedImageName() { Calendar calendar = Calendar.getInstance(); String year = "" + calendar.get(Calendar.YEAR); String month = ("0" + (calendar.get(Calendar.MONTH) + 1)); @@ -141,33 +138,32 @@ public static String getCapturedImageName(){ String hour = ("0" + calendar.get(Calendar.HOUR_OF_DAY)); String minute = ("0" + calendar.get(Calendar.MINUTE)); String second = ("0" + calendar.get(Calendar.SECOND)); - month = month.length() == 3 ? month.substring(1,month.length()) : month; - day = day.length() == 3 ? day.substring(1,day.length()) : day; - hour = hour.length() == 3 ? hour.substring(1,hour.length()) : hour; - minute = minute.length() == 3 ? minute.substring(1,minute.length()) : minute; - second = second.length() == 3 ? second.substring(1,second.length()) : second; + month = month.length() == 3 ? month.substring(1, month.length()) : month; + day = day.length() == 3 ? day.substring(1, day.length()) : day; + hour = hour.length() == 3 ? hour.substring(1, hour.length()) : hour; + minute = minute.length() == 3 ? minute.substring(1, minute.length()) : minute; + second = second.length() == 3 ? second.substring(1, second.length()) : second; String newImageName = "IMG_" + year + month + day + "_" + hour + minute + second; return newImageName; } - - public File getCapturedImageFile(){ + public File getCapturedImageFile() { File capturedImage = new File(capturedPhotoPath); File parent = capturedImage.getParentFile(); - File newImage = new File(parent,getCapturedImageName() + ".jpg"); + File newImage = new File(parent, getCapturedImageName() + ".jpg"); capturedImage.renameTo(newImage); capturedImage.delete(); capturedPhotoPath = newImage.getAbsolutePath(); return newImage; } - private File createImageFile(){ + private File createImageFile() { try { File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES); image = File.createTempFile(getCapturedImageName(), ".jpg", storageDir); capturedPhotoPath = image.getAbsolutePath(); - } catch(IOException exception){ - Log_OC.d(TAG,exception.toString()); + } catch (IOException exception) { + Log_OC.d(TAG, exception.toString()); } return image; } @@ -175,13 +171,13 @@ private File createImageFile(){ /** * Function to send an intent to the device's camera to capture a picture * */ - public void uploadFromCamera(final int requestCode){ + public void uploadFromCamera(final int requestCode) { Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File photoFile = createImageFile(); - if(photoFile != null){ + if (photoFile != null) { Uri photoUri = FileProvider.getUriForFile(activity.getApplicationContext(), - activity.getResources().getString(R.string.file_provider_authority),photoFile); - pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,photoUri); + activity.getResources().getString(R.string.file_provider_authority), photoFile); + pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); } if (pictureIntent.resolveActivity(activity.getPackageManager()) != null) { activity.startActivityForResult(pictureIntent, requestCode); @@ -193,7 +189,7 @@ public void onActivityResult(final OnCheckAvailableSpaceListener callback) { } public void deleteImageFile() { - if(image != null) { + if (image != null) { image.delete(); Log_OC.d(TAG, "File deleted"); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/SparseBooleanArrayParcelable.java b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/SparseBooleanArrayParcelable.java index c4d4fa7a763..6a29116a972 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/SparseBooleanArrayParcelable.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/SparseBooleanArrayParcelable.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.helpers; @@ -31,32 +30,32 @@ public class SparseBooleanArrayParcelable implements Parcelable { public static Parcelable.Creator CREATOR = - new Parcelable.Creator() { + new Parcelable.Creator() { - @Override - public SparseBooleanArrayParcelable createFromParcel(Parcel source) { - // read size of array from source - int size = source.readInt(); + @Override + public SparseBooleanArrayParcelable createFromParcel(Parcel source) { + // read size of array from source + int size = source.readInt(); - // then pairs of (key, value)s, in the object to wrap - SparseBooleanArray sba = new SparseBooleanArray(); - int key; - boolean value; - for (int i = 0; i < size; i++) { - key = source.readInt(); - value = (source.readInt() != 0); - sba.put(key, value); - } + // then pairs of (key, value)s, in the object to wrap + SparseBooleanArray sba = new SparseBooleanArray(); + int key; + boolean value; + for (int i = 0; i < size; i++) { + key = source.readInt(); + value = (source.readInt() != 0); + sba.put(key, value); + } - // wrap SparseBooleanArray - return new SparseBooleanArrayParcelable(sba); - } + // wrap SparseBooleanArray + return new SparseBooleanArrayParcelable(sba); + } - @Override - public SparseBooleanArrayParcelable[] newArray(int size) { - return new SparseBooleanArrayParcelable[size]; - } - }; + @Override + public SparseBooleanArrayParcelable[] newArray(int size) { + return new SparseBooleanArrayParcelable[size]; + } + }; private final SparseBooleanArray mSba; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/UriUploader.java b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/UriUploader.java index 5570eadaadc..725995afefb 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/UriUploader.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/UriUploader.java @@ -1,20 +1,19 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.helpers; @@ -22,8 +21,8 @@ import android.content.ContentResolver; import android.net.Uri; import android.os.Parcelable; -import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentManager; import com.owncloud.android.R; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.files.services.TransferRequester; diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/notifications/NotificationUtils.java b/owncloudApp/src/main/java/com/owncloud/android/ui/notifications/NotificationUtils.java index 54c0c3c46b1..df286fcc11d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/notifications/NotificationUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/notifications/NotificationUtils.java @@ -1,20 +1,19 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.notifications; @@ -24,8 +23,8 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Process; -import androidx.core.app.NotificationCompat; +import androidx.core.app.NotificationCompat; import com.owncloud.android.R; import java.util.Random; @@ -45,30 +44,30 @@ public class NotificationUtils { * change a lot in different Android versions. * * @param context Context that will use the builder to create notifications - * @return An instance of the regular {@link NotificationCompat.Builder}. + * @return An instance of the regular {@link NotificationCompat.Builder}. */ public static NotificationCompat.Builder newNotificationBuilder(Context context) { return new NotificationCompat.Builder(context). - setColor(context.getResources().getColor(R.color.primary)); + setColor(context.getResources().getColor(R.color.primary)); } public static void cancelWithDelay( final NotificationManager notificationManager, final int notificationId, long delayInMillis) { - + HandlerThread thread = new HandlerThread( "NotificationDelayerThread_" + (new Random(System.currentTimeMillis())).nextInt(), Process.THREAD_PRIORITY_BACKGROUND); thread.start(); - - Handler handler = new Handler(thread.getLooper()); - handler.postDelayed(new Runnable() { - public void run() { - notificationManager.cancel(notificationId); - ((HandlerThread)Thread.currentThread()).getLooper().quit(); - } - }, delayInMillis); - + + Handler handler = new Handler(thread.getLooper()); + handler.postDelayed(new Runnable() { + public void run() { + notificationManager.cancel(notificationId); + ((HandlerThread) Thread.currentThread()).getLooper().quit(); + } + }, delayInMillis); + } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/CustomHttpDataSourceFactory.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/CustomHttpDataSourceFactory.java index 54b0761af68..9ca2f2e65c4 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/CustomHttpDataSourceFactory.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/CustomHttpDataSourceFactory.java @@ -19,8 +19,6 @@ * along with this program. If not, see . */ -import android.util.Base64; - import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultHttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory; @@ -29,7 +27,9 @@ import java.util.Map; -/** A {@link Factory} that produces {@link CustomHttpDataSourceFactory} instances. */ +/** + * A {@link Factory} that produces {@link CustomHttpDataSourceFactory} instances. + */ public final class CustomHttpDataSourceFactory extends BaseFactory { private final String userAgent; @@ -46,8 +46,8 @@ public final class CustomHttpDataSourceFactory extends BaseFactory { * cross-protocol redirects. * * @param userAgent The User-Agent string that should be used. - * @param listener An optional listener. - * @param params http authentication header + * @param listener An optional listener. + * @param params http authentication header * @see #CustomHttpDataSourceFactory(String, TransferListener, int, int, boolean, * Map) */ @@ -59,14 +59,15 @@ public CustomHttpDataSourceFactory( } /** - * @param userAgent The User-Agent string that should be used. - * @param listener An optional listener. - * @param connectTimeoutMillis The connection timeout that should be used when requesting remote - * data, in milliseconds. A timeout of zero is interpreted as an infinite timeout. - * @param readTimeoutMillis The read timeout that should be used when requesting remote data, in - * milliseconds. A timeout of zero is interpreted as an infinite timeout. + * @param userAgent The User-Agent string that should be used. + * @param listener An optional listener. + * @param connectTimeoutMillis The connection timeout that should be used when requesting remote + * data, in milliseconds. A timeout of zero is interpreted as an infinite + * timeout. + * @param readTimeoutMillis The read timeout that should be used when requesting remote data, in + * milliseconds. A timeout of zero is interpreted as an infinite timeout. * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP - * to HTTPS and vice versa) are enabled. + * to HTTPS and vice versa) are enabled. */ public CustomHttpDataSourceFactory(String userAgent, TransferListener listener, diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java index 27af4d9f41d..0105c893ad0 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java @@ -1,35 +1,26 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.preview; -import com.owncloud.android.R; -import com.owncloud.android.datamodel.FileDataStorageManager; -import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.ui.controller.TransferProgressController; -import com.owncloud.android.ui.fragment.FileFragment; - import android.accounts.Account; import android.os.Bundle; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentStatePagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -37,11 +28,17 @@ import android.widget.ProgressBar; import android.widget.TextView; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentStatePagerAdapter; +import com.owncloud.android.R; +import com.owncloud.android.datamodel.FileDataStorageManager; +import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; +import com.owncloud.android.ui.controller.TransferProgressController; +import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.PreferenceUtils; - /** * This Fragment is used to monitor the progress of a file downloading. */ @@ -52,10 +49,10 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene public static final String EXTRA_FILE = "FILE"; public static final String EXTRA_ACCOUNT = "ACCOUNT"; private static final String EXTRA_ERROR = "ERROR"; - + private static final String ARG_FILE = "FILE"; private static final String ARG_IGNORE_FIRST = "IGNORE_FIRST"; - private static final String ARG_ACCOUNT = "ACCOUNT" ; + private static final String ARG_ACCOUNT = "ACCOUNT"; private Account mAccount; @@ -65,7 +62,6 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene private boolean mError; private ProgressBar mProgressBar; - /** * Public factory method to create a new fragment that shows the progress of a file download. * @@ -91,10 +87,9 @@ public static Fragment newInstance(OCFile file, Account account, boolean ignoreF return frag; } - /** * Creates an empty details fragment. - * + * * It's necessary to keep a public constructor without parameters; the system uses it when tries to * reinstantiate a fragment automatically. */ @@ -110,14 +105,13 @@ public FileDownloadFragment() { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); - setFile((OCFile)args.getParcelable(ARG_FILE)); - // TODO better in super, but needs to check ALL the class extending FileFragment; not right now + setFile((OCFile) args.getParcelable(ARG_FILE)); + // TODO better in super, but needs to check ALL the class extending FileFragment; not right now mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST); mAccount = args.getParcelable(ARG_ACCOUNT); } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -160,7 +154,6 @@ public void onActivityCreated(Bundle savedState) { mProgressController.setProgressBar(mProgressBar); } - @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -194,7 +187,6 @@ public void onClick(View v) { } } - /** * Enables buttons for a file being downloaded */ @@ -214,7 +206,6 @@ private void setButtonsForTransferring(View rootView) { } } - /** * Enables or disables buttons for a file locally available */ @@ -255,7 +246,6 @@ private void setButtonsForRemote(View rootView) { } } - @Override public void onTransferServiceConnected() { listenForTransferProgress(); @@ -283,7 +273,6 @@ public void onFileContentChanged() { // view does not need any update, parent activity will replace this fragment } - @Override public void updateViewForSyncInProgress() { setButtonsForTransferring(getView()); @@ -298,7 +287,6 @@ public void updateViewForSyncOff() { } } - private void listenForTransferProgress() { if (mProgressController != null) { mProgressController.startListeningProgressFor(getFile(), mAccount); @@ -306,14 +294,12 @@ private void listenForTransferProgress() { } } - private void leaveTransferProgress() { if (mProgressController != null) { mProgressController.stopListeningProgressFor(getFile(), mAccount); } } - public void setError(boolean error) { mError = error; } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/ImageViewCustom.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/ImageViewCustom.java index ba1864d3413..f8b5fb37359 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/ImageViewCustom.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/ImageViewCustom.java @@ -18,29 +18,28 @@ public class ImageViewCustom extends ImageView { private static final boolean IS_ICS_OR_HIGHER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH; private static final boolean IS_VERSION_BUGGY_ON_RECYCLES = Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1 || - Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR2; + Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR2; private int mBitmapHeight; private int mBitmapWidth; - public ImageViewCustom(Context context) { super(context); } - + public ImageViewCustom(Context context, AttributeSet attrs) { super(context, attrs); } - + public ImageViewCustom(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @SuppressLint("NewApi") - @Override + @Override protected void onDraw(Canvas canvas) { - if(IS_ICS_OR_HIGHER && checkIfMaximumBitmapExceed(canvas) || IS_VERSION_BUGGY_ON_RECYCLES ) { + if (IS_ICS_OR_HIGHER && checkIfMaximumBitmapExceed(canvas) || IS_VERSION_BUGGY_ON_RECYCLES) { // Software type is set with two targets: // 1. prevent that bitmaps larger than maximum textures allowed are shown as black views in devices // with LAYER_TYPE_HARDWARE enabled by default; @@ -55,23 +54,24 @@ protected void onDraw(Canvas canvas) { /** * Checks if current bitmaps exceed the maximum OpenGL texture size limit - * @param canvas Canvas where the view will be drawn into. + * + * @param canvas Canvas where the view will be drawn into. * @return boolean True means that the bitmap is too big for the canvas. */ @SuppressLint("NewApi") - private boolean checkIfMaximumBitmapExceed(Canvas canvas) { + private boolean checkIfMaximumBitmapExceed(Canvas canvas) { Log_OC.v(TAG, "Canvas maximum: " + canvas.getMaximumBitmapWidth() + " - " + canvas.getMaximumBitmapHeight()); return mBitmapWidth > canvas.getMaximumBitmapWidth() || mBitmapHeight > canvas.getMaximumBitmapHeight(); } - + @Override /** * Keeps the size of the bitmap cached in member variables for faster access in {@link #onDraw(Canvas)} , * but without keeping another reference to the {@link Bitmap} */ - public void setImageBitmap (Bitmap bm) { + public void setImageBitmap(Bitmap bm) { mBitmapWidth = bm.getWidth(); mBitmapHeight = bm.getHeight(); super.setImageBitmap(bm); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PrepareVideoPlayerAsyncTask.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PrepareVideoPlayerAsyncTask.java index d8a743f5088..3ebb2f4dab7 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PrepareVideoPlayerAsyncTask.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PrepareVideoPlayerAsyncTask.java @@ -43,7 +43,6 @@ public class PrepareVideoPlayerAsyncTask extends AsyncTask. + * ownCloud Android client application * + * @author David A. Velasco + * @author Christian Schabesberger + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.preview; @@ -55,13 +54,12 @@ import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.PreferenceUtils; - /** * This fragment shows a preview of a downloaded audio. * * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will * produce an {@link IllegalStateException}. - * + * * If the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is * generated on instantiation too. */ @@ -86,7 +84,6 @@ public class PreviewAudioFragment extends FileFragment { private static final String TAG = PreviewAudioFragment.class.getSimpleName(); - /** * Public factory method to create new PreviewAudioFragment instances. * @@ -95,13 +92,13 @@ public class PreviewAudioFragment extends FileFragment { * @param startPlaybackPosition Time in milliseconds where the play should be started * @param autoplay If 'true', the file will be played automatically when * the fragment is displayed. - * @return Fragment ready to be used. + * @return Fragment ready to be used. */ public static PreviewAudioFragment newInstance( - OCFile file, - Account account, - int startPlaybackPosition, - boolean autoplay + OCFile file, + Account account, + int startPlaybackPosition, + boolean autoplay ) { PreviewAudioFragment frag = new PreviewAudioFragment(); Bundle args = new Bundle(); @@ -113,13 +110,10 @@ public static PreviewAudioFragment newInstance( return frag; } - /** * Creates an empty fragment for preview audio files. - * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically * (for instance, when the device is turned a aside). - * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful * construction */ @@ -131,7 +125,6 @@ public PreviewAudioFragment() { mProgressController = null; } - /** * {@inheritDoc} */ @@ -141,7 +134,6 @@ public void onCreate(Bundle savedInstanceState) { setHasOptionsMenu(true); } - /** * {@inheritDoc} */ @@ -164,7 +156,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, return view; } - /** * {@inheritDoc} */ @@ -187,12 +178,12 @@ public void onActivityCreated(Bundle savedInstanceState) { setFile(file); mAccount = savedInstanceState.getParcelable(PreviewAudioFragment.EXTRA_ACCOUNT); mSavedPlaybackPosition = savedInstanceState.getInt( - PreviewAudioFragment.EXTRA_PLAY_POSITION, - args.getInt(PreviewAudioFragment.EXTRA_PLAY_POSITION) + PreviewAudioFragment.EXTRA_PLAY_POSITION, + args.getInt(PreviewAudioFragment.EXTRA_PLAY_POSITION) ); mAutoplay = savedInstanceState.getBoolean( - PreviewAudioFragment.EXTRA_PLAYING, - args.getBoolean(PreviewAudioFragment.EXTRA_PLAYING) + PreviewAudioFragment.EXTRA_PLAYING, + args.getBoolean(PreviewAudioFragment.EXTRA_PLAYING) ); } @@ -236,7 +227,6 @@ private void extractAndSetCoverArt(OCFile file) { } } - /** * {@inheritDoc} */ @@ -253,7 +243,6 @@ public void onSaveInstanceState(Bundle outState) { } } - @Override public void onStart() { super.onStart(); @@ -267,7 +256,6 @@ public void onStart() { mProgressController.startListeningProgressFor(getFile(), mAccount); } - @Override public void onTransferServiceConnected() { if (mProgressController != null) { @@ -307,7 +295,6 @@ public void updateViewForSyncOff() { mProgressController.hideProgressBar(); } - /** * {@inheritDoc} */ @@ -317,7 +304,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.file_actions_menu, menu); } - /** * {@inheritDoc} */ @@ -326,10 +312,10 @@ public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); FileMenuFilter mf = new FileMenuFilter( - getFile(), - mAccount, - mContainerActivity, - getActivity() + getFile(), + mAccount, + mContainerActivity, + getActivity() ); mf.filter(menu, false, false); @@ -356,7 +342,6 @@ public void onPrepareOptionsMenu(Menu menu) { } } - /** * {@inheritDoc} */ @@ -388,11 +373,11 @@ public boolean onOptionsItemSelected(MenuItem item) { mContainerActivity.getFileOperationsHelper().syncFile(getFile()); return true; } - case R.id.action_set_available_offline:{ + case R.id.action_set_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), true); return true; } - case R.id.action_unset_available_offline:{ + case R.id.action_unset_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), false); return true; } @@ -401,7 +386,6 @@ public boolean onOptionsItemSelected(MenuItem item) { } } - private void seeDetails() { mContainerActivity.showDetails(getFile()); } @@ -445,19 +429,18 @@ public void playAudio(boolean restart) { } } - private void bindMediaService() { Log_OC.d(TAG, "Binding to MediaService..."); if (mMediaServiceConnection == null) { mMediaServiceConnection = new MediaServiceConnection(); - getActivity().bindService( new Intent(getActivity(), - MediaService.class), - mMediaServiceConnection, - Context.BIND_AUTO_CREATE); + getActivity().bindService(new Intent(getActivity(), + MediaService.class), + mMediaServiceConnection, + Context.BIND_AUTO_CREATE); // follow the flow in MediaServiceConnection#onServiceConnected(...) } } - + /** Defines callbacks for service binding, passed to bindService() */ private class MediaServiceConnection implements ServiceConnection { @@ -495,8 +478,7 @@ public void onServiceDisconnected(ComponentName component) { Log_OC.w(TAG, "Media service suddenly disconnected"); if (mMediaController != null) { mMediaController.setMediaPlayer(null); - } - else { + } else { Log_OC.w(TAG, "No media controller to release when disconnected from media service"); } mMediaServiceBinder = null; @@ -505,7 +487,6 @@ public void onServiceDisconnected(ComponentName component) { } } - /** * Opens the previewed file with an external application. */ @@ -526,12 +507,10 @@ public static boolean canBePreviewed(OCFile file) { return (file != null && file.isDown() && file.isAudio()); } - public void stopPreview() { mMediaServiceBinder.pause(); } - /** * Finishes the preview */ @@ -539,5 +518,4 @@ private void finish() { getActivity().onBackPressed(); } - } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java index cbba1e9135e..c2c59ae9064 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author David González Verdugo - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hd that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author David González Verdugo + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hd that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.preview; @@ -33,14 +32,14 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; -import androidx.viewpager.widget.ViewPager; -import androidx.drawerlayout.widget.DrawerLayout; -import androidx.appcompat.app.ActionBar; import android.view.MenuItem; import android.view.View; import android.view.Window; +import androidx.appcompat.app.ActionBar; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; +import androidx.viewpager.widget.ViewPager; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.FileDataStorageManager; @@ -61,16 +60,15 @@ import com.owncloud.android.utils.Extras; import com.owncloud.android.utils.PreferenceUtils; - /** * Holds a swiping galley where image files contained in an ownCloud directory are shown */ public class PreviewImageActivity extends FileActivity implements FileFragment.ContainerActivity, ViewPager.OnPageChangeListener, OnRemoteOperationListener { - + public static final String TAG = PreviewImageActivity.class.getSimpleName(); - + private static final int INITIAL_HIDE_DELAY = 0; // immediate hide private ViewPager mViewPager; @@ -80,9 +78,8 @@ public class PreviewImageActivity extends FileActivity implements private LocalBroadcastManager mLocalBroadcastManager; private DownloadFinishReceiver mDownloadFinishReceiver; - + private View mFullScreenAnchorView; - @Override protected void onCreate(Bundle savedInstanceState) { @@ -97,27 +94,26 @@ protected void onCreate(Bundle savedInstanceState) { updateActionBarTitleAndHomeButton(null); actionBar.hide(); - /// FullScreen and Immersive Mode mFullScreenAnchorView = getWindow().getDecorView(); // to keep our UI controls visibility in line with system bars // visibility mFullScreenAnchorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() { - @SuppressLint("InlinedApi") - @Override - public void onSystemUiVisibilityChange(int flags) { - boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; - ActionBar actionBar = getSupportActionBar(); - if (visible) { - actionBar.show(); - setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); - } else { - actionBar.hide(); - setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); - } - } - }); + @SuppressLint("InlinedApi") + @Override + public void onSystemUiVisibilityChange(int flags) { + boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; + ActionBar actionBar = getSupportActionBar(); + if (visible) { + actionBar.show(); + setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); + } else { + actionBar.hide(); + setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + } + } + }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(getResources().getColor(R.color.owncloud_blue_dark_transparent)); @@ -162,9 +158,11 @@ private void initViewPager() { // this is necessary because mViewPager.setCurrentItem(0) does not trigger // a call to onPageSelected in the first layout request aftet mViewPager.setAdapter(...) ; // see, for example: - // https://android.googlesource.com/platform/frameworks/support.git/+/android-6.0.1_r55/v4/java/android/support/v4/view/ViewPager.java#541 + // https://android.googlesource.com/platform/frameworks/support.git/+/android-6.0 + // .1_r55/v4/java/android/support/v4/view/ViewPager.java#541 // ; or just: - // http://stackoverflow.com/questions/11794269/onpageselected-isnt-triggered-when-calling-setcurrentitem0 + // http://stackoverflow.com/questions/11794269/onpageselected-isnt-triggered-when-calling + // -setcurrentitem0 @Override public void run() { PreviewImageActivity.this.onPageSelected(mViewPager.getCurrentItem()); @@ -172,18 +170,17 @@ public void run() { }); } } - - - protected void onPostCreate(Bundle savedInstanceState) { + + protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); - + // Trigger the initial hide() shortly after the activity has been // created, to briefly hint to the user that UI controls // are available delayedHide(INITIAL_HIDE_DELAY); - + } - + Handler mHideSystemUiHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -191,31 +188,28 @@ public void handleMessage(Message msg) { getSupportActionBar().hide(); } }; - - private void delayedHide(int delayMillis) { + + private void delayedHide(int delayMillis) { mHideSystemUiHandler.removeMessages(0); mHideSystemUiHandler.sendEmptyMessageDelayed(0, delayMillis); } - - + /// handle Window Focus changes @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); - + // When the window loses focus (e.g. the action overflow is shown), // cancel any pending hide action. if (!hasFocus) { mHideSystemUiHandler.removeMessages(0); } } - - - + @Override public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { super.onRemoteOperationFinish(operation, result); - + if (operation instanceof RemoveFileOperation) { finish(); } else if (operation instanceof SynchronizeFileOperation) { @@ -223,7 +217,7 @@ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationRe } } - + private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) { if (result.isSuccess()) { @@ -241,7 +235,7 @@ private class PreviewImageServiceConnection implements ServiceConnection { @Override public void onServiceConnected(ComponentName component, IBinder service) { - + if (component.equals(new ComponentName(PreviewImageActivity.this, FileDownloader.class))) { Log_OC.d(TAG, "onServiceConnected, FileDownloader"); @@ -271,34 +265,32 @@ public void onServiceDisconnected(ComponentName component) { } } - @Override public boolean onOptionsItemSelected(MenuItem item) { boolean returnValue; - - switch(item.getItemId()){ - case android.R.id.home: - if (isDrawerOpen()) { - closeDrawer(); - } else { - backToDisplayActivity(); - } - returnValue = true; - break; - default: - returnValue = super.onOptionsItemSelected(item); + + switch (item.getItemId()) { + case android.R.id.home: + if (isDrawerOpen()) { + closeDrawer(); + } else { + backToDisplayActivity(); + } + returnValue = true; + break; + default: + returnValue = super.onOptionsItemSelected(item); } - + return returnValue; } - @Override protected void onResume() { super.onResume(); mDownloadFinishReceiver = new DownloadFinishReceiver(); - + IntentFilter filter = new IntentFilter(FileDownloader.getDownloadFinishMessage()); filter.addAction(FileDownloader.getDownloadAddedMessage()); mLocalBroadcastManager.registerReceiver(mDownloadFinishReceiver, filter); @@ -306,19 +298,18 @@ protected void onResume() { @Override public void onPause() { - if (mDownloadFinishReceiver != null){ + if (mDownloadFinishReceiver != null) { mLocalBroadcastManager.unregisterReceiver(mDownloadFinishReceiver); mDownloadFinishReceiver = null; } - + super.onPause(); } - private void backToDisplayActivity() { finish(); } - + @Override public void showDetails(OCFile file) { Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class); @@ -332,7 +323,7 @@ public void showDetails(OCFile file) { /** * This method will be invoked when a new page becomes selected. Animation is not necessarily * complete. - * + * * @param position Position index of the new selected page */ @Override @@ -365,11 +356,11 @@ public void run() { }); } } - + /** * Called when the scroll state changes. Useful for discovering when the user begins dragging, * when the pager is automatically settling to the current page. when it is fully stopped/idle. - * + * * @param state The new scroll state (SCROLL_STATE_IDLE, _DRAGGING, _SETTLING */ @Override @@ -379,11 +370,11 @@ public void onPageScrollStateChanged(int state) { /** * This method will be invoked when the current page is scrolled, either as part of a * programmatically initiated smooth scroll or a user initiated touch scroll. - * + * * @param position Position index of the first page currently being displayed. * Page position+1 will be visible if positionOffset is * nonzero. - * + * * @param positionOffset Value from [0, 1) indicating the offset from the page * at position. * @param positionOffsetPixels Value in pixels indicating the offset from position. @@ -391,11 +382,10 @@ public void onPageScrollStateChanged(int state) { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } - /** * Class waiting for broadcast events from the {@link FileDownloader} service. - * + * * Updates the UI when a download is started or finished, provided that it is relevant for the * folder displayed in the gallery. */ @@ -404,14 +394,14 @@ private class DownloadFinishReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { String accountName = intent.getStringExtra(Extras.EXTRA_ACCOUNT_NAME); String downloadedRemotePath = intent.getStringExtra(Extras.EXTRA_REMOTE_PATH); - if (getAccount().name.equals(accountName) && + if (getAccount().name.equals(accountName) && downloadedRemotePath != null) { OCFile file = getStorageManager().getFileByPath(downloadedRemotePath); mPreviewImagePagerAdapter.onDownloadEvent( - file, - intent.getAction(), - intent.getBooleanExtra(Extras.EXTRA_DOWNLOAD_RESULT, false) + file, + intent.getAction(), + intent.getBooleanExtra(Extras.EXTRA_DOWNLOAD_RESULT, false) ); } } @@ -419,7 +409,7 @@ public void onReceive(Context context, Intent intent) { } @SuppressLint("InlinedApi") - public void toggleFullScreen() { + public void toggleFullScreen() { boolean visible = (mFullScreenAnchorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; @@ -444,11 +434,12 @@ protected void onAccountSet(boolean stateWasRecovered) { if (!file.isImage()) { throw new IllegalArgumentException("Non-image file passed as argument"); } - + // Update file according to DB file, if it is possible - if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID) + if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID) { file = getStorageManager().getFileById(file.getFileId()); - + } + if (file != null) { /// Refresh the activity according to the Account and OCFile set setFile(file); // reset after getting it fresh from storageManager @@ -465,32 +456,32 @@ protected void onAccountSet(boolean stateWasRecovered) { @Override public void onBrowsedDownTo(OCFile folder) { // TODO Auto-generated method stub - + } @SuppressLint("InlinedApi") - private void hideSystemUI(View anchorView) { + private void hideSystemUI(View anchorView) { anchorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hides NAVIGATION BAR; Android >= 4.0 - | View.SYSTEM_UI_FLAG_FULLSCREEN // hides STATUS BAR; Android >= 4.1 - | View.SYSTEM_UI_FLAG_IMMERSIVE // stays interactive; Android >= 4.4 - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4.1 + | View.SYSTEM_UI_FLAG_FULLSCREEN // hides STATUS BAR; Android >= 4.1 + | View.SYSTEM_UI_FLAG_IMMERSIVE // stays interactive; Android >= 4.4 + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1 + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4.1 ); } - + @SuppressLint("InlinedApi") private void showSystemUI(View anchorView) { anchorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4.1 + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4.1 ); } @Override - public void allFilesOption(){ + public void allFilesOption() { backToDisplayActivity(); super.allFilesOption(); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index 4542cb90700..bad8bd9dd6a 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -1,23 +1,22 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author David González Verdugo - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author David González Verdugo + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.preview; @@ -26,8 +25,6 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; -import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentStatePagerAdapter; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -37,6 +34,8 @@ import android.widget.ProgressBar; import android.widget.TextView; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentStatePagerAdapter; import com.bumptech.glide.Glide; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.engine.GlideException; @@ -57,7 +56,6 @@ import java.io.File; - /** * This fragment shows a preview of a downloaded image. * @@ -100,7 +98,7 @@ public class PreviewImageFragment extends FileFragment { * @param ignoreFirstSavedState Flag to work around an unexpected behaviour of * {@link FragmentStatePagerAdapter} * ; TODO better solution - * @return Fragment ready to be used. + * @return Fragment ready to be used. */ public static PreviewImageFragment newInstance( OCFile file, @@ -116,8 +114,6 @@ public static PreviewImageFragment newInstance( return frag; } - - /** * Creates an empty fragment for image previews. * @@ -140,14 +136,13 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); setFile(args.getParcelable(ARG_FILE)); - // TODO better in super, but needs to check ALL the class extending FileFragment; - // not right now + // TODO better in super, but needs to check ALL the class extending FileFragment; + // not right now mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST); setHasOptionsMenu(true); } - /** * {@inheritDoc} */ @@ -165,7 +160,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mImageView = view.findViewById(R.id.photo_view); mImageView.setVisibility(View.GONE); mImageView.setOnClickListener(v -> { - if(getActivity() != null) { + if (getActivity() != null) { ((PreviewImageActivity) getActivity()).toggleFullScreen(); } }); @@ -206,7 +201,6 @@ public void onActivityCreated(Bundle savedInstanceState) { } } - /** * {@inheritDoc} */ @@ -216,7 +210,6 @@ public void onSaveInstanceState(Bundle outState) { outState.putParcelable(PreviewImageFragment.EXTRA_FILE, getFile()); } - @Override public void onStart() { super.onStart(); @@ -254,10 +247,10 @@ public void onPrepareOptionsMenu(Menu menu) { setFile(mContainerActivity.getStorageManager().getFileById(getFile().getFileId())); FileMenuFilter mf = new FileMenuFilter( - getFile(), - mContainerActivity.getStorageManager().getAccount(), - mContainerActivity, - getActivity() + getFile(), + mContainerActivity.getStorageManager().getAccount(), + mContainerActivity, + getActivity() ); mf.filter(menu, false, false); } @@ -294,7 +287,6 @@ public void onPrepareOptionsMenu(Menu menu) { } - /** * {@inheritDoc} */ @@ -326,11 +318,11 @@ public boolean onOptionsItemSelected(MenuItem item) { mContainerActivity.getFileOperationsHelper().syncFile(getFile()); return true; } - case R.id.action_set_available_offline:{ + case R.id.action_set_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), true); return true; } - case R.id.action_unset_available_offline:{ + case R.id.action_unset_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), false); return true; } @@ -339,7 +331,6 @@ public boolean onOptionsItemSelected(MenuItem item) { } } - private void seeDetails() { mContainerActivity.showDetails(getFile()); } @@ -349,14 +340,13 @@ public void onDestroy() { if (mBitmap != null) { mBitmap.recycle(); System.gc(); - // putting this in onStop() is just the same; the fragment is always destroyed by - // {@link FragmentStatePagerAdapter} when the fragment in swiped further than the - // valid offscreen distance, and onStop() is never called before than that + // putting this in onStop() is just the same; the fragment is always destroyed by + // {@link FragmentStatePagerAdapter} when the fragment in swiped further than the + // valid offscreen distance, and onStop() is never called before than that } super.onDestroy(); } - /** * Opens the previewed image with an external application. */ @@ -365,7 +355,6 @@ private void openFile() { finish(); } - @Override public void onTransferServiceConnected() { if (mProgressController != null) { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImagePagerAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImagePagerAdapter.java index f01b658df51..385fc4bb1fa 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImagePagerAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImagePagerAdapter.java @@ -20,19 +20,12 @@ */ package com.owncloud.android.ui.preview; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - import android.accounts.Account; +import android.view.ViewGroup; + import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; -import android.view.ViewGroup; - import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileDownloader; @@ -40,6 +33,13 @@ import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.utils.FileStorageUtils; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + /** * Adapter class that provides Fragment instances */ @@ -85,7 +85,8 @@ public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFo // TODO Enable when "On Device" is recovered ? mImageFiles = mStorageManager.getFolderImages(parentFolder/*, false*/); - mImageFiles = FileStorageUtils.sortFolder(mImageFiles, FileStorageUtils.mSortOrderFileDisp, FileStorageUtils.mSortAscendingFileDisp); + mImageFiles = FileStorageUtils.sortFolder(mImageFiles, FileStorageUtils.mSortOrderFileDisp, + FileStorageUtils.mSortAscendingFileDisp); mObsoleteFragments = new HashSet<>(); mObsoletePositions = new HashSet<>(); @@ -103,7 +104,6 @@ protected OCFile getFileAt(int position) { return mImageFiles.get(position); } - public Fragment getItem(int i) { OCFile file = mImageFiles.get(i); Fragment fragment; @@ -142,7 +142,6 @@ public CharSequence getPageTitle(int position) { return mImageFiles.get(position).getFileName(); } - private void updateFile(int position, OCFile file) { FileFragment fragmentToUpdate = mCachedFragments.get(position); if (fragmentToUpdate != null) { @@ -152,7 +151,6 @@ private void updateFile(int position, OCFile file) { mImageFiles.set(position, file); } - private void updateWithDownloadError(int position) { FileFragment fragmentToUpdate = mCachedFragments.get(position); if (fragmentToUpdate != null) { @@ -177,7 +175,6 @@ public void clearErrorAt(int position) { mDownloadErrors.remove(position); } - @Override public int getItemPosition(Object object) { if (mObsoleteFragments.contains(object)) { @@ -187,7 +184,6 @@ public int getItemPosition(Object object) { return super.getItemPosition(object); } - @Override public Object instantiateItem(ViewGroup container, int position) { Object fragment = super.instantiateItem(container, position); @@ -201,7 +197,6 @@ public void destroyItem(ViewGroup container, int position, Object object) { super.destroyItem(container, position, object); } - public boolean pendingErrorAt(int position) { return mDownloadErrors.contains(position); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java index bf86ef6eeeb..f65c468503b 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java @@ -1,21 +1,20 @@ /** - * ownCloud Android client application - * - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.preview; @@ -23,9 +22,6 @@ import android.accounts.Account; import android.os.AsyncTask; import android.os.Bundle; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -35,6 +31,9 @@ import android.widget.ProgressBar; import android.widget.TextView; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -68,17 +67,16 @@ public class PreviewTextFragment extends FileFragment { private TextView mTextPreview; private TextLoadAsyncTask mTextLoadTask; - /** * Public factory method to create new PreviewTextFragment instances. * * @param file An {@link OCFile} to preview in the fragment * @param account ownCloud account containing file - * @return Fragment ready to be used. + * @return Fragment ready to be used. */ public static PreviewTextFragment newInstance( - OCFile file, - Account account + OCFile file, + Account account ) { PreviewTextFragment frag = new PreviewTextFragment(); Bundle args = new Bundle(); @@ -179,7 +177,6 @@ private void loadAndShowTextPreview() { mTextLoadTask.execute(getFile().getStoragePath()); } - /** * Reads the file to preview and shows its contents. Too critical to be anonymous. */ @@ -191,7 +188,6 @@ private TextLoadAsyncTask(WeakReference textView) { mTextViewReference = textView; } - @Override protected void onPreExecute() { showLoadingDialog(); @@ -200,7 +196,8 @@ protected void onPreExecute() { @Override protected StringWriter doInBackground(java.lang.Object... params) { if (params.length != 1) { - throw new IllegalArgumentException("The parameter to " + TextLoadAsyncTask.class.getName() + " must be (1) the file location"); + throw new IllegalArgumentException("The parameter to " + TextLoadAsyncTask.class.getName() + " must " + + "be (1) the file location"); } final String location = (String) params[0]; @@ -213,11 +210,15 @@ protected StringWriter doInBackground(java.lang.Object... params) { sc = new Scanner(inputStream); while (sc.hasNextLine()) { bufferedWriter.append(sc.nextLine()); - if (sc.hasNextLine()) bufferedWriter.append("\n"); + if (sc.hasNextLine()) { + bufferedWriter.append("\n"); + } } bufferedWriter.close(); IOException exc = sc.ioException(); - if (exc != null) throw exc; + if (exc != null) { + throw exc; + } } catch (IOException e) { Log_OC.e(TAG, e.getMessage(), e); } finally { @@ -345,7 +346,7 @@ public void onPrepareOptionsMenu(Menu menu) { } item = menu.findItem(R.id.action_switch_view); - if (item != null){ + if (item != null) { item.setVisible(false); item.setEnabled(false); } @@ -394,11 +395,11 @@ public boolean onOptionsItemSelected(MenuItem item) { mContainerActivity.getFileOperationsHelper().syncFile(getFile()); return true; } - case R.id.action_set_available_offline:{ + case R.id.action_set_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), true); return true; } - case R.id.action_unset_available_offline:{ + case R.id.action_unset_available_offline: { mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(getFile(), false); return true; } @@ -461,7 +462,6 @@ public void updateViewForSyncOff() { mProgressController.hideProgressBar(); } - /** * Opens the previewed file with an external application. */ diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java index b29b250b3c6..98dbac08bd5 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java @@ -5,16 +5,16 @@ * @author David González Verdugo * @author Christian Schabesberger * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -25,11 +25,11 @@ import android.content.Intent; import android.os.Bundle; import android.os.Handler; -import androidx.appcompat.app.AlertDialog; import android.view.View; import android.widget.ImageButton; import android.widget.ProgressBar; +import androidx.appcompat.app.AlertDialog; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.ExoPlaybackException; @@ -109,7 +109,6 @@ public void onClick(View v) { } }); - Bundle extras = getIntent().getExtras(); mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoError.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoError.java index 90fd7466966..fb3dca900d0 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoError.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoError.java @@ -1,22 +1,21 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author David González Verdugo - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author David González Verdugo + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.preview; @@ -35,16 +34,14 @@ public class PreviewVideoError { // Error should trigger the preview file parent folder synchronization private boolean parentFolderSyncNeeded; - public PreviewVideoError(String errorMessage, boolean fileSyncNeeded, - boolean parentFolderSyncNeeded) { + boolean parentFolderSyncNeeded) { this.errorMessage = errorMessage; this.fileSyncNeeded = fileSyncNeeded; this.parentFolderSyncNeeded = parentFolderSyncNeeded; } - public String getErrorMessage() { return errorMessage; } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoErrorAdapter.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoErrorAdapter.java index 20850cba6b9..c9b6d9ba3de 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoErrorAdapter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoErrorAdapter.java @@ -44,8 +44,7 @@ public class PreviewVideoErrorAdapter { private static final int TEMPORARY_REDIRECTION = 302; /** - * - * @param error Exoplayer exception + * @param error Exoplayer exception * @param context * @return preview video error after processing the Exoplayer exception */ @@ -67,7 +66,7 @@ public static PreviewVideoError handlePreviewVideoError(ExoPlaybackException err /** * Handle video player source exceptions and create a PreviewVideoError with the appropriate info * - * @param error Exoplayer source exception + * @param error Exoplayer source exception * @param context * @return preview video error after processing the Exoplayer source exception */ @@ -78,44 +77,50 @@ private static PreviewVideoError handlePlayerSourceError(ExoPlaybackException er final IOException sourceException = error.getSourceException(); final Throwable cause = sourceException.getCause(); - if(cause != null) { - if(cause.getCause() instanceof CertificateException) + if (cause != null) { + if (cause.getCause() instanceof CertificateException) { return new PreviewVideoError( - context.getString(R.string.streaming_certificate_error), true,false); + context.getString(R.string.streaming_certificate_error), true, false); + } // Cannot connect with the server - if(sourceException.getCause() instanceof UnknownHostException) + if (sourceException.getCause() instanceof UnknownHostException) { return new PreviewVideoError( context.getString(R.string.network_error_socket_exception), false, false); + } // trying to access to a part of the video not available now; // ALSO: error obtained when (SAML) session expired while playing the video. To handle // this case, the parent folder is refreshed and login view is shown if (sourceException.getCause() != null && - sourceException.getCause() instanceof EOFException) + sourceException.getCause() instanceof EOFException) { return new PreviewVideoError( context.getString(R.string.streaming_position_not_available), false, true); + } } // Unsupported video file format // Important: this error is also thrown when the SAML session is expired an OC server // redirects to the IDP. // To handle this case, the parent folder is refreshed and login view is shown - if(sourceException instanceof UnrecognizedInputFormatException) + if (sourceException instanceof UnrecognizedInputFormatException) { return new PreviewVideoError( context.getString(R.string.streaming_unrecognized_input), true, true); + } if (sourceException instanceof HttpDataSource.InvalidResponseCodeException) { // Video file no longer exists in the server - if(((HttpDataSource.InvalidResponseCodeException) sourceException).responseCode == NOT_FOUND_ERROR) + if (((HttpDataSource.InvalidResponseCodeException) sourceException).responseCode == NOT_FOUND_ERROR) { return new PreviewVideoError( context.getString(R.string.streaming_file_not_found_error), false, false); + } // redirections are allowed, but crossed redirections not - if((((HttpDataSource.InvalidResponseCodeException) sourceException).responseCode == TEMPORARY_REDIRECTION)) + if ((((HttpDataSource.InvalidResponseCodeException) sourceException).responseCode == TEMPORARY_REDIRECTION)) { return new PreviewVideoError( - context.getString(R.string.streaming_crossed_redirection), true, false); + context.getString(R.string.streaming_crossed_redirection), true, false); + } } // if error could not be detected properly @@ -131,12 +136,11 @@ private static PreviewVideoError handlePlayerSourceError(ExoPlaybackException er * @return preview video error after processing the Exoplayer unexpected exception */ private static PreviewVideoError handlePlayerError(final String errorMessage, - Context context) { + Context context) { return (errorMessage != null) ? new PreviewVideoError(errorMessage, false, false) : new PreviewVideoError( - context.getString(R.string.previewing_video_common_error), false, false); + context.getString(R.string.previewing_video_common_error), false, false); } - } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java index cc16383ee6f..376c995ea36 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java @@ -5,16 +5,16 @@ * @author David González Verdugo * @author Christian Schabesberger * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -27,7 +27,6 @@ import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; -import androidx.appcompat.app.AlertDialog; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -37,6 +36,7 @@ import android.widget.ImageButton; import android.widget.ProgressBar; +import androidx.appcompat.app.AlertDialog; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlayer; @@ -65,7 +65,6 @@ import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.utils.DisplayUtils; - /** * This fragment shows a preview of a downloaded video file, or starts streaming if file is not * downloaded yet. @@ -135,7 +134,6 @@ public static PreviewVideoFragment newInstance( return frag; } - /** * Creates an empty fragment to preview video files. * @@ -151,7 +149,6 @@ public PreviewVideoFragment() { mAutoplay = true; } - // Fragment and activity lifecicle /** @@ -276,7 +273,7 @@ public void onSaveInstanceState(Bundle outState) { outState.putParcelable(PreviewVideoFragment.EXTRA_FILE, getFile()); outState.putParcelable(PreviewVideoFragment.EXTRA_ACCOUNT, mAccount); - if (player!= null) { + if (player != null) { outState.putBoolean(PreviewVideoFragment.EXTRA_AUTOPLAY, mAutoplay); outState.putLong(PreviewVideoFragment.EXTRA_PLAY_POSITION, player.getCurrentPosition()); } @@ -363,7 +360,7 @@ public void onPrepareOptionsMenu(Menu menu) { item.setEnabled(false); } - item = menu.findItem(R.id.action_switch_view); + item = menu.findItem(R.id.action_switch_view); if (item != null) { item.setVisible(false); item.setEnabled(false); @@ -431,7 +428,7 @@ public boolean onOptionsItemSelected(MenuItem item) { return true; } case R.id.action_cancel_sync: { - ((FileDisplayActivity)mContainerActivity).cancelTransference(getFile()); + ((FileDisplayActivity) mContainerActivity).cancelTransference(getFile()); return true; } default: @@ -519,7 +516,7 @@ private void showAlertDialog(final PreviewVideoError previewVideoError) { new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { - if (previewVideoError.isFileSyncNeeded() && mContainerActivity!= null) { + if (previewVideoError.isFileSyncNeeded() && mContainerActivity != null) { // Initialize the file download mContainerActivity.getFileOperationsHelper().syncFile(getFile()); } @@ -569,7 +566,6 @@ public void onTimelineChanged(Timeline timeline, Object manifest) { // Do nothing } - // File extra methods @Override public void onFileMetadataChanged(OCFile updatedFile) { @@ -600,13 +596,11 @@ public void onFileContentChanged() { } } - private void seeDetails() { releasePlayer(); mContainerActivity.showDetails(getFile()); } - @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/whatsnew/ProgressIndicator.java b/owncloudApp/src/main/java/com/owncloud/android/ui/whatsnew/ProgressIndicator.java index 95b4716ba6b..fd0c5ecfd3a 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/whatsnew/ProgressIndicator.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/whatsnew/ProgressIndicator.java @@ -1,22 +1,21 @@ /** - * ownCloud Android client application - * - * @author Bartosz Przybylski - * Copyright (C) 2019 Bartosz Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Bartosz Przybylski + * Copyright (C) 2019 Bartosz Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.ui.whatsnew; @@ -73,17 +72,19 @@ public void setNumberOfSteps(int steps) { } public void animateToStep(int step) { - if (step < 1 || step > mNumberOfSteps) return; + if (step < 1 || step > mNumberOfSteps) { + return; + } if (mCurrentStep != -1) { - ImageView prevDot = (ImageView) mDotsContainer.getChildAt(mCurrentStep-1); - TransitionDrawable transition = (TransitionDrawable)prevDot.getDrawable(); + ImageView prevDot = (ImageView) mDotsContainer.getChildAt(mCurrentStep - 1); + TransitionDrawable transition = (TransitionDrawable) prevDot.getDrawable(); transition.resetTransition(); } mCurrentStep = step; - ImageView dot = (ImageView)mDotsContainer.getChildAt(step-1); - TransitionDrawable transition = (TransitionDrawable)dot.getDrawable(); + ImageView dot = (ImageView) mDotsContainer.getChildAt(step - 1); + TransitionDrawable transition = (TransitionDrawable) dot.getDrawable(); transition.startTransition(500); } diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/BitmapUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/BitmapUtils.java index 5a6de22c1d2..9b55e0f1ea2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/BitmapUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/BitmapUtils.java @@ -1,38 +1,37 @@ /** - * ownCloud Android client application - * - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author David A. Velasco + * @author Christian Schabesberger + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; -import com.owncloud.android.authentication.AccountUtils; -import com.owncloud.android.lib.common.utils.Log_OC; - import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.graphics.Matrix; import android.graphics.BitmapFactory.Options; +import android.graphics.Matrix; import android.media.ExifInterface; import android.net.Uri; +import android.webkit.MimeTypeMap; + import androidx.core.graphics.drawable.RoundedBitmapDrawable; import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; -import android.webkit.MimeTypeMap; +import com.owncloud.android.authentication.AccountUtils; +import com.owncloud.android.lib.common.utils.Log_OC; import java.io.File; import java.io.UnsupportedEncodingException; @@ -41,25 +40,24 @@ import java.security.NoSuchAlgorithmException; import java.util.Locale; - /** * Utility class with methods for decoding Bitmaps. */ public class BitmapUtils { - + private static final String TAG = BitmapUtils.class.toString(); /** * Decodes a bitmap from a file containing it minimizing the memory use, known that the bitmap * will be drawn in a surface of reqWidth x reqHeight - * + * * @param srcPath Absolute path to the file containing the image. * @param reqWidth Width of the surface where the Bitmap will be drawn on, in pixels. * @param reqHeight Height of the surface where the Bitmap will be drawn on, in pixels. * @return */ public static Bitmap decodeSampledBitmapFromFile(String srcPath, int reqWidth, int reqHeight) { - + // set desired options that will affect the size of the bitmap final Options options = new Options(); options.inScaled = true; @@ -70,39 +68,38 @@ public static Bitmap decodeSampledBitmapFromFile(String srcPath, int reqWidth, i if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { options.inMutable = false; } - + // make a false load of the bitmap to get its dimensions options.inJustDecodeBounds = true; - - BitmapFactory.decodeFile(srcPath, options); - + + BitmapFactory.decodeFile(srcPath, options); + // calculate factor to subsample the bitmap options.inSampleSize = calculateSampleFactor(options, reqWidth, reqHeight); // decode bitmap with inSampleSize set options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(srcPath, options); - } - + } /** * Calculates a proper value for options.inSampleSize in order to decode a Bitmap minimizing * the memory overload and covering a target surface of reqWidth x reqHeight if the original * image is big enough. - * + * * @param options Bitmap decoding options; options.outHeight and options.inHeight should * be set. * @param reqWidth Width of the surface where the Bitmap will be drawn on, in pixels. * @param reqHeight Height of the surface where the Bitmap will be drawn on, in pixels. - * @return The largest inSampleSize value that is a power of 2 and keeps both + * @return The largest inSampleSize value that is a power of 2 and keeps both * height and width larger than reqWidth and reqHeight. */ private static int calculateSampleFactor(Options options, int reqWidth, int reqHeight) { - + final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; - + if (height > reqHeight || width > reqWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; @@ -114,7 +111,7 @@ private static int calculateSampleFactor(Options options, int reqWidth, int reqH inSampleSize *= 2; } } - + return inSampleSize; } @@ -125,16 +122,15 @@ private static int calculateSampleFactor(Options options, int reqWidth, int reqH * @param storagePath Path to source file of bitmap. Needed for EXIF information. * @return correctly EXIF-rotated bitmap */ - public static Bitmap rotateImage(final Bitmap bitmap, final String storagePath){ - try - { + public static Bitmap rotateImage(final Bitmap bitmap, final String storagePath) { + try { ExifInterface exifInterface = new ExifInterface(storagePath); final int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); Matrix matrix = new Matrix(); // 1: nothing to do - switch(orientation) { + switch (orientation) { case ExifInterface.ORIENTATION_FLIP_HORIZONTAL: matrix.postScale(-1.0f, 1.0f); break; @@ -161,24 +157,22 @@ public static Bitmap rotateImage(final Bitmap bitmap, final String storagePath){ } // Rotate the bitmap - final Bitmap resultBitmap =Bitmap.createBitmap(bitmap, 0, 0, + final Bitmap resultBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); if (resultBitmap != bitmap) { bitmap.recycle(); } return resultBitmap; - } - catch (Exception exception) - { + } catch (Exception exception) { Log_OC.e("BitmapUtil", "Could not rotate the image: " + storagePath); return bitmap; } } private static float fixRawHSLValue(final float value, final float upperBound, final float scale) { - return (value > upperBound) ? upperBound - :(value < 0f) ? 0f - : value * scale; + return (value > upperBound) ? upperBound + : (value < 0f) ? 0f + : value * scale; } /** @@ -191,8 +185,7 @@ private static float fixRawHSLValue(final float value, final float upperBound, f * adapted from https://svn.codehaus.org/griffon/builders/gfxbuilder/tags/GFXBUILDER_0.2/ * gfxbuilder-core/src/main/com/camick/awt/HSLColor.java */ - public static int[] HSLtoRGB(final float h, final float s, final float l, final float alpha) - { + public static int[] HSLtoRGB(final float h, final float s, final float l, final float alpha) { if (s < 0.0f || s > 100.0f) { Log_OC.w(TAG, "Color parameter outside of expected range - Saturation"); } @@ -201,15 +194,15 @@ public static int[] HSLtoRGB(final float h, final float s, final float l, final Log_OC.w(TAG, "Color parameter outside of expected range - Luminance"); } - if (alpha <0.0f || alpha > 1.0f) { + if (alpha < 0.0f || alpha > 1.0f) { Log_OC.w(TAG, "Color parameter outside of expected range - Alpha"); } // Formula needs all values between 0 - 1. final float hr = (h % 360.0f) / 360f; - final float sr = fixRawHSLValue(s, 100f, 1/100f); - final float lr = fixRawHSLValue(s, 100f, 1/100f); + final float sr = fixRawHSLValue(s, 100f, 1 / 100f); + final float lr = fixRawHSLValue(s, 100f, 1 / 100f); final float q = (lr < 0.5) ? lr * (1 + sr) @@ -222,16 +215,22 @@ public static int[] HSLtoRGB(final float h, final float s, final float l, final return new int[]{r, g, b}; } - private static float HueToRGB(final float p, final float q, final float h){ - final float hr = (h < 0) ? h + 1 - :(h > 1) ? h - 1 - : h; + private static float HueToRGB(final float p, final float q, final float h) { + final float hr = (h < 0) ? h + 1 + : (h > 1) ? h - 1 + : h; - if (6 * hr < 1) return p + ((q - p) * 6 * h); - if (2 * hr < 1 ) return q; - if (3 * hr < 2) return p + ( (q - p) * 6 * ((2.0f / 3.0f) - h) ); - return p; - } + if (6 * hr < 1) { + return p + ((q - p) * 6 * h); + } + if (2 * hr < 1) { + return q; + } + if (3 * hr < 2) { + return p + ((q - p) * 6 * ((2.0f / 3.0f) - h)); + } + return p; + } /** * Checks if file passed is an image diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java index c6d355a4af0..477ceca2ac2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java @@ -1,20 +1,20 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author David A. Velasco - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author David A. Velasco + * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; @@ -33,8 +33,8 @@ public static boolean isAppConnectedViaWiFi(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); boolean result = cm != null && cm.getActiveNetworkInfo() != null - && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI - && cm.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED; + && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI + && cm.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED; Log_OC.d(TAG, "is AppConnectedViaWifi returns " + result); return result; } @@ -46,7 +46,7 @@ public static boolean isAppConnected(Context context) { public static boolean isNetworkActive(Context context) { - ConnectivityManager cm = (ConnectivityManager)context. + ConnectivityManager cm = (ConnectivityManager) context. getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/DateUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/DateUtils.java index 9620a4b85c1..2801d634baf 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/DateUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/DateUtils.java @@ -1,20 +1,20 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author David González Verdugo - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author David González Verdugo + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; @@ -33,7 +33,7 @@ public class DateUtils { * @param days * @return */ - public static Date addDaysToDate (Date defaultDate, int days) { + public static Date addDaysToDate(Date defaultDate, int days) { Calendar c = Calendar.getInstance(); c.setTime(defaultDate); diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 4f87258e679..117478b903b 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -29,14 +29,14 @@ import android.graphics.Point; import android.graphics.PorterDuff; import android.os.Build; -import com.google.android.material.snackbar.Snackbar; -import androidx.core.content.ContextCompat; import android.text.format.DateUtils; import android.view.Display; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.SeekBar; +import androidx.core.content.ContextCompat; +import com.google.android.material.snackbar.Snackbar; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; @@ -123,8 +123,9 @@ public static String convertMIMEtoPrettyPrint(String mimetype) { if (mimeType2HumanReadable.containsKey(mimetype)) { return mimeType2HumanReadable.get(mimetype); } - if (mimetype.split("/").length >= 2) + if (mimetype.split("/").length >= 2) { return mimetype.split("/")[1].toUpperCase() + " file"; + } return "Unknown type"; } @@ -240,7 +241,6 @@ public static String getPathWithoutLastSlash(String path) { return path; } - /** * Gets the screen size in pixels in a backwards compatible way * diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/Extras.java b/owncloudApp/src/main/java/com/owncloud/android/utils/Extras.java index 2174069d1fa..0ae5abbd1d7 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/Extras.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/Extras.java @@ -1,22 +1,22 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author David A. Velasco - * @author David González Verdugo - * - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author David A. Velasco + * @author David González Verdugo + *

+ * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/FileStorageUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/FileStorageUtils.java index 125646c0fc9..2a34467347c 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/FileStorageUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/FileStorageUtils.java @@ -37,6 +37,7 @@ import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.RemoteFile; +import third_parties.daveKoeller.AlphanumComparator; import java.io.File; import java.util.ArrayList; @@ -44,9 +45,6 @@ import java.util.Comparator; import java.util.Vector; -import third_parties.daveKoeller.AlphanumComparator; - - /** * Static methods to help in access to local file system. */ diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/MimetypeIconUtil.java b/owncloudApp/src/main/java/com/owncloud/android/utils/MimetypeIconUtil.java index 520b637707c..1838aaacca6 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/MimetypeIconUtil.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/MimetypeIconUtil.java @@ -1,20 +1,19 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; @@ -107,7 +106,7 @@ public static int getFolderTypeIconId(boolean isSharedViaUsers, boolean isShared * into account the MIME types known by ownCloud first. * * @param filename Name of file - * @return A single MIME type, "application/octet-stream" for unknown file extensions. + * @return A single MIME type, "application/octet-stream" for unknown file extensions. */ public static String getBestMimeTypeByFilename(String filename) { List candidates = determineMimeTypesByFilename(filename); @@ -230,13 +229,20 @@ private static void populateMimeTypeIconMapping() { MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.text-master", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.text-template", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.text-web", R.drawable.file_doc); - MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.presentation", R.drawable.file_ppt); - MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.slideshow", R.drawable.file_ppt); - MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.template", R.drawable.file_ppt); - MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", R.drawable.file_xls); - MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.spreadsheetml.template", R.drawable.file_xls); - MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", R.drawable.file_doc); - MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.template", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.presentation", + R.drawable.file_ppt); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.slideshow", + R.drawable.file_ppt); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.template", + R.drawable.file_ppt); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + R.drawable.file_xls); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.spreadsheetml.template", + R.drawable.file_xls); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", + R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.template", + R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/x-7z-compressed", R.drawable.file_zip); MIMETYPE_TO_ICON_MAPPING.put("application/x-bin", R.drawable.file_application); MIMETYPE_TO_ICON_MAPPING.put("application/x-cbr", R.drawable.file_text); @@ -300,7 +306,8 @@ private static void populateFileExtensionMimeTypeMapping() { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("7z", Collections.singletonList("application/x-7z-compressed")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("accdb", Collections.singletonList("application/msaccess")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ai", Collections.singletonList("application/illustrator")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("apk", Collections.singletonList("application/vnd.android.package-archive")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("apk", Collections.singletonList("application/vnd.android" + + ".package-archive")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("arw", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("avi", Collections.singletonList("video/x-msvideo")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bash", Collections.singletonList("text/x-shellscript")); @@ -329,10 +336,13 @@ private static void populateFileExtensionMimeTypeMapping() { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("deb", Collections.singletonList("application/x-deb")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dng", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("doc", Collections.singletonList("application/msword")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("docm", Collections.singletonList("application/vnd.ms-word.document.macroEnabled.12")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("docx", Collections.singletonList("application/vnd.openxmlformats-officedocument.wordprocessingml.document")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("docm", Collections.singletonList("application/vnd.ms-word.document" + + ".macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("docx", Collections.singletonList("application/vnd" + + ".openxmlformats-officedocument.wordprocessingml.document")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dot", Collections.singletonList("application/msword")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dotx", Collections.singletonList("application/vnd.openxmlformats-officedocument.wordprocessingml.template")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dotx", Collections.singletonList("application/vnd" + + ".openxmlformats-officedocument.wordprocessingml.template")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dv", Collections.singletonList("video/dv")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("eot", Collections.singletonList("application/vnd.ms-fontobject")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("epub", Collections.singletonList("application/epub+zip")); @@ -360,7 +370,8 @@ private static void populateFileExtensionMimeTypeMapping() { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("k25", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kdc", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("key", Collections.singletonList("application/x-iwork-keynote-sffkey")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("keynote", Collections.singletonList("application/x-iwork-keynote-sffkey")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("keynote", Collections.singletonList("application/x-iwork-keynote" + + "-sffkey")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kra", Collections.singletonList("application/x-krita")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m2t", Collections.singletonList("video/mp2t")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m4v", Collections.singletonList("video/mp4")); @@ -383,19 +394,26 @@ private static void populateFileExtensionMimeTypeMapping() { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mts", Collections.singletonList("video/MP2T")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mt2s", Collections.singletonList("video/MP2T")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("nef", Collections.singletonList("image/x-dcraw")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("numbers", Collections.singletonList("application/x-iwork-numbers-sffnumbers")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odf", Collections.singletonList("application/vnd.oasis.opendocument.formula")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odg", Collections.singletonList("application/vnd.oasis.opendocument.graphics")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odp", Collections.singletonList("application/vnd.oasis.opendocument.presentation")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ods", Collections.singletonList("application/vnd.oasis.opendocument.spreadsheet")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odt", Collections.singletonList("application/vnd.oasis.opendocument.text")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("numbers", Collections.singletonList("application/x-iwork-numbers" + + "-sffnumbers")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odf", Collections.singletonList("application/vnd.oasis.opendocument" + + ".formula")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odg", Collections.singletonList("application/vnd.oasis.opendocument" + + ".graphics")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odp", Collections.singletonList("application/vnd.oasis.opendocument" + + ".presentation")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ods", Collections.singletonList("application/vnd.oasis.opendocument" + + ".spreadsheet")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odt", Collections.singletonList("application/vnd.oasis.opendocument" + + ".text")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("oga", Collections.singletonList("audio/ogg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ogg", Collections.singletonList("audio/ogg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ogv", Collections.singletonList("video/ogg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("opus", Collections.singletonList("audio/ogg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("orf", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("otf", Collections.singletonList("application/font-sfnt")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pages", Collections.singletonList("application/x-iwork-pages-sffpages")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pages", Collections.singletonList("application/x-iwork-pages-sffpages" + )); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pdf", Collections.singletonList("application/pdf")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pfb", Collections.singletonList("application/x-font")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pef", Collections.singletonList("image/x-dcraw")); @@ -403,16 +421,23 @@ private static void populateFileExtensionMimeTypeMapping() { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pl", Collections.singletonList("application/x-perl")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("png", Collections.singletonList("image/png")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pot", Collections.singletonList("application/vnd.ms-powerpoint")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("potm", Collections.singletonList("application/vnd.ms-powerpoint.template.macroEnabled.12")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("potx", Collections.singletonList("application/vnd.openxmlformats-officedocument.presentationml.template")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("potm", Collections.singletonList("application/vnd.ms-powerpoint" + + ".template.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("potx", Collections.singletonList("application/vnd" + + ".openxmlformats-officedocument.presentationml.template")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppa", Collections.singletonList("application/vnd.ms-powerpoint")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppam", Collections.singletonList("application/vnd.ms-powerpoint.addin.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppam", Collections.singletonList("application/vnd.ms-powerpoint.addin" + + ".macroEnabled.12")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pps", Collections.singletonList("application/vnd.ms-powerpoint")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppsm", Collections.singletonList("application/vnd.ms-powerpoint.slideshow.macroEnabled.12")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppsx", Collections.singletonList("application/vnd.openxmlformats-officedocument.presentationml.slideshow")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppsm", Collections.singletonList("application/vnd.ms-powerpoint" + + ".slideshow.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppsx", Collections.singletonList("application/vnd" + + ".openxmlformats-officedocument.presentationml.slideshow")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppt", Collections.singletonList("application/vnd.ms-powerpoint")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pptm", Collections.singletonList("application/vnd.ms-powerpoint.presentation.macroEnabled.12")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pptx", Collections.singletonList("application/vnd.openxmlformats-officedocument.presentationml.presentation")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pptm", Collections.singletonList("application/vnd.ms-powerpoint" + + ".presentation.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pptx", Collections.singletonList("application/vnd" + + ".openxmlformats-officedocument.presentationml.presentation")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ps", Collections.singletonList("application/postscript")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("psd", Collections.singletonList("application/x-photoshop")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("py", Collections.singletonList("text/x-python")); @@ -427,7 +452,8 @@ private static void populateFileExtensionMimeTypeMapping() { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("srf", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sr2", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("svg", Arrays.asList("image/svg+xml", "text/plain")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("swf", Arrays.asList("application/x-shockwave-flash", "application/octet-stream")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("swf", Arrays.asList("application/x-shockwave-flash", "application" + + "/octet-stream")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tar", Collections.singletonList("application/x-tar")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gz", Collections.singletonList("application/x-compressed")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tex", Collections.singletonList("application/x-tex")); @@ -445,14 +471,20 @@ private static void populateFileExtensionMimeTypeMapping() { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("wmv", Collections.singletonList("video/x-ms-wmv")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xcf", Collections.singletonList("application/x-gimp")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xla", Collections.singletonList("application/vnd.ms-excel")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlam", Collections.singletonList("application/vnd.ms-excel.addin.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlam", Collections.singletonList("application/vnd.ms-excel.addin" + + ".macroEnabled.12")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xls", Collections.singletonList("application/vnd.ms-excel")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsb", Collections.singletonList("application/vnd.ms-excel.sheet.binary.macroEnabled.12")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsm", Collections.singletonList("application/vnd.ms-excel.sheet.macroEnabled.12")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsx", Collections.singletonList("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsb", Collections.singletonList("application/vnd.ms-excel.sheet" + + ".binary.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsm", Collections.singletonList("application/vnd.ms-excel.sheet" + + ".macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsx", Collections.singletonList("application/vnd" + + ".openxmlformats-officedocument.spreadsheetml.sheet")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlt", Collections.singletonList("application/vnd.ms-excel")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xltm", Collections.singletonList("application/vnd.ms-excel.template.macroEnabled.12")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xltx", Collections.singletonList("application/vnd.openxmlformats-officedocument.spreadsheetml.template")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xltm", Collections.singletonList("application/vnd.ms-excel.template" + + ".macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xltx", Collections.singletonList("application/vnd" + + ".openxmlformats-officedocument.spreadsheetml.template")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xml", Arrays.asList("application/xml", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xrf", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("yaml", Arrays.asList("application/yaml", "text/plain")); diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/OwnCloudSession.java b/owncloudApp/src/main/java/com/owncloud/android/utils/OwnCloudSession.java index 5742b30e7db..3b30680e970 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/OwnCloudSession.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/OwnCloudSession.java @@ -1,22 +1,21 @@ /** - * ownCloud Android client application - * - * @author Bartek Przybylski - * Copyright (C) 2011 Bartek Przybylski - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Bartek Przybylski + * Copyright (C) 2011 Bartek Przybylski + * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/PermissionUtil.java b/owncloudApp/src/main/java/com/owncloud/android/utils/PermissionUtil.java index aa8695cfb73..2a5b38659ea 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/PermissionUtil.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/PermissionUtil.java @@ -3,6 +3,7 @@ import android.Manifest; import android.app.Activity; import android.content.Context; + import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -17,7 +18,6 @@ public class PermissionUtil { * Determine whether the app has been granted a particular permission. * * @param permission The name of the permission being checked. - * * @return true if app has the permission, or false if not. */ public static boolean checkSelfPermission(Context context, String permission) { @@ -32,7 +32,7 @@ public static boolean checkSelfPermission(Context context, String permission) { * which the permission is requested does not clearly communicate to the user * what would be the benefit from granting this permission. * - * @param activity The target activity. + * @param activity The target activity. * @param permission A permission to be requested. * @return Whether to show permission rationale UI. */ diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/PowerUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/PowerUtils.java index eab3719ff9d..27b50f3442b 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/PowerUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/PowerUtils.java @@ -1,20 +1,20 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author David A. Velasco - * Copyright (C) 2017 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author David A. Velasco + * Copyright (C) 2017 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; @@ -27,8 +27,8 @@ public class PowerUtils { public static boolean isDeviceIdle(Context context) { return ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && - ((PowerManager)context.getSystemService(Context.POWER_SERVICE)).isDeviceIdleMode() + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && + ((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isDeviceIdleMode() ); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/PreferenceUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/PreferenceUtils.java index 825820826c9..1bc06c91a02 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/PreferenceUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/PreferenceUtils.java @@ -3,16 +3,16 @@ * * @author David González Verdugo * Copyright (C) 2019 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/SecurityUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/SecurityUtils.java index 0752ed38819..61bed362e29 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/SecurityUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/SecurityUtils.java @@ -1,20 +1,20 @@ /** - * ownCloud Android client application + * ownCloud Android client application * - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * @author David González Verdugo + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; @@ -35,7 +35,7 @@ public static String stringToMD5Hash(String stringToTransform) { try { messageDigest = MessageDigest.getInstance("MD5"); - messageDigest.update(stringToTransform.getBytes(),0,stringToTransform.length()); + messageDigest.update(stringToTransform.getBytes(), 0, stringToTransform.length()); hash = new BigInteger(1, messageDigest.digest()).toString(16); } catch (NoSuchAlgorithmException e) { Log_OC.d(TAG, "It's been not possible to generate the MD5 hash because of " + e); diff --git a/owncloudApp/src/main/java/com/owncloud/android/utils/UriUtils.java b/owncloudApp/src/main/java/com/owncloud/android/utils/UriUtils.java index 5b87a001d64..f8c40408d71 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/utils/UriUtils.java +++ b/owncloudApp/src/main/java/com/owncloud/android/utils/UriUtils.java @@ -1,20 +1,19 @@ /** - * ownCloud Android client application - * - * Copyright (C) 2016 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * + * ownCloud Android client application + *

+ * Copyright (C) 2016 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.utils; @@ -33,7 +32,6 @@ import com.owncloud.android.lib.common.utils.Log_OC; - /** * A helper class for some Uri operations. */ @@ -42,12 +40,11 @@ public class UriUtils { public static final String TAG = UriUtils.class.getSimpleName(); public static final String URI_CONTENT_SCHEME = "content://"; - - + /** * Get the value of the data column for this Uri. This is useful for * MediaStore Uris, and other file-based ContentProviders. - * + * * @param context The context. * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. @@ -58,7 +55,7 @@ public static String getDataColumn(Context context, Uri uri, String selection, S Cursor cursor = null; final String column = "_data"; - final String[] projection = { column }; + final String[] projection = {column}; try { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); @@ -68,8 +65,9 @@ public static String getDataColumn(Context context, Uri uri, String selection, S return cursor.getString(column_index); } } finally { - if (cursor != null) + if (cursor != null) { cursor.close(); + } } return null; } @@ -107,7 +105,7 @@ public static boolean isGooglePhotosUri(Uri uri) { } /** - * + * * @param uri The Uri to check. * @return Whether the Uri is from a content provider as kind "content://..." */ @@ -115,12 +113,11 @@ public static boolean isContentDocument(Uri uri) { return uri.toString().startsWith(URI_CONTENT_SCHEME); } - /** * Translates a content:// URI referred to a local file file to a path on the local filesystem * * @param uri The URI to resolve - * @return The path in the file system to the content or null if it could not be found (not a file) + * @return The path in the file system to the content or null if it could not be found (not a file) */ @TargetApi(Build.VERSION_CODES.KITKAT) public static String getLocalPath(Uri uri, Context context) { @@ -163,7 +160,7 @@ else if (UriUtils.isMediaDocument(uri)) { } final String selection = "_id=?"; - final String[] selectionArgs = new String[] { split[1] }; + final String[] selectionArgs = new String[]{split[1]}; return UriUtils.getDataColumn(context, contentUri, selection, selectionArgs); } @@ -176,8 +173,9 @@ else if (UriUtils.isContentDocument(uri)) { else if ("content".equalsIgnoreCase(uri.getScheme())) { // Return the remote address - if (UriUtils.isGooglePhotosUri(uri)) + if (UriUtils.isGooglePhotosUri(uri)) { return uri.getLastPathSegment(); + } return UriUtils.getDataColumn(context, uri, null, null); } @@ -188,8 +186,6 @@ else if ("file".equalsIgnoreCase(uri.getScheme())) { return null; } - - public static String getDisplayNameForUri(Uri uri, Context context) { if (uri == null || context == null) { @@ -215,7 +211,7 @@ public static String getDisplayNameForUri(Uri uri, Context context) { // Add best possible extension int index = displayName.lastIndexOf("."); if (index == -1 || MimeTypeMap.getSingleton(). - getMimeTypeFromExtension(displayName.substring(index + 1)) == null) { + getMimeTypeFromExtension(displayName.substring(index + 1)) == null) { String mimeType = context.getContentResolver().getType(uri); String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType); if (extension != null) { @@ -232,7 +228,6 @@ public static String getDisplayNameForUri(Uri uri, Context context) { return displayName.replaceAll("/", "-"); } - private static String getDisplayNameFromContentResolver(Uri uri, Context context) { String displayName = null; String mimeType = context.getContentResolver().getType(uri); @@ -254,11 +249,11 @@ private static String getDisplayNameFromContentResolver(Uri uri, Context context Cursor cursor = null; try { cursor = context.getContentResolver().query( - uri, - new String[]{displayNameColumn}, - null, - null, - null + uri, + new String[]{displayNameColumn}, + null, + null, + null ); if (cursor != null) { cursor.moveToFirst(); @@ -278,5 +273,4 @@ private static String getDisplayNameFromContentResolver(Uri uri, Context context return displayName; } - } diff --git a/owncloudApp/src/main/java/com/owncloud/android/widgets/ActionEditText.java b/owncloudApp/src/main/java/com/owncloud/android/widgets/ActionEditText.java index 2525f97fae8..5df72d498cb 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/widgets/ActionEditText.java +++ b/owncloudApp/src/main/java/com/owncloud/android/widgets/ActionEditText.java @@ -1,42 +1,41 @@ /** - * ownCloud Android client application - * - * @author Bartek Przybylski - * @author Christian Schabesberger - * Copyright (C) 2012 Bartek Przybylski - * Copyright (C) 2019 ownCloud GmbH. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * ownCloud Android client application * + * @author Bartek Przybylski + * @author Christian Schabesberger + * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2019 ownCloud GmbH. + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.owncloud.android.widgets; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import com.owncloud.android.R; - import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; -import androidx.appcompat.widget.AppCompatEditText; import android.util.AttributeSet; import android.view.MotionEvent; +import androidx.appcompat.widget.AppCompatEditText; +import com.owncloud.android.R; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + public class ActionEditText extends AppCompatEditText { private String s; private String optionOneString; @@ -79,10 +78,11 @@ protected void onDraw(Canvas canvas) { mButtonRect.right = getWidth() - 10; btn_rect = mButtonRect; - if (s.equals(optionOneString)) + if (s.equals(optionOneString)) { p.setColor(optionOneColor); - else + } else { p.setColor(optionTwoColor); + } canvas.drawRect(mButtonRect, p); p.setColor(Color.GRAY); @@ -99,10 +99,11 @@ public boolean onTouchEvent(MotionEvent event) { boolean r = super.onTouchEvent(event); if (event.getAction() == MotionEvent.ACTION_UP) { if (btn_rect.contains(touchX, touchY)) { - if (s.equals(optionTwoString)) + if (s.equals(optionTwoString)) { s = optionOneString; - else + } else { s = optionTwoString; + } if (badgeClickCallback != null) { @SuppressWarnings("rawtypes") Class[] paramtypes = new Class[2]; diff --git a/owncloudApp/src/main/java/third_parties/daveKoeller/AlphanumComparator.java b/owncloudApp/src/main/java/third_parties/daveKoeller/AlphanumComparator.java index 0f1ba3602ba..6a1f1f09134 100644 --- a/owncloudApp/src/main/java/third_parties/daveKoeller/AlphanumComparator.java +++ b/owncloudApp/src/main/java/third_parties/daveKoeller/AlphanumComparator.java @@ -24,11 +24,11 @@ package third_parties.daveKoeller; +import com.owncloud.android.datamodel.OCFile; + import java.text.Collator; import java.util.Comparator; -import com.owncloud.android.datamodel.OCFile; - /** * This is an updated version with enhancements made by Daniel Migowski, * Andre Bogus, and David Koelle @@ -58,16 +58,18 @@ private final String getChunk(String s, int slength, int marker) { if (isDigit(c)) { while (marker < slength) { c = s.charAt(marker); - if (!isDigit(c)) + if (!isDigit(c)) { break; + } chunk.append(c); marker++; } } else { while (marker < slength) { c = s.charAt(marker); - if (isDigit(c)) + if (isDigit(c)) { break; + } chunk.append(c); marker++; } @@ -112,8 +114,9 @@ public int compare(OCFile o1, OCFile o2) { result = collator.compare(thisChunk, thatChunk); } - if (result != 0) + if (result != 0) { return result; + } } return s1Length - s2Length; diff --git a/owncloudApp/src/main/java/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java b/owncloudApp/src/main/java/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java index be487634f47..a756ee3316e 100644 --- a/owncloudApp/src/main/java/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java +++ b/owncloudApp/src/main/java/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java @@ -16,7 +16,6 @@ */ package third_parties.in.srain.cube; - import android.annotation.TargetApi; import android.content.Context; import android.database.DataSetObservable; @@ -277,7 +276,8 @@ private int getNumColumnsCompatible() { if (mNumColumns != -1) { return mNumColumns; } - throw new RuntimeException("Can not determine the mNumColumns for this API platform, please call setNumColumns to set it."); + throw new RuntimeException("Can not determine the mNumColumns for this API platform, please call " + + "setNumColumns to set it."); } } } @@ -360,7 +360,8 @@ public void tryToScrollToBottomSmoothly(int duration) { @Override public void setAdapter(ListAdapter adapter) { if (mHeaderViewInfos.size() > 0 || mFooterViewInfos.size() > 0) { - HeaderViewGridAdapter headerViewGridAdapter = new HeaderViewGridAdapter(mHeaderViewInfos, mFooterViewInfos, adapter); + HeaderViewGridAdapter headerViewGridAdapter = new HeaderViewGridAdapter(mHeaderViewInfos, + mFooterViewInfos, adapter); int numColumns = getNumColumnsCompatible(); if (numColumns > 1) { headerViewGridAdapter.setNumColumns(numColumns); @@ -438,7 +439,8 @@ private static class HeaderViewGridAdapter implements WrapperListAdapter, Filter // From Recycle Bin or calling getView, this a question... private boolean mCacheFirstHeaderView = false; - public HeaderViewGridAdapter(ArrayList headerViewInfos, ArrayList footViewInfos, ListAdapter adapter) { + public HeaderViewGridAdapter(ArrayList headerViewInfos, ArrayList footViewInfos + , ListAdapter adapter) { mAdapter = adapter; mIsFilterable = adapter instanceof Filterable; if (headerViewInfos == null) { @@ -732,7 +734,8 @@ public int getItemViewType(int position) { } } if (DEBUG) { - Log.d(LOG_TAG, String.format("getItemViewType: pos: %s, result: %s", position, type, mCachePlaceHoldView, mCacheFirstHeaderView)); + Log.d(LOG_TAG, String.format("getItemViewType: pos: %s, result: %s", position, type, + mCachePlaceHoldView, mCacheFirstHeaderView)); } return type; } @@ -792,16 +795,15 @@ public void notifyDataSetChanged() { } } - /** * Sets the selected item and positions the selection y pixels from the top edge of the ListView. * (If in touch mode, the item will not be selected but it will still be positioned appropriately.) * - * @param position Index (starting at 0) of the data item to be selected. - * @param y The distance from the top edge of the ListView (plus padding) - * that the item will be positioned. - * - * @see Original code + * @param position Index (starting at 0) of the data item to be selected. + * @param y The distance from the top edge of the ListView (plus padding) + * that the item will be positioned. + * @see + * Original code */ public void setSelectionFromTop(int position, int y) { if (getAdapter() == null) { diff --git a/owncloudApp/src/main/res/anim/disappear.xml b/owncloudApp/src/main/res/anim/disappear.xml index cf5e35f1479..15b7eaed1e1 100644 --- a/owncloudApp/src/main/res/anim/disappear.xml +++ b/owncloudApp/src/main/res/anim/disappear.xml @@ -19,9 +19,10 @@ --> - + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/grow_from_bottom.xml b/owncloudApp/src/main/res/anim/grow_from_bottom.xml index 1f63f1101ae..c9ec7fa3238 100644 --- a/owncloudApp/src/main/res/anim/grow_from_bottom.xml +++ b/owncloudApp/src/main/res/anim/grow_from_bottom.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/grow_from_bottomleft_to_topright.xml b/owncloudApp/src/main/res/anim/grow_from_bottomleft_to_topright.xml index a53375de564..ba7cb2980d4 100644 --- a/owncloudApp/src/main/res/anim/grow_from_bottomleft_to_topright.xml +++ b/owncloudApp/src/main/res/anim/grow_from_bottomleft_to_topright.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/grow_from_bottomright_to_topleft.xml b/owncloudApp/src/main/res/anim/grow_from_bottomright_to_topleft.xml index 5ae822f1a55..1a3acb37ce7 100644 --- a/owncloudApp/src/main/res/anim/grow_from_bottomright_to_topleft.xml +++ b/owncloudApp/src/main/res/anim/grow_from_bottomright_to_topleft.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/grow_from_top.xml b/owncloudApp/src/main/res/anim/grow_from_top.xml index b075faf616b..b3c94e54e44 100644 --- a/owncloudApp/src/main/res/anim/grow_from_top.xml +++ b/owncloudApp/src/main/res/anim/grow_from_top.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/grow_from_topleft_to_bottomright.xml b/owncloudApp/src/main/res/anim/grow_from_topleft_to_bottomright.xml index 1d7c38be707..cb1cc22c401 100644 --- a/owncloudApp/src/main/res/anim/grow_from_topleft_to_bottomright.xml +++ b/owncloudApp/src/main/res/anim/grow_from_topleft_to_bottomright.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/grow_from_topright_to_bottomleft.xml b/owncloudApp/src/main/res/anim/grow_from_topright_to_bottomleft.xml index 151d6e004e3..2a7b573c3cc 100644 --- a/owncloudApp/src/main/res/anim/grow_from_topright_to_bottomleft.xml +++ b/owncloudApp/src/main/res/anim/grow_from_topright_to_bottomleft.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/pump_bottom.xml b/owncloudApp/src/main/res/anim/pump_bottom.xml index 6359e87cca1..581eb19caf8 100644 --- a/owncloudApp/src/main/res/anim/pump_bottom.xml +++ b/owncloudApp/src/main/res/anim/pump_bottom.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/pump_top.xml b/owncloudApp/src/main/res/anim/pump_top.xml index bae0e95d36c..cb61b7491bc 100644 --- a/owncloudApp/src/main/res/anim/pump_top.xml +++ b/owncloudApp/src/main/res/anim/pump_top.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/shrink_from_bottom.xml b/owncloudApp/src/main/res/anim/shrink_from_bottom.xml index 9982a34ee70..2fbd7f743f9 100644 --- a/owncloudApp/src/main/res/anim/shrink_from_bottom.xml +++ b/owncloudApp/src/main/res/anim/shrink_from_bottom.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/shrink_from_bottomleft_to_topright.xml b/owncloudApp/src/main/res/anim/shrink_from_bottomleft_to_topright.xml index f9862b7f2ae..d7b3243402c 100644 --- a/owncloudApp/src/main/res/anim/shrink_from_bottomleft_to_topright.xml +++ b/owncloudApp/src/main/res/anim/shrink_from_bottomleft_to_topright.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/shrink_from_bottomright_to_topleft.xml b/owncloudApp/src/main/res/anim/shrink_from_bottomright_to_topleft.xml index 8d993f5875e..d4e9b52a849 100644 --- a/owncloudApp/src/main/res/anim/shrink_from_bottomright_to_topleft.xml +++ b/owncloudApp/src/main/res/anim/shrink_from_bottomright_to_topleft.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/shrink_from_top.xml b/owncloudApp/src/main/res/anim/shrink_from_top.xml index 79603f2e036..94e5f9a60b9 100644 --- a/owncloudApp/src/main/res/anim/shrink_from_top.xml +++ b/owncloudApp/src/main/res/anim/shrink_from_top.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/shrink_from_topleft_to_bottomright.xml b/owncloudApp/src/main/res/anim/shrink_from_topleft_to_bottomright.xml index fa5bd26afef..3a4f0b7e5b4 100644 --- a/owncloudApp/src/main/res/anim/shrink_from_topleft_to_bottomright.xml +++ b/owncloudApp/src/main/res/anim/shrink_from_topleft_to_bottomright.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/shrink_from_topright_to_bottomleft.xml b/owncloudApp/src/main/res/anim/shrink_from_topright_to_bottomleft.xml index e4356b28e46..de01901abbe 100644 --- a/owncloudApp/src/main/res/anim/shrink_from_topright_to_bottomleft.xml +++ b/owncloudApp/src/main/res/anim/shrink_from_topright_to_bottomleft.xml @@ -18,15 +18,19 @@ along with this program. If not, see . --> - - + + diff --git a/owncloudApp/src/main/res/anim/slide_in_left.xml b/owncloudApp/src/main/res/anim/slide_in_left.xml index 281da62a02d..c7a477661ab 100755 --- a/owncloudApp/src/main/res/anim/slide_in_left.xml +++ b/owncloudApp/src/main/res/anim/slide_in_left.xml @@ -19,6 +19,12 @@ --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/slide_in_right.xml b/owncloudApp/src/main/res/anim/slide_in_right.xml index 6fbb8979a57..f21e0635ddb 100755 --- a/owncloudApp/src/main/res/anim/slide_in_right.xml +++ b/owncloudApp/src/main/res/anim/slide_in_right.xml @@ -19,6 +19,12 @@ --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/slide_out_left.xml b/owncloudApp/src/main/res/anim/slide_out_left.xml index b3adeaa626a..adb88ceed22 100755 --- a/owncloudApp/src/main/res/anim/slide_out_left.xml +++ b/owncloudApp/src/main/res/anim/slide_out_left.xml @@ -19,6 +19,12 @@ --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/anim/slide_out_right.xml b/owncloudApp/src/main/res/anim/slide_out_right.xml index 30b5eba855a..4447ffd3d2a 100755 --- a/owncloudApp/src/main/res/anim/slide_out_right.xml +++ b/owncloudApp/src/main/res/anim/slide_out_right.xml @@ -19,6 +19,12 @@ --> - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/action_item_btn.xml b/owncloudApp/src/main/res/drawable/action_item_btn.xml index 69432d375b0..02fdd765b59 100644 --- a/owncloudApp/src/main/res/drawable/action_item_btn.xml +++ b/owncloudApp/src/main/res/drawable/action_item_btn.xml @@ -20,16 +20,16 @@ - - - - + android:state_pressed="true" + android:drawable="@drawable/action_item_selected" /> + + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/btn.xml b/owncloudApp/src/main/res/drawable/btn.xml index d7aa97972cb..d7affb1fbe0 100644 --- a/owncloudApp/src/main/res/drawable/btn.xml +++ b/owncloudApp/src/main/res/drawable/btn.xml @@ -18,9 +18,9 @@ along with this program. If not, see . --> - - - - - + + + + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/btn_round.xml b/owncloudApp/src/main/res/drawable/btn_round.xml index a11e1d35b58..21a19287864 100644 --- a/owncloudApp/src/main/res/drawable/btn_round.xml +++ b/owncloudApp/src/main/res/drawable/btn_round.xml @@ -1,4 +1,4 @@ - + - - - - - + + + + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/btn_round_pressed.xml b/owncloudApp/src/main/res/drawable/btn_round_pressed.xml index c7cf737d9eb..6ce86ef3026 100644 --- a/owncloudApp/src/main/res/drawable/btn_round_pressed.xml +++ b/owncloudApp/src/main/res/drawable/btn_round_pressed.xml @@ -1,4 +1,4 @@ - + - - - - - + + + + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/btn_small_round.xml b/owncloudApp/src/main/res/drawable/btn_small_round.xml index 6638ed9e25d..6e34b8b2078 100755 --- a/owncloudApp/src/main/res/drawable/btn_small_round.xml +++ b/owncloudApp/src/main/res/drawable/btn_small_round.xml @@ -1,46 +1,57 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/fab_label_background.xml b/owncloudApp/src/main/res/drawable/fab_label_background.xml index 4460dab0ae4..5126af0cb3c 100644 --- a/owncloudApp/src/main/res/drawable/fab_label_background.xml +++ b/owncloudApp/src/main/res/drawable/fab_label_background.xml @@ -1,11 +1,11 @@ - + + android:bottom="4dp" /> + android:radius="2dp" /> \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/ic_star_black_24dp.xml b/owncloudApp/src/main/res/drawable/ic_star_black_24dp.xml index 3babfdda41b..8da4813f73c 100644 --- a/owncloudApp/src/main/res/drawable/ic_star_black_24dp.xml +++ b/owncloudApp/src/main/res/drawable/ic_star_black_24dp.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z" /> diff --git a/owncloudApp/src/main/res/drawable/indicator_dot_not_selected.xml b/owncloudApp/src/main/res/drawable/indicator_dot_not_selected.xml index 225b1d7a4c9..9c88942a139 100644 --- a/owncloudApp/src/main/res/drawable/indicator_dot_not_selected.xml +++ b/owncloudApp/src/main/res/drawable/indicator_dot_not_selected.xml @@ -18,12 +18,18 @@ along with this program. If not, see . --> - + - - + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/indicator_dot_selected.xml b/owncloudApp/src/main/res/drawable/indicator_dot_selected.xml index 7e7af0954c6..68a3f168779 100644 --- a/owncloudApp/src/main/res/drawable/indicator_dot_selected.xml +++ b/owncloudApp/src/main/res/drawable/indicator_dot_selected.xml @@ -18,11 +18,17 @@ along with this program. If not, see . --> - + - - + + diff --git a/owncloudApp/src/main/res/drawable/list_selector.xml b/owncloudApp/src/main/res/drawable/list_selector.xml index 8a7f6ae1ec3..5197326817f 100644 --- a/owncloudApp/src/main/res/drawable/list_selector.xml +++ b/owncloudApp/src/main/res/drawable/list_selector.xml @@ -20,8 +20,8 @@ - - + + diff --git a/owncloudApp/src/main/res/drawable/logo_icon.xml b/owncloudApp/src/main/res/drawable/logo_icon.xml index dbcebcc5394..28d97875716 100644 --- a/owncloudApp/src/main/res/drawable/logo_icon.xml +++ b/owncloudApp/src/main/res/drawable/logo_icon.xml @@ -1,13 +1,14 @@ - - + android:width="108dp" + android:height="108dp" + android:viewportWidth="304.76193" + android:viewportHeight="304.7568"> + + diff --git a/owncloudApp/src/main/res/drawable/progress_small.xml b/owncloudApp/src/main/res/drawable/progress_small.xml index a205ea63118..84c35400f1c 100644 --- a/owncloudApp/src/main/res/drawable/progress_small.xml +++ b/owncloudApp/src/main/res/drawable/progress_small.xml @@ -20,9 +20,9 @@ + android:startOffset="0" /> diff --git a/owncloudApp/src/main/res/drawable/round_button.xml b/owncloudApp/src/main/res/drawable/round_button.xml index 08c98a7469a..4a7167e8017 100644 --- a/owncloudApp/src/main/res/drawable/round_button.xml +++ b/owncloudApp/src/main/res/drawable/round_button.xml @@ -1,5 +1,5 @@ - + diff --git a/owncloudApp/src/main/res/drawable/shadow_gradient.xml b/owncloudApp/src/main/res/drawable/shadow_gradient.xml index 570b3fba5fb..6a6b1c5225e 100644 --- a/owncloudApp/src/main/res/drawable/shadow_gradient.xml +++ b/owncloudApp/src/main/res/drawable/shadow_gradient.xml @@ -1,7 +1,8 @@ - + + android:angle="90" /> \ No newline at end of file diff --git a/owncloudApp/src/main/res/drawable/top_progress_bar_indeterminate.xml b/owncloudApp/src/main/res/drawable/top_progress_bar_indeterminate.xml index 1cd653b3e81..05184c46498 100644 --- a/owncloudApp/src/main/res/drawable/top_progress_bar_indeterminate.xml +++ b/owncloudApp/src/main/res/drawable/top_progress_bar_indeterminate.xml @@ -1,13 +1,29 @@ - - - - - - - - + xmlns:android="http://schemas.android.com/apk/res/android" + android:oneshot="false"> + + + + + + + + diff --git a/owncloudApp/src/main/res/drawable/uploader_list_separator.xml b/owncloudApp/src/main/res/drawable/uploader_list_separator.xml index 7944be6f6a2..c6c5fca17cb 100644 --- a/owncloudApp/src/main/res/drawable/uploader_list_separator.xml +++ b/owncloudApp/src/main/res/drawable/uploader_list_separator.xml @@ -18,6 +18,9 @@ along with this program. If not, see . --> - + xmlns:android="http://schemas.android.com/apk/res/android"> + \ No newline at end of file diff --git a/owncloudApp/src/main/res/layout/account_action.xml b/owncloudApp/src/main/res/layout/account_action.xml index 6f9d2b210ad..5b3f7342521 100644 --- a/owncloudApp/src/main/res/layout/account_action.xml +++ b/owncloudApp/src/main/res/layout/account_action.xml @@ -30,7 +30,7 @@ android:layout_gravity="center_vertical" android:layout_marginLeft="20dp" android:layout_marginStart="20dp" - android:src="@drawable/ic_account_plus"/> + android:src="@drawable/ic_account_plus" /> + android:textSize="@dimen/two_line_primary_text_size" /> \ No newline at end of file diff --git a/owncloudApp/src/main/res/layout/account_item.xml b/owncloudApp/src/main/res/layout/account_item.xml index f6a79fe5863..b2b9a7ce951 100644 --- a/owncloudApp/src/main/res/layout/account_item.xml +++ b/owncloudApp/src/main/res/layout/account_item.xml @@ -18,7 +18,6 @@ --> @@ -47,8 +46,8 @@ android:layout_marginTop="-8dp" android:src="@drawable/ic_current" /> - + + android:ellipsize="end" /> + android:ellipsize="end" /> + android:src="@drawable/ic_key" /> + android:src="@drawable/ic_action_delete_grey" /> \ No newline at end of file diff --git a/owncloudApp/src/main/res/layout/account_setup.xml b/owncloudApp/src/main/res/layout/account_setup.xml index 94887f985f8..4d92a611656 100644 --- a/owncloudApp/src/main/res/layout/account_setup.xml +++ b/owncloudApp/src/main/res/layout/account_setup.xml @@ -28,7 +28,7 @@ android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/login_background_image" - android:visibility="invisible"/> + android:visibility="invisible" /> + android:src="@drawable/logo" /> + android:visibility="gone" /> + android:visibility="gone" /> - + + android:src="@drawable/ic_arrow_right" /> + android:visibility="gone" /> + android:textColor="@color/login_connection_text_color" /> + android:visibility="gone" /> + android:visibility="gone" /> + android:visibility="gone" /> + android:visibility="gone" /> + android:textColor="@color/login_text_color" /> diff --git a/owncloudApp/src/main/res/layout/accounts_layout.xml b/owncloudApp/src/main/res/layout/accounts_layout.xml index b9540b366da..13d830ba474 100644 --- a/owncloudApp/src/main/res/layout/accounts_layout.xml +++ b/owncloudApp/src/main/res/layout/accounts_layout.xml @@ -17,21 +17,21 @@ along with this program. If not, see . --> + android:id="@+id/accounts_layout" + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> - + - - + + diff --git a/owncloudApp/src/main/res/layout/activity_privacy_policy.xml b/owncloudApp/src/main/res/layout/activity_privacy_policy.xml index ad5860f387c..3adb9367ab1 100644 --- a/owncloudApp/src/main/res/layout/activity_privacy_policy.xml +++ b/owncloudApp/src/main/res/layout/activity_privacy_policy.xml @@ -28,9 +28,8 @@ - - + . --> - - - - - + + + + + - + - + - + - + - + // This is the custom button + + android:visibility="gone" /> + android:visibility="gone" /> @@ -65,7 +71,8 @@ android:gravity="center_vertical" android:orientation="horizontal"> - + android:textColor="#FFBEBEBE" /> - + style="?android:attr/progressBarStyleHorizontal" /> - + android:textColor="#FFBEBEBE" /> diff --git a/owncloudApp/src/main/res/layout/dialog_upload_text.xml b/owncloudApp/src/main/res/layout/dialog_upload_text.xml index 9b7d63ed1fd..06a4759284c 100644 --- a/owncloudApp/src/main/res/layout/dialog_upload_text.xml +++ b/owncloudApp/src/main/res/layout/dialog_upload_text.xml @@ -10,6 +10,6 @@ android:id="@+id/inputFileName" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="@string/uploader_upload_text_filename_hint"/> + android:hint="@string/uploader_upload_text_filename_hint" /> \ No newline at end of file diff --git a/owncloudApp/src/main/res/layout/drawer.xml b/owncloudApp/src/main/res/layout/drawer.xml index 6af592cca90..c9d0bd63f24 100644 --- a/owncloudApp/src/main/res/layout/drawer.xml +++ b/owncloudApp/src/main/res/layout/drawer.xml @@ -17,7 +17,7 @@ along with this program. If not, see . --> + xmlns:app="http://schemas.android.com/apk/res-auto"> + android:visibility="visible" /> + android:text="@string/drawer_loading_quota" /> diff --git a/owncloudApp/src/main/res/layout/drawer_header.xml b/owncloudApp/src/main/res/layout/drawer_header.xml index 2b1b43bb137..812a92a42ef 100644 --- a/owncloudApp/src/main/res/layout/drawer_header.xml +++ b/owncloudApp/src/main/res/layout/drawer_header.xml @@ -27,7 +27,7 @@ android:id="@+id/drawer_header_background" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop"/> + android:scaleType="centerCrop" /> + android:src="@drawable/ic_account_circle" /> + android:onClick="onAccountDrawerClick" /> + android:onClick="onAccountDrawerClick" /> + android:textStyle="bold" /> + android:textSize="12sp" /> + android:inputType="textNoSuggestions|textCapSentences" /> diff --git a/owncloudApp/src/main/res/layout/edit_share_layout.xml b/owncloudApp/src/main/res/layout/edit_share_layout.xml index cd6260f301f..65174b1a6bc 100644 --- a/owncloudApp/src/main/res/layout/edit_share_layout.xml +++ b/owncloudApp/src/main/res/layout/edit_share_layout.xml @@ -26,9 +26,11 @@ android:id="@+id/shareScroll" > - + + - - + android:layout_marginLeft="@dimen/standard_margin" + android:layout_marginRight="@dimen/standard_margin" + android:layout_marginBottom="@dimen/standard_margin"> - + - + - + - - + + + + \ No newline at end of file diff --git a/owncloudApp/src/main/res/layout/file_actions.xml b/owncloudApp/src/main/res/layout/file_actions.xml index 0e2a3f92c88..7db8b5ebfc6 100644 --- a/owncloudApp/src/main/res/layout/file_actions.xml +++ b/owncloudApp/src/main/res/layout/file_actions.xml @@ -32,4 +32,4 @@ android:layout_weight="1" /> - \ No newline at end of file + \ No newline at end of file diff --git a/owncloudApp/src/main/res/layout/file_details_empty.xml b/owncloudApp/src/main/res/layout/file_details_empty.xml index c34141aeaab..137c4619337 100644 --- a/owncloudApp/src/main/res/layout/file_details_empty.xml +++ b/owncloudApp/src/main/res/layout/file_details_empty.xml @@ -17,14 +17,14 @@ along with this program. If not, see . --> - + android:src="@drawable/file" /> + android:textAppearance="?android:attr/textAppearanceLarge" /> @@ -78,7 +78,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/filedetails_type" - android:textAppearance="?android:attr/textAppearanceMedium"/> + android:textAppearance="?android:attr/textAppearanceMedium" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> + android:visibility="gone" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> + android:visibility="gone" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> diff --git a/owncloudApp/src/main/res/layout/file_download_fragment.xml b/owncloudApp/src/main/res/layout/file_download_fragment.xml index b3f83fe1175..2310a2e4a50 100644 --- a/owncloudApp/src/main/res/layout/file_download_fragment.xml +++ b/owncloudApp/src/main/res/layout/file_download_fragment.xml @@ -15,73 +15,74 @@ along with this program. If not, see . --> - - - + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:layout_gravity="center" + android:gravity="center_vertical" + android:padding="20dp" + android:background="@color/black" + android:filterTouchesWhenObscured="true"> + + + - - + + + + + + - /> + - + - - - - - - diff --git a/owncloudApp/src/main/res/layout/fingerprint_dialog.xml b/owncloudApp/src/main/res/layout/fingerprint_dialog.xml index b2783f01a86..36286c31c6d 100644 --- a/owncloudApp/src/main/res/layout/fingerprint_dialog.xml +++ b/owncloudApp/src/main/res/layout/fingerprint_dialog.xml @@ -20,12 +20,12 @@ ~ Copyright (C) 2019 ownCloud GmbH. --> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingBottom="8dp" + android:paddingEnd="24dp" + android:paddingStart="24dp" + android:paddingTop="@dimen/standard_margin"> + android:textColor="@color/black" /> + android:src="@drawable/ic_fp_40px" /> + android:textColor="@color/secondaryTextColor" /> + android:theme="@style/Button.Primary" /> \ No newline at end of file diff --git a/owncloudApp/src/main/res/layout/generic_explanation.xml b/owncloudApp/src/main/res/layout/generic_explanation.xml index 939dfcbad49..66102fdeb43 100644 --- a/owncloudApp/src/main/res/layout/generic_explanation.xml +++ b/owncloudApp/src/main/res/layout/generic_explanation.xml @@ -18,35 +18,35 @@ - - - - + + + + + android:orientation="horizontal">