Compare commits
32 Commits
2.1-Rc1
...
feature/#3
| Author | SHA1 | Date | |
|---|---|---|---|
| d1b4ab1e8c | |||
| ff5495249f | |||
| 217370079d | |||
| add100146d | |||
| ceebe92f8b | |||
| 4f87321e2c | |||
| 81c540c2a5 | |||
| a45043424e | |||
| 18326e952f | |||
| a099659b2c | |||
| 61745c95a4 | |||
| 164cf6900f | |||
| 89ab0afaf5 | |||
| 9d8de2dd3c | |||
| fcb8c12454 | |||
| 34e64e6e50 | |||
| 694989a917 | |||
| 1e8e72557d | |||
| 2e40d0315c | |||
| 9ddbdb698c | |||
| c40d473fa5 | |||
| 507944794f | |||
| 068e36c5f6 | |||
| 7e722feb27 | |||
| fb4c83d60a | |||
| 0c80e05f5c | |||
| 8ca82d1734 | |||
| 9385deeb24 | |||
| fadd206e9e | |||
| 6768391caf | |||
| aa3e68dc5c | |||
| 3ec8c27b96 |
75
.drone.yml
@@ -1,75 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Android
|
||||
|
||||
steps:
|
||||
- name: prepare signing
|
||||
image: busybox
|
||||
environment:
|
||||
STOREPASSWORD:
|
||||
from_secret: StorePassword
|
||||
KEYPASSWORD:
|
||||
from_secret: KeyPassword
|
||||
commands:
|
||||
- touch keystore.properties
|
||||
- echo "storePassword=$STOREPASSWORD" >> keystore.properties
|
||||
- echo "keyPassword=$KEYPASSWORD" >> keystore.properties
|
||||
- echo "keyAlias=key0" >> keystore.properties
|
||||
- echo "storeFile=../AndroidKey" >> keystore.properties
|
||||
|
||||
- name: generate versionCode
|
||||
image: busybox
|
||||
commands:
|
||||
- touch version.properties
|
||||
- let timestamp=$(date +%s)/10
|
||||
- echo "versionCode=$timestamp" >> version.properties
|
||||
|
||||
- name: build
|
||||
image: mingc/android-build-box
|
||||
commands:
|
||||
- ./gradlew test
|
||||
- ./gradlew assembleRelease
|
||||
- ./gradlew bundleRelease
|
||||
|
||||
- name: deploy latest build
|
||||
image: curlimages/curl
|
||||
environment:
|
||||
SEAFILE_API_KEY:
|
||||
from_secret: SeafileApiKey
|
||||
APK_FILE: app/build/outputs/apk/release/app-release.apk
|
||||
BUNDLE_FILE: app/build/outputs/bundle/release/app-release.aab
|
||||
SEAFILE_REPO: 6debeef9-121e-46ba-acc7-81e109fdcbdd
|
||||
commands:
|
||||
- 'UPLOAD_URL=$(curl -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/upload-link/ | tr -d "\"")'
|
||||
- echo $UPLOAD_URL
|
||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$APK_FILE -F parent_dir=/ -F relative_path=latest/ -F replace=1 "$UPLOAD_URL"'
|
||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$BUNDLE_FILE -F parent_dir=/ -F relative_path=latest/ -F replace=1 "$UPLOAD_URL"'
|
||||
|
||||
- name: deploy tagged build
|
||||
image: curlimages/curl
|
||||
environment:
|
||||
SEAFILE_API_KEY:
|
||||
from_secret: SeafileApiKey
|
||||
APK_FILE: app/build/outputs/apk/release/app-release.apk
|
||||
BUNDLE_FILE: app/build/outputs/bundle/release/app-release.aab
|
||||
SEAFILE_REPO: 6debeef9-121e-46ba-acc7-81e109fdcbdd
|
||||
commands:
|
||||
- 'UPLOAD_URL=$(curl -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/upload-link/ | tr -d "\"")'
|
||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$APK_FILE -F parent_dir=/ -F relative_path=tagged/$DRONE_TAG/ -F replace=1 "$UPLOAD_URL"'
|
||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$BUNDLE_FILE -F parent_dir=/ -F relative_path=tagged/$DRONE_TAG/ -F replace=1 "$UPLOAD_URL"'
|
||||
- 'curl -d "operation=rename&newname=app-release$DRONE_TAG.apk" -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/file/?p=/tagged/$DRONE_TAG/app-release.apk'
|
||||
- 'curl -d "operation=rename&newname=app-release$DRONE_TAG.aab" -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/file/?p=/tagged/$DRONE_TAG/app-release.aab'
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: slack notification
|
||||
image: plugins/slack
|
||||
settings:
|
||||
webhook:
|
||||
from_secret: SlackWebhook
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
- success
|
||||
48
.gitea/workflows/buildAndroid.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Build Android
|
||||
on: [pull_request, push]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest-android
|
||||
steps:
|
||||
- name: Checkout the code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Prepare signing
|
||||
run: |
|
||||
touch keystore.properties
|
||||
echo "storePassword=${{ secrets.STOREPASSWORD }}" >> keystore.properties
|
||||
echo "keyPassword=${{ secrets.KEYPASSWORD }}" >> keystore.properties
|
||||
echo "keyAlias=key0" >> keystore.properties
|
||||
echo "storeFile=../AndroidKey" >> keystore.properties
|
||||
|
||||
- name: Generate versionCode
|
||||
run: |
|
||||
touch version.properties
|
||||
let timestamp=$(date +%s)/10
|
||||
echo "versionCode=$timestamp" >> version.properties
|
||||
|
||||
- name: Test the app
|
||||
run: ./gradlew test
|
||||
|
||||
- name: Build apk
|
||||
run: ./gradlew assembleRelease
|
||||
|
||||
- name: Build abb
|
||||
run: ./gradlew bundleRelease
|
||||
|
||||
- name: Deploy latest to Nextcloud
|
||||
run: |
|
||||
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.apk"
|
||||
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.aab"
|
||||
|
||||
- name: Deploy tagged build to Nextcloud
|
||||
run: |
|
||||
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.apk"
|
||||
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.aab"
|
||||
|
||||
- uses: https://github.com/ravsamhq/notify-slack-action@v2
|
||||
if: always()
|
||||
with:
|
||||
status: ${{ job.status }} # required
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
|
||||
@@ -16,7 +16,7 @@ def keystoreProperties = new Properties()
|
||||
def versionProperties = new Properties()
|
||||
|
||||
def versionMajor = 2
|
||||
def versionMinor = 1
|
||||
def versionMinor = 2
|
||||
|
||||
// Load your keystore.properties file into the keystoreProperties object.
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
@@ -32,7 +32,7 @@ android {
|
||||
targetSdkVersion 33
|
||||
versionCode versionProperties["versionCode"].toInteger()
|
||||
versionName "${versionMajor}.${versionMinor}.${versionProperties["versionCode"].toInteger()}"
|
||||
resConfigs 'de', 'en'
|
||||
resourceConfigurations += ['de', 'en']
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
vectorDrawables {
|
||||
@@ -68,7 +68,7 @@ android {
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.3.2"
|
||||
kotlinCompilerExtensionVersion = "1.4.7"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -89,9 +89,9 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.9.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.0-rc01'
|
||||
implementation "androidx.compose.material3:material3:1.0.1"
|
||||
implementation 'androidx.core:core-ktx:1.10.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation "androidx.compose.material3:material3:1.1.0"
|
||||
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.9.0'
|
||||
@@ -99,32 +99,32 @@ dependencies {
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.5.5'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.5.7'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
|
||||
implementation 'androidx.compose.material:material-icons-extended:1.3.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
|
||||
implementation 'androidx.compose.material:material-icons-extended:1.4.3'
|
||||
implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0"
|
||||
implementation 'androidx.activity:activity-compose:1.6.1'
|
||||
implementation "androidx.compose.ui:ui:1.3.3"
|
||||
implementation "androidx.compose.ui:ui-tooling-preview:1.3.3"
|
||||
implementation "androidx.compose.runtime:runtime-livedata:1.3.3"
|
||||
implementation 'androidx.activity:activity-compose:1.7.2'
|
||||
implementation "androidx.compose.ui:ui:1.4.3"
|
||||
implementation "androidx.compose.ui:ui-tooling-preview:1.4.3"
|
||||
implementation "androidx.compose.runtime:runtime-livedata:1.4.3"
|
||||
implementation "androidx.navigation:navigation-compose:2.5.3"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
implementation "com.google.dagger:hilt-android:2.44"
|
||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.3.3"
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:1.3.3"
|
||||
debugImplementation "androidx.compose.ui:ui-test-manifest:1.3.3"
|
||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.4.3"
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:1.4.3"
|
||||
debugImplementation "androidx.compose.ui:ui-test-manifest:1.4.3"
|
||||
kapt "com.google.dagger:hilt-compiler:2.44"
|
||||
implementation "androidx.room:room-runtime:2.5.0"
|
||||
annotationProcessor "androidx.room:room-compiler:2.5.0"
|
||||
kapt "androidx.room:room-compiler:2.5.0"
|
||||
implementation "androidx.room:room-ktx:2.5.0"
|
||||
implementation "androidx.room:room-runtime:2.5.1"
|
||||
annotationProcessor "androidx.room:room-compiler:2.5.1"
|
||||
kapt "androidx.room:room-compiler:2.5.1"
|
||||
implementation "androidx.room:room-ktx:2.5.1"
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
api "androidx.navigation:navigation-fragment-ktx:2.5.3"
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:localeConfig="@xml/locales_config"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
|
||||
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 28 KiB |
@@ -37,7 +37,7 @@ import me.zobrist.tichucounter.ui.settings.SettingsViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : AppCompatActivity(), ISettingsChangeListener {
|
||||
class MainActivity : AppCompatActivity(), ISystemSettingsChangeListener {
|
||||
|
||||
@Inject
|
||||
lateinit var settingsAdapter: SettingsAdapter
|
||||
@@ -88,7 +88,6 @@ class MainActivity : AppCompatActivity(), ISettingsChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
private fun NavigationDrawer() {
|
||||
val drawerState = rememberDrawerState(DrawerValue.Closed)
|
||||
@@ -142,7 +141,6 @@ class MainActivity : AppCompatActivity(), ISettingsChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun MyScaffoldLayout(
|
||||
drawerState: DrawerState,
|
||||
@@ -205,7 +203,12 @@ class MainActivity : AppCompatActivity(), ISettingsChangeListener {
|
||||
},
|
||||
|
||||
))
|
||||
) { scope.launch { drawerState.open() } }
|
||||
) {
|
||||
scope.launch {
|
||||
currentFocus?.clearFocus()
|
||||
drawerState.open()
|
||||
}
|
||||
}
|
||||
|
||||
Counter(counterViewModel)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package me.zobrist.tichucounter.data
|
||||
|
||||
import androidx.room.ProvidedTypeConverter
|
||||
import androidx.room.TypeConverter
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
|
||||
@ProvidedTypeConverter
|
||||
object DateConverter {
|
||||
|
||||
@@ -35,4 +35,7 @@ interface GameDao : DaoBase<Game> {
|
||||
@Query("UPDATE game SET active = 0 WHERE uid is not :gameId;")
|
||||
fun setOthersInactive(gameId: Long)
|
||||
|
||||
@Query("SELECT names FROM (SELECT nameA AS names FROM game UNION ALL SELECT nameB AS names FROM game) GROUP BY names")
|
||||
fun getDistinctTeamNames(): Flow<List<String>>
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package me.zobrist.tichucounter.data.entity
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
|
||||
@Entity
|
||||
data class Game(
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.navigation.*
|
||||
import androidx.navigation.NamedNavArgument
|
||||
import androidx.navigation.NavBackStackEntry
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDeepLink
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.compose.composable
|
||||
|
||||
fun NavController.navigate(route: Route) {
|
||||
|
||||
@@ -16,17 +16,26 @@ enum class Language(val value: LocaleListCompat) {
|
||||
|
||||
enum class KeepScreenOn(val value: Boolean) { ON(true), OFF(false) }
|
||||
|
||||
interface ISettingsChangeListener {
|
||||
enum class CounterListView { BY_ROUND, CONTINUOUS }
|
||||
|
||||
|
||||
interface ISystemSettingsChangeListener {
|
||||
fun onLanguageChanged(language: Language)
|
||||
fun onThemeChanged(theme: Theme)
|
||||
fun onScreenOnChanged(keepOn: KeepScreenOn)
|
||||
}
|
||||
|
||||
interface IDisplaySettingsChangeListener {
|
||||
fun onCounterListViewChanged(listView: CounterListView)
|
||||
}
|
||||
|
||||
@Singleton
|
||||
class SettingsAdapter @Inject constructor(@ApplicationContext private val context: Context) {
|
||||
|
||||
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
private var listenerList = mutableListOf<ISettingsChangeListener>()
|
||||
private var systemListenerList = mutableListOf<ISystemSettingsChangeListener>()
|
||||
private var displayListenerList = mutableListOf<IDisplaySettingsChangeListener>()
|
||||
|
||||
|
||||
var language: Language
|
||||
private set
|
||||
@@ -37,6 +46,9 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
||||
var keepScreenOn: KeepScreenOn
|
||||
private set
|
||||
|
||||
var counterListView: CounterListView
|
||||
private set
|
||||
|
||||
init {
|
||||
language = try {
|
||||
enumValueOf(sharedPreferences.getString(Language::class.simpleName, null)!!)
|
||||
@@ -55,19 +67,37 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
||||
} catch (_: java.lang.Exception) {
|
||||
KeepScreenOn.OFF
|
||||
}
|
||||
|
||||
counterListView = try {
|
||||
enumValueOf(sharedPreferences.getString(CounterListView::class.simpleName, null)!!)
|
||||
} catch (_: java.lang.Exception) {
|
||||
CounterListView.BY_ROUND
|
||||
}
|
||||
}
|
||||
|
||||
fun registerOnChangeListener(listener: ISettingsChangeListener) {
|
||||
listenerList.add(listener)
|
||||
fun registerOnChangeListener(listener: ISystemSettingsChangeListener) {
|
||||
systemListenerList.add(listener)
|
||||
|
||||
listener.onThemeChanged(theme)
|
||||
listener.onLanguageChanged(language)
|
||||
listener.onScreenOnChanged(keepScreenOn)
|
||||
}
|
||||
|
||||
fun unregisterOnChangeListener(listener: ISettingsChangeListener?) {
|
||||
fun registerOnChangeListener(listener: IDisplaySettingsChangeListener) {
|
||||
displayListenerList.add(listener)
|
||||
|
||||
listener.onCounterListViewChanged(counterListView)
|
||||
}
|
||||
|
||||
fun unregisterOnChangeListener(listener: ISystemSettingsChangeListener?) {
|
||||
if (listener != null) {
|
||||
listenerList.remove(listener)
|
||||
systemListenerList.remove(listener)
|
||||
}
|
||||
}
|
||||
|
||||
fun unregisterOnChangeListener(listener: IDisplaySettingsChangeListener?) {
|
||||
if (listener != null) {
|
||||
displayListenerList.remove(listener)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +119,12 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
||||
notifyListeners(setting)
|
||||
}
|
||||
|
||||
fun setCounterViewList(setting: CounterListView) {
|
||||
this.counterListView = setting
|
||||
updatePreference(CounterListView::class.simpleName, setting.name)
|
||||
notifyListeners(setting)
|
||||
}
|
||||
|
||||
private fun updatePreference(name: String?, value: String) {
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putString(name, value)
|
||||
@@ -96,21 +132,27 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
||||
}
|
||||
|
||||
private fun notifyListeners(language: Language) {
|
||||
listenerList.forEach {
|
||||
systemListenerList.forEach {
|
||||
it.onLanguageChanged(language)
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifyListeners(theme: Theme) {
|
||||
listenerList.forEach {
|
||||
systemListenerList.forEach {
|
||||
it.onThemeChanged(theme)
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifyListeners(keepScreenOn: KeepScreenOn) {
|
||||
listenerList.forEach {
|
||||
systemListenerList.forEach {
|
||||
it.onScreenOnChanged(keepScreenOn)
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifyListeners(counterListView: CounterListView) {
|
||||
displayListenerList.forEach {
|
||||
it.onCounterListViewChanged(counterListView)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import me.zobrist.tichucounter.data.GameWithScores
|
||||
import me.zobrist.tichucounter.data.RoundDao
|
||||
import me.zobrist.tichucounter.data.entity.Game
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
|
||||
class GameRepository @Inject constructor(
|
||||
@@ -130,4 +130,8 @@ class GameRepository @Inject constructor(
|
||||
fun getAllWithRoundFlow(): Flow<List<GameWithScores>> {
|
||||
return gameDao.getGamesWithRounds()
|
||||
}
|
||||
|
||||
fun getDistinctTeamNames(): Flow<List<String>> {
|
||||
return gameDao.getDistinctTeamNames()
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@ package me.zobrist.tichucounter.ui
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.*
|
||||
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
|
||||
|
||||
|
||||
@@ -2,14 +2,25 @@ package me.zobrist.tichucounter.ui.about
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.background
|
||||
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.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Mail
|
||||
import androidx.compose.material.icons.outlined.Shop
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ShapeDefaults
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment.Companion.Top
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
@@ -37,15 +48,19 @@ fun AboutView() {
|
||||
|
||||
) {
|
||||
|
||||
Row() {
|
||||
Row {
|
||||
Image(
|
||||
modifier = Modifier
|
||||
.height(80.dp)
|
||||
.padding(end = 10.dp)
|
||||
.align(Top),
|
||||
painter = painterResource(R.drawable.app_logo),
|
||||
.align(Top)
|
||||
.size(75.dp)
|
||||
.background(
|
||||
color = Color.Red,
|
||||
shape = ShapeDefaults.Medium
|
||||
),
|
||||
painter = painterResource(R.drawable.tichu_logo),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Fit
|
||||
contentScale = ContentScale.None
|
||||
)
|
||||
|
||||
Column {
|
||||
@@ -86,7 +101,7 @@ fun AboutView() {
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
fun AboutViewPreview() {
|
||||
AppTheme() {
|
||||
AppTheme {
|
||||
Surface {
|
||||
AboutView()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package me.zobrist.tichucounter.ui.composables
|
||||
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldColors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.input.key.Key
|
||||
import androidx.compose.ui.input.key.key
|
||||
import androidx.compose.ui.input.key.onKeyEvent
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
fun TypeaheadTextField(
|
||||
value: String,
|
||||
items: List<String>,
|
||||
onValueChange: (String) -> Unit,
|
||||
modifier: Modifier,
|
||||
colors: TextFieldColors,
|
||||
textStyle: TextStyle
|
||||
) {
|
||||
|
||||
var isFocused by remember { mutableStateOf(false) }
|
||||
val focusManager = LocalFocusManager.current
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = isFocused,
|
||||
modifier = modifier,
|
||||
onExpandedChange = {}
|
||||
) {
|
||||
|
||||
var dropDownWidth by remember { mutableStateOf(0) }
|
||||
|
||||
TextField(
|
||||
value = value,
|
||||
textStyle = textStyle,
|
||||
onValueChange = {
|
||||
onValueChange(it)
|
||||
},
|
||||
singleLine = true,
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Done,
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = {
|
||||
focusManager.clearFocus()
|
||||
}
|
||||
),
|
||||
modifier = Modifier
|
||||
.menuAnchor()
|
||||
.onFocusChanged {
|
||||
isFocused = it.isFocused
|
||||
}
|
||||
.onSizeChanged { dropDownWidth = it.width }
|
||||
.onKeyEvent { event ->
|
||||
if (event.key == Key.Back || event.key == Key.Enter) {
|
||||
focusManager.clearFocus()
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
},
|
||||
colors = colors
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = isFocused && items.isNotEmpty(),
|
||||
modifier = Modifier
|
||||
.width(with(LocalDensity.current) { dropDownWidth.toDp() }),
|
||||
onDismissRequest = { }
|
||||
) {
|
||||
|
||||
items.forEach {
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onValueChange(it)
|
||||
focusManager.clearFocus()
|
||||
},
|
||||
text = { Text(it) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,11 @@ import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
@@ -35,6 +39,8 @@ fun Landscape(viewModel: ICounterViewModel) {
|
||||
TeamNamesView(
|
||||
viewModel.teamNameA,
|
||||
viewModel.teamNameB,
|
||||
viewModel.teamNameSuggestionsA,
|
||||
viewModel.teamNameSuggestionsB,
|
||||
{ viewModel.updateNameA(it) },
|
||||
{ viewModel.updateNameB(it) }
|
||||
)
|
||||
@@ -46,6 +52,7 @@ fun Landscape(viewModel: ICounterViewModel) {
|
||||
|
||||
RoundListView(
|
||||
viewModel.roundScoreList,
|
||||
viewModel.sumUpScores,
|
||||
Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
@@ -64,6 +71,8 @@ fun Portrait(viewModel: ICounterViewModel) {
|
||||
TeamNamesView(
|
||||
viewModel.teamNameA,
|
||||
viewModel.teamNameB,
|
||||
viewModel.teamNameSuggestionsA,
|
||||
viewModel.teamNameSuggestionsB,
|
||||
{ viewModel.updateNameA(it) },
|
||||
{ viewModel.updateNameB(it) }
|
||||
)
|
||||
@@ -75,6 +84,7 @@ fun Portrait(viewModel: ICounterViewModel) {
|
||||
|
||||
RoundListView(
|
||||
viewModel.roundScoreList,
|
||||
viewModel.sumUpScores,
|
||||
Modifier.weight(1f)
|
||||
)
|
||||
|
||||
@@ -101,6 +111,7 @@ internal class PreviewViewModel : ICounterViewModel {
|
||||
override var totalScoreB: Int = 750
|
||||
override var teamNameA: String = "Team A"
|
||||
override var teamNameB: String = "Team B"
|
||||
override val sumUpScores: Boolean = false
|
||||
override var currentScoreA: String = ""
|
||||
override var currentScoreB: String = "45"
|
||||
override var isValidRound: Boolean = false
|
||||
@@ -111,6 +122,10 @@ internal class PreviewViewModel : ICounterViewModel {
|
||||
override var activeValue: String = currentScoreA
|
||||
override var inactiveValue: String = currentScoreB
|
||||
override var keyboardHidden: Boolean = false
|
||||
override val teamNameSuggestionsA: List<String> =
|
||||
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
||||
override val teamNameSuggestionsB: List<String> =
|
||||
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
||||
|
||||
override fun focusLastInput() {
|
||||
}
|
||||
|
||||
@@ -11,9 +11,7 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.domain.Tichu
|
||||
import me.zobrist.tichucounter.domain.digitCount
|
||||
import me.zobrist.tichucounter.domain.getTotalPoints
|
||||
import me.zobrist.tichucounter.domain.*
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -53,8 +51,11 @@ interface ICounterViewModel : IKeyBoardViewModel {
|
||||
val roundScoreList: List<Round>
|
||||
val totalScoreA: Int
|
||||
val totalScoreB: Int
|
||||
val sumUpScores: Boolean
|
||||
val teamNameA: String
|
||||
val teamNameB: String
|
||||
val teamNameSuggestionsA: List<String>
|
||||
val teamNameSuggestionsB: List<String>
|
||||
|
||||
fun updateNameA(value: String)
|
||||
fun updateNameB(value: String)
|
||||
@@ -62,9 +63,10 @@ interface ICounterViewModel : IKeyBoardViewModel {
|
||||
|
||||
@HiltViewModel
|
||||
class CounterViewModel @Inject constructor(
|
||||
private val gameRepository: GameRepository
|
||||
private val gameRepository: GameRepository,
|
||||
private val settingsAdapter: SettingsAdapter
|
||||
) :
|
||||
ViewModel(), ICounterViewModel {
|
||||
ViewModel(), ICounterViewModel, IDisplaySettingsChangeListener {
|
||||
|
||||
override var roundScoreList by mutableStateOf(emptyList<Round>())
|
||||
private set
|
||||
@@ -78,6 +80,9 @@ class CounterViewModel @Inject constructor(
|
||||
override var teamNameA by mutableStateOf("")
|
||||
private set
|
||||
|
||||
override var sumUpScores by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
override var teamNameB by mutableStateOf("")
|
||||
private set
|
||||
|
||||
@@ -105,6 +110,12 @@ class CounterViewModel @Inject constructor(
|
||||
override var keyboardHidden by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
override var teamNameSuggestionsA by mutableStateOf(listOf<String>())
|
||||
private set
|
||||
|
||||
override var teamNameSuggestionsB by mutableStateOf(listOf<String>())
|
||||
private set
|
||||
|
||||
override var activeValue: String
|
||||
get() {
|
||||
return if (isBFocused) {
|
||||
@@ -144,6 +155,8 @@ class CounterViewModel @Inject constructor(
|
||||
|
||||
private var deleteJob: Job? = null
|
||||
|
||||
private var distinctTeamNames = listOf<String>()
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
gameRepository.getActiveGameFlow().collect {
|
||||
@@ -157,9 +170,26 @@ class CounterViewModel @Inject constructor(
|
||||
|
||||
teamNameA = it.game.nameA
|
||||
teamNameB = it.game.nameB
|
||||
|
||||
buildTeamNameSuggestions()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
gameRepository.getDistinctTeamNames().collect {
|
||||
distinctTeamNames = it
|
||||
|
||||
buildTeamNameSuggestions()
|
||||
}
|
||||
}
|
||||
|
||||
settingsAdapter.registerOnChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
settingsAdapter.unregisterOnChangeListener(this)
|
||||
}
|
||||
|
||||
override fun focusLastInput() {
|
||||
@@ -255,12 +285,14 @@ class CounterViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
override fun updateNameA(value: String) {
|
||||
teamNameA = value
|
||||
viewModelScope.launch {
|
||||
gameRepository.updateActiveTeamName(nameA = value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateNameB(value: String) {
|
||||
teamNameB = value
|
||||
viewModelScope.launch {
|
||||
gameRepository.updateActiveTeamName(nameB = value)
|
||||
}
|
||||
@@ -324,4 +356,23 @@ class CounterViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildTeamNameSuggestions() {
|
||||
teamNameSuggestionsA = buildTypeaheadList(distinctTeamNames, teamNameA)
|
||||
teamNameSuggestionsB = buildTypeaheadList(distinctTeamNames, teamNameB)
|
||||
}
|
||||
|
||||
private fun buildTypeaheadList(rawList: List<String>, currentInput: String): List<String> {
|
||||
var filtered = rawList.filter { it.isNotEmpty() && it != currentInput }
|
||||
|
||||
if (currentInput.isNotEmpty()) {
|
||||
filtered = filtered.filter { it.contains(currentInput, ignoreCase = true) }
|
||||
}
|
||||
|
||||
return filtered.sorted().sortedBy { it.length }.take(10)
|
||||
}
|
||||
|
||||
override fun onCounterListViewChanged(listView: CounterListView) {
|
||||
sumUpScores = listView == CounterListView.CONTINUOUS
|
||||
}
|
||||
}
|
||||
@@ -251,7 +251,6 @@ fun KeyboardIconButton(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun CenteredTextField(
|
||||
value: String,
|
||||
|
||||
@@ -21,13 +21,22 @@ import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
|
||||
@Composable
|
||||
fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
||||
fun RoundListView(rounds: List<Round>, sumUpRounds: Boolean = false, modifier: Modifier) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
val scope = rememberCoroutineScope()
|
||||
var sumA = 0
|
||||
var sumB = 0
|
||||
|
||||
LazyColumn(state = lazyListState, modifier = modifier) {
|
||||
itemsIndexed(rounds) { index, item ->
|
||||
RoundListItem(item, index)
|
||||
if (sumUpRounds) {
|
||||
sumA += item.scoreA
|
||||
sumB += item.scoreB
|
||||
RoundListItem(sumA, sumB, index)
|
||||
|
||||
} else {
|
||||
RoundListItem(item.scoreA, item.scoreB, index)
|
||||
}
|
||||
}
|
||||
|
||||
scope.launch {
|
||||
@@ -37,14 +46,14 @@ fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RoundListItem(round: Round, index: Int) {
|
||||
private fun RoundListItem(scoreA: Int, scoreB: Int, index: Int) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(all = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = round.scoreA.toString(),
|
||||
text = scoreA.toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.weight(5f),
|
||||
textAlign = TextAlign.Center
|
||||
@@ -56,7 +65,7 @@ private fun RoundListItem(round: Round, index: Int) {
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
text = round.scoreB.toString(),
|
||||
text = scoreB.toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.weight(5f),
|
||||
textAlign = TextAlign.Center
|
||||
@@ -78,7 +87,7 @@ fun RoundListViewPreview() {
|
||||
|
||||
AppTheme {
|
||||
Surface {
|
||||
RoundListView(rounds, Modifier)
|
||||
RoundListView(rounds, true, Modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,46 +2,53 @@ package me.zobrist.tichucounter.ui.counter
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.*
|
||||
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
import me.zobrist.tichucounter.ui.composables.TypeaheadTextField
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun TeamNamesView(
|
||||
nameA: String,
|
||||
nameB: String,
|
||||
nameSuggestionsA: List<String>,
|
||||
nameSuggestionsB: List<String>,
|
||||
updateA: (String) -> Unit,
|
||||
updateB: (String) -> Unit
|
||||
) {
|
||||
|
||||
val color = TextFieldDefaults.textFieldColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)
|
||||
val containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)
|
||||
val color = TextFieldDefaults.colors(
|
||||
focusedContainerColor = containerColor,
|
||||
unfocusedContainerColor = containerColor,
|
||||
disabledContainerColor = containerColor,
|
||||
)
|
||||
|
||||
Row {
|
||||
TextField(
|
||||
|
||||
TypeaheadTextField(
|
||||
value = nameA,
|
||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
|
||||
items = nameSuggestionsA,
|
||||
onValueChange = { updateA(it) },
|
||||
singleLine = true,
|
||||
modifier = Modifier.weight(1f),
|
||||
colors = color
|
||||
colors = color,
|
||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center)
|
||||
)
|
||||
|
||||
TextField(
|
||||
TypeaheadTextField(
|
||||
value = nameB,
|
||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
|
||||
items = nameSuggestionsB,
|
||||
onValueChange = { updateB(it) },
|
||||
singleLine = true,
|
||||
modifier = Modifier.weight(1f),
|
||||
colors = color
|
||||
colors = color,
|
||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center)
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +57,6 @@ fun TeamNamesView(
|
||||
@Composable
|
||||
private fun TeamNamesViewPreview() {
|
||||
AppTheme {
|
||||
TeamNamesView("TeamA", "TeamB", {}, {})
|
||||
TeamNamesView("TeamA", "TeamB", listOf("Test1", "Test3"), listOf("Test3", "Test5"), {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,11 @@ import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.ElevatedCard
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
|
||||
@@ -2,14 +2,31 @@ package me.zobrist.tichucounter.ui.history
|
||||
|
||||
|
||||
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.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.DeleteForever
|
||||
import androidx.compose.material.icons.outlined.MoreVert
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -23,7 +40,8 @@ import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.domain.getTotalPoints
|
||||
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
||||
import java.text.DateFormat
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -16,7 +16,6 @@ import me.zobrist.tichucounter.domain.*
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
import me.zobrist.tichucounter.ui.counter.*
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DrawerContent(
|
||||
drawerItems: List<DrawerItem>,
|
||||
|
||||
@@ -8,8 +8,16 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.ArrowDropDown
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment.Companion.End
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -17,6 +25,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import me.zobrist.tichucounter.R
|
||||
import me.zobrist.tichucounter.domain.CounterListView
|
||||
import me.zobrist.tichucounter.domain.KeepScreenOn
|
||||
import me.zobrist.tichucounter.domain.Language
|
||||
import me.zobrist.tichucounter.domain.Theme
|
||||
@@ -36,6 +45,11 @@ val themeMap = mapOf(
|
||||
Theme.LIGHT to R.string.light
|
||||
)
|
||||
|
||||
val counterListViewMap = mapOf(
|
||||
CounterListView.BY_ROUND to R.string.by_round,
|
||||
CounterListView.CONTINUOUS to R.string.continuous,
|
||||
)
|
||||
|
||||
|
||||
@Composable
|
||||
fun SettingsView(viewModel: SettingsViewModel) {
|
||||
@@ -43,9 +57,11 @@ fun SettingsView(viewModel: SettingsViewModel) {
|
||||
viewModel.screenOn.value,
|
||||
viewModel.language,
|
||||
viewModel.theme,
|
||||
viewModel.counterListView,
|
||||
{ viewModel.updateScreenOn(it) },
|
||||
{ viewModel.updateLanguage(it) },
|
||||
{ viewModel.updateTheme(it) })
|
||||
{ viewModel.updateTheme(it) },
|
||||
{ viewModel.updateCounterListView(it) })
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -53,9 +69,11 @@ fun SettingsView(
|
||||
valueScreenOn: Boolean = true,
|
||||
valueLanguage: Language = Language.ENGLISH,
|
||||
valueTheme: Theme = Theme.DARK,
|
||||
valueCounterListView: CounterListView = CounterListView.BY_ROUND,
|
||||
updateScreenOn: (KeepScreenOn) -> Unit = {},
|
||||
updateLanguage: (Language) -> Unit = {},
|
||||
updateTheme: (Theme) -> Unit = {}
|
||||
updateTheme: (Theme) -> Unit = {},
|
||||
updateCounterListView: (CounterListView) -> Unit = {}
|
||||
) {
|
||||
Column {
|
||||
BooleanSetting(
|
||||
@@ -74,6 +92,14 @@ fun SettingsView(
|
||||
themeMap,
|
||||
valueTheme,
|
||||
) { updateTheme(it) }
|
||||
|
||||
StringSetting(
|
||||
stringResource(R.string.counter_mode),
|
||||
counterListViewMap,
|
||||
valueCounterListView,
|
||||
) { updateCounterListView(it) }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,7 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import me.zobrist.tichucounter.domain.KeepScreenOn
|
||||
import me.zobrist.tichucounter.domain.Language
|
||||
import me.zobrist.tichucounter.domain.SettingsAdapter
|
||||
import me.zobrist.tichucounter.domain.Theme
|
||||
import me.zobrist.tichucounter.domain.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@@ -24,6 +21,9 @@ class SettingsViewModel @Inject constructor(private val settings: SettingsAdapte
|
||||
var screenOn by mutableStateOf(settings.keepScreenOn)
|
||||
private set
|
||||
|
||||
var counterListView by mutableStateOf(settings.counterListView)
|
||||
private set
|
||||
|
||||
fun updateLanguage(language: Language) {
|
||||
settings.setLanguage(language)
|
||||
this.language = settings.language
|
||||
@@ -39,4 +39,9 @@ class SettingsViewModel @Inject constructor(private val settings: SettingsAdapte
|
||||
screenOn = settings.keepScreenOn
|
||||
}
|
||||
|
||||
fun updateCounterListView(value: CounterListView) {
|
||||
settings.setCounterViewList(value)
|
||||
counterListView = settings.counterListView
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 16 KiB |
54
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="50.684"
|
||||
android:viewportHeight="39.77">
|
||||
<group
|
||||
android:scaleX="0.46444446"
|
||||
android:scaleY="0.36443365"
|
||||
android:translateX="13.572049"
|
||||
android:translateY="12.638237">
|
||||
<path
|
||||
android:fillColor="#ffff00"
|
||||
android:pathData="m25.885,0.371 l-25.752,0.047 0.094,9.167 8.174,0.094 -0.094,29.957 9.592,-0.094 -0.047,-29.957h8.08z"
|
||||
android:strokeWidth="0.26458300000000001"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#ffff00"
|
||||
android:pathData="m50.503,39.494 l-0.047,-9.214h-10.773c-0.738,-0.009 -2.147,-0.64 -2.139,-1.95 0.009,-1.415 0.012,-16.903 0.012,-16.903 -0.001,-1.41 1.227,-2.055 1.89,-2.079l11.009,-0.142 0.094,-9.072 -11.86,0.189c-2.609,0.059 -10.536,2.804 -10.537,13.23 -0,10.079 0.218,15.921 0.218,15.921 0.223,4.386 5.741,9.979 10.125,9.99l12.006,0.03z"
|
||||
android:strokeWidth="0.26458300000000001"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m8.403,10.083c0.049,-0.713 -0.112,-0.88 -0.029,-2.095 0.366,-1.278 9.609,-5.62 16.985,-2.65 0.403,0.162 0.5,-0.375 0.299,-0.467 -2.964,-2.692 -13.318,-8.128 -25.314,0.286l8.059,4.521"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m13.09,39.45 l-4.651,-7.072 1.436,-0.155c1.716,-3.55 8.698,-15.304 2.46,-24.75 -0.307,-0.496 0.802,-2.297 1.512,-0.563 5.772,10.547 5.161,23.028 -0.757,32.54z"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m42.812,9.194 l7.51,-4.144c-4.938,-5.973 -14.39,-7.27 -20.302,4.385 -0.2,0.447 0.901,0.888 1.106,0.649 5.387,-7.535 11.325,-3.968 11.686,-2.476 0.158,0.461 0.006,1.054 0.001,1.585z"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m42.429,30.41 l7.935,4.743c-13.982,13.838 -26.059,-8.724 -21.01,-24.194 0.143,-0.438 1.306,-0.12 1.201,0.408 -1.411,6.97 1.621,22.234 11.726,20.975z"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
</group>
|
||||
</vector>
|
||||
48
app/src/main/res/drawable/tichu_logo.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="50.684dp"
|
||||
android:height="39.77dp"
|
||||
android:viewportWidth="50.684"
|
||||
android:viewportHeight="39.77">
|
||||
<path
|
||||
android:fillColor="#ffff00"
|
||||
android:pathData="m25.885,0.371 l-25.752,0.047 0.094,9.167 8.174,0.094 -0.094,29.957 9.592,-0.094 -0.047,-29.957h8.08z"
|
||||
android:strokeWidth="0.26458300000000001"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#ffff00"
|
||||
android:pathData="m50.503,39.494 l-0.047,-9.214h-10.773c-0.738,-0.009 -2.147,-0.64 -2.139,-1.95 0.009,-1.415 0.012,-16.903 0.012,-16.903 -0.001,-1.41 1.227,-2.055 1.89,-2.079l11.009,-0.142 0.094,-9.072 -11.86,0.189c-2.609,0.059 -10.536,2.804 -10.537,13.23 -0,10.079 0.218,15.921 0.218,15.921 0.223,4.386 5.741,9.979 10.125,9.99l12.006,0.03z"
|
||||
android:strokeWidth="0.26458300000000001"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m8.403,10.083c0.049,-0.713 -0.112,-0.88 -0.029,-2.095 0.366,-1.278 9.609,-5.62 16.985,-2.65 0.403,0.162 0.5,-0.375 0.299,-0.467 -2.964,-2.692 -13.318,-8.128 -25.314,0.286l8.059,4.521"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m13.09,39.45 l-4.651,-7.072 1.436,-0.155c1.716,-3.55 8.698,-15.304 2.46,-24.75 -0.307,-0.496 0.802,-2.297 1.512,-0.563 5.772,10.547 5.161,23.028 -0.757,32.54z"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m42.812,9.194 l7.51,-4.144c-4.938,-5.973 -14.39,-7.27 -20.302,4.385 -0.2,0.447 0.901,0.888 1.106,0.649 5.387,-7.535 11.325,-3.968 11.686,-2.476 0.158,0.461 0.006,1.054 0.001,1.585z"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m42.429,30.41 l7.935,4.743c-13.982,13.838 -26.059,-8.724 -21.01,-24.194 0.143,-0.438 1.306,-0.12 1.201,0.408 -1.411,6.97 1.621,22.234 11.726,20.975z"
|
||||
android:strokeWidth="0.264583"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="butt"
|
||||
android:strokeLineJoin="miter" />
|
||||
</vector>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 14 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="primaryColor">#d50000</color>
|
||||
|
||||
</resources>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">@color/primaryColor</color>
|
||||
<color name="ic_launcher_background">#DC0E00</color>
|
||||
</resources>
|
||||
@@ -19,13 +19,16 @@
|
||||
<string name="delete_inactive_title">Delete history</string>
|
||||
<string name="delete_inactive_text">You really want to delete the the history? This action can\'t be undone.</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="deleteAll">Delete all</string>
|
||||
<string name="active">Current Game</string>
|
||||
<string name="inactive">Old Games</string>
|
||||
<string name="menu_counter">Counter</string>
|
||||
<string name="menu_about">About</string>
|
||||
<string name="by_round">Display Single Round</string>
|
||||
<string name="continuous">Sum up rounds</string>
|
||||
<string name="counter_mode">Counter Mode</string>
|
||||
<string name="contact_us">Contact us</string>
|
||||
<string name="play_store" translatable="false">Play Store</string>
|
||||
</resources>
|
||||
@@ -1,7 +1,9 @@
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import me.zobrist.tichucounter.domain.Tichu
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext {
|
||||
compose_version = '1.1.1'
|
||||
}
|
||||
ext.kotlin_version = "1.7.20"
|
||||
ext.kotlin_version = "1.8.21"
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.4.2'
|
||||
classpath 'com.android.tools.build:gradle:8.0.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
||||
@@ -18,4 +18,7 @@ android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=false
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
kotlin.code.style=official
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonFinalResIds=false
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
|
||||
|
||||