From c7bfa7827b7ee0d014bbc6206dc71509261245b0 Mon Sep 17 00:00:00 2001 From: Bambooin Date: Sun, 5 Nov 2023 22:09:54 +0800 Subject: [PATCH] fix: fix some code analysis warning --- .../filemanager/adapters/AppsRecyclerAdapter.kt | 15 ++------------- .../asynchronous/services/ZipService.kt | 4 ---- .../filemanager/filesystem/FileProperties.kt | 6 ++++++ .../filemanager/filesystem/MakeFileOperation.kt | 13 +++++++++++++ .../filemanager/filesystem/RenameOperation.kt | 1 - .../ui/views/drawer/DrawerViewModel.kt | 5 +++++ 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/adapters/AppsRecyclerAdapter.kt b/app/src/main/java/com/amaze/filemanager/adapters/AppsRecyclerAdapter.kt index ea43e19f0e..d3bf5ae753 100644 --- a/app/src/main/java/com/amaze/filemanager/adapters/AppsRecyclerAdapter.kt +++ b/app/src/main/java/com/amaze/filemanager/adapters/AppsRecyclerAdapter.kt @@ -189,10 +189,8 @@ class AppsRecyclerAdapter( ) } holder.txtTitle.text = rowItem.label - holder.packageName.text = rowItem.packageName holder.packageName.isSelected = true // for marquee - val enableMarqueeFilename = (fragment.requireActivity() as MainActivity) .getBoolean(PreferencesConstants.PREFERENCE_ENABLE_MARQUEE_FILENAME) @@ -205,8 +203,6 @@ class AppsRecyclerAdapter( } marqueeAfterDelay(2000, holder.txtTitle) } - - // File f = new File(rowItem.getDesc()); if (!isBottomSheet) { holder.txtDesc.text = rowItem.fileSize + " |" } @@ -311,11 +307,7 @@ class AppsRecyclerAdapter( ) { context = ContextThemeWrapper(context, R.style.overflow_black) } - val popupMenu = - PopupMenu( - context, - view, - ) + val popupMenu = PopupMenu(context, view) popupMenu.setOnMenuItemClickListener { item: MenuItem -> val themedActivity: MainActivity = fragment.requireActivity() as MainActivity val colorAccent = themedActivity.accent @@ -349,10 +341,7 @@ class AppsRecyclerAdapter( Intent( Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse( - String.format( - "package:%s", - rowItem!!.packageName, - ), + String.format("package:%s", rowItem!!.packageName), ), ), ) diff --git a/app/src/main/java/com/amaze/filemanager/asynchronous/services/ZipService.kt b/app/src/main/java/com/amaze/filemanager/asynchronous/services/ZipService.kt index ab451e9510..f5b81d95e8 100644 --- a/app/src/main/java/com/amaze/filemanager/asynchronous/services/ZipService.kt +++ b/app/src/main/java/com/amaze/filemanager/asynchronous/services/ZipService.kt @@ -107,7 +107,6 @@ class ZipService : AbstractProgressiveService() { .utilsProvider .colorPreference .getCurrentUserColorPreferences(this, sharedPreferences).accent - val notificationIntent = Intent(this, MainActivity::class.java) .putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true) @@ -118,10 +117,8 @@ class ZipService : AbstractProgressiveService() { notificationIntent, getPendingIntentFlag(0), ) - customSmallContentViews = RemoteViews(packageName, R.layout.notification_service_small) customBigContentViews = RemoteViews(packageName, R.layout.notification_service_big) - val stopIntent = Intent(KEY_COMPRESS_BROADCAST_CANCEL) val stopPendingIntent = PendingIntent.getBroadcast( @@ -147,7 +144,6 @@ class ZipService : AbstractProgressiveService() { .addAction(action) .setOngoing(true) .setColor(accentColor) - NotificationConstants.setMetadata(this, mBuilder, NotificationConstants.TYPE_NORMAL) startForeground(NotificationConstants.ZIP_ID, mBuilder.build()) initNotificationViews() diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/FileProperties.kt b/app/src/main/java/com/amaze/filemanager/filesystem/FileProperties.kt index c5a448db4a..2fbab94011 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/FileProperties.kt +++ b/app/src/main/java/com/amaze/filemanager/filesystem/FileProperties.kt @@ -247,6 +247,12 @@ object FileProperties { } } + /** + * Remap file path + * @param path file path + * @param openDocumentTree open document tree default false + * @return remapped file path + */ @JvmStatic fun remapPathForApi30OrAbove( path: String, diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/MakeFileOperation.kt b/app/src/main/java/com/amaze/filemanager/filesystem/MakeFileOperation.kt index 6dc1b7cb60..1e49ef1fda 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/MakeFileOperation.kt +++ b/app/src/main/java/com/amaze/filemanager/filesystem/MakeFileOperation.kt @@ -51,6 +51,12 @@ object MakeFileOperation { return File(extDir, file.name) } + /** + * Make normal file + * @param file File + * @param context Context + * @return true for success and false for failed + */ @JvmStatic fun mkfile( file: File?, @@ -97,6 +103,13 @@ object MakeFileOperation { } } + /** + * Make text file + * @param data file data + * @param path path + * @param fileName file name + * @return true for success and false for failed + */ @JvmStatic fun mktextfile( data: String?, diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/RenameOperation.kt b/app/src/main/java/com/amaze/filemanager/filesystem/RenameOperation.kt index 0f1b942ab6..7fed73b3ae 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/RenameOperation.kt +++ b/app/src/main/java/com/amaze/filemanager/filesystem/RenameOperation.kt @@ -51,7 +51,6 @@ object RenameOperation { var outChannel: FileChannel? = null try { inStream = FileInputStream(source) - // First try the normal way if (FileProperties.isWritable(target)) { // standard way diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/drawer/DrawerViewModel.kt b/app/src/main/java/com/amaze/filemanager/ui/views/drawer/DrawerViewModel.kt index 83e2ddbacc..3742688814 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/drawer/DrawerViewModel.kt +++ b/app/src/main/java/com/amaze/filemanager/ui/views/drawer/DrawerViewModel.kt @@ -31,6 +31,11 @@ class DrawerViewModel : ViewModel() { return requireNotNull(menuMetadataMap[item.toNonLeaking()]) } + /** + * Put drawer meta data + * @param item menu item + * @param metadata menu meta data + */ fun putDrawerMetadata( item: MenuItem, metadata: MenuMetadata,