Skip to content

Commit

Permalink
feat(ui): switch to androidx edge to edge implementation (#690)
Browse files Browse the repository at this point in the history
* switch to androidx edge to edge implementation

* switch to androidx edge to edge implementation for CrashReportActivity

* Remove systemuicontroller
enableEdgeToEdge() has replaced systemuicontroller

* Remove systemuicontroller dependency

* clean code
  • Loading branch information
Moderpach committed Apr 27, 2024
1 parent 71b470a commit 1199c68
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ dependencies {
implementation "androidx.compose.material3:material3:$material3"

// https://github.com/google/accompanist/releases
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist"
implementation "com.google.accompanist:accompanist-pager:$accompanist"
implementation "com.google.accompanist:accompanist-flowlayout:$accompanist"
implementation "com.google.accompanist:accompanist-navigation-animation:$accompanist"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

package me.ash.reader.infrastructure.android

import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -41,8 +43,6 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import me.ash.reader.R
import me.ash.reader.infrastructure.preference.LocalDarkTheme
import me.ash.reader.infrastructure.preference.LocalOpenLink
Expand All @@ -55,11 +55,9 @@ import me.ash.reader.ui.theme.AppTheme
class CrashReportActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { v, insets ->
v.setPadding(0, 0, 0, 0)
insets
}

enableEdgeToEdge()

val errorMessage: String = intent.getStringExtra(ERROR_REPORT_KEY).toString()

setContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.util.Log
import android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
import android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.CompositionLocalProvider
Expand Down Expand Up @@ -45,12 +46,10 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.addFlags(FLAG_LAYOUT_IN_SCREEN or FLAG_LAYOUT_NO_LIMITS)
}
Log.i("RLog", "onCreate: ${ProfileInstallerInitializer().create(this)}")

enableEdgeToEdge()

// Set the language
if (Build.VERSION.SDK_INT < 33) {
LanguagesPreference.fromValue(languages).let {
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/java/me/ash/reader/ui/page/common/HomeEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.hilt.navigation.compose.hiltViewModel
import com.google.accompanist.navigation.animation.AnimatedNavHost
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collectLatest
import me.ash.reader.domain.model.general.Filter
Expand Down Expand Up @@ -144,12 +142,6 @@ fun HomeEntry(
else LocalDarkTheme.current.isDarkTheme()
) {

rememberSystemUiController().run {
setStatusBarColor(Color.Transparent, !useDarkTheme)
setSystemBarsColor(Color.Transparent, !useDarkTheme)
setNavigationBarColor(Color.Transparent, !useDarkTheme)
}

AnimatedNavHost(
modifier = Modifier.background(MaterialTheme.colorScheme.surface),
navController = navController,
Expand Down

0 comments on commit 1199c68

Please sign in to comment.