From 80b0622e70b2a1a49f62888a2ac1912c767203ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 31 Dec 2024 14:49:26 +0100 Subject: [PATCH 1/8] Bump compile and target sdk to 35 (Android 15) --- config.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.gradle b/config.gradle index 8f971f88..205571ee 100644 --- a/config.gradle +++ b/config.gradle @@ -5,8 +5,8 @@ ext { buildConfig = [ "minSdk" : 21, - "compileSdk": 34, - "targetSdk" : 34, + "compileSdk": 35, + "targetSdk" : 35, "buildTools": "34.0.0" ] releaseConfig = [ From a11bde30e7c5056ec96aebaede2001c94c9dc68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 31 Dec 2024 15:01:18 +0100 Subject: [PATCH 2/8] Fix SDK 35 compile errors --- .../com/infinum/sentinel/data/models/raw/ApplicationData.kt | 2 +- .../sentinel/data/sources/raw/formatters/HtmlFormatter.kt | 2 +- .../sentinel/data/sources/raw/formatters/JsonFormatter.kt | 2 +- .../sentinel/data/sources/raw/formatters/XmlFormatter.kt | 2 +- .../sources/raw/formatters/shared/StringBuilderFormatter.kt | 2 +- .../infinum/sentinel/ui/main/application/ApplicationFragment.kt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/raw/ApplicationData.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/raw/ApplicationData.kt index ad25da58..593020b1 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/raw/ApplicationData.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/data/models/raw/ApplicationData.kt @@ -6,7 +6,7 @@ internal data class ApplicationData( val applicationIcon: Drawable, val applicationName: String, val versionCode: String, - val versionName: String, + val versionName: String?, val firstInstall: String, val lastUpdate: String, val minSdk: String, diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/HtmlFormatter.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/HtmlFormatter.kt index 05a5fa20..0ec24ddb 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/HtmlFormatter.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/HtmlFormatter.kt @@ -83,7 +83,7 @@ internal class HtmlFormatter( .apply { applicationCollector().let { addDiv(R.string.sentinel_version_code, it.versionCode) - addDiv(R.string.sentinel_version_name, it.versionName) + addDiv(R.string.sentinel_version_name, it.versionName ?: "") addDiv(R.string.sentinel_first_install, it.firstInstall) addDiv(R.string.sentinel_last_update, it.lastUpdate) addDiv(R.string.sentinel_min_sdk, it.minSdk) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/JsonFormatter.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/JsonFormatter.kt index db160a80..ab20bd11 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/JsonFormatter.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/JsonFormatter.kt @@ -60,7 +60,7 @@ internal class JsonFormatter( JSONObject().apply { applicationCollector().let { addKey(R.string.sentinel_version_code, it.versionCode) - addKey(R.string.sentinel_version_name, it.versionName) + addKey(R.string.sentinel_version_name, it.versionName ?: "") addKey(R.string.sentinel_first_install, it.firstInstall) addKey(R.string.sentinel_last_update, it.lastUpdate) addKey(R.string.sentinel_min_sdk, it.minSdk) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/XmlFormatter.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/XmlFormatter.kt index c6a4415d..e8730409 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/XmlFormatter.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/XmlFormatter.kt @@ -91,7 +91,7 @@ internal class XmlFormatter( startTag(NAMESPACE, APPLICATION) applicationCollector().let { addNode(R.string.sentinel_version_code, it.versionCode) - addNode(R.string.sentinel_version_name, it.versionName) + addNode(R.string.sentinel_version_name, it.versionName ?: "") addNode(R.string.sentinel_first_install, it.firstInstall) addNode(R.string.sentinel_last_update, it.lastUpdate) addNode(R.string.sentinel_min_sdk, it.minSdk) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/shared/StringBuilderFormatter.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/shared/StringBuilderFormatter.kt index 09dc7922..c05852df 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/shared/StringBuilderFormatter.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/data/sources/raw/formatters/shared/StringBuilderFormatter.kt @@ -34,7 +34,7 @@ internal abstract class StringBuilderFormatter { internal fun addApplicationData(builder: StringBuilder, data: ApplicationData) { addLine(builder, R.string.sentinel_version_code, data.versionCode) - addLine(builder, R.string.sentinel_version_name, data.versionName) + addLine(builder, R.string.sentinel_version_name, data.versionName ?: "") addLine(builder, R.string.sentinel_first_install, data.firstInstall) addLine(builder, R.string.sentinel_last_update, data.lastUpdate) addLine(builder, R.string.sentinel_min_sdk, data.minSdk) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/main/application/ApplicationFragment.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/main/application/ApplicationFragment.kt index be389583..2c38787a 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/main/application/ApplicationFragment.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/main/application/ApplicationFragment.kt @@ -26,7 +26,7 @@ internal class ApplicationFragment : when (state) { is ApplicationState.Data -> with(binding) { versionCodeView.data = state.value.versionCode - versionNameView.data = state.value.versionName + versionNameView.data = state.value.versionName ?: "" firstInstallView.data = state.value.firstInstall lastUpdateView.data = state.value.lastUpdate minSdkView.data = state.value.minSdk From 69edebdb6cd83ec8033a7ac805ba49e5e48d7580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Tue, 31 Dec 2024 15:31:12 +0100 Subject: [PATCH 3/8] Fix edge to edge support --- gradle/libs.versions.toml | 2 +- .../src/main/res/layout/sentinel_fragment_bundle_details.xml | 1 + sentinel/src/main/res/layout/sentinel_fragment_bundles.xml | 1 + .../main/res/layout/sentinel_fragment_certificate_details.xml | 1 + sentinel/src/main/res/layout/sentinel_fragment_certificates.xml | 1 + .../src/main/res/layout/sentinel_fragment_crash_details.xml | 1 + sentinel/src/main/res/layout/sentinel_fragment_crashes.xml | 1 + .../src/main/res/layout/sentinel_fragment_preference_editor.xml | 1 + sentinel/src/main/res/layout/sentinel_fragment_settings.xml | 1 + tool-timber/src/main/res/layout/sentinel_activity_logger.xml | 1 + tool-timber/src/main/res/layout/sentinel_activity_logs.xml | 1 + 11 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 22413f7f..025f1bbd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,7 +24,7 @@ ktlintplugin = "11.3.1" ktlint = "0.45.2" cpd = "3.3" dokka = "1.8.10" -chucker = "4.0.0" +chucker = "4.1.0" collar = "1.4.0" dbinspector = "5.4.9" leakcanary = "2.11" diff --git a/sentinel/src/main/res/layout/sentinel_fragment_bundle_details.xml b/sentinel/src/main/res/layout/sentinel_fragment_bundle_details.xml index 2b8170c7..0b27ecd0 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_bundle_details.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_bundle_details.xml @@ -8,6 +8,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> diff --git a/sentinel/src/main/res/layout/sentinel_fragment_bundles.xml b/sentinel/src/main/res/layout/sentinel_fragment_bundles.xml index 4de04181..8b96badd 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_bundles.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_bundles.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> diff --git a/sentinel/src/main/res/layout/sentinel_fragment_certificate_details.xml b/sentinel/src/main/res/layout/sentinel_fragment_certificate_details.xml index b25987dd..d9006cd1 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_certificate_details.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_certificate_details.xml @@ -8,6 +8,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> diff --git a/sentinel/src/main/res/layout/sentinel_fragment_certificates.xml b/sentinel/src/main/res/layout/sentinel_fragment_certificates.xml index bfbbc8f4..9e7896b0 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_certificates.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_certificates.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> diff --git a/sentinel/src/main/res/layout/sentinel_fragment_crash_details.xml b/sentinel/src/main/res/layout/sentinel_fragment_crash_details.xml index 9c1df033..663b1fcd 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_crash_details.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_crash_details.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> diff --git a/sentinel/src/main/res/layout/sentinel_fragment_crashes.xml b/sentinel/src/main/res/layout/sentinel_fragment_crashes.xml index f93fd3dc..42e20478 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_crashes.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_crashes.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> diff --git a/sentinel/src/main/res/layout/sentinel_fragment_preference_editor.xml b/sentinel/src/main/res/layout/sentinel_fragment_preference_editor.xml index 978a5321..868e9533 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_preference_editor.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_preference_editor.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/nestedScrollView"> diff --git a/sentinel/src/main/res/layout/sentinel_fragment_settings.xml b/sentinel/src/main/res/layout/sentinel_fragment_settings.xml index 953fdbec..8efc6db2 100644 --- a/sentinel/src/main/res/layout/sentinel_fragment_settings.xml +++ b/sentinel/src/main/res/layout/sentinel_fragment_settings.xml @@ -8,6 +8,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/nestedScrollView"> diff --git a/tool-timber/src/main/res/layout/sentinel_activity_logger.xml b/tool-timber/src/main/res/layout/sentinel_activity_logger.xml index d6e334be..72fba56f 100644 --- a/tool-timber/src/main/res/layout/sentinel_activity_logger.xml +++ b/tool-timber/src/main/res/layout/sentinel_activity_logger.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> diff --git a/tool-timber/src/main/res/layout/sentinel_activity_logs.xml b/tool-timber/src/main/res/layout/sentinel_activity_logs.xml index d585744a..6d9c750c 100644 --- a/tool-timber/src/main/res/layout/sentinel_activity_logs.xml +++ b/tool-timber/src/main/res/layout/sentinel_activity_logs.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:colorBackground" + android:fitsSystemWindows="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior" app:liftOnScroll="true" app:liftOnScrollTargetViewId="@id/recyclerView"> From b4e1725e751502a70927701063f7c7d6055369b4 Mon Sep 17 00:00:00 2001 From: Asim Ribo Date: Wed, 8 Jan 2025 12:27:18 +0100 Subject: [PATCH 4/8] Enable edge to edge --- .../infinum/sentinel/sample/BundleActivity.kt | 2 ++ .../sentinel/sample/JavaMainActivity.java | 34 +++++++++++++++++-- .../infinum/sentinel/sample/MainActivity.kt | 3 ++ sample/src/main/res/values/styles.xml | 2 +- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/sample/src/main/kotlin/com/infinum/sentinel/sample/BundleActivity.kt b/sample/src/main/kotlin/com/infinum/sentinel/sample/BundleActivity.kt index 0f9e3782..9de32a87 100644 --- a/sample/src/main/kotlin/com/infinum/sentinel/sample/BundleActivity.kt +++ b/sample/src/main/kotlin/com/infinum/sentinel/sample/BundleActivity.kt @@ -1,6 +1,7 @@ package com.infinum.sentinel.sample import android.os.Bundle +import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import com.infinum.sentinel.sample.databinding.ActivityBundleBinding @@ -9,6 +10,7 @@ class BundleActivity : AppCompatActivity() { private lateinit var viewBinding: ActivityBundleBinding override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() super.onCreate(savedInstanceState) viewBinding = ActivityBundleBinding.inflate(layoutInflater) diff --git a/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java b/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java index a2338fce..8c832754 100644 --- a/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java +++ b/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java @@ -1,10 +1,15 @@ package com.infinum.sentinel.sample; +import android.content.res.Configuration; +import android.graphics.Color; import android.os.Build; import android.os.Bundle; +import android.view.View; +import android.view.Window; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.view.WindowCompat; import com.infinum.sentinel.Sentinel; import com.infinum.sentinel.sample.databinding.ActivityJavaMainBinding; @@ -23,8 +28,8 @@ public class JavaMainActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + setEdgeToEdge(); super.onCreate(savedInstanceState); - final ActivityJavaMainBinding viewBinding = ActivityJavaMainBinding.inflate(getLayoutInflater()); setContentView(viewBinding.getRoot()); @@ -35,11 +40,36 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { tools.add(new GooglePlayTool()); tools.add(new ThimbleTool()); tools.add(new TimberTool()); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { tools.add(new CertificateTool()); } Sentinel.watch(tools); viewBinding.showSentinel.setOnClickListener(v -> Sentinel.show()); } + + private void setEdgeToEdge() { + Window window = getWindow(); + WindowCompat.setDecorFitsSystemWindows(window, false); + window.setStatusBarColor(Color.TRANSPARENT); + window.setNavigationBarColor(Color.TRANSPARENT); + + handleStatusBarFlag(window); + } + + private void handleStatusBarFlag(Window window) { + View decorView = window.getDecorView(); + int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; + if (isLightMode()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } + } + decorView.setSystemUiVisibility(flags); + } + + private boolean isLightMode() { + int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + return currentNightMode != Configuration.UI_MODE_NIGHT_YES; + } } diff --git a/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt b/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt index 02e5cf23..d431c85a 100644 --- a/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt +++ b/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt @@ -5,6 +5,7 @@ import android.content.Intent import android.content.SharedPreferences import android.os.Bundle import android.util.Log +import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.preference.PreferenceManager import androidx.security.crypto.EncryptedSharedPreferences @@ -23,7 +24,9 @@ class MainActivity : AppCompatActivity() { @Suppress("TooGenericExceptionCaught", "LongMethod") override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() super.onCreate(savedInstanceState) + viewBinding = ActivityMainBinding.inflate(layoutInflater) setContentView(viewBinding.root) diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml index 6287ada9..4c69df7a 100644 --- a/sample/src/main/res/values/styles.xml +++ b/sample/src/main/res/values/styles.xml @@ -1,5 +1,5 @@ - From bce9d74e53e143a303de4a0958abe28b07069152 Mon Sep 17 00:00:00 2001 From: Asim Ribo Date: Wed, 8 Jan 2025 13:37:09 +0100 Subject: [PATCH 5/8] Merge double if into a single one --- .../com/infinum/sentinel/sample/JavaMainActivity.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java b/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java index 8c832754..0b10c28f 100644 --- a/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java +++ b/sample/src/main/kotlin/com/infinum/sentinel/sample/JavaMainActivity.java @@ -60,10 +60,8 @@ private void setEdgeToEdge() { private void handleStatusBarFlag(Window window) { View decorView = window.getDecorView(); int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; - if (isLightMode()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } + if (isLightMode() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } decorView.setSystemUiVisibility(flags); } From f58b6f43dd9e08b159b52ebb1c739b608b60c793 Mon Sep 17 00:00:00 2001 From: Asim Ribo Date: Wed, 8 Jan 2025 15:25:32 +0100 Subject: [PATCH 6/8] Apply insets to last element to prevent overlap with system navigation --- .../com/infinum/sentinel/sample/MainActivity.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt b/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt index d431c85a..533cae64 100644 --- a/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt +++ b/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt @@ -5,8 +5,12 @@ import android.content.Intent import android.content.SharedPreferences import android.os.Bundle import android.util.Log +import android.view.ViewGroup import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.updateLayoutParams import androidx.preference.PreferenceManager import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKey @@ -30,6 +34,9 @@ class MainActivity : AppCompatActivity() { viewBinding = ActivityMainBinding.inflate(layoutInflater) setContentView(viewBinding.root) + + applyInsetsToLastElement() + val allPrefs = listOf( PreferenceManager.getDefaultSharedPreferences(applicationContext), applicationContext.getSharedPreferences( @@ -161,6 +168,16 @@ class MainActivity : AppCompatActivity() { } } + private fun applyInsetsToLastElement() { + ViewCompat.setOnApplyWindowInsetsListener(viewBinding.generateErrorException) { view, insets -> + val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + view.updateLayoutParams { + bottomMargin = systemBarsInsets.bottom + } + insets + } + } + private fun putRandomIntoPreferences(sharedPreferences: SharedPreferences) = sharedPreferences.edit() .putBoolean(randomizeName(Boolean::class.simpleName), Random.nextBoolean()) From b42bc55b7e0d1225f1f45aa2f115c777673e7770 Mon Sep 17 00:00:00 2001 From: Asim Ribo Date: Wed, 8 Jan 2025 15:36:54 +0100 Subject: [PATCH 7/8] Remove extra empty line --- .../src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt b/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt index 533cae64..af4aac8f 100644 --- a/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt +++ b/sample/src/main/kotlin/com/infinum/sentinel/sample/MainActivity.kt @@ -34,7 +34,6 @@ class MainActivity : AppCompatActivity() { viewBinding = ActivityMainBinding.inflate(layoutInflater) setContentView(viewBinding.root) - applyInsetsToLastElement() val allPrefs = listOf( From 869f8716e7b8d1303ef2cee396934c645b84c48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karlo=20=C4=8Ceh?= Date: Fri, 10 Jan 2025 13:17:07 +0100 Subject: [PATCH 8/8] Enable edge-to-edge for all sentinel activities --- .../kotlin/com/infinum/sentinel/ui/shared/base/BaseActivity.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/base/BaseActivity.kt b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/base/BaseActivity.kt index 59948487..967c83c7 100644 --- a/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/base/BaseActivity.kt +++ b/sentinel/src/main/kotlin/com/infinum/sentinel/ui/shared/base/BaseActivity.kt @@ -3,6 +3,7 @@ package com.infinum.sentinel.ui.shared.base import android.content.res.Configuration import android.os.Build import android.os.Bundle +import androidx.activity.enableEdgeToEdge import androidx.annotation.CallSuper import androidx.annotation.RestrictTo import androidx.core.content.ContextCompat @@ -17,6 +18,8 @@ internal abstract class BaseActivity : FragmentActivity(), BaseVie override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + enableEdgeToEdge() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) { Configuration.UI_MODE_NIGHT_YES -> false