Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 15: Edge-To-Edge #1469

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package eu.darken.sdmse.common
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.content.res.ColorStateList
import android.content.res.TypedArray
import android.util.TypedValue
import androidx.annotation.*
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.PluralsRes
import androidx.core.content.ContextCompat
import eu.darken.sdmse.common.debug.logging.log
import okio.Source
Expand Down Expand Up @@ -77,4 +81,6 @@ fun Context.getSpanCount(widthDp: Int = 390): Int {
return max(count, 1).also {
log { "getSpanCount($screenWidthDp/$widthDp)=$it" }
}
}
}

fun Context.getPackageInfo(): PackageInfo = packageManager.getPackageInfo(packageName, 0)
12 changes: 10 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ apply(plugin = "androidx.navigation.safeargs.kotlin")
val commitHashProvider = providers.of(CommitHashValueSource::class) {}

android {
compileSdk = projectConfig.compileSdk
if (projectConfig.compileSdkPreview != null) {
compileSdkPreview = projectConfig.compileSdkPreview
} else {
compileSdk = projectConfig.compileSdk
}

defaultConfig {
namespace = projectConfig.packageName

minSdk = projectConfig.minSdk
targetSdk = projectConfig.targetSdk
if (projectConfig.targetSdkPreview != null) {
targetSdkPreview = projectConfig.targetSdkPreview
} else {
targetSdk = projectConfig.targetSdk
}

versionCode = projectConfig.version.code.toInt()
versionName = projectConfig.version.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import eu.darken.sdmse.common.debug.logging.Logging.Priority.WARN
import eu.darken.sdmse.common.debug.logging.asLog
import eu.darken.sdmse.common.debug.logging.log
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.getPackageInfo
import eu.darken.sdmse.common.pkgs.features.getInstallerInfo
import java.time.Duration
import java.time.Instant
Expand Down Expand Up @@ -96,8 +97,7 @@ class FossUpdateChecker @Inject constructor(

override fun isEnabledByDefault(): Boolean {
val pm = context.packageManager
val installers: Set<String> = pm
.getPackageInfo(context.packageName, 0)
val installers: Set<String> = context.getPackageInfo()
.getInstallerInfo(pm)
.allInstallers
.map { it.id.name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.setupWithNavController
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.uix.Fragment3
import eu.darken.sdmse.common.viewbinding.viewBinding
import eu.darken.sdmse.databinding.UpgradeFragmentBinding
Expand All @@ -19,6 +20,11 @@ class UpgradeFragment : Fragment3(R.layout.upgrade_fragment) {
override val ui: UpgradeFragmentBinding by viewBinding()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.scrollView)
}

ui.toolbar.setupWithNavController(findNavController())

ui.upgradeGithubSponsorsAction.setOnClickListener {
Expand Down
3 changes: 2 additions & 1 deletion app/src/foss/res/layout/upgrade_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
android:id="@+id/toolbar"
style="@style/Widget.MaterialComponents.Toolbar.Surface"
android:layout_width="0dp"
android:minHeight="?actionBarSize"
android:layout_height="wrap_content"
android:minHeight="?actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand All @@ -19,6 +19,7 @@
app:titleCentered="true" />

<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.navigation.ui.setupWithNavController
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.log
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.uix.Fragment3
Expand All @@ -24,6 +25,11 @@ class UpgradeFragment : Fragment3(R.layout.upgrade_fragment) {
override val ui: UpgradeFragmentBinding by viewBinding()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.scrollView)
}

ui.toolbar.setupWithNavController(findNavController())

vm.state.observe2(ui) { state ->
Expand Down
2 changes: 2 additions & 0 deletions app/src/gplay/res/layout/upgrade_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/scrollView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">

<LinearLayout
android:id="@+id/scrollview_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.lists.differ.update
import eu.darken.sdmse.common.lists.setupDefaults
Expand All @@ -26,6 +27,11 @@ class AppDetailsFragment : Fragment3(R.layout.analyzer_app_fragment) {
get() = ui.toolbar.menu?.findItem(R.id.menu_action_refresh)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.list)
}

ui.toolbar.apply {
setupWithNavController(findNavController())
setOnMenuItemClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.navigation.ui.setupWithNavController
import androidx.recyclerview.widget.GridLayoutManager
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.lists.differ.update
import eu.darken.sdmse.common.lists.setupDefaults
Expand All @@ -24,6 +25,11 @@ class AppsFragment : Fragment3(R.layout.analyzer_apps_fragment) {
override val ui: AnalyzerAppsFragmentBinding by viewBinding()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.list)
}

ui.toolbar.apply {
setupWithNavController(findNavController())
setOnMenuItemClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.error.asErrorDialogBuilder
import eu.darken.sdmse.common.getQuantityString2
Expand Down Expand Up @@ -46,6 +47,11 @@ class ContentFragment : Fragment3(R.layout.analyzer_content_fragment) {
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.list)
}

ui.toolbar.apply {
setupWithNavController(findNavController())
setNavigationOnClickListener { vm.onNavigateBack() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.navigation.ui.setupWithNavController
import androidx.recyclerview.widget.GridLayoutManager
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.lists.differ.update
import eu.darken.sdmse.common.lists.setupDefaults
Expand All @@ -22,7 +23,14 @@ class DeviceStorageFragment : Fragment3(R.layout.analyzer_device_fragment) {

override val vm: DeviceStorageViewModel by viewModels()
override val ui: AnalyzerDeviceFragmentBinding by viewBinding()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.list)
bottomHalf(ui.refreshActionContainer)
}

ui.toolbar.apply {
setupWithNavController(findNavController())
setOnMenuItemClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.navigation.ui.setupWithNavController
import androidx.recyclerview.widget.GridLayoutManager
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.lists.differ.update
import eu.darken.sdmse.common.lists.setupDefaults
Expand All @@ -36,6 +37,12 @@ class StorageContentFragment : Fragment3(R.layout.analyzer_storage_fragment) {
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.list)
bottomHalf(ui.refreshActionContainer)
}

ui.toolbar.apply {
setupWithNavController(findNavController())
setOnMenuItemClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.viewpager.widget.ViewPager
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.log
import eu.darken.sdmse.common.uix.Fragment3
import eu.darken.sdmse.common.viewbinding.viewBinding
Expand All @@ -26,14 +27,17 @@ class AppJunkDetailsFragment : Fragment3(R.layout.appcleaner_details_fragment) {
@Inject lateinit var dashAdapter: DashboardAdapter

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
}

ui.toolbar.apply {
setupWithNavController(findNavController())
setOnMenuItemClickListener {
when (it.itemId) {
else -> super.onOptionsItemSelected(it)
}
}

}

val pagerAdapter = AppJunkDetailsPagerAdapter(requireActivity(), childFragmentManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import eu.darken.sdmse.appcleaner.ui.details.appjunk.elements.AppJunkElementFile
import eu.darken.sdmse.appcleaner.ui.details.appjunk.elements.AppJunkElementHeaderVH
import eu.darken.sdmse.appcleaner.ui.details.appjunk.elements.AppJunkElementInaccessibleVH
import eu.darken.sdmse.appcleaner.ui.labelRes
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.lists.ViewHolderBasedDivider
import eu.darken.sdmse.common.lists.differ.update
import eu.darken.sdmse.common.lists.installListSelection
Expand Down Expand Up @@ -46,6 +47,10 @@ class AppJunkFragment : Fragment3(R.layout.appcleaner_appjunk_fragment) {
get() = requireParentFragment().requireView().findViewById(R.id.viewpager)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
bottomHalf(ui.list)
}

val adapter = AppJunkElementsAdapter()
ui.list.apply {
setupDefaults(adapter, verticalDividers = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.getQuantityString2
import eu.darken.sdmse.common.lists.differ.update
import eu.darken.sdmse.common.lists.installListSelection
Expand All @@ -30,6 +31,11 @@ class AppCleanerListFragment : Fragment3(R.layout.appcleaner_list_fragment) {
override val ui: AppcleanerListFragmentBinding by viewBinding()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
topHalf(ui.toolbar)
bottomHalf(ui.list)
}

ui.toolbar.apply {
setupWithNavController(findNavController())
setOnMenuItemClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.appcontrol.core.FilterSettings
import eu.darken.sdmse.appcontrol.core.SortSettings
import eu.darken.sdmse.common.EdgeToEdge
import eu.darken.sdmse.common.debug.logging.Logging.Priority.WARN
import eu.darken.sdmse.common.debug.logging.log
import eu.darken.sdmse.common.debug.logging.logTag
Expand Down Expand Up @@ -88,6 +89,9 @@ class AppControlListFragment : Fragment3(R.layout.appcontrol_list_fragment) {
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
EdgeToEdge().apply {
whole(ui.root)
}
ui.list.setupDefaults(
adapter = adapter,
horizontalDividers = true,
Expand Down
59 changes: 59 additions & 0 deletions app/src/main/java/eu/darken/sdmse/common/EdgeToEdgeExtensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package eu.darken.sdmse.common

import android.view.View
import androidx.core.graphics.Insets
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat


class EdgeToEdge {

fun whole(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
val systemBars: Insets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
}

fun topHalf(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
val systemBars: Insets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, 0)
insets
}
}

fun middleEdge(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
val systemBars: Insets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, 0, systemBars.right, 0)
insets
}
}

fun leftHalf(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
val systemBars: Insets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, 0, systemBars.bottom)
insets
}
}

fun rightHalf(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
val systemBars: Insets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(0, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
}

fun bottomHalf(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
val systemBars: Insets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, 0, systemBars.right, systemBars.bottom)
insets
}
}

}
Loading
Loading