From 91b1f4775b9ff61c895f18b5c5d06e1c547fadd1 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Thu, 18 Jan 2024 02:04:14 -0600 Subject: [PATCH] status bar height fix --- app/src/main/java/ani/dantotsu/MainActivity.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ani/dantotsu/MainActivity.kt b/app/src/main/java/ani/dantotsu/MainActivity.kt index 6ff1aeed66..eadae423a7 100644 --- a/app/src/main/java/ani/dantotsu/MainActivity.kt +++ b/app/src/main/java/ani/dantotsu/MainActivity.kt @@ -1,6 +1,7 @@ package ani.dantotsu import android.animation.ObjectAnimator +import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.graphics.drawable.Animatable @@ -68,6 +69,7 @@ class MainActivity : AppCompatActivity() { private var uiSettings = UserInterfaceSettings() + @SuppressLint("InternalInsetResource", "DiscouragedApi") @OptIn(UnstableApi::class) override fun onCreate(savedInstanceState: Bundle?) { ThemeManager(this).applyTheme() @@ -96,8 +98,14 @@ class MainActivity : AppCompatActivity() { } + val offset = try { + val statusBarHeightId = resources.getIdentifier("status_bar_height", "dimen", "android") + resources.getDimensionPixelSize(statusBarHeightId) + } catch (e: Exception) { + statusBarHeight + } val layoutParams = binding.incognitoTextView.layoutParams as ViewGroup.MarginLayoutParams - layoutParams.topMargin = 11 * statusBarHeight / 12 + layoutParams.topMargin = 11 * offset / 12 binding.incognitoTextView.layoutParams = layoutParams incognitoLiveData = SharedPreferenceBooleanLiveData( sharedPreferences,