Remove old files. Add theme and apply it
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -27,6 +27,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.zobrist.tichucounter.domain.TopBarAction
|
import me.zobrist.tichucounter.domain.TopBarAction
|
||||||
import me.zobrist.tichucounter.repository.GameRepository
|
import me.zobrist.tichucounter.repository.GameRepository
|
||||||
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
import me.zobrist.tichucounter.ui.MainViewModel
|
import me.zobrist.tichucounter.ui.MainViewModel
|
||||||
import me.zobrist.tichucounter.ui.counter.*
|
import me.zobrist.tichucounter.ui.counter.*
|
||||||
import me.zobrist.tichucounter.ui.history.HistoryList
|
import me.zobrist.tichucounter.ui.history.HistoryList
|
||||||
@@ -63,7 +64,7 @@ class MainActivity : BaseActivity() {
|
|||||||
navController: NavHostController
|
navController: NavHostController
|
||||||
) {
|
) {
|
||||||
|
|
||||||
MaterialTheme() {
|
AppTheme() {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = { TopBar(drawerState, scope, mainViewModel.topBarActions) }) {
|
topBar = { TopBar(drawerState, scope, mainViewModel.topBarActions) }) {
|
||||||
|
|
||||||
|
|||||||
67
app/src/main/java/me/zobrist/tichucounter/ui/Color.kt
Normal file
67
app/src/main/java/me/zobrist/tichucounter/ui/Color.kt
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package me.zobrist.tichucounter.ui
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
val md_theme_light_primary = Color(0xFFBE0034)
|
||||||
|
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
|
||||||
|
val md_theme_light_primaryContainer = Color(0xFFFFDADA)
|
||||||
|
val md_theme_light_onPrimaryContainer = Color(0xFF40000B)
|
||||||
|
val md_theme_light_secondary = Color(0xFF6E5D00)
|
||||||
|
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
|
||||||
|
val md_theme_light_secondaryContainer = Color(0xFFFFE261)
|
||||||
|
val md_theme_light_onSecondaryContainer = Color(0xFF221B00)
|
||||||
|
val md_theme_light_tertiary = Color(0xFF76592F)
|
||||||
|
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
|
||||||
|
val md_theme_light_tertiaryContainer = Color(0xFFFFDDB1)
|
||||||
|
val md_theme_light_onTertiaryContainer = Color(0xFF291800)
|
||||||
|
val md_theme_light_error = Color(0xFFBA1A1A)
|
||||||
|
val md_theme_light_errorContainer = Color(0xFFFFDAD6)
|
||||||
|
val md_theme_light_onError = Color(0xFFFFFFFF)
|
||||||
|
val md_theme_light_onErrorContainer = Color(0xFF410002)
|
||||||
|
val md_theme_light_background = Color(0xFFFFFBFF)
|
||||||
|
val md_theme_light_onBackground = Color(0xFF201A1A)
|
||||||
|
val md_theme_light_surface = Color(0xFFFFFBFF)
|
||||||
|
val md_theme_light_onSurface = Color(0xFF201A1A)
|
||||||
|
val md_theme_light_surfaceVariant = Color(0xFFF4DDDD)
|
||||||
|
val md_theme_light_onSurfaceVariant = Color(0xFF524343)
|
||||||
|
val md_theme_light_outline = Color(0xFF857373)
|
||||||
|
val md_theme_light_inverseOnSurface = Color(0xFFFBEEED)
|
||||||
|
val md_theme_light_inverseSurface = Color(0xFF362F2F)
|
||||||
|
val md_theme_light_inversePrimary = Color(0xFFFFB3B5)
|
||||||
|
val md_theme_light_shadow = Color(0xFF000000)
|
||||||
|
val md_theme_light_surfaceTint = Color(0xFFBE0034)
|
||||||
|
val md_theme_light_outlineVariant = Color(0xFFD7C1C1)
|
||||||
|
val md_theme_light_scrim = Color(0xFF000000)
|
||||||
|
|
||||||
|
val md_theme_dark_primary = Color(0xFFFFB3B5)
|
||||||
|
val md_theme_dark_onPrimary = Color(0xFF680018)
|
||||||
|
val md_theme_dark_primaryContainer = Color(0xFF920026)
|
||||||
|
val md_theme_dark_onPrimaryContainer = Color(0xFFFFDADA)
|
||||||
|
val md_theme_dark_secondary = Color(0xFFE6C500)
|
||||||
|
val md_theme_dark_onSecondary = Color(0xFF3A3000)
|
||||||
|
val md_theme_dark_secondaryContainer = Color(0xFF534600)
|
||||||
|
val md_theme_dark_onSecondaryContainer = Color(0xFFFFE261)
|
||||||
|
val md_theme_dark_tertiary = Color(0xFFE6C18D)
|
||||||
|
val md_theme_dark_onTertiary = Color(0xFF422C05)
|
||||||
|
val md_theme_dark_tertiaryContainer = Color(0xFF5C421A)
|
||||||
|
val md_theme_dark_onTertiaryContainer = Color(0xFFFFDDB1)
|
||||||
|
val md_theme_dark_error = Color(0xFFFFB4AB)
|
||||||
|
val md_theme_dark_errorContainer = Color(0xFF93000A)
|
||||||
|
val md_theme_dark_onError = Color(0xFF690005)
|
||||||
|
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
|
||||||
|
val md_theme_dark_background = Color(0xFF201A1A)
|
||||||
|
val md_theme_dark_onBackground = Color(0xFFECE0DF)
|
||||||
|
val md_theme_dark_surface = Color(0xFF201A1A)
|
||||||
|
val md_theme_dark_onSurface = Color(0xFFECE0DF)
|
||||||
|
val md_theme_dark_surfaceVariant = Color(0xFF524343)
|
||||||
|
val md_theme_dark_onSurfaceVariant = Color(0xFFD7C1C1)
|
||||||
|
val md_theme_dark_outline = Color(0xFF9F8C8C)
|
||||||
|
val md_theme_dark_inverseOnSurface = Color(0xFF201A1A)
|
||||||
|
val md_theme_dark_inverseSurface = Color(0xFFECE0DF)
|
||||||
|
val md_theme_dark_inversePrimary = Color(0xFFBE0034)
|
||||||
|
val md_theme_dark_shadow = Color(0xFF000000)
|
||||||
|
val md_theme_dark_surfaceTint = Color(0xFFFFB3B5)
|
||||||
|
val md_theme_dark_outlineVariant = Color(0xFF524343)
|
||||||
|
val md_theme_dark_scrim = Color(0xFF000000)
|
||||||
|
|
||||||
|
|
||||||
|
val seed = Color(0xFFED0043)
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package me.zobrist.tichucounter.ui
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
|
|
||||||
abstract class FragmentBase<VB : ViewBinding> : Fragment() {
|
|
||||||
|
|
||||||
private var _binding: VB? = null
|
|
||||||
abstract val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> VB
|
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
|
||||||
// onDestroyView.
|
|
||||||
protected val binding get() = _binding!!
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View {
|
|
||||||
_binding = bindingInflater.invoke(inflater, container, false)
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
|
||||||
super.onDestroyView()
|
|
||||||
_binding = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
90
app/src/main/java/me/zobrist/tichucounter/ui/Theme.kt
Normal file
90
app/src/main/java/me/zobrist/tichucounter/ui/Theme.kt
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package me.zobrist.tichucounter.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
|
import androidx.compose.material3.darkColorScheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
|
|
||||||
|
private val LightColors = lightColorScheme(
|
||||||
|
primary = md_theme_light_primary,
|
||||||
|
onPrimary = md_theme_light_onPrimary,
|
||||||
|
primaryContainer = md_theme_light_primaryContainer,
|
||||||
|
onPrimaryContainer = md_theme_light_onPrimaryContainer,
|
||||||
|
secondary = md_theme_light_secondary,
|
||||||
|
onSecondary = md_theme_light_onSecondary,
|
||||||
|
secondaryContainer = md_theme_light_secondaryContainer,
|
||||||
|
onSecondaryContainer = md_theme_light_onSecondaryContainer,
|
||||||
|
tertiary = md_theme_light_tertiary,
|
||||||
|
onTertiary = md_theme_light_onTertiary,
|
||||||
|
tertiaryContainer = md_theme_light_tertiaryContainer,
|
||||||
|
onTertiaryContainer = md_theme_light_onTertiaryContainer,
|
||||||
|
error = md_theme_light_error,
|
||||||
|
errorContainer = md_theme_light_errorContainer,
|
||||||
|
onError = md_theme_light_onError,
|
||||||
|
onErrorContainer = md_theme_light_onErrorContainer,
|
||||||
|
background = md_theme_light_background,
|
||||||
|
onBackground = md_theme_light_onBackground,
|
||||||
|
surface = md_theme_light_surface,
|
||||||
|
onSurface = md_theme_light_onSurface,
|
||||||
|
surfaceVariant = md_theme_light_surfaceVariant,
|
||||||
|
onSurfaceVariant = md_theme_light_onSurfaceVariant,
|
||||||
|
outline = md_theme_light_outline,
|
||||||
|
inverseOnSurface = md_theme_light_inverseOnSurface,
|
||||||
|
inverseSurface = md_theme_light_inverseSurface,
|
||||||
|
inversePrimary = md_theme_light_inversePrimary,
|
||||||
|
surfaceTint = md_theme_light_surfaceTint,
|
||||||
|
outlineVariant = md_theme_light_outlineVariant,
|
||||||
|
scrim = md_theme_light_scrim,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
private val DarkColors = darkColorScheme(
|
||||||
|
primary = md_theme_dark_primary,
|
||||||
|
onPrimary = md_theme_dark_onPrimary,
|
||||||
|
primaryContainer = md_theme_dark_primaryContainer,
|
||||||
|
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
|
||||||
|
secondary = md_theme_dark_secondary,
|
||||||
|
onSecondary = md_theme_dark_onSecondary,
|
||||||
|
secondaryContainer = md_theme_dark_secondaryContainer,
|
||||||
|
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
|
||||||
|
tertiary = md_theme_dark_tertiary,
|
||||||
|
onTertiary = md_theme_dark_onTertiary,
|
||||||
|
tertiaryContainer = md_theme_dark_tertiaryContainer,
|
||||||
|
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
|
||||||
|
error = md_theme_dark_error,
|
||||||
|
errorContainer = md_theme_dark_errorContainer,
|
||||||
|
onError = md_theme_dark_onError,
|
||||||
|
onErrorContainer = md_theme_dark_onErrorContainer,
|
||||||
|
background = md_theme_dark_background,
|
||||||
|
onBackground = md_theme_dark_onBackground,
|
||||||
|
surface = md_theme_dark_surface,
|
||||||
|
onSurface = md_theme_dark_onSurface,
|
||||||
|
surfaceVariant = md_theme_dark_surfaceVariant,
|
||||||
|
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
|
||||||
|
outline = md_theme_dark_outline,
|
||||||
|
inverseOnSurface = md_theme_dark_inverseOnSurface,
|
||||||
|
inverseSurface = md_theme_dark_inverseSurface,
|
||||||
|
inversePrimary = md_theme_dark_inversePrimary,
|
||||||
|
surfaceTint = md_theme_dark_surfaceTint,
|
||||||
|
outlineVariant = md_theme_dark_outlineVariant,
|
||||||
|
scrim = md_theme_dark_scrim,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AppTheme(
|
||||||
|
useDarkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
content: @Composable() () -> Unit
|
||||||
|
) {
|
||||||
|
val colors = if (!useDarkTheme) {
|
||||||
|
LightColors
|
||||||
|
} else {
|
||||||
|
DarkColors
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialTheme(
|
||||||
|
colorScheme = colors,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package me.zobrist.tichucounter.ui.settings
|
|
||||||
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.preference.ListPreference
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
|
||||||
import me.zobrist.tichucounter.R
|
|
||||||
|
|
||||||
class SettingsFragment : PreferenceFragmentCompat() {
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
||||||
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
|
||||||
|
|
||||||
val index = when (getCurrentLocale()) {
|
|
||||||
"de" -> 1
|
|
||||||
"en" -> 0
|
|
||||||
else -> 0
|
|
||||||
}
|
|
||||||
|
|
||||||
findPreference<ListPreference>("language")?.setValueIndex(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCurrentLocale(): String? {
|
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
resources.configuration.locales.get(0).language
|
|
||||||
} else {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
resources.configuration.locale.language
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/display">
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
app:defaultValue="default"
|
|
||||||
app:entries="@array/theme_entries"
|
|
||||||
app:entryValues="@array/theme_values"
|
|
||||||
app:key="theme"
|
|
||||||
app:title="@string/choose_theme_text"
|
|
||||||
app:useSimpleSummaryProvider="true" />
|
|
||||||
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
app:defaultValue="reply"
|
|
||||||
app:entries="@array/language_entries"
|
|
||||||
app:entryValues="@array/language_values"
|
|
||||||
app:key="language"
|
|
||||||
app:title="@string/choose_language_text"
|
|
||||||
app:useSimpleSummaryProvider="true" />
|
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
|
||||||
app:defaultValue="false"
|
|
||||||
app:key="screen_on"
|
|
||||||
app:title="@string/keep_screen_on" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
</PreferenceScreen>
|
|
||||||
Reference in New Issue
Block a user