improvements for previewing validation & captcha screens
This commit is contained in:
@@ -7,7 +7,6 @@ import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.FileProvider
|
||||
@@ -121,10 +120,6 @@ object AndroidUtils {
|
||||
return intent
|
||||
}
|
||||
|
||||
fun isBatterySaverOn(context: Context): Boolean {
|
||||
return (context.getSystemService(Context.POWER_SERVICE) as? PowerManager)?.isPowerSaveMode == true
|
||||
}
|
||||
|
||||
fun getImageToShare(context: Context, existingFile: File): Uri? {
|
||||
val imageFolder = File(context.cacheDir, "images")
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.compositionLocalOf
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
import com.meloda.app.fast.ui.util.isUsingDarkTheme
|
||||
import com.meloda.app.fast.ui.theme.LocalIsDarkTheme
|
||||
|
||||
/**
|
||||
* Default alpha levels used by Material components.
|
||||
@@ -79,7 +79,7 @@ object ContentAlpha {
|
||||
lowContrastAlpha: Float
|
||||
): Float {
|
||||
val contentColor = LocalContentColor.current
|
||||
return if (!isUsingDarkTheme()) {
|
||||
return if (!LocalIsDarkTheme.current) {
|
||||
if (contentColor.luminance() > 0.5) highContrastAlpha else lowContrastAlpha
|
||||
} else {
|
||||
if (contentColor.luminance() < 0.5) highContrastAlpha else lowContrastAlpha
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.compositionLocalOf
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -115,6 +116,8 @@ val LocalTheme = compositionLocalOf {
|
||||
)
|
||||
}
|
||||
|
||||
val LocalIsDarkTheme = compositionLocalOf { false }
|
||||
|
||||
val LocalHazeState = compositionLocalOf {
|
||||
HazeState()
|
||||
}
|
||||
@@ -178,9 +181,11 @@ fun AppTheme(
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = predefinedColorScheme ?: colorScheme,
|
||||
typography = typography,
|
||||
content = content
|
||||
)
|
||||
CompositionLocalProvider(LocalIsDarkTheme provides useDarkTheme) {
|
||||
MaterialTheme(
|
||||
colorScheme = predefinedColorScheme ?: colorScheme,
|
||||
typography = typography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.meloda.app.fast.ui.util
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.view.KeyEvent
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -11,34 +10,9 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.key.onKeyEvent
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.meloda.app.fast.common.UiText
|
||||
import com.meloda.app.fast.common.util.AndroidUtils
|
||||
|
||||
@Composable
|
||||
fun isUsingDarkTheme(): Boolean {
|
||||
// val nightThemeMode = AppCompatDelegate.MODE_NIGHT_YES
|
||||
|
||||
// SettingsController.getInt(
|
||||
// SettingsKeys.KEY_APPEARANCE_DARK_THEME,
|
||||
// SettingsKeys.DEFAULT_VALUE_APPEARANCE_DARK_THEME
|
||||
// )
|
||||
// val appForceDarkMode = nightThemeMode == AppCompatDelegate.MODE_NIGHT_YES
|
||||
// val appBatterySaver = nightThemeMode == AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
val systemUiNightMode = context.resources.configuration.uiMode
|
||||
|
||||
val isSystemBatterySaver = AndroidUtils.isBatterySaverOn(context)
|
||||
val isSystemUsingDarkTheme =
|
||||
systemUiNightMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||
|
||||
return true
|
||||
// return appForceDarkMode || (appBatterySaver && isSystemBatterySaver) || (!appBatterySaver && isSystemUsingDarkTheme && nightThemeMode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun UiText?.getString(): String? {
|
||||
|
||||
Reference in New Issue
Block a user