Fix warnings. Remove unused files.
Some checks are pending
continuous-integration/drone/push Build is running
Some checks are pending
continuous-integration/drone/push Build is running
This commit is contained in:
@@ -36,6 +36,12 @@ android {
|
|||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
useSupportLibrary true
|
useSupportLibrary true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
javaCompileOptions {
|
||||||
|
annotationProcessorOptions {
|
||||||
|
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
create("release") {
|
create("release") {
|
||||||
@@ -86,7 +92,7 @@ dependencies {
|
|||||||
implementation "androidx.compose.material3:material3:1.0.1"
|
implementation "androidx.compose.material3:material3:1.0.1"
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.code.gson:gson:2.8.9'
|
implementation 'com.google.code.gson:gson:2.9.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
||||||
|
|||||||
102
app/schemas/me.zobrist.tichucounter.data.AppDatabase/1.json
Normal file
102
app/schemas/me.zobrist.tichucounter.data.AppDatabase/1.json
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 1,
|
||||||
|
"identityHash": "f07e88c78e54c69c73890495a2121bf4",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "Round",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`gameId` INTEGER NOT NULL, `scoreA` INTEGER NOT NULL, `scoreB` INTEGER NOT NULL, `uid` INTEGER PRIMARY KEY AUTOINCREMENT)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "gameId",
|
||||||
|
"columnName": "gameId",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "scoreA",
|
||||||
|
"columnName": "scoreA",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "scoreB",
|
||||||
|
"columnName": "scoreB",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "uid",
|
||||||
|
"columnName": "uid",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"uid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [],
|
||||||
|
"foreignKeys": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "Game",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`active` INTEGER NOT NULL, `nameA` TEXT NOT NULL, `nameB` TEXT NOT NULL, `created` INTEGER NOT NULL, `modified` INTEGER NOT NULL, `uid` INTEGER PRIMARY KEY AUTOINCREMENT)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "active",
|
||||||
|
"columnName": "active",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "nameA",
|
||||||
|
"columnName": "nameA",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "nameB",
|
||||||
|
"columnName": "nameB",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "created",
|
||||||
|
"columnName": "created",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "modified",
|
||||||
|
"columnName": "modified",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "uid",
|
||||||
|
"columnName": "uid",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"uid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [],
|
||||||
|
"foreignKeys": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"views": [],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f07e88c78e54c69c73890495a2121bf4')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,7 +75,7 @@ abstract class BaseActivity : AppCompatActivity(),
|
|||||||
private fun setLanguage(language: Language) {
|
private fun setLanguage(language: Language) {
|
||||||
val currentLocale = AppCompatDelegate.getApplicationLocales()[0].toString()
|
val currentLocale = AppCompatDelegate.getApplicationLocales()[0].toString()
|
||||||
|
|
||||||
if (language.value != null && language.value != currentLocale) {
|
if (language.value != currentLocale) {
|
||||||
val newLocale = LocaleListCompat.forLanguageTags(language.value)
|
val newLocale = LocaleListCompat.forLanguageTags(language.value)
|
||||||
AppCompatDelegate.setApplicationLocales(newLocale)
|
AppCompatDelegate.setApplicationLocales(newLocale)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class MainActivity : BaseActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
AppTheme() {
|
AppTheme {
|
||||||
val systemUiController = rememberSystemUiController()
|
val systemUiController = rememberSystemUiController()
|
||||||
systemUiController.setStatusBarColor(MaterialTheme.colorScheme.background)
|
systemUiController.setStatusBarColor(MaterialTheme.colorScheme.background)
|
||||||
NavigationDrawer()
|
NavigationDrawer()
|
||||||
@@ -168,7 +168,8 @@ class MainActivity : BaseActivity() {
|
|||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
|
|
||||||
val items = listOf(
|
val items = listOf(
|
||||||
Screen("history", Icons.Outlined.List, R.string.menu_history),Screen("settings", Icons.Outlined.Settings, R.string.menu_settings)
|
Screen("history", Icons.Outlined.List, R.string.menu_history),
|
||||||
|
Screen("settings", Icons.Outlined.Settings, R.string.menu_settings)
|
||||||
)
|
)
|
||||||
|
|
||||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||||
|
|||||||
@@ -13,5 +13,4 @@ data class GameAndScore(
|
|||||||
override var gameId: Long,
|
override var gameId: Long,
|
||||||
override var scoreA: Int,
|
override var scoreA: Int,
|
||||||
override var scoreB: Int,
|
override var scoreB: Int,
|
||||||
) : IGame, IRound {
|
) : IGame, IRound
|
||||||
}
|
|
||||||
@@ -15,6 +15,7 @@ interface RoundDao : DaoBase<Round> {
|
|||||||
"LEFT JOIN game ON game.uid = round.gameId " +
|
"LEFT JOIN game ON game.uid = round.gameId " +
|
||||||
"WHERE game.active == 1"
|
"WHERE game.active == 1"
|
||||||
)
|
)
|
||||||
|
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
|
||||||
fun getRoundSumForActiveGame(): Flow<Round>
|
fun getRoundSumForActiveGame(): Flow<Round>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package me.zobrist.tichucounter.domain
|
package me.zobrist.tichucounter.domain
|
||||||
|
|
||||||
import kotlin.math.abs
|
|
||||||
|
|
||||||
|
|
||||||
fun Int.isMultipleOf5(): Boolean {
|
fun Int.isMultipleOf5(): Boolean {
|
||||||
return (this % 5) == 0
|
return (this % 5) == 0
|
||||||
@@ -11,6 +9,3 @@ fun Int.isMultipleOf100(): Boolean {
|
|||||||
return (this % 100) == 0
|
return (this % 100) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Int.getAbsoluteDifference(other: Int): Int {
|
|
||||||
return abs(this - other)
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
package me.zobrist.tichucounter.domain
|
package me.zobrist.tichucounter.domain
|
||||||
|
|
||||||
class NavigationAction(val aciton: () -> Unit)
|
class NavigationAction(val action: () -> Unit)
|
||||||
@@ -16,13 +16,14 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
|||||||
|
|
||||||
val language: Language
|
val language: Language
|
||||||
get() {
|
get() {
|
||||||
var setting = sharedPreferences.getString(Language::class.simpleName, null)
|
return try {
|
||||||
if (setting == null) {
|
var setting = sharedPreferences.getString(Language::class.simpleName, null)
|
||||||
setCurrentLanguage()
|
enumValueOf(setting!!)
|
||||||
setting =
|
} catch (_: NullPointerException) {
|
||||||
sharedPreferences.getString(Language::class.simpleName, Language.ENGLISH.name)
|
val current = getCurrentAppLanguage()
|
||||||
|
setLanguage(current)
|
||||||
|
current
|
||||||
}
|
}
|
||||||
return enumValueOf(setting!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val theme: Theme
|
val theme: Theme
|
||||||
@@ -36,30 +37,29 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
|||||||
return sharedPreferences.getBoolean("keep_screen_on", false)
|
return sharedPreferences.getBoolean("keep_screen_on", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setCurrentLanguage() {
|
private fun getCurrentAppLanguage(): Language {
|
||||||
var setting = when (getApplicationLocales()[0].toString()) {
|
return when (getApplicationLocales()[0].toString()) {
|
||||||
"de" -> Language.GERMAN
|
"de" -> Language.GERMAN
|
||||||
else -> Language.ENGLISH
|
else -> Language.ENGLISH
|
||||||
}
|
}
|
||||||
setLanguage(setting)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLanguage(language: Language) {
|
fun setLanguage(language: Language) {
|
||||||
val editor = sharedPreferences.edit()
|
val editor = sharedPreferences.edit()
|
||||||
editor.putString(Language::class.simpleName, language.name)
|
editor.putString(Language::class.simpleName, language.name)
|
||||||
editor.commit()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTheme(theme: Theme) {
|
fun setTheme(theme: Theme) {
|
||||||
val editor = sharedPreferences.edit()
|
val editor = sharedPreferences.edit()
|
||||||
editor.putString(Theme::class.simpleName, theme.name)
|
editor.putString(Theme::class.simpleName, theme.name)
|
||||||
editor.commit()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setKeepScreenOn(setting: Boolean) {
|
fun setKeepScreenOn(setting: Boolean) {
|
||||||
val editor = sharedPreferences.edit()
|
val editor = sharedPreferences.edit()
|
||||||
editor.putBoolean("keep_screen_on", setting)
|
editor.putBoolean("keep_screen_on", setting)
|
||||||
editor.commit()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,6 @@ import javax.inject.Inject
|
|||||||
class Tichu @Inject constructor() {
|
class Tichu @Inject constructor() {
|
||||||
|
|
||||||
fun calculateOtherScore(score: Int): Int? {
|
fun calculateOtherScore(score: Int): Int? {
|
||||||
if (score == null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
if (!score.isMultipleOf5()) {
|
if (!score.isMultipleOf5()) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -24,6 +21,6 @@ class Tichu @Inject constructor() {
|
|||||||
if (scoreA == null || scoreB == null) {
|
if (scoreA == null || scoreB == null) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return (scoreA!!.isMultipleOf5()) && scoreB!!.isMultipleOf5() && (scoreA!! + scoreB!!).isMultipleOf100()
|
return (scoreA.isMultipleOf5()) && scoreB.isMultipleOf5() && (scoreA + scoreB).isMultipleOf100()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package me.zobrist.tichucounter.framework
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.annotation.MainThread
|
|
||||||
import androidx.lifecycle.LifecycleOwner
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import androidx.lifecycle.Observer
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A lifecycle-aware observable that sends only new updates after subscription, used for events like
|
|
||||||
* navigation and Snackbar messages.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This avoids a common problem with events: on configuration change (like rotation) an update
|
|
||||||
* can be emitted if the observer is active. This LiveData only calls the observable if there's an
|
|
||||||
* explicit call to setValue() or call().
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Note that only one observer is going to be notified of changes.
|
|
||||||
*/
|
|
||||||
class SingleLiveEvent<T> : MutableLiveData<T>() {
|
|
||||||
private val pending = AtomicBoolean(false)
|
|
||||||
|
|
||||||
@MainThread
|
|
||||||
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) {
|
|
||||||
if (hasActiveObservers()) {
|
|
||||||
Log.w(TAG, "Multiple observers registered but only one will be notified of changes.")
|
|
||||||
}
|
|
||||||
// Observe the internal MutableLiveData
|
|
||||||
super.observe(owner) { t ->
|
|
||||||
if (pending.compareAndSet(true, false)) {
|
|
||||||
observer.onChanged(t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@MainThread
|
|
||||||
override fun setValue(t: T?) {
|
|
||||||
pending.set(true)
|
|
||||||
super.setValue(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for cases where T is Void, to make calls cleaner.
|
|
||||||
*/
|
|
||||||
@MainThread
|
|
||||||
fun call() {
|
|
||||||
value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAG = "me.zobrist.tichucounter.framework.SingleLiveEvent"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("unused", "unused", "unused")
|
||||||
|
|
||||||
package me.zobrist.tichucounter.ui
|
package me.zobrist.tichucounter.ui
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class MainViewModel @Inject constructor(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
roundDao.getForActiveGame().collect() {
|
roundDao.getForActiveGame().collect {
|
||||||
isUndoActionActive = it.isNotEmpty()
|
isUndoActionActive = it.isNotEmpty()
|
||||||
|
|
||||||
if (expectedRoundCount != it.count()) {
|
if (expectedRoundCount != it.count()) {
|
||||||
@@ -51,7 +51,7 @@ class MainViewModel @Inject constructor(
|
|||||||
|
|
||||||
|
|
||||||
fun onNavigateClicked() {
|
fun onNavigateClicked() {
|
||||||
topBarNavigationAction.aciton()
|
topBarNavigationAction.action()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun undoLastRound() {
|
fun undoLastRound() {
|
||||||
@@ -77,10 +77,6 @@ class MainViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearRedoList() {
|
|
||||||
redoRounds.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun newGame() {
|
fun newGame() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
redoRounds.clear()
|
redoRounds.clear()
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ private val DarkColors = darkColorScheme(
|
|||||||
@Composable
|
@Composable
|
||||||
fun AppTheme(
|
fun AppTheme(
|
||||||
useDarkTheme: Boolean = isSystemInDarkTheme(),
|
useDarkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
content: @Composable() () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import androidx.compose.material3.*
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.scale
|
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.focus.onFocusChanged
|
import androidx.compose.ui.focus.onFocusChanged
|
||||||
@@ -158,7 +157,10 @@ fun KeyboardView(
|
|||||||
@Composable
|
@Composable
|
||||||
fun KeyboardTextButton(text: String, onClicked: () -> Unit) {
|
fun KeyboardTextButton(text: String, onClicked: () -> Unit) {
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
modifier = Modifier.fillMaxWidth().height(50.dp).padding(2.dp),
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(2.dp),
|
||||||
onClick = { onClicked() },
|
onClick = { onClicked() },
|
||||||
) { Text(text) }
|
) { Text(text) }
|
||||||
}
|
}
|
||||||
@@ -168,7 +170,10 @@ fun KeyboardIconButton(icon: ImageVector, enabled: Boolean = true, onClicked: ()
|
|||||||
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onClick = { onClicked() },
|
onClick = { onClicked() },
|
||||||
modifier = Modifier.fillMaxWidth().height(50.dp).padding(2.dp),
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(50.dp)
|
||||||
|
.padding(2.dp),
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@@ -28,7 +27,7 @@ fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
|||||||
|
|
||||||
LazyColumn(state = lazyListState, modifier = modifier) {
|
LazyColumn(state = lazyListState, modifier = modifier) {
|
||||||
itemsIndexed(rounds) { index, item ->
|
itemsIndexed(rounds) { index, item ->
|
||||||
RoundListItem(item, index, lazyListState)
|
RoundListItem(item, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
@@ -38,7 +37,7 @@ fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RoundListItem(round: Round, index: Int, lazyListState: LazyListState) {
|
private fun RoundListItem(round: Round, index: Int) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ fun TeamNamesView(
|
|||||||
updateA: (String) -> Unit,
|
updateA: (String) -> Unit,
|
||||||
updateB: (String) -> Unit
|
updateB: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Row() {
|
Row {
|
||||||
TextField(
|
TextField(
|
||||||
value = nameA,
|
value = nameA,
|
||||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
|
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import me.zobrist.tichucounter.ui.AppTheme
|
|||||||
@Composable
|
@Composable
|
||||||
fun TeamScoresView(scoreA: Int, scoreB: Int) {
|
fun TeamScoresView(scoreA: Int, scoreB: Int) {
|
||||||
|
|
||||||
ElevatedCard() {
|
ElevatedCard {
|
||||||
Row() {
|
Row {
|
||||||
Text(
|
Text(
|
||||||
style = MaterialTheme.typography.headlineSmall,
|
style = MaterialTheme.typography.headlineSmall,
|
||||||
text = scoreA.toString(),
|
text = scoreA.toString(),
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ fun HistoryListItem(game: GameAndScore) {
|
|||||||
Modifier
|
Modifier
|
||||||
.padding(all = 12.dp),
|
.padding(all = 12.dp),
|
||||||
) {
|
) {
|
||||||
Row() {
|
Row {
|
||||||
Text(
|
Text(
|
||||||
text = game.nameA,
|
text = game.nameA,
|
||||||
style = MaterialTheme.typography.headlineSmall
|
style = MaterialTheme.typography.headlineSmall
|
||||||
@@ -57,7 +57,7 @@ fun HistoryListItem(game: GameAndScore) {
|
|||||||
style = MaterialTheme.typography.headlineSmall
|
style = MaterialTheme.typography.headlineSmall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row() {
|
Row {
|
||||||
Text(
|
Text(
|
||||||
text = game.nameB,
|
text = game.nameB,
|
||||||
style = MaterialTheme.typography.headlineSmall
|
style = MaterialTheme.typography.headlineSmall
|
||||||
@@ -67,7 +67,7 @@ fun HistoryListItem(game: GameAndScore) {
|
|||||||
style = MaterialTheme.typography.headlineSmall
|
style = MaterialTheme.typography.headlineSmall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row() {
|
Row {
|
||||||
Text(
|
Text(
|
||||||
text = format.format(game.modified),
|
text = format.format(game.modified),
|
||||||
style = MaterialTheme.typography.labelSmall
|
style = MaterialTheme.typography.labelSmall
|
||||||
@@ -80,7 +80,7 @@ fun HistoryListItem(game: GameAndScore) {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
private fun HistoryListPreview() {
|
private fun HistoryListPreview() {
|
||||||
val tempData = listOf<GameAndScore>(
|
val tempData = listOf(
|
||||||
GameAndScore(false, "abc", "def", Date(), Date(), 1, 10, 50),
|
GameAndScore(false, "abc", "def", Date(), Date(), 1, 10, 50),
|
||||||
GameAndScore(true, "ADTH", "dogfg", Date(), Date(), 2, 20, 60),
|
GameAndScore(true, "ADTH", "dogfg", Date(), Date(), 2, 20, 60),
|
||||||
GameAndScore(false, "TeamA3", "TeamB3", Date(), Date(), 3, 30, 70),
|
GameAndScore(false, "TeamA3", "TeamB3", Date(), Date(), 3, 30, 70),
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package me.zobrist.tichucounter.ui.settings
|
|||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.ArrowDropDown
|
import androidx.compose.material.icons.outlined.ArrowDropDown
|
||||||
import androidx.compose.material.icons.outlined.Check
|
import androidx.compose.material.icons.outlined.Check
|
||||||
@@ -52,7 +55,7 @@ fun SettingsView(
|
|||||||
updateLanguage: (Language) -> Unit = {},
|
updateLanguage: (Language) -> Unit = {},
|
||||||
updateTheme: (Theme) -> Unit = {}
|
updateTheme: (Theme) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
Column() {
|
Column {
|
||||||
BooleanSetting(
|
BooleanSetting(
|
||||||
stringResource(R.string.keep_screen_on),
|
stringResource(R.string.keep_screen_on),
|
||||||
valueScreenOn
|
valueScreenOn
|
||||||
@@ -72,7 +75,6 @@ fun SettingsView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BooleanSetting(name: String, value: Boolean, updateValue: (Boolean) -> Unit) {
|
fun BooleanSetting(name: String, value: Boolean, updateValue: (Boolean) -> Unit) {
|
||||||
|
|
||||||
@@ -153,8 +155,8 @@ fun <T> StringSetting(name: String, map: Map<T, Int>, selected: T, onSelected: (
|
|||||||
@Composable
|
@Composable
|
||||||
fun SettingsViewPreview() {
|
fun SettingsViewPreview() {
|
||||||
|
|
||||||
AppTheme() {
|
AppTheme {
|
||||||
Surface() {
|
Surface {
|
||||||
SettingsView()
|
SettingsView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24.0"
|
|
||||||
android:viewportHeight="24.0">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24.0"
|
|
||||||
android:viewportHeight="24.0">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24.0"
|
|
||||||
android:viewportHeight="24.0">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:tint="#FFFFFF"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="@color/primaryColor"
|
|
||||||
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:autoMirrored="true"
|
|
||||||
android:tint="#FFFFFF"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="@color/primaryColor"
|
|
||||||
android:pathData="M12.5,8c-2.65,0 -5.05,0.99 -6.9,2.6L2,7v9h9l-3.62,-3.62c1.39,-1.16 3.16,-1.88 5.12,-1.88 3.54,0 6.55,2.31 7.6,5.5l2.37,-0.78C21.08,11.03 17.15,8 12.5,8z" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<gradient
|
|
||||||
android:angle="135"
|
|
||||||
android:centerColor="#009688"
|
|
||||||
android:endColor="#00695C"
|
|
||||||
android:startColor="#4DB6AC"
|
|
||||||
android:type="linear" />
|
|
||||||
</shape>
|
|
||||||
@@ -1,27 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="clear">Neues Spiel starten</string>
|
|
||||||
<string name="undo">Letzte Runde löschen</string>
|
|
||||||
<string name="choose_theme_text">Theme auswählen</string>
|
<string name="choose_theme_text">Theme auswählen</string>
|
||||||
<string name="keep_screen_on">Bildschirm eingeschaltet lassen</string>
|
<string name="keep_screen_on">Bildschirm eingeschaltet lassen</string>
|
||||||
<string name="confirmNew">Möchten Sie wirklich ein neues Spiel starten?</string>
|
|
||||||
<string name="yes">Ja</string>
|
|
||||||
<string name="no">Nein</string>
|
|
||||||
<string name="back">Zurück</string>
|
|
||||||
<string name="choose_language_text">Sprache wählen</string>
|
<string name="choose_language_text">Sprache wählen</string>
|
||||||
<string name="android_default_text">Android Standard</string>
|
<string name="android_default_text">Android Standard</string>
|
||||||
<string name="english">Englisch</string>
|
<string name="english">Englisch</string>
|
||||||
<string name="german">Deutsch</string>
|
<string name="german">Deutsch</string>
|
||||||
<string name="light">Hell</string>
|
<string name="light">Hell</string>
|
||||||
<string name="dark">Dunkel</string>
|
<string name="dark">Dunkel</string>
|
||||||
<string name="settings">Einstellungen</string>
|
|
||||||
<string name="display">Anzeige</string>
|
|
||||||
<string name="activate">Aktivieren</string>
|
|
||||||
<string name="delete">Löschen</string>
|
|
||||||
<string name="menu_history">Verlauf</string>
|
<string name="menu_history">Verlauf</string>
|
||||||
<string name="menu_settings">Einstellungen</string>
|
<string name="menu_settings">Einstellungen</string>
|
||||||
<string name="menu_counter">Counter</string>
|
|
||||||
<string name="submit">Übermitteln</string>
|
|
||||||
<string name="on">Ein</string>
|
<string name="on">Ein</string>
|
||||||
<string name="off">Aus</string>
|
<string name="off">Aus</string>
|
||||||
<string name="newGame">Neues Spiel</string>
|
<string name="newGame">Neues Spiel</string>
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<dimen name="fab_margin">48dp</dimen>
|
|
||||||
</resources>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<dimen name="fab_margin">200dp</dimen>
|
|
||||||
</resources>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<dimen name="fab_margin">48dp</dimen>
|
|
||||||
</resources>
|
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="primaryColor">#d50000</color>
|
<color name="primaryColor">#d50000</color>
|
||||||
<color name="primaryLightColor">#ff5131</color>
|
|
||||||
<color name="primaryDarkColor">#9b0000</color>
|
|
||||||
<color name="secondaryColor">#ffccbc</color>
|
|
||||||
<color name="secondaryLightColor">#ffffee</color>
|
|
||||||
<color name="secondaryDarkColor">#cb9b8c</color>
|
|
||||||
<color name="primaryTextColor">#ffffff</color>
|
|
||||||
<color name="secondaryTextColor">#000000</color>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
|
||||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
|
||||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
|
||||||
<dimen name="nav_header_vertical_spacing">8dp</dimen>
|
|
||||||
<dimen name="nav_header_height">176dp</dimen>
|
|
||||||
<dimen name="fab_margin">16dp</dimen>
|
|
||||||
<dimen name="text_margin">16dp</dimen>
|
|
||||||
</resources>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
|
|
||||||
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
|
|
||||||
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
|
|
||||||
<item name="ic_menu_manage" type="drawable">@android:drawable/ic_menu_manage</item>
|
|
||||||
<item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item>
|
|
||||||
<item name="ic_menu_send" type="drawable">@android:drawable/ic_menu_send</item>
|
|
||||||
</resources>
|
|
||||||
@@ -1,33 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name" translatable="false">Tichu Counter</string>
|
<string name="app_name" translatable="false">Tichu Counter</string>
|
||||||
<string name="team_a" translatable="false">Team A</string>
|
|
||||||
<string name="team_b" translatable="false">Team B</string>
|
|
||||||
<string name="title_activity_settings" translatable="false">SettingsActivity</string>
|
|
||||||
|
|
||||||
<string name="clear">Start new game</string>
|
|
||||||
<string name="undo">Undo last round</string>
|
|
||||||
<string name="choose_theme_text">Choose theme</string>
|
<string name="choose_theme_text">Choose theme</string>
|
||||||
<string name="keep_screen_on">Keep screen on</string>
|
<string name="keep_screen_on">Keep screen on</string>
|
||||||
<string name="confirmNew">Do you really want to start a new Game?</string>
|
|
||||||
<string name="yes">Yes</string>
|
|
||||||
<string name="no">No</string>
|
|
||||||
<string name="back">Back</string>
|
|
||||||
<string name="choose_language_text">Choose language</string>
|
<string name="choose_language_text">Choose language</string>
|
||||||
<string name="android_default_text">Android Default</string>
|
<string name="android_default_text">Android Default</string>
|
||||||
<string name="english">English</string>
|
<string name="english">English</string>
|
||||||
<string name="german">German</string>
|
<string name="german">German</string>
|
||||||
<string name="light">Light</string>
|
<string name="light">Light</string>
|
||||||
<string name="dark">Dark</string>
|
<string name="dark">Dark</string>
|
||||||
<string name="display">Display</string>
|
|
||||||
<string name="settings">Settings</string>
|
|
||||||
|
|
||||||
<string name="menu_counter">Counter</string>
|
|
||||||
<string name="menu_history">History</string>
|
<string name="menu_history">History</string>
|
||||||
<string name="menu_settings">Settings</string>
|
<string name="menu_settings">Settings</string>
|
||||||
<string name="activate">Activate</string>
|
|
||||||
<string name="delete">Delete</string>
|
|
||||||
<string name="submit">Submit</string>
|
|
||||||
<string name="on">On</string>
|
<string name="on">On</string>
|
||||||
<string name="off">Off</string>
|
<string name="off">Off</string>
|
||||||
<string name="newGame">New Game</string>
|
<string name="newGame">New Game</string>
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"></style>
|
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar" />
|
||||||
|
|
||||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" />
|
|
||||||
|
|
||||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light" />
|
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user