Procházet zdrojové kódy

working on statusBarColor and navigationBarColor

Khubaib před 10 měsíci
rodič
revize
a12b12fc1d

+ 6 - 0
app/src/main/AndroidManifest.xml

@@ -61,6 +61,12 @@
                 <category android:name="android.intent.category.LAUNCHER" />
                 <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
             </intent-filter>
+            <meta-data
+                android:name="android:windowTranslucentStatus"
+                android:value="true" />
+            <meta-data
+                android:name="android:windowFullscreen"
+                android:value="true" />
         </activity>
         <activity
             android:name=".activities.SplashActivity"

+ 8 - 0
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/AccountScreen.kt

@@ -1,5 +1,6 @@
 package com.vpn.fastestvpnservice.screens.bottomNavBarScreens
 
+import android.app.Activity
 import android.content.Intent
 import android.content.res.Configuration
 import android.os.Handler
@@ -51,9 +52,11 @@ import androidx.compose.ui.draw.alpha
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.ColorFilter
 import androidx.compose.ui.graphics.painter.Painter
+import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.input.pointer.pointerInput
 import androidx.compose.ui.platform.LocalConfiguration
 import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalView
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.TextStyle
@@ -103,6 +106,11 @@ fun Account(navHostController: NavHostController,
 //        contentAlignment = Alignment.Center
 
         ) {
+            val view = LocalView.current
+            val window = (view.context as Activity).window
+            window.statusBarColor = MaterialTheme.colorScheme.background.toArgb()
+            window.navigationBarColor = MaterialTheme.colorScheme.onBackground.toArgb()
+
             Column(
                 verticalArrangement = Arrangement.Top,
                 horizontalAlignment = Alignment.Start,

+ 8 - 0
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/HelpScreen.kt

@@ -1,5 +1,6 @@
 package com.vpn.fastestvpnservice.screens.bottomNavBarScreens
 
+import android.app.Activity
 import android.util.Log
 import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.Image
@@ -31,8 +32,10 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.alpha
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.ColorFilter
+import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.graphics.vector.ImageVector
 import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.platform.LocalView
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.TextUnit
@@ -59,6 +62,11 @@ fun Help(navHostController: NavHostController) {
 //        contentAlignment = Alignment.Center
 
         ) {
+            val view = LocalView.current
+            val window = (view.context as Activity).window
+            window.statusBarColor = MaterialTheme.colorScheme.background.toArgb()
+            window.navigationBarColor = MaterialTheme.colorScheme.onBackground.toArgb()
+
             Column(
                 verticalArrangement = Arrangement.Top,
                 horizontalAlignment = Alignment.Start,

+ 18 - 2
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/HomeScreen.kt

@@ -1,9 +1,10 @@
 package com.vpn.fastestvpnservice.screens.bottomNavBarScreens
 
+import android.app.Activity
 import android.content.Context
 import android.content.Intent
 import android.content.res.Configuration
-import android.net.TrafficStats
+import androidx.compose.ui.graphics.Color
 import android.os.Handler
 import android.util.Log
 import androidx.activity.ComponentActivity
@@ -52,14 +53,15 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.alpha
 import androidx.compose.ui.draw.clip
 import androidx.compose.ui.draw.paint
-import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.ColorFilter
 import androidx.compose.ui.graphics.painter.Painter
+import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.input.pointer.pointerInput
 import androidx.compose.ui.layout.ContentScale
 import androidx.compose.ui.platform.LocalConfiguration
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalLifecycleOwner
+import androidx.compose.ui.platform.LocalView
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.AnnotatedString
@@ -71,6 +73,7 @@ import androidx.compose.ui.unit.sp
 import androidx.compose.ui.window.DialogProperties
 import androidx.constraintlayout.compose.ConstraintLayout
 import androidx.constraintlayout.compose.Dimension
+import androidx.core.graphics.toColorInt
 import androidx.lifecycle.Lifecycle
 import androidx.lifecycle.LifecycleEventObserver
 import androidx.lifecycle.LifecycleOwner
@@ -344,11 +347,24 @@ fun Home(
 
 //    Log.d("test_istablet", "Is Tablet ? $isTablet , width = ${configuration.screenWidthDp}, height = ${configuration.screenHeightDp}")
 
+
     Column(
         modifier = Modifier
             .background(MaterialTheme.colorScheme.background)
             .fillMaxSize(),
     ) {
+//        val alpha = (255.0 * 0.1).toInt()
+//        val color = Color(141, 8, 1, alpha)
+//        val s = String.format("#%06X", (color.toArgb() and 0xFFFFFF))
+//
+//        val c = Color(0x1A8d0801)
+        val view = LocalView.current
+        val window = (view.context as Activity).window
+
+        window.statusBarColor = colorResource(id = R.color.pink_background).toArgb()
+//        window.statusBarColor = Color(0x1A8d0801).toArgb()
+        window.navigationBarColor = MaterialTheme.colorScheme.onBackground.toArgb()
+
         if (isServerDialog.value) {
             ShowServerDialog(
                 basePreferenceHelper,

+ 23 - 4
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/SettingsScreen.kt

@@ -8,7 +8,10 @@ import android.os.Build
 import android.os.Bundle
 import android.os.Handler
 import android.util.Log
+import android.view.View
+import android.view.WindowManager
 import android.widget.Toast
+import androidx.annotation.RequiresApi
 import androidx.compose.animation.AnimatedVisibility
 import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.Image
@@ -103,7 +106,9 @@ import androidx.compose.ui.unit.Dp
 import androidx.compose.ui.unit.TextUnit
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import androidx.core.content.ContextCompat
 import androidx.core.content.ContextCompat.startActivity
+import androidx.core.view.WindowCompat
 import androidx.lifecycle.viewmodel.compose.viewModel
 import androidx.navigation.NavHostController
 import androidx.navigation.compose.rememberNavController
@@ -141,11 +146,25 @@ fun Settings(navHostController: NavHostController) {
             ,
 //        contentAlignment = Alignment.Center
         ) {
-//        val view = LocalView.current
-//        val window = (view.context as Activity).window
-//        window.statusBarColor = colorResource(id = R.color.background_color_gray2).toArgb()
 
-            val context = LocalContext.current
+        val context = LocalContext.current
+        val view = LocalView.current
+        val window = (view.context as Activity).window
+        window.statusBarColor = MaterialTheme.colorScheme.background.toArgb()
+        window.navigationBarColor = MaterialTheme.colorScheme.onBackground.toArgb()
+
+//        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
+//        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
+//            window.addFlags(View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
+//            WindowCompat.setDecorFitsSystemWindows(window, false)
+//            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
+//            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
+//            window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_FULLSCREEN)
+//            window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
+//            @RequiresApi(Build.VERSION_CODES.Q)
+//            window.isStatusBarContrastEnforced = true
+//            window.statusBarColor = ContextCompat.getColor(context, R.color.yellow_text)
+
             val basePreferenceHelper = BasePreferenceHelper(context)
             Column(
                 verticalArrangement = Arrangement.Top,

+ 1 - 1
app/src/main/java/com/vpn/fastestvpnservice/ui/theme/Theme.kt

@@ -116,7 +116,7 @@ fun FastestVPNTheme(
         SideEffect {
             val window = (view.context as Activity).window
 //            window.statusBarColor = colorScheme.primary.toArgb()
-            WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
+            WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
         }
     }
 

+ 1 - 0
app/src/main/res/values/colors.xml

@@ -34,6 +34,7 @@
     <color name="dark_black_gray">#2d2d2d</color>
     <color name="pink_color">#bd9fa7</color>
     <color name="maroon_text">#a61c3c</color>
+    <color name="pink_background">#ECDEE1</color>
     <color name="switch_green">#17AA5D</color>
     <color name="switch_gray">#bfbfbb</color>
     <color name="radio_button_blue">#4287f5</color>

+ 10 - 0
app/src/main/res/values/themes.xml

@@ -8,6 +8,16 @@
     <style name="Theme.AppCompat.Light.NoActionBar.App" parent="Theme.AppCompat.Light.NoActionBar" >
         <item name="android:windowDisablePreview">true</item>
         <item name="android:windowBackground">@color/light_blue</item>
+
+<!--        <item name="android:statusBarColor">@color/background_color_gray</item>-->
+<!--        <item name="statusBarForeground">@color/background_color_gray</item>-->
+<!--        <item name="statusBarBackground">@color/background_color_gray</item>-->
+<!--        <item name="statusBarScrim">@color/background_color_gray</item>-->
+
+
+<!--        <item name="colorPrimaryDark">@color/background_color_gray</item>-->
+<!--        <item name="colorPrimary">@color/yellow</item>-->
+<!--        <item name="colorAccent">@color/gray</item>-->
     </style>
 
     <!-- strongswan -->