From a4c8da6c31be46191ea0f6e8ee0ef2de35fc6078 Mon Sep 17 00:00:00 2001 From: Naveen Singh <36371707+naveensingh@users.noreply.github.com> Date: Sun, 26 Oct 2025 22:58:02 +0530 Subject: [PATCH] chore: bump target SDK version to 35 (#241) * chore: bump target SDK version to 35 * fix: address nullability issues * chore: bump target SDK version to 36 * refactor: update edge-to-edge implementation * refactor: update edge-to-edge implementation * refactor: update edge-to-edge implementation * refactor: migrate away from deprecated onBackPressed() * chore(deps): update org.fossify.commons to 5.5.0 * docs: update changelog * build: bump detekt return count limit * chore: update lint baselines --- CHANGELOG.md | 4 + app/detekt-baseline.xml | 8 +- app/lint-baseline.xml | 115 ++++++++---------- .../activities/DecompressActivity.kt | 14 +-- .../activities/FavoritesActivity.kt | 7 +- .../filemanager/activities/MainActivity.kt | 21 ++-- .../activities/MimeTypesActivity.kt | 7 +- .../activities/ReadTextActivity.kt | 23 ++-- .../filemanager/activities/SaveAsActivity.kt | 2 +- .../activities/SettingsActivity.kt | 7 +- .../adapters/DecompressItemsAdapter.kt | 4 +- .../filemanager/adapters/ItemsAdapter.kt | 4 +- .../filemanager/extensions/Activity.kt | 26 ---- .../main/res/layout/activity_decompress.xml | 25 ++-- .../main/res/layout/activity_favorites.xml | 25 ++-- app/src/main/res/layout/activity_main.xml | 2 +- .../main/res/layout/activity_mimetypes.xml | 23 ++-- .../main/res/layout/activity_read_text.xml | 25 ++-- app/src/main/res/layout/activity_save_as.xml | 21 ++-- app/src/main/res/layout/activity_settings.xml | 23 ++-- detekt.yml | 5 + gradle/libs.versions.toml | 6 +- settings.gradle.kts | 1 + 23 files changed, 205 insertions(+), 193 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a0c6d9f..7c5b5267 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Compatibility updates for Android 15 & 16 + ## [1.3.1] - 2025-10-02 ### Changed - Updated translations diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml index 8624d560..aa8bafb8 100644 --- a/app/detekt-baseline.xml +++ b/app/detekt-baseline.xml @@ -52,12 +52,10 @@ MaxLineLength:CompressAsDialog.kt$CompressAsDialog$val indexOfDot = if (filename.contains('.') && !activity.getIsPathDirectory(path)) filename.lastIndexOf(".") else filename.length MaxLineLength:Config.kt$Config$set(wasStorageAnalysisTabAdded) = prefs.edit().putBoolean(WAS_STORAGE_ANALYSIS_TAB_ADDED, wasStorageAnalysisTabAdded).apply() MaxLineLength:Context.kt$fun Context.isPathOnRoot(path: String) - MaxLineLength:DecompressActivity.kt$DecompressActivity$updateMaterialActivityViews(decompressCoordinator, decompressList, useTransparentNavigation = true, useTopSearchMenu = false) MaxLineLength:DecompressItemsAdapter.kt$DecompressItemsAdapter$class MaxLineLength:DecompressItemsAdapter.kt$DecompressItemsAdapter$val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").lowercase(Locale.getDefault()), { fileDrawable }) MaxLineLength:FavoritesActivity.kt$FavoritesActivity$FilePickerDialog MaxLineLength:FavoritesActivity.kt$FavoritesActivity$ManageFavoritesAdapter(this@FavoritesActivity, favorites, this@FavoritesActivity, manageFavoritesList) { } - MaxLineLength:FavoritesActivity.kt$FavoritesActivity$updateMaterialActivityViews(manageFavoritesCoordinator, manageFavoritesList, useTransparentNavigation = true, useTopSearchMenu = false) MaxLineLength:ItemsAdapter.kt$ItemsAdapter$} MaxLineLength:ItemsFragment.kt$ItemsFragment$ItemsAdapter MaxLineLength:ItemsFragment.kt$ItemsFragment$class @@ -81,17 +79,14 @@ MaxLineLength:MainActivity.kt$MainActivity$if MaxLineLength:MainActivity.kt$MainActivity$private fun getInactiveTabIndexes(activeIndex: Int) MaxLineLength:MainActivity.kt$MainActivity$resultIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION - MaxLineLength:MainActivity.kt$MainActivity$updateMaterialActivityViews(binding.mainCoordinator, null, useTransparentNavigation = false, useTopSearchMenu = true) MaxLineLength:MainActivity.kt$MainActivity$val licenses = LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GESTURE_VIEWS or LICENSE_AUTOFITTEXTVIEW or LICENSE_ZIP4J MaxLineLength:MimeTypesActivity.kt$MimeTypesActivity$!extraAudioMimeTypes.contains(fullMimetype) MaxLineLength:MimeTypesActivity.kt$MimeTypesActivity$if - MaxLineLength:MimeTypesActivity.kt$MimeTypesActivity$updateMaterialActivityViews(mimetypesCoordinator, mimetypesList, useTransparentNavigation = true, useTopSearchMenu = false) MaxLineLength:MimeTypesActivity.kt$MimeTypesActivity$val fullMimetype = cursor.getStringValue(MediaStore.Files.FileColumns.MIME_TYPE)?.lowercase(Locale.getDefault()) ?: return@queryCursor MaxLineLength:MyViewPagerFragment.kt$MyViewPagerFragment$abstract MaxLineLength:MyViewPagerFragment.kt$MyViewPagerFragment$val fabIcon = context.resources.getColoredDrawableWithColor(iconId, context.getProperPrimaryColor().getContrastColor()) MaxLineLength:ReadTextActivity.kt$ReadTextActivity$if MaxLineLength:ReadTextActivity.kt$ReadTextActivity$private - MaxLineLength:ReadTextActivity.kt$ReadTextActivity$updateMaterialActivityViews(readTextCoordinator, readTextView, useTransparentNavigation = true, useTopSearchMenu = false) MaxLineLength:RecentsFragment.kt$RecentsFragment$ItemsAdapter MaxLineLength:RecentsFragment.kt$RecentsFragment$binding.recentsSwipeRefresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false MaxLineLength:RecentsFragment.kt$RecentsFragment$class @@ -101,7 +96,6 @@ MaxLineLength:SaveAsActivity.kt$SaveAsActivity$FilePickerDialog MaxLineLength:SaveAsDialog.kt$SaveAsDialog$val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename) MaxLineLength:SettingsActivity.kt$SettingsActivity$settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) - MaxLineLength:SettingsActivity.kt$SettingsActivity$updateMaterialActivityViews(settingsCoordinator, settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false) MaxLineLength:StorageFragment.kt$StorageFragment$class MaxLineLength:StorageFragment.kt$StorageFragment$mainStorageUsageProgressbar MaxLineLength:StorageFragment.kt$StorageFragment$mainStorageUsageProgressbar.progress = ((totalStorageSpace - freeStorageSpace) / SIZE_DIVIDER).toInt() @@ -118,7 +112,7 @@ NestedBlockDepth:RecentsFragment.kt$RecentsFragment$private fun getRecents(callback: (recents: ArrayList<ListItem>) -> Unit) NestedBlockDepth:StorageFragment.kt$StorageFragment$override fun setupFragment(activity: SimpleActivity) NestedBlockDepth:StorageFragment.kt$StorageFragment$private fun getAllFiles(volumeName: String): ArrayList<FileDirItem> - ReturnCount:ItemsAdapter.kt$ItemsAdapter$@SuppressLint("NewApi") private fun compressPaths( sourcePaths: List<String>, targetPath: String, password: String? = null ): Boolean + ReturnCount:MainActivity.kt$MainActivity$override fun onBackPressedCompat(): Boolean SwallowedException:ItemsAdapter.kt$ItemsAdapter$e: Exception SwallowedException:MimeTypesActivity.kt$MimeTypesActivity$e: Exception SwallowedException:StorageFragment.kt$StorageFragment$e: Exception diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index 7e056a3f..e242d2fd 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -19,21 +19,10 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - @@ -62,20 +51,20 @@ errorLine1="gradlePlugins-agp = "8.11.1"" errorLine2=" ~~~~~~~~"> + id="NewerVersionAvailable" + message="A newer version of org.jetbrains.kotlin.android than 2.2.20 is available: 2.2.21" + errorLine1="kotlin = "2.2.20"" + errorLine2=" ~~~~~~~~"> + file="$HOME/Projects/Fossify/FossifyOrg/File-Manager/gradle/libs.versions.toml" + line="3" + column="10"/> + requireToolbar().setOnMenuItemClickListener { menuItem -> if (getCurrentFragment() == null) { return@setOnMenuItemClickListener true } @@ -274,7 +279,6 @@ class MainActivity : SimpleActivity() { } private fun updateMenuColors() { - updateStatusbarColor(getProperBackgroundColor()) binding.mainMenu.updateColors() } @@ -417,7 +421,6 @@ class MainActivity : SimpleActivity() { } val bottomBarColor = getBottomNavigationBackgroundColor() - updateNavigationBarColor(bottomBarColor) mainTabsHolder.setBackgroundColor(bottomBarColor) } } diff --git a/app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt b/app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt index 9febd299..1ed92132 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt @@ -44,14 +44,13 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener { private var currentVolume = PRIMARY_VOLUME_NAME override fun onCreate(savedInstanceState: Bundle?) { - isMaterialActivity = true super.onCreate(savedInstanceState) setContentView(binding.root) setupOptionsMenu() refreshMenuItems() binding.apply { - updateMaterialActivityViews(mimetypesCoordinator, mimetypesList, useTransparentNavigation = true, useTopSearchMenu = false) - setupMaterialScrollListener(mimetypesList, mimetypesToolbar) + setupEdgeToEdge(padBottomSystem = listOf(mimetypesList)) + setupMaterialScrollListener(binding.mimetypesList, binding.mimetypesAppbar) } currentMimeType = intent.getStringExtra(SHOW_MIMETYPE) ?: return @@ -85,7 +84,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener { override fun onResume() { super.onResume() - setupToolbar(binding.mimetypesToolbar, NavigationIcon.Arrow, searchMenuItem = searchMenuItem) + setupTopAppBar(binding.mimetypesAppbar, NavigationIcon.Arrow, searchMenuItem = searchMenuItem) } private fun refreshMenuItems() { diff --git a/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt b/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt index 6e7a7294..9696e065 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/ReadTextActivity.kt @@ -51,13 +51,12 @@ class ReadTextActivity : SimpleActivity() { private lateinit var searchClearBtn: ImageView override fun onCreate(savedInstanceState: Bundle?) { - isMaterialActivity = true super.onCreate(savedInstanceState) setContentView(binding.root) setupOptionsMenu() binding.apply { - updateMaterialActivityViews(readTextCoordinator, readTextView, useTransparentNavigation = true, useTopSearchMenu = false) - setupMaterialScrollListener(readTextHolder, readTextToolbar) + setupEdgeToEdge(padBottomImeAndSystem = listOf(readTextView)) + setupMaterialScrollListener(binding.readTextHolder, binding.readTextAppbar) } searchQueryET = findViewById(R.id.search_query) @@ -96,7 +95,7 @@ class ReadTextActivity : SimpleActivity() { override fun onResume() { super.onResume() - setupToolbar(binding.readTextToolbar, NavigationIcon.Arrow) + setupTopAppBar(binding.readTextAppbar, NavigationIcon.Arrow) } override fun onSaveInstanceState(outState: Bundle) { @@ -120,22 +119,26 @@ class ReadTextActivity : SimpleActivity() { } } - override fun onBackPressed() { + override fun onBackPressedCompat(): Boolean { val hasUnsavedChanges = originalText != binding.readTextView.text.toString() - when { - isSearchActive -> closeSearch() + return when { + isSearchActive -> { + closeSearch() + true + } hasUnsavedChanges && System.currentTimeMillis() - lastSavePromptTS > SAVE_DISCARD_PROMPT_INTERVAL -> { lastSavePromptTS = System.currentTimeMillis() ConfirmationAdvancedDialog(this, "", R.string.save_before_closing, R.string.save, R.string.discard) { if (it) { saveText(true) } else { - super.onBackPressed() + performDefaultBack() } } + true } - else -> super.onBackPressed() + else -> false } } @@ -233,7 +236,7 @@ class ReadTextActivity : SimpleActivity() { } if (shouldExitAfterSaving) { - super.onBackPressed() + performDefaultBack() } } else { toast(R.string.unknown_error_occurred) diff --git a/app/src/main/kotlin/org/fossify/filemanager/activities/SaveAsActivity.kt b/app/src/main/kotlin/org/fossify/filemanager/activities/SaveAsActivity.kt index 0681f30c..9bd7b047 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/SaveAsActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/SaveAsActivity.kt @@ -79,7 +79,7 @@ class SaveAsActivity : SimpleActivity() { override fun onResume() { super.onResume() - setupToolbar(binding.activitySaveAsToolbar, NavigationIcon.Arrow) + setupTopAppBar(binding.activitySaveAsAppbar, NavigationIcon.Arrow) } private fun sanitizeFilename(filename: String): String { diff --git a/app/src/main/kotlin/org/fossify/filemanager/activities/SettingsActivity.kt b/app/src/main/kotlin/org/fossify/filemanager/activities/SettingsActivity.kt index 234ccb2d..7f00eb6f 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/SettingsActivity.kt @@ -21,18 +21,17 @@ class SettingsActivity : SimpleActivity() { private val binding by viewBinding(ActivitySettingsBinding::inflate) override fun onCreate(savedInstanceState: Bundle?) { - isMaterialActivity = true super.onCreate(savedInstanceState) setContentView(binding.root) binding.apply { - updateMaterialActivityViews(settingsCoordinator, settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false) - setupMaterialScrollListener(settingsNestedScrollview, settingsToolbar) + setupEdgeToEdge(padBottomSystem = listOf(settingsNestedScrollview)) + setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsAppbar) } } override fun onResume() { super.onResume() - setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow) + setupTopAppBar(binding.settingsAppbar, NavigationIcon.Arrow) setupCustomizeColors() setupUseEnglish() diff --git a/app/src/main/kotlin/org/fossify/filemanager/adapters/DecompressItemsAdapter.kt b/app/src/main/kotlin/org/fossify/filemanager/adapters/DecompressItemsAdapter.kt index b604a693..4478a40e 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/adapters/DecompressItemsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/adapters/DecompressItemsAdapter.kt @@ -117,8 +117,8 @@ class DecompressItemsAdapter(activity: SimpleActivity, var listItems: MutableLis private fun getImagePathToLoad(path: String): Any { return if (path.endsWith(".apk", true)) { val packageInfo = activity.packageManager.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES) - if (packageInfo != null) { - val appInfo = packageInfo.applicationInfo + val appInfo = packageInfo?.applicationInfo + if (appInfo != null) { appInfo.sourceDir = path appInfo.publicSourceDir = path appInfo.loadIcon(activity.packageManager) diff --git a/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt index 67712316..bea52946 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/adapters/ItemsAdapter.kt @@ -1116,8 +1116,8 @@ class ItemsAdapter( var itemToLoad = if (path.endsWith(".apk", true)) { val packageInfo = activity.packageManager.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES) - if (packageInfo != null) { - val appInfo = packageInfo.applicationInfo + val appInfo = packageInfo?.applicationInfo + if (appInfo != null) { appInfo.sourceDir = path appInfo.publicSourceDir = path appInfo.loadIcon(activity.packageManager) diff --git a/app/src/main/kotlin/org/fossify/filemanager/extensions/Activity.kt b/app/src/main/kotlin/org/fossify/filemanager/extensions/Activity.kt index 6d721421..82603c18 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/extensions/Activity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/extensions/Activity.kt @@ -2,8 +2,6 @@ package org.fossify.filemanager.extensions import android.app.Activity import android.content.Intent -import android.view.View -import androidx.appcompat.app.AppCompatActivity import androidx.core.content.FileProvider import org.fossify.commons.activities.BaseSimpleActivity import org.fossify.commons.extensions.getFilenameFromPath @@ -85,27 +83,3 @@ fun BaseSimpleActivity.toggleItemVisibility(oldPath: String, hide: Boolean, call } } } - -fun AppCompatActivity.showSystemUI(toggleActionBarVisibility: Boolean) { - if (toggleActionBarVisibility) { - supportActionBar?.show() - } - - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN -} - -fun AppCompatActivity.hideSystemUI(toggleActionBarVisibility: Boolean) { - if (toggleActionBarVisibility) { - supportActionBar?.hide() - } - - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or - View.SYSTEM_UI_FLAG_LOW_PROFILE or - View.SYSTEM_UI_FLAG_FULLSCREEN or - View.SYSTEM_UI_FLAG_IMMERSIVE -} diff --git a/app/src/main/res/layout/activity_decompress.xml b/app/src/main/res/layout/activity_decompress.xml index d2ee6c96..f8e1318d 100644 --- a/app/src/main/res/layout/activity_decompress.xml +++ b/app/src/main/res/layout/activity_decompress.xml @@ -5,22 +5,29 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:layout_height="wrap_content"> + + + + + android:scrollbars="none" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + android:layout_height="wrap_content"> + + + + + android:scrollbars="none" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + android:layout_height="wrap_content"> + + + + + android:scrollbars="none" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + android:layout_height="wrap_content"> + + + + + android:scrollbars="none" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + android:layout_height="wrap_content"> + + + + + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index e3311e70..a2c55413 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -6,21 +6,28 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:layout_height="wrap_content"> + + + + + android:scrollbars="none" + app:layout_behavior="@string/appbar_scrolling_view_behavior">