added dark mode , detect system theme
This commit is contained in:
@@ -8,6 +8,20 @@ Stims lets you select apps that should prevent your screen from turning off. Whe
|
||||
|
||||
---
|
||||
|
||||
## Permissions
|
||||
|
||||
Stims requires **Usage Access** permission to detect which app is in the foreground so it can keep the phone awake.
|
||||
|
||||
On first launch the app will redirect you to the system settings screen. To enable it:
|
||||
|
||||
1. Go to **Settings → Apps → Special app access → Usage access**
|
||||
2. Find **Stims** in the list and toggle it on
|
||||
3. Return to the app
|
||||
|
||||
Without this permission the background service cannot detect foreground apps and the screen will not be kept awake.
|
||||
|
||||
---
|
||||
|
||||
# Building from source
|
||||
|
||||
**Requirements**
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import acidburn.stims.ui.theme.StimsTheme
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -49,11 +50,13 @@ class MainActivity : ComponentActivity() {
|
||||
prefs = getSharedPreferences("stims_prefs", Context.MODE_PRIVATE)
|
||||
|
||||
setContent {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
AppListScreen(prefs)
|
||||
StimsTheme {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
AppListScreen(prefs)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package acidburn.stims.ui.theme
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
@Composable
|
||||
fun StimsTheme(content: @Composable () -> Unit) {
|
||||
val darkTheme = isSystemInDarkTheme()
|
||||
val context = LocalContext.current
|
||||
|
||||
val colorScheme = when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
if (darkTheme) dynamicDarkColorScheme(context)
|
||||
else dynamicLightColorScheme(context)
|
||||
}
|
||||
darkTheme -> darkColorScheme()
|
||||
else -> lightColorScheme()
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Stims" parent="Theme.Material3.Light.NoActionBar">
|
||||
<style name="Theme.Stims" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user