From 8cf7f6120af34bd26524212123699a9eb05a037a Mon Sep 17 00:00:00 2001 From: parneet-guraya Date: Fri, 15 Dec 2023 17:13:20 +0530 Subject: [PATCH] fix lint Signed-off-by: parneet-guraya --- .../ui/activity/FileDisplayActivity.java | 6 +-- .../dialog/SetupEncryptionDialogFragment.kt | 4 +- .../ui/preview/PreviewMediaActivity.kt | 53 ++++++++++++------- .../preview/PreviewVideoFullscreenDialog.kt | 1 - app/src/main/res/values/styles.xml | 8 --- 5 files changed, 40 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index deaab6008855..b0b23675dcdc 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1395,7 +1395,7 @@ public void onReceive(Context context, Intent intent) { if (uploadWasFine) { OCFile ocFile = getFile(); if (PreviewImageFragment.canBePreviewed(ocFile)) { - startImagePreview(getFile(),true); + startImagePreview(getFile(), true); } else if (PreviewTextFileFragment.canBePreviewed(ocFile)) { startTextPreview(ocFile, true); } @@ -2044,7 +2044,7 @@ public void startMediaPreview(OCFile file, long startPlaybackPosition, boolean a } if (showPreview && file.isDown() && !file.isDownloading() || streamMedia) { if (showInActivity) { - startMediaActivity(file, startPlaybackPosition, autoplay, showPreview, streamMedia, user); + startMediaActivity(file, startPlaybackPosition, autoplay, user); } else { configureToolbarForPreview(file); Fragment mediaFragment = PreviewMediaFragment.newInstance(file, user.get(), startPlaybackPosition, autoplay, false); @@ -2060,7 +2060,7 @@ public void startMediaPreview(OCFile file, long startPlaybackPosition, boolean a } } - private void startMediaActivity(OCFile file, long startPlaybackPosition, boolean autoplay, boolean showPreview, boolean streamMedia, Optional user) { + private void startMediaActivity(OCFile file, long startPlaybackPosition, boolean autoplay, Optional user) { Intent previewMediaIntent = new Intent(this, PreviewMediaActivity.class); previewMediaIntent.putExtra(PreviewMediaActivity.EXTRA_FILE, file); previewMediaIntent.putExtra(PreviewMediaActivity.EXTRA_USER, user.get()); diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.kt index ea904a967823..9a507dfc59bf 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.kt @@ -155,6 +155,7 @@ class SetupEncryptionDialogFragment : DialogFragment(), Injectable { dialog.dismiss() notifyResult() } + KEY_EXISTING_USED -> { decryptPrivateKey(dialog) } @@ -162,6 +163,7 @@ class SetupEncryptionDialogFragment : DialogFragment(), Injectable { KEY_GENERATE -> { generateKey() } + else -> dialog.dismiss() } } @@ -376,7 +378,7 @@ class SetupEncryptionDialogFragment : DialogFragment(), Injectable { binding.encryptionStatus.setText(R.string.end_to_end_encryption_generating_keys) } - @Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown", "ReturnCount") + @Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown", "ReturnCount", "LongMethod") @Deprecated("Deprecated in Java") override fun doInBackground(vararg voids: Void?): String { // - create CSR, push to server, store returned public key in database diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index fda6539f56e9..8407ca17a6eb 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -109,10 +109,14 @@ import javax.inject.Inject * By now, if the [OCFile] passed is not downloaded, an [IllegalStateException] is generated on * instantiation too. */ -class PreviewMediaActivity - - : FileActivity(), FileFragment.ContainerActivity, OnRemoteOperationListener, - SendShareDialog.SendShareDialogDownloader, Injectable { +@Suppress("TooManyFunctions") +class PreviewMediaActivity : + + FileActivity(), + FileFragment.ContainerActivity, + OnRemoteOperationListener, + SendShareDialog.SendShareDialogDownloader, + Injectable { private var user: User? = null private var savedPlaybackPosition: Long = 0 private var autoplay = true @@ -206,6 +210,7 @@ class PreviewMediaActivity * * @param file audio file with potential cover art */ + @Suppress("TooGenericExceptionCaught", "NestedBlockDepth") private fun extractAndSetCoverArt(file: OCFile) { if (MimeTypeUtil.isAudio(file)) { if (file.storagePath == null) { @@ -217,7 +222,7 @@ class PreviewMediaActivity val data = mmr.embeddedPicture if (data != null) { val bitmap = BitmapFactory.decodeByteArray(data, 0, data.size) - binding.imagePreview.setImageBitmap(bitmap) //associated cover art in bitmap + binding.imagePreview.setImageBitmap(bitmap) // associated cover art in bitmap } else { setThumbnailForAudio(file) } @@ -349,21 +354,24 @@ class PreviewMediaActivity WindowInsetsCompat.CONSUMED } } + @OptIn(UnstableApi::class) private fun setupVideoView() { initWindowInsetsController() val type = WindowInsetsCompat.Type.systemBars() binding.exoplayerView.setShowNextButton(false) binding.exoplayerView.setShowPreviousButton(false) - binding.exoplayerView.setControllerVisibilityListener(PlayerView.ControllerVisibilityListener { visibility -> - if (visibility == View.VISIBLE) { - windowInsetsController.show(type) - supportActionBar!!.show() - } else if (visibility == View.GONE) { - windowInsetsController.hide(type) - supportActionBar!!.hide() + binding.exoplayerView.setControllerVisibilityListener( + PlayerView.ControllerVisibilityListener { visibility -> + if (visibility == View.VISIBLE) { + windowInsetsController.show(type) + supportActionBar!!.show() + } else if (visibility == View.GONE) { + windowInsetsController.hide(type) + supportActionBar!!.hide() + } } - }) + ) binding.exoplayerView.player = exoPlayer } @@ -409,11 +417,15 @@ class PreviewMediaActivity additionalFilter.add(R.id.action_send_share_file) } newInstance(file, false, additionalFilter) - .setResultListener(supportFragmentManager, this, object : ResultListener { - override fun onResult(actionId: Int) { - onFileActionChosen(actionId) + .setResultListener( + supportFragmentManager, + this, + object : ResultListener { + override fun onResult(actionId: Int) { + onFileActionChosen(actionId) + } } - }) + ) .show(supportFragmentManager, "actions") } @@ -541,6 +553,7 @@ class PreviewMediaActivity fileOperationsHelper.sendShareFile(file) } + @Suppress("TooGenericExceptionCaught") private fun playVideo() { setupVideoView() // load the video file in the video player @@ -588,7 +601,9 @@ class PreviewMediaActivity val result = sfo.execute(client) return if (!result.isSuccess) { null - } else Uri.parse(result.data[0] as String) + } else { + Uri.parse(result.data[0] as String) + } } override fun onPostExecute(uri: Uri?) { @@ -721,4 +736,4 @@ class PreviewMediaActivity return file != null && (MimeTypeUtil.isAudio(file) || MimeTypeUtil.isVideo(file)) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFullscreenDialog.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFullscreenDialog.kt index 99615f20f6b7..35893c19da83 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFullscreenDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFullscreenDialog.kt @@ -128,7 +128,6 @@ class PreviewVideoFullscreenDialog( } } - override fun onBackPressed() { val isPlaying = mExoPlayer.isPlaying if (isPlaying) { diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 57c2d977af5c..c1ef3a3c3f36 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -250,10 +250,6 @@ true - - - -