Skip to content

Commit

Permalink
navigation bar visibility changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Jan 21, 2024
1 parent cf568bc commit 42c10c2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -64,6 +65,8 @@ import kotlinx.coroutines.launch

class ApplicationLogsActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()

super.onCreate(savedInstanceState)
setContent {
val themeOption by PreferenceUtils.useIntPreference(PreferenceUtils.Key.THEME)
Expand Down
27 changes: 15 additions & 12 deletions app/src/main/java/com/geode/launcher/GeometryDashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import com.customRobTop.BaseRobTopActivity
import com.customRobTop.JniToCpp
import com.geode.launcher.utils.Constants
import com.geode.launcher.utils.DownloadUtils
import com.geode.launcher.utils.LaunchUtils
import com.geode.launcher.utils.GeodeUtils
import com.geode.launcher.utils.LaunchUtils
import com.geode.launcher.utils.PreferenceUtils
import org.cocos2dx.lib.Cocos2dxEditText
import org.cocos2dx.lib.Cocos2dxGLSurfaceView
Expand All @@ -46,10 +46,10 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
private var mReceiver: BroadcastReceiver? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setupUIState()

super.onCreate(savedInstanceState)

// return back to main if Geometry Dash isn't found
if (!LaunchUtils.isGeometryDashInstalled(packageManager)) {
returnToMain()
Expand Down Expand Up @@ -288,13 +288,24 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL

private fun hideSystemUi() {
WindowCompat.setDecorFitsSystemWindows(window, false)

WindowCompat.getInsetsController(window, window.decorView).apply {
hide(WindowInsetsCompat.Type.systemBars())
systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
hide(WindowInsetsCompat.Type.systemBars())
}
}

override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
super.onWindowFocusChanged(hasWindowFocus)
mHasWindowFocus = hasWindowFocus
if (hasWindowFocus && !mIsOnPause) {
resumeGame()
}

hideSystemUi()
}

override fun onDestroy() {
super.onDestroy()
unregisterReceivers()
Expand Down Expand Up @@ -350,14 +361,6 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
}
}

override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
super.onWindowFocusChanged(hasWindowFocus)
mHasWindowFocus = hasWindowFocus
if (hasWindowFocus && !mIsOnPause) {
resumeGame()
}
}

override fun runOnGLThread(runnable: Runnable) {
mGLSurfaceView?.queueEvent(runnable)
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/geode/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.text.format.Formatter.formatShortFileSize
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
Expand Down Expand Up @@ -51,6 +52,8 @@ import java.net.UnknownHostException

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()

super.onCreate(savedInstanceState)

val gdInstalled = LaunchUtils.isGeometryDashInstalled(packageManager)
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/geode/launcher/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
Expand Down Expand Up @@ -58,7 +59,9 @@ import java.net.UnknownHostException

class SettingsActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)

setContent {
val themeOption by PreferenceUtils.useIntPreference(PreferenceUtils.Key.THEME)
val theme = Theme.fromInt(themeOption)
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/java/com/geode/launcher/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,6 @@ fun GeodeLauncherTheme(
else -> LightColorScheme
}

val view = LocalView.current

if (!view.isInEditMode) {
SideEffect {
with ((view.context as Activity).window) {
WindowCompat.setDecorFitsSystemWindows(this, false)

statusBarColor = Color.Transparent.toArgb()
navigationBarColor = Color.Transparent.toArgb()

WindowCompat.getInsetsController(this, view).apply {
isAppearanceLightStatusBars = theme == Theme.LIGHT
isAppearanceLightNavigationBars = theme == Theme.LIGHT
}
}
}
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
Expand Down

0 comments on commit 42c10c2

Please sign in to comment.