Compare commits
242 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 994908be9a | |||
| 6856f7abd7 | |||
| d8f0a50c88 | |||
| ea3e86353b | |||
| a2da0da9d0 | |||
| 311a562658 | |||
| cf5c408464 | |||
| fdf8c5c7df | |||
| 7ed3a29c5b | |||
| 9434d1f1b9 | |||
| 9abff51cb8 | |||
| 93f51b9220 | |||
| 8bb2b9bf20 | |||
| 00569666be | |||
| 2cf6578378 | |||
| fbcf9af761 | |||
| 80039a5f94 | |||
| 1c6674373f | |||
| 67e803f913 | |||
| 4c01fe13a8 | |||
| 2d30de8855 | |||
| 45ae61584d | |||
| fa9786de04 | |||
| 461dc4a30c | |||
| 44246e329e | |||
| c968d2ee91 | |||
| 1a2002e812 | |||
| c3c0f09313 | |||
| 81a0d680e9 | |||
| 27cb2f670b | |||
| 6a96749501 | |||
| 2fa4e218e5 | |||
| 2599e3320a | |||
| c97d98704b | |||
| 37bbf45ce0 | |||
| dbef6e047a | |||
| 450c8a1547 | |||
| 536b5b7fd2 | |||
| 57b02ce74a | |||
| 4e4653da97 | |||
| e5041c98e1 | |||
| 8521247c58 | |||
| 7108af4cf4 | |||
| 55a2293b6c | |||
| c8098fc904 | |||
| ec3b51051a | |||
| 07219bffb4 | |||
| ff5495249f | |||
| 217370079d | |||
| add100146d | |||
| ceebe92f8b | |||
| 4f87321e2c | |||
| 81c540c2a5 | |||
| a45043424e | |||
| 18326e952f | |||
| 1819802748 | |||
| a099659b2c | |||
| 61745c95a4 | |||
| 164cf6900f | |||
| 89ab0afaf5 | |||
| 9d8de2dd3c | |||
| fcb8c12454 | |||
| 34e64e6e50 | |||
| 694989a917 | |||
| 1e8e72557d | |||
| 2e40d0315c | |||
| 9ddbdb698c | |||
| c40d473fa5 | |||
| 507944794f | |||
| 068e36c5f6 | |||
| 7e722feb27 | |||
| fb4c83d60a | |||
| 0c80e05f5c | |||
| 8ca82d1734 | |||
| 9385deeb24 | |||
| fadd206e9e | |||
| 6768391caf | |||
| aa3e68dc5c | |||
| a2b84640b1 | |||
| 895264de2a | |||
| 3ec8c27b96 | |||
| 343d1d8e75 | |||
| 801a17d759 | |||
| 8e26f6b337 | |||
| 9e658853eb | |||
| 5a229d6c57 | |||
| bcc3bd3848 | |||
| 17d861403e | |||
| a1f344580d | |||
| b3bdbfbc05 | |||
| a611de6da4 | |||
| 4108512139 | |||
| 30723f7862 | |||
| 661b88b961 | |||
| c41816898e | |||
| 2e8d6a7a4e | |||
| ae0f85bec0 | |||
| e1e25ff607 | |||
| 6aedb0d7f9 | |||
| 48374c5980 | |||
| 02213f41b6 | |||
| 9ae0890f71 | |||
| cd8f1959af | |||
| 58d4fc0e43 | |||
| c71b608a7b | |||
| 89f2e3ecd5 | |||
| f52bfa64ce | |||
| 4346af3d2b | |||
| ca88bd1054 | |||
| c54f63736e | |||
| 8d24e46687 | |||
| f40b66077b | |||
| 9ca830a707 | |||
| db58e475d1 | |||
| 33e57bcfd7 | |||
| c1567efe52 | |||
| 4d37e77f55 | |||
| 984afb610f | |||
| c3c6c253bc | |||
| 9189d79982 | |||
| ad0236556e | |||
| 52a73bf204 | |||
| 6d0192df18 | |||
| 63f213bc75 | |||
| 68a5d34e45 | |||
| 98ea66772f | |||
| 84a63a2bcb | |||
| c5de57c416 | |||
| 7f904f916f | |||
| c4a552ad8c | |||
| 45746aef0b | |||
| cd39384207 | |||
| f44b51c075 | |||
| 9ec2a0e465 | |||
| f7ccf46b55 | |||
| 0da8a508f5 | |||
| 90f0b09e3d | |||
| eac916d8ec | |||
| 57bb4deebe | |||
| 8b4ce20c99 | |||
| bd19858834 | |||
| 395f93ca89 | |||
| 45f11d5caf | |||
| f947c5aeb2 | |||
| fb10dce89e | |||
| e09bd26859 | |||
| bcc08e4605 | |||
| f2cd02e130 | |||
| 9c653d788b | |||
| a4ccd62d72 | |||
| 823d1a6ca4 | |||
| 0f4d008104 | |||
| 2ed221a99f | |||
| 5f6da1d7d4 | |||
| ae6210073d | |||
| 26a44dcc18 | |||
| b73ddbf4cc | |||
| b7a821b9f6 | |||
| 6b396dba24 | |||
| 2bf0666946 | |||
| 74be455d48 | |||
| 1e428e854e | |||
| 94cdbcad0b | |||
| f8b35bddda | |||
| ec765b5fec | |||
| 39b092c7c5 | |||
| 8fb90bd6d0 | |||
| e01df3a5c7 | |||
| 3b7b71ce77 | |||
| 968edfbb67 | |||
| 6ded9efe68 | |||
| bdc9b64c63 | |||
| bdb4410638 | |||
| f6b3f70e18 | |||
| 70da57df9c | |||
| 17ed7d18f6 | |||
| 30c8941bd1 | |||
| bdf3c0a98e | |||
| 09739ccc8e | |||
| 7655d1d7a3 | |||
| 6edbe12fd1 | |||
| db5384201f | |||
| 252889eff7 | |||
| 4e6193501b | |||
| 637a34efd7 | |||
| 346ac10e68 | |||
| 0e31908c7a | |||
| 5e0c80be17 | |||
| a835580682 | |||
| 479f5476e0 | |||
| e825c86855 | |||
| b3793caba2 | |||
| e972400313 | |||
| 72bb963bd2 | |||
| beddcb7125 | |||
| f3e50dea8b | |||
| 1cc60756d1 | |||
| d9486dfec4 | |||
| c3999f45d9 | |||
| 5ee8b4114b | |||
| e1634dafd9 | |||
| 1291d24ee3 | |||
| 06367bb101 | |||
| f9aec95547 | |||
| 50391c3018 | |||
| 6f221d7880 | |||
| a4355df9d0 | |||
| ab6bc2212d | |||
| c16a865937 | |||
| 12de9b9ebd | |||
| ba337a3e0e | |||
| c2882a9751 | |||
| 15e24afe12 | |||
| 5ec74da139 | |||
| fa24e254dc | |||
| 5447c47d61 | |||
| 9986fd7565 | |||
| bc44dfd386 | |||
| c895c08924 | |||
| 3022e8442b | |||
| fe95de53b4 | |||
| 383162ea3a | |||
| 818965e16c | |||
| 6cec709476 | |||
| 78059fd187 | |||
| 630f9689ad | |||
| 531bfb42b6 | |||
| cdb00abbe3 | |||
| bc673b4ef7 | |||
| f7b68c368a | |||
| 88c5096c7c | |||
| bbab1a1eb4 | |||
| d4fa1483cd | |||
| 6146219d9c | |||
| eec11bef81 | |||
| b8ad540b57 | |||
| ed28d054ec | |||
| 78481d29fc | |||
| a7b3247796 | |||
| 0ed30dc87a | |||
| cc8ae173f8 | |||
| 00ace8ddc0 |
44
.gitea/workflows/buildAndroid.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
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
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: app-release
|
||||
retention-days: 10
|
||||
path: app/build/outputs/**/release/app-release.*
|
||||
|
||||
- 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
|
||||
4
.gitignore
vendored
@@ -12,3 +12,7 @@
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
.idea
|
||||
keystore.properties
|
||||
version.properties
|
||||
.vscode/
|
||||
|
||||
1
.idea/.name
generated
@@ -1 +0,0 @@
|
||||
Tichu Counter
|
||||
138
.idea/codeStyles/Project.xml
generated
@@ -1,138 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
10
.idea/dictionaries/fabian.xml
generated
@@ -1,10 +0,0 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="fabian">
|
||||
<words>
|
||||
<w>checkmark</w>
|
||||
<w>tichu</w>
|
||||
<w>tichucounter</w>
|
||||
<w>zobrist</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
21
.idea/gradle.xml
generated
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="PLATFORM" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
25
.idea/jarRepositories.xml
generated
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
48
.idea/misc.xml
generated
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="12">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||
<item index="6" class="java.lang.String" itemvalue="android.annotation.Nullable" />
|
||||
<item index="7" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||
<item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="11">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||
<item index="5" class="java.lang.String" itemvalue="android.annotation.NonNull" />
|
||||
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||
<item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
12
.idea/runConfigurations.xml
generated
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
BIN
AndroidKey
Normal file
674
LICENCE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
4
README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Tichu Counter
|
||||
Simple Tichu Coutner Android application.
|
||||
|
||||
The application can be installed from [Play Store](https://play.google.com/store/apps/details?id=me.zobrist.tichucounter)
|
||||
1
app/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/build
|
||||
/release
|
||||
138
app/build.gradle
@@ -1,51 +1,135 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'com.google.dagger.hilt.android'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.google.devtools.ksp'
|
||||
}
|
||||
|
||||
// Create a variable called keystorePropertiesFile, and initialize it to your
|
||||
// keystore.properties file, in the rootProject folder.
|
||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
def versionPropertiesFile = rootProject.file("version.properties")
|
||||
|
||||
|
||||
// Initialize a new Properties() object called keystoreProperties.
|
||||
def keystoreProperties = new Properties()
|
||||
def versionProperties = new Properties()
|
||||
|
||||
def versionMajor = 2
|
||||
def versionMinor = 3
|
||||
|
||||
// Load your keystore.properties file into the keystoreProperties object.
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
versionProperties.load(new FileInputStream(versionPropertiesFile))
|
||||
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.2"
|
||||
compileSdk 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId "me.zobrist.tichucounter"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 7
|
||||
versionName "1.0.0"
|
||||
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 36
|
||||
versionCode versionProperties["versionCode"].toInteger()
|
||||
versionName "${versionMajor}.${versionMinor}.${versionProperties["versionCode"].toInteger()}"
|
||||
resourceConfigurations += ['de', 'en']
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
multiDexEnabled true
|
||||
vectorDrawables {
|
||||
useSupportLibrary true
|
||||
}
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
keyAlias = keystoreProperties["keyAlias"]
|
||||
keyPassword = keystoreProperties["keyPassword"]
|
||||
storeFile = file(keystoreProperties["storeFile"])
|
||||
storePassword = keystoreProperties["storePassword"]
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.5.14"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
jvmTarget = '17'
|
||||
}
|
||||
namespace 'me.zobrist.tichucounter'
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.3.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.0'
|
||||
implementation 'com.google.android.play:core:1.8.0'
|
||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.13.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||
implementation "androidx.compose.material3:material3:1.2.1"
|
||||
implementation 'com.google.android.play:review:2.0.1'
|
||||
implementation 'com.google.android.play:review-ktx:2.0.1'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.7.7'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.4'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.8.2'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4'
|
||||
implementation 'androidx.compose.material:material-icons-extended:1.6.8'
|
||||
implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0"
|
||||
implementation 'androidx.activity:activity-compose:1.9.1'
|
||||
implementation "androidx.compose.ui:ui:1.6.8"
|
||||
implementation "androidx.compose.ui:ui-tooling-preview:1.6.8"
|
||||
implementation "androidx.compose.runtime:runtime-livedata:1.6.8"
|
||||
implementation "androidx.navigation:navigation-compose:2.7.7"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4"
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
||||
implementation "com.google.dagger:hilt-android:2.51.1"
|
||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.6.8"
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:1.6.8"
|
||||
debugImplementation "androidx.compose.ui:ui-test-manifest:1.6.8"
|
||||
kapt "com.google.dagger:hilt-compiler:2.51.1"
|
||||
annotationProcessor "androidx.room:room-compiler:2.6.1"
|
||||
implementation "androidx.room:room-runtime:2.6.1"
|
||||
ksp "androidx.room:room-compiler:2.6.1"
|
||||
implementation "androidx.room:room-ktx:2.6.1"
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
api "androidx.navigation:navigation-fragment-ktx:2.7.7"
|
||||
}
|
||||
|
||||
// Allow references to generated code
|
||||
kapt {
|
||||
correctErrorTypes true
|
||||
}
|
||||
102
app/schemas/me.zobrist.tichucounter.data.AppDatabase/1.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "1739540cd7d5436941316932a1036d83",
|
||||
"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 NOT NULL)",
|
||||
"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": true
|
||||
}
|
||||
],
|
||||
"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 NOT NULL)",
|
||||
"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": true
|
||||
}
|
||||
],
|
||||
"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, '1739540cd7d5436941316932a1036d83')"
|
||||
]
|
||||
}
|
||||
}
|
||||
102
app/schemas/me.zobrist.tichucounter.data.AppDatabase/2.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 2,
|
||||
"identityHash": "1739540cd7d5436941316932a1036d83",
|
||||
"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 NOT NULL)",
|
||||
"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": true
|
||||
}
|
||||
],
|
||||
"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 NOT NULL)",
|
||||
"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": true
|
||||
}
|
||||
],
|
||||
"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, '1739540cd7d5436941316932a1036d83')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("me.zobrist.tichucounter", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import me.zobrist.tichucounter.data.AppDatabase
|
||||
import me.zobrist.tichucounter.data.GameDao
|
||||
import me.zobrist.tichucounter.data.RoundDao
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import org.junit.After
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class RepositoryInstrumentedTest {
|
||||
private lateinit var gameDao: GameDao
|
||||
private lateinit var roundDao: RoundDao
|
||||
private lateinit var repository: GameRepository
|
||||
private lateinit var db: AppDatabase
|
||||
|
||||
@Before
|
||||
fun createDb() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
db = Room.inMemoryDatabaseBuilder(
|
||||
context, AppDatabase::class.java
|
||||
).build()
|
||||
roundDao = db.roundDao()
|
||||
gameDao = db.gameDao()
|
||||
|
||||
repository = GameRepository(gameDao, roundDao)
|
||||
}
|
||||
|
||||
@After
|
||||
@Throws(IOException::class)
|
||||
fun closeDb() {
|
||||
db.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun gameInitialisation() = runTest {
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
assertEquals("TeamA", it.game.nameA)
|
||||
assertEquals("TeamB", it.game.nameB)
|
||||
assertTrue(it.game.active)
|
||||
assertEquals(0, it.rounds.count())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun modifyNames() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.updateActiveTeamName(nameA = "aaa")
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
assertEquals("aaa", it.game.nameA)
|
||||
assertEquals("TeamB", it.game.nameB)
|
||||
}
|
||||
|
||||
repository.updateActiveTeamName(nameB = "bbb")
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
assertEquals("aaa", it.game.nameA)
|
||||
assertEquals("bbb", it.game.nameB)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun newGame() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(6, it.count())
|
||||
|
||||
var uid: Long = 1
|
||||
it.forEach { game ->
|
||||
assertEquals(uid++, game.game.uid)
|
||||
assertEquals(0, game.rounds.count())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun setActive() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
val filtered = it.filter { it.game.active }
|
||||
assertEquals(1, filtered.count())
|
||||
assertEquals(6, filtered.first().game.uid)
|
||||
}
|
||||
|
||||
repository.setActive(2)
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
val filtered = it.filter { it.game.active }
|
||||
assertEquals(1, filtered.count())
|
||||
assertEquals(2, filtered.first().game.uid)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun addRoundToActiveGame() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
val filtered = it.filter { it.rounds.isNotEmpty() }
|
||||
assertEquals(1, filtered.count())
|
||||
assertEquals(6, filtered.first().rounds.count())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun lastRound() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
assertNull(repository.getLastRound())
|
||||
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
|
||||
var lastRound = repository.getLastRound()
|
||||
assertEquals(6, lastRound?.scoreA)
|
||||
assertEquals(6, lastRound?.scoreB)
|
||||
|
||||
repository.deleteLastRound()
|
||||
|
||||
lastRound = repository.getLastRound()
|
||||
assertEquals(5, lastRound?.scoreA)
|
||||
assertEquals(5, lastRound?.scoreB)
|
||||
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
|
||||
assertNull(repository.getLastRound())
|
||||
|
||||
// No error thrown
|
||||
repository.deleteLastRound()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun deleteInactive() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
for (i in 1..6) {
|
||||
repository.newGame()
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
}
|
||||
assertEquals(6 * 6, roundDao.getAll().count())
|
||||
|
||||
repository.deleteAllInactive()
|
||||
|
||||
// Consists of two transactions. Delete games then delete rounds.
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(1, it.count())
|
||||
assertEquals(6, it.first().rounds.count())
|
||||
}
|
||||
assertEquals(6, roundDao.getAll().count())
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun deleteById() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
for (i in 1..6) {
|
||||
repository.newGame()
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
}
|
||||
|
||||
// Non existing Id
|
||||
repository.deleteGame(10)
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(7, it.count())
|
||||
}
|
||||
|
||||
// Non existing Id
|
||||
val toDelete: Long = 3
|
||||
repository.deleteGame(toDelete)
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(6, it.count())
|
||||
assertEquals(0, it.count { it.game.uid == toDelete })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="me.zobrist.tichucounter">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:name=".framework.TichuCounterApplication"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_descriptor"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:localeConfig="@xml/locales_config"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:fullBackupContent="@xml/backup_descriptor">
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
|
||||
android:enabled="false"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="autoStoreLocales"
|
||||
android:value="true" />
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 28 KiB |
@@ -1,58 +0,0 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
|
||||
class History {
|
||||
private var scores: ArrayList<Round> = ArrayList()
|
||||
|
||||
fun getScoreA(): Int {
|
||||
var tempScore = 0
|
||||
scores.forEach {
|
||||
tempScore += it.scoreA
|
||||
}
|
||||
return tempScore
|
||||
}
|
||||
|
||||
fun getScoreB(): Int {
|
||||
var tempScore = 0
|
||||
scores.forEach {
|
||||
tempScore += it.scoreB
|
||||
}
|
||||
return tempScore
|
||||
}
|
||||
|
||||
fun getHistoryA(): String {
|
||||
var tempHistory = String()
|
||||
scores.forEach {
|
||||
tempHistory += it.scoreA.toString() + "\n"
|
||||
}
|
||||
return tempHistory
|
||||
}
|
||||
|
||||
fun getHistoryB(): String {
|
||||
var tempHistory = String()
|
||||
scores.forEach {
|
||||
tempHistory += it.scoreB.toString() + "\n"
|
||||
}
|
||||
return tempHistory
|
||||
}
|
||||
|
||||
fun logRound(round: Round) {
|
||||
scores.add(round)
|
||||
}
|
||||
|
||||
fun revertLastRound() {
|
||||
if (scores.isNotEmpty()) {
|
||||
scores.removeAt(scores.size - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearAll() {
|
||||
scores.clear()
|
||||
}
|
||||
|
||||
fun isEmpty(): Boolean {
|
||||
return scores.isEmpty()
|
||||
}
|
||||
}
|
||||
@@ -1,454 +1,313 @@
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.ScrollView
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.android.synthetic.main.content_main.*
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.List
|
||||
import androidx.compose.material.icons.automirrored.outlined.Redo
|
||||
import androidx.compose.material.icons.automirrored.outlined.Undo
|
||||
import androidx.compose.material.icons.outlined.Calculate
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.Keyboard
|
||||
import androidx.compose.material.icons.outlined.MoreVert
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material3.DrawerState
|
||||
import androidx.compose.material3.DrawerValue
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalNavigationDrawer
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.rememberDrawerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.domain.DrawerItem
|
||||
import me.zobrist.tichucounter.domain.KeepScreenOn
|
||||
import me.zobrist.tichucounter.domain.Language
|
||||
import me.zobrist.tichucounter.domain.ReviewService
|
||||
import me.zobrist.tichucounter.domain.Route
|
||||
import me.zobrist.tichucounter.domain.SettingsAdapter
|
||||
import me.zobrist.tichucounter.domain.Theme
|
||||
import me.zobrist.tichucounter.domain.TopBarAction
|
||||
import me.zobrist.tichucounter.domain.TopBarState
|
||||
import me.zobrist.tichucounter.domain.navigate
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
import me.zobrist.tichucounter.ui.MainViewModel
|
||||
import me.zobrist.tichucounter.ui.about.AboutView
|
||||
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
||||
import me.zobrist.tichucounter.ui.counter.Counter
|
||||
import me.zobrist.tichucounter.ui.counter.CounterViewModel
|
||||
import me.zobrist.tichucounter.ui.history.HistoryList
|
||||
import me.zobrist.tichucounter.ui.history.HistoryViewModel
|
||||
import me.zobrist.tichucounter.ui.layout.DrawerContent
|
||||
import me.zobrist.tichucounter.ui.layout.TopBar
|
||||
import me.zobrist.tichucounter.ui.settings.SettingsView
|
||||
import me.zobrist.tichucounter.ui.settings.SettingsViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private var updateOnChange: Boolean = true
|
||||
@Inject
|
||||
lateinit var settingsAdapter: SettingsAdapter
|
||||
|
||||
private lateinit var history: History
|
||||
private var currentRound = Round()
|
||||
@Inject
|
||||
lateinit var repository: GameRepository
|
||||
|
||||
@Inject
|
||||
lateinit var reviewService: ReviewService
|
||||
|
||||
private val counterViewModel: CounterViewModel by viewModels()
|
||||
private val historyViewModel: HistoryViewModel by viewModels()
|
||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||
private val mainViewModel: MainViewModel by viewModels()
|
||||
|
||||
private var requestReview: Boolean = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
setSupportActionBar(findViewById(R.id.toolbar))
|
||||
inputTeamA.setRawInputType(InputType.TYPE_NULL)
|
||||
inputTeamB.setRawInputType(InputType.TYPE_NULL)
|
||||
inputTeamA.requestFocus()
|
||||
disableSubmitButton()
|
||||
updateTheme(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2))
|
||||
keepScreenOn(
|
||||
this.getSharedPreferences("Settings", Context.MODE_PRIVATE)
|
||||
.getBoolean("Screen_On", false)
|
||||
)
|
||||
|
||||
val json = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("history", "{\"scores\":[]}")
|
||||
history = Gson().fromJson(json, History::class.java)
|
||||
nameTeamA.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamA", "TeamA"))
|
||||
nameTeamB.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamB", "TeamB"))
|
||||
updateView()
|
||||
changeTheme(settingsAdapter.theme.value)
|
||||
setKeepScreenOn(settingsAdapter.keepScreenOn.value)
|
||||
changeLanguage(settingsAdapter.language.value)
|
||||
|
||||
|
||||
inputTeamA.setOnFocusChangeListener { view, b ->
|
||||
if (b) {
|
||||
hideKeyboard()
|
||||
lifecycleScope.launch {
|
||||
settingsAdapter.theme.collect {
|
||||
changeTheme(it)
|
||||
}
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
settingsAdapter.keepScreenOn.collect {
|
||||
setKeepScreenOn(it)
|
||||
}
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
settingsAdapter.language.collect {
|
||||
changeLanguage(it)
|
||||
}
|
||||
}
|
||||
|
||||
inputTeamB.setOnFocusChangeListener { view, b ->
|
||||
if (b) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
inputTeamA.doOnTextChanged { text, start, count, after ->
|
||||
if (inputTeamA.isFocused) {
|
||||
if (inputTeamA.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), true)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(1, 1)
|
||||
}
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
} else {
|
||||
inputTeamA.text.clear()
|
||||
inputTeamB.text.clear()
|
||||
lifecycleScope.launch {
|
||||
settingsAdapter.gameFinished.collect {
|
||||
if (!requestReview) {
|
||||
requestReview = true
|
||||
return@collect
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||
enableSubmitButton()
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
inputTeamB.doOnTextChanged { text, start, count, after ->
|
||||
if (inputTeamB.isFocused) {
|
||||
if (inputTeamB.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), false)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(1, 1)
|
||||
}
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
|
||||
} else {
|
||||
inputTeamA.text.clear()
|
||||
inputTeamB.text.clear()
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||
enableSubmitButton()
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
|
||||
buttonAdd100.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.isFocused) {
|
||||
|
||||
currentRound.scoreA = try {
|
||||
inputTeamA.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreB = 0
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
100
|
||||
}
|
||||
updateOnChange = false
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
}
|
||||
|
||||
if (inputTeamB.isFocused) {
|
||||
currentRound.scoreB = try {
|
||||
inputTeamB.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreA = 0
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
100
|
||||
|
||||
}
|
||||
updateOnChange = false
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
buttonSub100.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.isFocused) {
|
||||
currentRound.scoreA = try {
|
||||
inputTeamA.text.toString().toInt() - 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreB = 0
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
-100
|
||||
}
|
||||
updateOnChange = false
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
}
|
||||
|
||||
if (inputTeamB.isFocused) {
|
||||
currentRound.scoreB = try {
|
||||
inputTeamB.text.toString().toInt() - 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreA = 0
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
-100
|
||||
}
|
||||
updateOnChange = false
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
}
|
||||
}
|
||||
|
||||
button0.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('0')
|
||||
}
|
||||
|
||||
button1.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('1')
|
||||
}
|
||||
|
||||
button2.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('2')
|
||||
}
|
||||
|
||||
button3.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('3')
|
||||
}
|
||||
|
||||
button4.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('4')
|
||||
}
|
||||
|
||||
button5.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('5')
|
||||
}
|
||||
|
||||
button6.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('6')
|
||||
}
|
||||
|
||||
button7.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('7')
|
||||
}
|
||||
|
||||
button8.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('8')
|
||||
}
|
||||
|
||||
button9.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('9')
|
||||
}
|
||||
|
||||
buttonInv.setOnClickListener {
|
||||
val tempInt: Int
|
||||
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.isFocused) {
|
||||
if (inputTeamA.text.toString().equals("-")) {
|
||||
inputTeamA.text.clear()
|
||||
} else if (inputTeamA.text.isNotEmpty()) {
|
||||
tempInt = inputTeamA.text.toString().toInt() * -1
|
||||
inputTeamA.setText(tempInt.toString())
|
||||
} else {
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1,1)
|
||||
}
|
||||
|
||||
|
||||
} else if (inputTeamB.isFocused) {
|
||||
if (inputTeamB.text.toString().equals("-")) {
|
||||
inputTeamB.text.clear()
|
||||
} else if (inputTeamB.text.isNotEmpty()) {
|
||||
tempInt = inputTeamB.text.toString().toInt() * -1
|
||||
inputTeamB.setText(tempInt.toString())
|
||||
} else {
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1,1)
|
||||
if (it) {
|
||||
reviewService.request()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buttonBack.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.isFocused) {
|
||||
if (inputTeamA.text.isNotEmpty()) {
|
||||
val string = inputTeamA.text.toString()
|
||||
inputTeamA.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
|
||||
} else if (inputTeamB.isFocused) {
|
||||
if (inputTeamB.text.isNotEmpty()) {
|
||||
val string = inputTeamB.text.toString()
|
||||
inputTeamB.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
submit.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||
|
||||
history.logRound(
|
||||
Round(
|
||||
inputTeamA.text.toString().toInt(),
|
||||
inputTeamB.text.toString().toInt()
|
||||
)
|
||||
)
|
||||
|
||||
updateView()
|
||||
|
||||
inputTeamA.text.clear()
|
||||
inputTeamB.text.clear()
|
||||
disableSubmitButton()
|
||||
|
||||
scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
setContent {
|
||||
AppTheme {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
systemUiController.setStatusBarColor(MaterialTheme.colorScheme.background)
|
||||
NavigationDrawer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
|
||||
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||
prefs.putString("history", Gson().toJson(history))
|
||||
prefs.putString("nameTeamA", nameTeamA.text.toString())
|
||||
prefs.putString("nameTeamB", nameTeamB.text.toString())
|
||||
prefs.apply()
|
||||
|
||||
private fun changeLanguage(language: Language) {
|
||||
AppCompatDelegate.setApplicationLocales(language.value)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
|
||||
menu.findItem(R.id.action_screenOn).isChecked =
|
||||
this.getSharedPreferences("Settings", Context.MODE_PRIVATE)
|
||||
.getBoolean("Screen_On", false)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_clear -> {
|
||||
val builder = AlertDialog.Builder(this)
|
||||
builder.setMessage(getString(R.string.confirmClear))
|
||||
.setTitle(R.string.clear)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.yes)) { dialog, id ->
|
||||
dialog.dismiss()
|
||||
clearAll()
|
||||
}
|
||||
.setNegativeButton(getString(R.string.no)) { dialog, id ->
|
||||
dialog.cancel()
|
||||
}
|
||||
|
||||
builder.create().show()
|
||||
true
|
||||
}
|
||||
R.id.action_undo -> {
|
||||
undoLastRound()
|
||||
true
|
||||
}
|
||||
R.id.action_theme -> {
|
||||
chooseThemeDialog()
|
||||
true
|
||||
}
|
||||
R.id.action_screenOn -> {
|
||||
item.isChecked = !item.isChecked
|
||||
keepScreenOn(item.isChecked)
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
private fun changeTheme(theme: Theme) {
|
||||
val themeValue = when (theme) {
|
||||
Theme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
|
||||
Theme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
Theme.DEFAULT -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
}
|
||||
AppCompatDelegate.setDefaultNightMode(themeValue)
|
||||
}
|
||||
|
||||
private fun hideKeyboard() {
|
||||
val imm: InputMethodManager =
|
||||
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
|
||||
}
|
||||
|
||||
private fun giveFocusToAIfNone() {
|
||||
if (!inputTeamA.isFocused && !inputTeamB.isFocused) {
|
||||
inputTeamA.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
private fun undoLastRound() {
|
||||
history.revertLastRound()
|
||||
updateView()
|
||||
}
|
||||
|
||||
private fun updateView() {
|
||||
scoreA.text = history.getScoreA().toString()
|
||||
scoreB.text = history.getScoreB().toString()
|
||||
|
||||
historyA.text = history.getHistoryA()
|
||||
historyB.text = history.getHistoryB()
|
||||
}
|
||||
|
||||
private fun clearAll() {
|
||||
historyA.text = ""
|
||||
historyB.text = ""
|
||||
inputTeamA.text.clear()
|
||||
inputTeamB.text.clear()
|
||||
scoreA.text = "0"
|
||||
scoreB.text = "0"
|
||||
|
||||
history.clearAll()
|
||||
}
|
||||
|
||||
private fun appendToFocusedInput(toAppend: Char) {
|
||||
if (inputTeamA.isFocused) {
|
||||
inputTeamA.text.append(toAppend)
|
||||
} else if (inputTeamB.isFocused) {
|
||||
inputTeamB.text.append(toAppend)
|
||||
}
|
||||
}
|
||||
|
||||
private fun enableSubmitButton() {
|
||||
submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
|
||||
submit.isEnabled = true
|
||||
}
|
||||
|
||||
private fun disableSubmitButton() {
|
||||
submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
||||
submit.isEnabled = false
|
||||
}
|
||||
|
||||
private fun chooseThemeDialog() {
|
||||
|
||||
val builder = AlertDialog.Builder(this)
|
||||
builder.setTitle(getString(R.string.choose_theme_text))
|
||||
val styles = arrayOf("Light", "Dark", "System default")
|
||||
|
||||
val checkedItem =
|
||||
this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2)
|
||||
|
||||
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||
|
||||
|
||||
builder.setSingleChoiceItems(styles, checkedItem) { dialog, which ->
|
||||
|
||||
prefs.putInt("Theme", which)
|
||||
prefs.apply()
|
||||
|
||||
updateTheme(which)
|
||||
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
val dialog = builder.create()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun updateTheme(which: Int) {
|
||||
when (which) {
|
||||
0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
}
|
||||
delegate.applyDayNight()
|
||||
}
|
||||
|
||||
private fun keepScreenOn(keepOn: Boolean) {
|
||||
if (keepOn) {
|
||||
private fun setKeepScreenOn(keepOn: KeepScreenOn) {
|
||||
if (keepOn.value) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
} else {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
|
||||
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||
prefs.putBoolean("Screen_On", keepOn)
|
||||
prefs.apply()
|
||||
@Composable
|
||||
private fun NavigationDrawer() {
|
||||
val drawerState = rememberDrawerState(DrawerValue.Closed)
|
||||
val scope = rememberCoroutineScope()
|
||||
val navController = rememberNavController()
|
||||
|
||||
val items = listOf(
|
||||
DrawerItem(
|
||||
Route.COUNTER,
|
||||
Icons.Outlined.Calculate,
|
||||
stringResource(R.string.menu_counter)
|
||||
),
|
||||
DrawerItem(
|
||||
Route.HISTORY,
|
||||
Icons.AutoMirrored.Outlined.List,
|
||||
stringResource(R.string.menu_history)
|
||||
),
|
||||
DrawerItem(
|
||||
Route.SETTINGS,
|
||||
Icons.Outlined.Settings,
|
||||
stringResource(R.string.menu_settings)
|
||||
),
|
||||
DrawerItem(
|
||||
Route.ABOUT,
|
||||
Icons.Outlined.Info,
|
||||
stringResource(R.string.menu_about)
|
||||
)
|
||||
)
|
||||
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentDestination =
|
||||
Route.valueOf(navBackStackEntry?.destination?.route ?: Route.COUNTER.name)
|
||||
|
||||
ModalNavigationDrawer(
|
||||
drawerState = drawerState,
|
||||
gesturesEnabled = drawerState.isOpen,
|
||||
drawerContent = {
|
||||
DrawerContent(
|
||||
drawerItems = items,
|
||||
selectedDrawerItem = items.first { it.route == currentDestination }) {
|
||||
scope.launch {
|
||||
drawerState.close()
|
||||
|
||||
}
|
||||
navController.navigate(it)
|
||||
}
|
||||
}
|
||||
) {
|
||||
MyScaffoldLayout(
|
||||
drawerState,
|
||||
scope,
|
||||
navController,
|
||||
counterViewModel.keyboardHidden && (currentDestination == Route.COUNTER)
|
||||
) { counterViewModel.showKeyboard() }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MyScaffoldLayout(
|
||||
drawerState: DrawerState,
|
||||
scope: CoroutineScope,
|
||||
navController: NavHostController,
|
||||
showFab: Boolean,
|
||||
fabAction: () -> Unit
|
||||
) {
|
||||
|
||||
var topBarState by remember { mutableStateOf(TopBarState()) }
|
||||
val snackbarHostState by remember { mutableStateOf(SnackbarHostState()) }
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = { SnackbarHost(snackbarHostState) },
|
||||
floatingActionButton = {
|
||||
if (showFab) {
|
||||
FloatingActionButton(
|
||||
onClick = { fabAction() }) {
|
||||
Icon(Icons.Outlined.Keyboard, null)
|
||||
}
|
||||
}
|
||||
},
|
||||
topBar = { TopBar(topBarState) }) { paddings ->
|
||||
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = Route.COUNTER.name,
|
||||
modifier = Modifier.padding(paddings)
|
||||
) {
|
||||
this.composable(Route.COUNTER.name) {
|
||||
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
|
||||
topBarState = TopBarState(
|
||||
title = stringResource(R.string.app_name),
|
||||
actions = (listOf(
|
||||
TopBarAction(
|
||||
Icons.AutoMirrored.Outlined.Undo,
|
||||
mainViewModel.isUndoActionActive,
|
||||
{ mainViewModel.undoLastRound() }),
|
||||
TopBarAction(
|
||||
Icons.AutoMirrored.Outlined.Redo,
|
||||
mainViewModel.isRedoActionActive,
|
||||
{ mainViewModel.redoLastRound() }),
|
||||
TopBarAction(
|
||||
Icons.Outlined.MoreVert,
|
||||
mainViewModel.activeGameHasRounds,
|
||||
{ expanded = true }
|
||||
) {
|
||||
val newGameTranslated = stringResource(R.string.new_game)
|
||||
DropDownMenu(
|
||||
listOf(newGameTranslated),
|
||||
"",
|
||||
expanded,
|
||||
) {
|
||||
expanded = false
|
||||
it?.let {
|
||||
when (it) {
|
||||
newGameTranslated -> lifecycleScope.launch { repository.newGame() }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
))
|
||||
) {
|
||||
scope.launch {
|
||||
currentFocus?.clearFocus()
|
||||
drawerState.open()
|
||||
}
|
||||
}
|
||||
|
||||
Counter(counterViewModel)
|
||||
}
|
||||
composable(Route.HISTORY.name) {
|
||||
topBarState =
|
||||
TopBarState(title = stringResource(R.string.menu_history)) { scope.launch { drawerState.open() } }
|
||||
|
||||
HistoryList(
|
||||
historyViewModel,
|
||||
snackbarHostState
|
||||
) { navController.navigate(Route.COUNTER) }
|
||||
}
|
||||
composable(Route.SETTINGS.name) {
|
||||
topBarState =
|
||||
TopBarState(title = stringResource(R.string.menu_settings)) { scope.launch { drawerState.open() } }
|
||||
|
||||
SettingsView(settingsViewModel)
|
||||
}
|
||||
|
||||
composable(Route.ABOUT.name) {
|
||||
topBarState =
|
||||
TopBarState(title = stringResource(R.string.menu_about)) { scope.launch { drawerState.open() } }
|
||||
|
||||
AboutView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
class Round() : Serializable {
|
||||
var scoreA: Int = 0
|
||||
var scoreB: Int = 0
|
||||
|
||||
constructor(score: Int, isScoreA: Boolean) : this() {
|
||||
if (isScoreA) {
|
||||
scoreA = score
|
||||
scoreB = calculateOtherScore(scoreA)
|
||||
} else {
|
||||
scoreB = score
|
||||
scoreA = calculateOtherScore(scoreB)
|
||||
}
|
||||
}
|
||||
|
||||
constructor(scoreA: Int, scoreB: Int) : this() {
|
||||
this.scoreA = scoreA
|
||||
this.scoreB = scoreB
|
||||
}
|
||||
|
||||
private fun calculateOtherScore(score: Int): Int {
|
||||
if (isMultipleOf100(score)) {
|
||||
return 0
|
||||
}
|
||||
return 100 - (score % 100)
|
||||
}
|
||||
|
||||
private fun isMultipleOf100(score: Int): Boolean {
|
||||
return (score / 100) >= 1 && (score % 100) == 0
|
||||
}
|
||||
|
||||
fun isValidRound(): Boolean {
|
||||
return (scoreA % 5 == 0) && (scoreB % 5 == 0) && ((scoreA + scoreB) % 100 == 0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.zobrist.tichucounter.data
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import me.zobrist.tichucounter.data.entity.Game
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
|
||||
@Database(entities = [Round::class, Game::class], version = 1)
|
||||
@TypeConverters(DateConverter::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun roundDao(): RoundDao
|
||||
abstract fun gameDao(): GameDao
|
||||
}
|
||||
22
app/src/main/java/me/zobrist/tichucounter/data/DaoBase.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package me.zobrist.tichucounter.data
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Update
|
||||
|
||||
@Dao
|
||||
interface DaoBase<T> {
|
||||
|
||||
@Insert
|
||||
fun insert(entity: T): Long
|
||||
|
||||
@Update
|
||||
fun update(entity: T)
|
||||
|
||||
@Delete
|
||||
fun delete(entity: T)
|
||||
|
||||
@Delete
|
||||
fun delete(entity: List<T>)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.zobrist.tichucounter.data
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@Module
|
||||
class DatabaseModule {
|
||||
@Provides
|
||||
fun provideRoundDao(appDatabase: AppDatabase): RoundDao {
|
||||
return appDatabase.roundDao()
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun provideGameDao(appDatabase: AppDatabase): GameDao {
|
||||
return appDatabase.gameDao()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAppDatabase(@ApplicationContext appContext: Context): AppDatabase {
|
||||
return Room.databaseBuilder(
|
||||
appContext,
|
||||
AppDatabase::class.java,
|
||||
"TichuCounterDb"
|
||||
).build()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package me.zobrist.tichucounter.data
|
||||
|
||||
import androidx.room.ProvidedTypeConverter
|
||||
import androidx.room.TypeConverter
|
||||
import java.util.Date
|
||||
|
||||
@ProvidedTypeConverter
|
||||
object DateConverter {
|
||||
@TypeConverter
|
||||
fun toDate(dateLong: Long?): Date? {
|
||||
return dateLong?.let { Date(it) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun fromDate(date: Date?): Long? {
|
||||
return date?.time
|
||||
}
|
||||
}
|
||||
43
app/src/main/java/me/zobrist/tichucounter/data/GameDao.kt
Normal file
@@ -0,0 +1,43 @@
|
||||
package me.zobrist.tichucounter.data
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import me.zobrist.tichucounter.data.entity.Game
|
||||
|
||||
|
||||
@Dao
|
||||
interface GameDao : DaoBase<Game> {
|
||||
|
||||
@Query("SELECT * FROM game")
|
||||
fun getAll(): Flow<List<Game>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM game")
|
||||
fun getGamesWithRounds(): Flow<List<GameWithScores>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM game WHERE active is 1")
|
||||
fun getActiveWithRounds(): Flow<GameWithScores?>
|
||||
|
||||
@Query("SELECT * FROM game WHERE uid is :gameId")
|
||||
fun getGameById(gameId: Long): Game
|
||||
|
||||
@Query("SELECT * FROM game WHERE active is 1")
|
||||
fun getActiveAsFlow(): Flow<Game?>
|
||||
|
||||
@Query("SELECT * FROM game WHERE active is 1")
|
||||
fun getActive(): Game?
|
||||
|
||||
|
||||
@Query("UPDATE game SET active = 1 WHERE uid is :gameId;")
|
||||
fun setActive(gameId: Long)
|
||||
|
||||
@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>>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package me.zobrist.tichucounter.data
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Relation
|
||||
import me.zobrist.tichucounter.data.entity.Game
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
|
||||
@Entity
|
||||
data class GameWithScores(
|
||||
@Embedded val game: Game = Game(),
|
||||
@Relation(
|
||||
parentColumn = "uid",
|
||||
entityColumn = "gameId"
|
||||
)
|
||||
val rounds: List<Round> = emptyList()
|
||||
)
|
||||
16
app/src/main/java/me/zobrist/tichucounter/data/RoundDao.kt
Normal file
@@ -0,0 +1,16 @@
|
||||
package me.zobrist.tichucounter.data
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
|
||||
@Dao
|
||||
interface RoundDao : DaoBase<Round> {
|
||||
|
||||
@Query("SELECT * FROM round")
|
||||
fun getAll(): List<Round>
|
||||
|
||||
@Query("SELECT * FROM round WHERE gameId is :gameId")
|
||||
fun getAllForGame(gameId: Long?): List<Round>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package me.zobrist.tichucounter.data.entity
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.util.Date
|
||||
|
||||
@Entity
|
||||
data class Game(
|
||||
var active: Boolean = true,
|
||||
var nameA: String = "TeamA",
|
||||
var nameB: String = "TeamB",
|
||||
val created: Date = Date(),
|
||||
var modified: Date = Date(),
|
||||
@PrimaryKey(autoGenerate = true) override val uid: Long = 0
|
||||
) : IEntity
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.zobrist.tichucounter.data.entity
|
||||
|
||||
interface IEntity {
|
||||
val uid: Long
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package me.zobrist.tichucounter.data.entity
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity
|
||||
data class Round(
|
||||
var gameId: Long,
|
||||
var scoreA: Int,
|
||||
var scoreB: Int,
|
||||
@PrimaryKey(autoGenerate = true) override val uid: Long = 0
|
||||
) : IEntity
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
data class DrawerItem(val route: Route, val menuIcon: ImageVector, val menuName: String)
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import me.zobrist.tichucounter.data.GameWithScores
|
||||
|
||||
fun GameWithScores.getTotalPoints(): Pair<Int, Int> {
|
||||
var scoreA = 0
|
||||
var scoreB = 0
|
||||
|
||||
this.rounds.forEach {
|
||||
scoreA += it.scoreA
|
||||
scoreB += it.scoreB
|
||||
}
|
||||
return Pair(scoreA, scoreB)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
|
||||
fun Int.isMultipleOf5(): Boolean {
|
||||
return (this % 5) == 0
|
||||
}
|
||||
|
||||
fun Int.isMultipleOf100(): Boolean {
|
||||
return (this % 100) == 0
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import androidx.navigation.NavController
|
||||
|
||||
fun NavController.navigate(route: Route) {
|
||||
this.navigate(route.name) {
|
||||
// Pop up to the start destination of the graph to
|
||||
// avoid building up a large stack of destinations
|
||||
// on the back stack as users select items
|
||||
popUpTo(Route.COUNTER.name) {
|
||||
saveState = true
|
||||
}
|
||||
// Avoid multiple copies of the same destination when
|
||||
// reselecting the same item
|
||||
launchSingleTop = true
|
||||
// Restore state when reselecting a previously selected item
|
||||
restoreState = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.play.core.review.ReviewManagerFactory
|
||||
import dagger.hilt.android.qualifiers.ActivityContext
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
|
||||
class ReviewService @Inject constructor(@ActivityContext private val appContext: Context) {
|
||||
|
||||
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext)
|
||||
|
||||
private val THREE_MONTHS: Long = 7776000000
|
||||
|
||||
private var requestCalled: Int
|
||||
get() = sharedPreferences.getInt("requestCalled", 0)
|
||||
set(value) {
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putInt("requestCalled", value)
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
private var nextReviewedDate: Date
|
||||
get() = Date(sharedPreferences.getLong("lastReviewedDate", 0))
|
||||
set(value) {
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putLong("lastReviewedDate", value.time)
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
fun request() {
|
||||
requestCalled += 1
|
||||
|
||||
if (requestCalled >= 3) {
|
||||
if (nextReviewedDate.time < System.currentTimeMillis()) {
|
||||
requestCalled = 0
|
||||
nextReviewedDate = Date(System.currentTimeMillis() + THREE_MONTHS)
|
||||
|
||||
val manager = ReviewManagerFactory.create(appContext)
|
||||
|
||||
val request = manager.requestReviewFlow()
|
||||
request.addOnCompleteListener { task ->
|
||||
if (task.isSuccessful) {
|
||||
// We got the ReviewInfo object
|
||||
val reviewInfo = task.result
|
||||
manager.launchReviewFlow(appContext as Activity, reviewInfo)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
enum class Route { COUNTER, HISTORY, SETTINGS, ABOUT }
|
||||
@@ -0,0 +1,112 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
enum class Theme { DEFAULT, DARK, LIGHT }
|
||||
enum class Language(val value: LocaleListCompat) {
|
||||
DEFAULT(LocaleListCompat.getEmptyLocaleList()),
|
||||
ENGLISH(LocaleListCompat.forLanguageTags("en")),
|
||||
GERMAN(LocaleListCompat.forLanguageTags("de"))
|
||||
}
|
||||
|
||||
enum class KeepScreenOn(val value: Boolean) { ON(true), OFF(false) }
|
||||
|
||||
typealias VictoryPoints = Int
|
||||
typealias GameWon = Boolean
|
||||
|
||||
@Singleton
|
||||
class SettingsAdapter @Inject constructor(@ApplicationContext private val context: Context) {
|
||||
|
||||
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
val language = MutableStateFlow(Language.DEFAULT)
|
||||
|
||||
val theme = MutableStateFlow(Theme.DEFAULT)
|
||||
|
||||
val keepScreenOn = MutableStateFlow(KeepScreenOn.OFF)
|
||||
|
||||
val victoryPoints = MutableStateFlow(0)
|
||||
|
||||
val gameFinished = MutableStateFlow(false)
|
||||
|
||||
init {
|
||||
language.value = try {
|
||||
enumValueOf(sharedPreferences.getString(Language::class.simpleName, null)!!)
|
||||
} catch (_: NullPointerException) {
|
||||
Language.DEFAULT
|
||||
}
|
||||
|
||||
theme.value = try {
|
||||
enumValueOf(sharedPreferences.getString(Theme::class.simpleName, null)!!)
|
||||
} catch (_: java.lang.Exception) {
|
||||
Theme.DEFAULT
|
||||
}
|
||||
|
||||
keepScreenOn.value = try {
|
||||
enumValueOf(sharedPreferences.getString(KeepScreenOn::class.simpleName, null)!!)
|
||||
} catch (_: java.lang.Exception) {
|
||||
KeepScreenOn.OFF
|
||||
}
|
||||
|
||||
victoryPoints.value = sharedPreferences.getInt(VictoryPoints::class.simpleName, 1000)
|
||||
|
||||
gameFinished.value = sharedPreferences.getBoolean(GameWon::class.simpleName, false)
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
language.collect {
|
||||
updatePreference(Language::class.simpleName, it.name)
|
||||
}
|
||||
}
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
theme.collect {
|
||||
updatePreference(Theme::class.simpleName, it.name)
|
||||
}
|
||||
}
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
keepScreenOn.collect {
|
||||
updatePreference(KeepScreenOn::class.simpleName, it.name)
|
||||
}
|
||||
}
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
victoryPoints.collect {
|
||||
updatePreference(VictoryPoints::class.simpleName, it)
|
||||
}
|
||||
}
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
gameFinished.collect {
|
||||
updatePreference(GameWon::class.simpleName, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePreference(name: String?, value: String) {
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putString(name, value)
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
private fun updatePreference(name: String?, value: Boolean) {
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putBoolean(name, value)
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
private fun updatePreference(name: String?, value: Int) {
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putInt(name, value)
|
||||
editor.apply()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
fun String.digitCount(): Int {
|
||||
var count = 0
|
||||
this.forEach {
|
||||
if (it.isDigit()) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
26
app/src/main/java/me/zobrist/tichucounter/domain/Tichu.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
class Tichu @Inject constructor() {
|
||||
|
||||
fun calculateOtherScore(score: Int): Int? {
|
||||
if (!score.isMultipleOf5()) {
|
||||
return null
|
||||
}
|
||||
if (score.isMultipleOf100() && score != 0) {
|
||||
return 0
|
||||
}
|
||||
if (score in 101..125) {
|
||||
return 0 - (score % 100)
|
||||
}
|
||||
return 100 - (score % 100)
|
||||
}
|
||||
|
||||
fun isValidRound(scoreA: Int?, scoreB: Int?): Boolean {
|
||||
if (scoreA == null || scoreB == null) {
|
||||
return false
|
||||
}
|
||||
return (scoreA.isMultipleOf5()) && scoreB.isMultipleOf5() && (scoreA + scoreB).isMultipleOf100()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
class TopBarAction(
|
||||
val imageVector: ImageVector,
|
||||
val isActive: Boolean,
|
||||
val action: () -> Unit,
|
||||
val composeCode: @Composable () -> Unit = {}
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Menu
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
data class TopBarState(
|
||||
var title: String = "",
|
||||
var icon: ImageVector = Icons.Outlined.Menu,
|
||||
var actions: List<TopBarAction> = emptyList(),
|
||||
var onNavigate: () -> Unit = {}
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.zobrist.tichucounter.framework
|
||||
|
||||
import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
@HiltAndroidApp
|
||||
class TichuCounterApplication : Application()
|
||||
@@ -0,0 +1,166 @@
|
||||
package me.zobrist.tichucounter.repository
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.take
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import me.zobrist.tichucounter.data.GameDao
|
||||
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.Date
|
||||
import javax.inject.Inject
|
||||
|
||||
class GameRepository @Inject constructor(
|
||||
private val gameDao: GameDao,
|
||||
private val roundDao: RoundDao
|
||||
) {
|
||||
|
||||
private var activeGame: Game = Game(true, "TeamA", "TeamB", Date(), Date())
|
||||
|
||||
private val newGameFlow = MutableStateFlow(Game())
|
||||
|
||||
private var deletedGame: GameWithScores? = null
|
||||
|
||||
init {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
gameDao.getActiveAsFlow().collect {
|
||||
if (it == null) {
|
||||
newGame()
|
||||
} else {
|
||||
activeGame = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun newGame() {
|
||||
withContext(Dispatchers.IO) {
|
||||
val id = gameDao.insert(Game(true, activeGame.nameA, activeGame.nameB, Date(), Date()))
|
||||
setActive(id)
|
||||
newGameFlow.value = gameDao.getGameById(id)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun updateActiveTeamName(nameA: String? = null, nameB: String? = null) {
|
||||
|
||||
val newA = nameA ?: activeGame.nameA
|
||||
val newB = nameB ?: activeGame.nameB
|
||||
|
||||
if (newA == activeGame.nameA && newB == activeGame.nameB) {
|
||||
return
|
||||
}
|
||||
|
||||
activeGame.modified = Date()
|
||||
activeGame.nameA = newA
|
||||
activeGame.nameB = newB
|
||||
withContext(Dispatchers.IO) {
|
||||
gameDao.update(activeGame)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun setActive(id: Long) {
|
||||
withContext(Dispatchers.IO) {
|
||||
gameDao.setActive(id)
|
||||
gameDao.setOthersInactive(id)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLastRound(): Round? {
|
||||
return try {
|
||||
withContext(Dispatchers.IO) {
|
||||
roundDao.getAllForGame(activeGame.uid).last()
|
||||
}
|
||||
} catch (_: NoSuchElementException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deleteLastRound() {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
roundDao.delete(getLastRound()!!)
|
||||
} catch (_: NullPointerException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun addRoundToActiveGame(scoreA: Int, scoreB: Int) {
|
||||
withContext(Dispatchers.IO) {
|
||||
val active = activeGame
|
||||
active.modified = Date()
|
||||
val round = Round(active.uid, scoreA, scoreB)
|
||||
roundDao.insert(round)
|
||||
gameDao.update(active)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deleteGame(uid: Long) {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val game = gameDao.getGameById(uid)
|
||||
val rounds = roundDao.getAllForGame(game.uid)
|
||||
|
||||
deletedGame = GameWithScores(game, rounds)
|
||||
|
||||
gameDao.delete(game)
|
||||
roundDao.delete(rounds)
|
||||
} catch (_: NullPointerException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun restoreLastDeletedGame() {
|
||||
if (deletedGame == null) {
|
||||
return
|
||||
}
|
||||
val revert = deletedGame!!
|
||||
deletedGame = null
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
gameDao.insert(revert.game)
|
||||
|
||||
revert.rounds.forEach {
|
||||
roundDao.insert(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deleteAllInactive() {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
gameDao.getAll().take(1).collect { games ->
|
||||
|
||||
val gamesToDelete = games.filter { it.uid != activeGame.uid }
|
||||
val roundsToDelete = roundDao.getAll().filter { it.gameId != activeGame.uid }
|
||||
|
||||
gameDao.delete(gamesToDelete)
|
||||
roundDao.delete(roundsToDelete)
|
||||
}
|
||||
} catch (_: NullPointerException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getActiveGameFlow(): Flow<GameWithScores> {
|
||||
return gameDao.getActiveWithRounds().filter { it != null }.map { it!! }
|
||||
}
|
||||
|
||||
fun getAllWithRoundFlow(): Flow<List<GameWithScores>> {
|
||||
return gameDao.getGamesWithRounds()
|
||||
}
|
||||
|
||||
fun getDistinctTeamNames(): Flow<List<String>> {
|
||||
return gameDao.getDistinctTeamNames()
|
||||
}
|
||||
|
||||
fun getNewGameStarted(): Flow<Game> {
|
||||
return newGameFlow
|
||||
}
|
||||
}
|
||||
70
app/src/main/java/me/zobrist/tichucounter/ui/Color.kt
Normal file
@@ -0,0 +1,70 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package me.zobrist.tichucounter.ui
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val md_theme_light_primary = Color(0xFF9C404D)
|
||||
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
|
||||
val md_theme_light_primaryContainer = Color(0xFFFFDADB)
|
||||
val md_theme_light_onPrimaryContainer = Color(0xFF40000F)
|
||||
val md_theme_light_secondary = Color(0xFF765659)
|
||||
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
|
||||
val md_theme_light_secondaryContainer = Color(0xFFFFDADB)
|
||||
val md_theme_light_onSecondaryContainer = Color(0xFF2C1517)
|
||||
val md_theme_light_tertiary = Color(0xFF775930)
|
||||
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
|
||||
val md_theme_light_tertiaryContainer = Color(0xFFFFDDB5)
|
||||
val md_theme_light_onTertiaryContainer = Color(0xFF2A1800)
|
||||
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(0xFFF4DDDE)
|
||||
val md_theme_light_onSurfaceVariant = Color(0xFF524344)
|
||||
val md_theme_light_outline = Color(0xFF857374)
|
||||
val md_theme_light_inverseOnSurface = Color(0xFFFBEEEE)
|
||||
val md_theme_light_inverseSurface = Color(0xFF362F2F)
|
||||
val md_theme_light_inversePrimary = Color(0xFFFFB2B9)
|
||||
val md_theme_light_shadow = Color(0xFF000000)
|
||||
val md_theme_light_surfaceTint = Color(0xFF9C404D)
|
||||
val md_theme_light_outlineVariant = Color(0xFFD7C1C2)
|
||||
val md_theme_light_scrim = Color(0xFF000000)
|
||||
|
||||
val md_theme_dark_primary = Color(0xFFFFB2B9)
|
||||
val md_theme_dark_onPrimary = Color(0xFF5F1222)
|
||||
val md_theme_dark_primaryContainer = Color(0xFF7D2937)
|
||||
val md_theme_dark_onPrimaryContainer = Color(0xFFFFDADB)
|
||||
val md_theme_dark_secondary = Color(0xFFE5BDBF)
|
||||
val md_theme_dark_onSecondary = Color(0xFF44292C)
|
||||
val md_theme_dark_secondaryContainer = Color(0xFF5C3F41)
|
||||
val md_theme_dark_onSecondaryContainer = Color(0xFFFFDADB)
|
||||
val md_theme_dark_tertiary = Color(0xFFE8C08E)
|
||||
val md_theme_dark_onTertiary = Color(0xFF442B06)
|
||||
val md_theme_dark_tertiaryContainer = Color(0xFF5D411B)
|
||||
val md_theme_dark_onTertiaryContainer = Color(0xFFFFDDB5)
|
||||
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(0xFF524344)
|
||||
val md_theme_dark_onSurfaceVariant = Color(0xFFD7C1C2)
|
||||
val md_theme_dark_outline = Color(0xFF9F8C8D)
|
||||
val md_theme_dark_inverseOnSurface = Color(0xFF201A1A)
|
||||
val md_theme_dark_inverseSurface = Color(0xFFECE0DF)
|
||||
val md_theme_dark_inversePrimary = Color(0xFF9C404D)
|
||||
val md_theme_dark_shadow = Color(0xFF000000)
|
||||
val md_theme_dark_surfaceTint = Color(0xFFFFB2B9)
|
||||
val md_theme_dark_outlineVariant = Color(0xFF524344)
|
||||
val md_theme_dark_scrim = Color(0xFF000000)
|
||||
|
||||
|
||||
val seed = Color(0xFF833842)
|
||||
@@ -0,0 +1,85 @@
|
||||
package me.zobrist.tichucounter.ui
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.data.entity.Game
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class MainViewModel @Inject constructor(
|
||||
private val gameRepository: GameRepository
|
||||
) : ViewModel() {
|
||||
|
||||
|
||||
private var redoRounds = mutableStateListOf<Round>()
|
||||
private var expectedRoundCount = 0
|
||||
|
||||
var isUndoActionActive by mutableStateOf(false)
|
||||
|
||||
val isRedoActionActive: Boolean
|
||||
get() = redoRounds.isNotEmpty()
|
||||
|
||||
var activeGameHasRounds by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
private var newGame: Game? = null
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
|
||||
gameRepository.getActiveGameFlow().collect {
|
||||
|
||||
activeGameHasRounds = it.rounds.isNotEmpty() == true
|
||||
|
||||
isUndoActionActive = it.rounds.isNotEmpty()
|
||||
|
||||
if (expectedRoundCount != it.rounds.count()) {
|
||||
redoRounds.clear()
|
||||
}
|
||||
|
||||
expectedRoundCount = it.rounds.count()
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
gameRepository.getNewGameStarted().collect {
|
||||
if (newGame == null) {
|
||||
newGame = it
|
||||
return@collect
|
||||
}
|
||||
redoRounds.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun undoLastRound() {
|
||||
viewModelScope.launch {
|
||||
val round = gameRepository.getLastRound()
|
||||
if (round != null) {
|
||||
redoRounds.add(round)
|
||||
expectedRoundCount--
|
||||
gameRepository.deleteLastRound()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun redoLastRound() {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val round = redoRounds.last()
|
||||
redoRounds.remove(round)
|
||||
expectedRoundCount++
|
||||
gameRepository.addRoundToActiveGame(round.scoreA, round.scoreB)
|
||||
} catch (_: NoSuchElementException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
99
app/src/main/java/me/zobrist/tichucounter/ui/Theme.kt
Normal file
@@ -0,0 +1,99 @@
|
||||
package me.zobrist.tichucounter.ui
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
|
||||
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 dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
|
||||
val colors = when {
|
||||
dynamicColor && useDarkTheme -> dynamicDarkColorScheme(LocalContext.current)
|
||||
dynamicColor && !useDarkTheme -> dynamicLightColorScheme(LocalContext.current)
|
||||
useDarkTheme -> DarkColors
|
||||
else -> LightColors
|
||||
}
|
||||
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colors,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
109
app/src/main/java/me/zobrist/tichucounter/ui/about/AboutView.kt
Normal file
@@ -0,0 +1,109 @@
|
||||
package me.zobrist.tichucounter.ui.about
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.Image
|
||||
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.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
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import me.zobrist.tichucounter.BuildConfig
|
||||
import me.zobrist.tichucounter.R
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
|
||||
|
||||
@Composable
|
||||
fun AboutView() {
|
||||
|
||||
val uriHandler = LocalUriHandler.current
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
top = 20.dp,
|
||||
start = 20.dp,
|
||||
end = 20.dp,
|
||||
bottom = 40.dp
|
||||
),
|
||||
|
||||
) {
|
||||
|
||||
Row {
|
||||
Image(
|
||||
modifier = Modifier
|
||||
.padding(end = 10.dp)
|
||||
.align(Top)
|
||||
.size(75.dp)
|
||||
.background(
|
||||
color = Color.Red,
|
||||
shape = ShapeDefaults.Medium
|
||||
),
|
||||
painter = painterResource(R.drawable.tichu_logo),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.None
|
||||
)
|
||||
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_name),
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
Text(text = "V" + BuildConfig.VERSION_NAME)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Button(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 30.dp),
|
||||
onClick = { uriHandler.openUri("market://details?id=me.zobrist.tichucounter") }
|
||||
) {
|
||||
Icon(imageVector = Icons.Outlined.Shop, contentDescription = null)
|
||||
Text(stringResource(id = R.string.play_store))
|
||||
}
|
||||
|
||||
Button(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 30.dp),
|
||||
onClick = { uriHandler.openUri("mailto:app@zobrist.me") }
|
||||
) {
|
||||
Icon(imageVector = Icons.Outlined.Mail, contentDescription = null)
|
||||
Text(stringResource(id = R.string.contact_us))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
fun AboutViewPreview() {
|
||||
AppTheme {
|
||||
Surface {
|
||||
AboutView()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.zobrist.tichucounter.ui.composables
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Check
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun <T> DropDownMenu(
|
||||
list: Collection<T>,
|
||||
selected: T,
|
||||
expanded: Boolean,
|
||||
onSelected: (T?) -> Unit
|
||||
) {
|
||||
DropdownMenu(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { onSelected(null) }
|
||||
) {
|
||||
list.forEach {
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onSelected(it)
|
||||
},
|
||||
trailingIcon = {
|
||||
if (it == selected) {
|
||||
Icon(Icons.Outlined.Check, null)
|
||||
}
|
||||
},
|
||||
text = { Text(it.toString()) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.mutableIntStateOf
|
||||
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.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)
|
||||
@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 { mutableIntStateOf(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) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package me.zobrist.tichucounter.ui.counter
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.EmojiEvents
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
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
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import me.zobrist.tichucounter.R
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
|
||||
|
||||
@Composable
|
||||
fun Counter(viewModel: ICounterViewModel = PreviewViewModel()) {
|
||||
|
||||
var orientation by remember { mutableIntStateOf(Configuration.ORIENTATION_PORTRAIT) }
|
||||
orientation = LocalConfiguration.current.orientation
|
||||
|
||||
if (viewModel.showVictoryDialog) {
|
||||
GameVictoryDialog(
|
||||
viewModel.totalScoreA,
|
||||
viewModel.totalScoreB,
|
||||
viewModel.teamNameA,
|
||||
viewModel.teamNameB,
|
||||
{ viewModel.victoryDialogExecuted(false) })
|
||||
{
|
||||
viewModel.victoryDialogExecuted(true)
|
||||
}
|
||||
}
|
||||
|
||||
Surface {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
Landscape(viewModel)
|
||||
} else {
|
||||
Portrait(viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Landscape(viewModel: ICounterViewModel) {
|
||||
Row {
|
||||
Column(Modifier.weight(1f)) {
|
||||
TeamNamesView(
|
||||
viewModel.teamNameA,
|
||||
viewModel.teamNameB,
|
||||
viewModel.teamNameSuggestionsA,
|
||||
viewModel.teamNameSuggestionsB,
|
||||
{ viewModel.updateNameA(it) },
|
||||
{ viewModel.updateNameB(it) }
|
||||
)
|
||||
|
||||
TeamScoresView(
|
||||
viewModel.totalScoreA,
|
||||
viewModel.totalScoreB
|
||||
)
|
||||
|
||||
RoundListView(
|
||||
viewModel.roundScoreList,
|
||||
Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
if (!viewModel.keyboardHidden) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyBoardView(viewModel = viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Portrait(viewModel: ICounterViewModel) {
|
||||
|
||||
Column {
|
||||
TeamNamesView(
|
||||
viewModel.teamNameA,
|
||||
viewModel.teamNameB,
|
||||
viewModel.teamNameSuggestionsA,
|
||||
viewModel.teamNameSuggestionsB,
|
||||
{ viewModel.updateNameA(it) },
|
||||
{ viewModel.updateNameB(it) }
|
||||
)
|
||||
|
||||
TeamScoresView(
|
||||
viewModel.totalScoreA,
|
||||
viewModel.totalScoreB
|
||||
)
|
||||
|
||||
RoundListView(
|
||||
viewModel.roundScoreList,
|
||||
Modifier.weight(1f)
|
||||
)
|
||||
|
||||
if (!viewModel.keyboardHidden) {
|
||||
KeyBoardView(viewModel = viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
fun CounterViewPreview() {
|
||||
AppTheme {
|
||||
Counter()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun GameVictoryDialog(
|
||||
pointsA: Int = 2000,
|
||||
pointsB: Int = 50,
|
||||
nameA: String = "nameA",
|
||||
nameB: String = "nameB",
|
||||
onDismiss: () -> Unit = {},
|
||||
onNewGame: () -> Unit = {},
|
||||
) {
|
||||
|
||||
val winner = if (pointsA > pointsB) {
|
||||
nameA
|
||||
} else {
|
||||
nameB
|
||||
}
|
||||
|
||||
val message = if (pointsA == pointsB) {
|
||||
stringResource(R.string.draw_message, winner, 100)
|
||||
} else {
|
||||
stringResource(R.string.victory_message)
|
||||
}
|
||||
|
||||
val title = if (pointsA == pointsB) {
|
||||
stringResource(R.string.draw_title)
|
||||
} else {
|
||||
stringResource(R.string.victory_title, winner)
|
||||
}
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { onDismiss() },
|
||||
dismissButton = {
|
||||
TextButton({ onDismiss() }) {
|
||||
Text(stringResource(R.string.abort))
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton({ onNewGame() }) {
|
||||
Text(stringResource(R.string.new_game))
|
||||
}
|
||||
},
|
||||
icon = { Icon(Icons.Outlined.EmojiEvents, null) },
|
||||
title = { Text(title) },
|
||||
text = { Text(message) }
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
internal class PreviewViewModel : ICounterViewModel {
|
||||
override var roundScoreList: List<Round> =
|
||||
listOf(Round(1, 10, 90), Round(1, 50, 50), Round(1, 70, 30))
|
||||
override var totalScoreA: Int = 350
|
||||
override var totalScoreB: Int = 750
|
||||
override var teamNameA: String = "Team A"
|
||||
override var teamNameB: String = "Team B"
|
||||
override var currentScoreA: String = ""
|
||||
override var currentScoreB: String = "45"
|
||||
override var isValidRound: Boolean = false
|
||||
override var isAFocused: Boolean = false
|
||||
override var isBFocused: Boolean = false
|
||||
override var requestFocusA: FocusRequester = FocusRequester()
|
||||
override var requestFocusB: FocusRequester = FocusRequester()
|
||||
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 var showVictoryDialog: Boolean = false
|
||||
|
||||
override fun focusLastInput() {
|
||||
}
|
||||
|
||||
override fun updateOtherScore() {
|
||||
}
|
||||
|
||||
override fun isValidTichuRound(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun updateSubmitButton() {
|
||||
}
|
||||
|
||||
override fun submitClicked() {
|
||||
}
|
||||
|
||||
override fun digitClicked(digit: String) {
|
||||
}
|
||||
|
||||
override fun negateClicked() {
|
||||
}
|
||||
|
||||
override fun addSub100Clicked(toAdd: Int) {
|
||||
}
|
||||
|
||||
override fun updateNameA(value: String) {
|
||||
}
|
||||
|
||||
override fun updateNameB(value: String) {
|
||||
}
|
||||
|
||||
override fun victoryDialogExecuted(result: Boolean) {
|
||||
}
|
||||
|
||||
override fun updateFocusStateA(state: Boolean) {
|
||||
}
|
||||
|
||||
override fun updateFocusStateB(state: Boolean) {
|
||||
}
|
||||
|
||||
override fun swapInputScores() {
|
||||
}
|
||||
|
||||
override fun hideKeyboard() {
|
||||
}
|
||||
|
||||
override fun showKeyboard() {
|
||||
}
|
||||
|
||||
override fun deleteState(pressed: Boolean) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
package me.zobrist.tichucounter.ui.counter
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.data.entity.Game
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.domain.SettingsAdapter
|
||||
import me.zobrist.tichucounter.domain.Tichu
|
||||
import me.zobrist.tichucounter.domain.digitCount
|
||||
import me.zobrist.tichucounter.domain.getTotalPoints
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
private enum class Focused { TEAM_A, TEAM_B }
|
||||
|
||||
interface IKeyBoardViewModel {
|
||||
|
||||
val currentScoreA: String
|
||||
val currentScoreB: String
|
||||
val isValidRound: Boolean
|
||||
val isAFocused: Boolean
|
||||
val isBFocused: Boolean
|
||||
val requestFocusA: FocusRequester
|
||||
val requestFocusB: FocusRequester
|
||||
val activeValue: String
|
||||
val inactiveValue: String
|
||||
val keyboardHidden: Boolean
|
||||
|
||||
fun focusLastInput()
|
||||
fun updateOtherScore()
|
||||
fun isValidTichuRound(): Boolean
|
||||
fun updateSubmitButton()
|
||||
fun submitClicked()
|
||||
fun digitClicked(digit: String)
|
||||
fun negateClicked()
|
||||
fun addSub100Clicked(toAdd: Int)
|
||||
fun updateFocusStateA(state: Boolean)
|
||||
fun updateFocusStateB(state: Boolean)
|
||||
fun swapInputScores()
|
||||
fun hideKeyboard()
|
||||
fun showKeyboard()
|
||||
fun deleteState(pressed: Boolean)
|
||||
|
||||
}
|
||||
|
||||
interface ICounterViewModel : IKeyBoardViewModel {
|
||||
val roundScoreList: List<Round>
|
||||
val totalScoreA: Int
|
||||
val totalScoreB: Int
|
||||
val teamNameA: String
|
||||
val teamNameB: String
|
||||
val teamNameSuggestionsA: List<String>
|
||||
val teamNameSuggestionsB: List<String>
|
||||
val showVictoryDialog: Boolean
|
||||
|
||||
fun updateNameA(value: String)
|
||||
fun updateNameB(value: String)
|
||||
fun victoryDialogExecuted(result: Boolean)
|
||||
}
|
||||
|
||||
@HiltViewModel
|
||||
class CounterViewModel @Inject constructor(
|
||||
private val gameRepository: GameRepository,
|
||||
private val settings: SettingsAdapter
|
||||
) :
|
||||
ViewModel(), ICounterViewModel {
|
||||
|
||||
override var roundScoreList by mutableStateOf(emptyList<Round>())
|
||||
private set
|
||||
|
||||
override var totalScoreA by mutableIntStateOf(0)
|
||||
private set
|
||||
|
||||
override var totalScoreB by mutableIntStateOf(0)
|
||||
private set
|
||||
|
||||
override var teamNameA by mutableStateOf("")
|
||||
private set
|
||||
|
||||
override var teamNameB by mutableStateOf("")
|
||||
private set
|
||||
|
||||
override var currentScoreA by mutableStateOf("")
|
||||
private set
|
||||
|
||||
override var currentScoreB by mutableStateOf("")
|
||||
private set
|
||||
|
||||
override var isValidRound by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
override var isAFocused by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
override var isBFocused by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
override var requestFocusA by mutableStateOf(FocusRequester())
|
||||
private set
|
||||
|
||||
override var requestFocusB by mutableStateOf(FocusRequester())
|
||||
private set
|
||||
|
||||
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 showVictoryDialog by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
override var activeValue: String
|
||||
get() {
|
||||
return if (isBFocused) {
|
||||
currentScoreB
|
||||
} else {
|
||||
currentScoreA
|
||||
}
|
||||
}
|
||||
set(value) {
|
||||
if (isBFocused) {
|
||||
currentScoreB = value
|
||||
} else {
|
||||
currentScoreA = value
|
||||
}
|
||||
}
|
||||
|
||||
override var inactiveValue: String
|
||||
get() {
|
||||
return if (isAFocused) {
|
||||
currentScoreB
|
||||
} else {
|
||||
currentScoreA
|
||||
}
|
||||
}
|
||||
set(value) {
|
||||
if (isAFocused) {
|
||||
currentScoreB = value
|
||||
} else {
|
||||
currentScoreA = value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var lastFocused = Focused.TEAM_A
|
||||
|
||||
private var deletePressed = false
|
||||
|
||||
private var deleteJob: Job? = null
|
||||
|
||||
private var distinctTeamNames = listOf<String>()
|
||||
|
||||
private var lastGame: Game? = null
|
||||
private var lastVictoryPoints: Int? = null
|
||||
|
||||
private val gameWon: Boolean
|
||||
get() = totalScoreA >= settings.victoryPoints.value || totalScoreB >= settings.victoryPoints.value
|
||||
|
||||
private var lastRoundCount: Int = 0
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
gameRepository.getActiveGameFlow().collect {
|
||||
if (it != null) {
|
||||
val score = it.getTotalPoints()
|
||||
|
||||
roundScoreList = it.rounds
|
||||
totalScoreA = score.first
|
||||
totalScoreB = score.second
|
||||
|
||||
teamNameA = it.game.nameA
|
||||
teamNameB = it.game.nameB
|
||||
|
||||
buildTeamNameSuggestions()
|
||||
|
||||
// Game has changed
|
||||
if (it.game.uid != lastGame?.uid) {
|
||||
if (lastGame != null) {
|
||||
settings.gameFinished.value = false
|
||||
}
|
||||
lastGame = it.game
|
||||
lastRoundCount = it.rounds.size
|
||||
return@collect
|
||||
}
|
||||
|
||||
// Game winning condition
|
||||
if (!settings.gameFinished.value) {
|
||||
if (gameWon) {
|
||||
showVictoryDialog = true
|
||||
}
|
||||
}
|
||||
|
||||
// Undo game winning if rounds were removed
|
||||
if (lastRoundCount > it.rounds.size) {
|
||||
if (!gameWon) {
|
||||
settings.gameFinished.value = false
|
||||
}
|
||||
}
|
||||
lastRoundCount = it.rounds.size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
gameRepository.getDistinctTeamNames().collect {
|
||||
distinctTeamNames = it
|
||||
|
||||
buildTeamNameSuggestions()
|
||||
}
|
||||
}
|
||||
viewModelScope.launch {
|
||||
settings.victoryPoints.collect {
|
||||
if (lastVictoryPoints == null) {
|
||||
lastVictoryPoints = it
|
||||
return@collect
|
||||
}
|
||||
|
||||
// Game was already won and will be won also with new settings
|
||||
settings.gameFinished.value = settings.gameFinished.value && gameWon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun focusLastInput() {
|
||||
when (lastFocused) {
|
||||
Focused.TEAM_A -> if (!isAFocused) requestFocusA.requestFocus()
|
||||
Focused.TEAM_B -> if (!isBFocused) requestFocusB.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateOtherScore() {
|
||||
inactiveValue = try {
|
||||
val tichu = Tichu()
|
||||
val myScore = activeValue.toInt()
|
||||
val hisScore = tichu.calculateOtherScore(myScore)
|
||||
if (tichu.isValidRound(myScore, hisScore)) {
|
||||
hisScore?.toString() ?: ""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
override fun isValidTichuRound(): Boolean {
|
||||
return try {
|
||||
val tichu = Tichu()
|
||||
tichu.isValidRound(currentScoreA.toInt(), currentScoreB.toInt())
|
||||
} catch (_: java.lang.NumberFormatException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateSubmitButton() {
|
||||
isValidRound = isValidTichuRound()
|
||||
}
|
||||
|
||||
override fun submitClicked() {
|
||||
viewModelScope.launch {
|
||||
gameRepository.addRoundToActiveGame(currentScoreA.toInt(), currentScoreB.toInt())
|
||||
}
|
||||
currentScoreA = ""
|
||||
currentScoreB = ""
|
||||
isValidRound = false
|
||||
}
|
||||
|
||||
override fun digitClicked(digit: String) {
|
||||
focusLastInput()
|
||||
|
||||
|
||||
if (activeValue.digitCount() >= 5) {
|
||||
// 5 digits is enough
|
||||
return
|
||||
}
|
||||
|
||||
val newValue = activeValue + digit
|
||||
|
||||
try {
|
||||
activeValue = newValue.toInt().toString()
|
||||
} catch (_: NumberFormatException) {
|
||||
}
|
||||
|
||||
updateOtherScore()
|
||||
updateSubmitButton()
|
||||
}
|
||||
|
||||
override fun negateClicked() {
|
||||
focusLastInput()
|
||||
|
||||
activeValue = if (activeValue.contains("-")) {
|
||||
activeValue.replace("-", "")
|
||||
} else {
|
||||
"-$activeValue"
|
||||
}
|
||||
updateOtherScore()
|
||||
updateSubmitButton()
|
||||
}
|
||||
|
||||
override fun addSub100Clicked(toAdd: Int) {
|
||||
focusLastInput()
|
||||
|
||||
activeValue = try {
|
||||
val temp = activeValue.toInt() + toAdd
|
||||
temp.toString()
|
||||
} catch (e: Exception) {
|
||||
toAdd.toString()
|
||||
}
|
||||
if (inactiveValue == "") {
|
||||
updateOtherScore()
|
||||
}
|
||||
|
||||
updateSubmitButton()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
override fun victoryDialogExecuted(result: Boolean) {
|
||||
showVictoryDialog = false
|
||||
settings.gameFinished.value = true
|
||||
|
||||
if (result) {
|
||||
viewModelScope.launch {
|
||||
gameRepository.newGame()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateFocusStateA(state: Boolean) {
|
||||
isAFocused = state
|
||||
if (state) {
|
||||
lastFocused = Focused.TEAM_A
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateFocusStateB(state: Boolean) {
|
||||
isBFocused = state
|
||||
if (state) {
|
||||
lastFocused = Focused.TEAM_B
|
||||
}
|
||||
}
|
||||
|
||||
override fun swapInputScores() {
|
||||
val swap = currentScoreA
|
||||
currentScoreA = currentScoreB
|
||||
currentScoreB = swap
|
||||
}
|
||||
|
||||
override fun hideKeyboard() {
|
||||
keyboardHidden = true
|
||||
}
|
||||
|
||||
override fun showKeyboard() {
|
||||
keyboardHidden = false
|
||||
}
|
||||
|
||||
override fun deleteState(pressed: Boolean) {
|
||||
deletePressed = pressed
|
||||
|
||||
if (deletePressed) {
|
||||
if (deleteJob?.isActive != true) {
|
||||
deleteJob = deleteRepeatedlyUntilRelease()
|
||||
}
|
||||
} else {
|
||||
deleteJob?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteLastDigitActive() {
|
||||
if (activeValue != "") {
|
||||
activeValue = activeValue.dropLast(1)
|
||||
}
|
||||
updateOtherScore()
|
||||
updateSubmitButton()
|
||||
}
|
||||
|
||||
private fun deleteRepeatedlyUntilRelease(): Job {
|
||||
return viewModelScope.launch {
|
||||
deleteLastDigitActive()
|
||||
delay(500)
|
||||
while (deletePressed) {
|
||||
deleteLastDigitActive()
|
||||
delay(100)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
package me.zobrist.tichucounter.ui.counter
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.animation.core.RepeatMode
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentWidth
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.Backspace
|
||||
import androidx.compose.material.icons.outlined.Check
|
||||
import androidx.compose.material.icons.outlined.KeyboardHide
|
||||
import androidx.compose.material.icons.outlined.SwapHoriz
|
||||
import androidx.compose.material3.ElevatedButton
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.FocusState
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalTextInputService
|
||||
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
|
||||
|
||||
@Composable
|
||||
fun KeyBoardView(viewModel: IKeyBoardViewModel) {
|
||||
KeyboardView(
|
||||
viewModel.currentScoreA,
|
||||
viewModel.currentScoreB,
|
||||
viewModel.requestFocusA,
|
||||
viewModel.requestFocusB,
|
||||
viewModel.isValidRound,
|
||||
viewModel.isAFocused,
|
||||
viewModel.isBFocused,
|
||||
{ viewModel.updateFocusStateA(it) },
|
||||
{ viewModel.updateFocusStateB(it) },
|
||||
{ viewModel.digitClicked(it) },
|
||||
{ viewModel.addSub100Clicked(it) },
|
||||
{ viewModel.negateClicked() },
|
||||
{ viewModel.submitClicked() },
|
||||
{ viewModel.hideKeyboard() },
|
||||
{ viewModel.swapInputScores() },
|
||||
{ viewModel.deleteState(it) }
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun KeyboardView(
|
||||
scoreA: String,
|
||||
scoreB: String,
|
||||
requestFocusA: FocusRequester,
|
||||
requestFocusB: FocusRequester,
|
||||
isValidScore: Boolean,
|
||||
focusStateA: Boolean,
|
||||
focusStateB: Boolean,
|
||||
updateFocusStateA: (Boolean) -> Unit,
|
||||
updateFocusStateB: (Boolean) -> Unit,
|
||||
digitClicked: (String) -> Unit,
|
||||
addSub100Clicked: (Int) -> Unit,
|
||||
negateClicked: () -> Unit,
|
||||
submitClicked: () -> Unit,
|
||||
hideKeyboardClicked: () -> Unit,
|
||||
onSwapClicked: () -> Unit,
|
||||
deleteButtonPressedState: (Boolean) -> Unit
|
||||
) {
|
||||
Column {
|
||||
Row(Modifier.height(IntrinsicSize.Max)) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
CenteredTextField(
|
||||
scoreA,
|
||||
"0",
|
||||
focusStateA,
|
||||
requestFocusA
|
||||
) { updateFocusStateA(it.isFocused) }
|
||||
|
||||
}
|
||||
Surface(
|
||||
Modifier
|
||||
.wrapContentWidth()
|
||||
.fillMaxHeight(),
|
||||
tonalElevation = 3.dp,
|
||||
shape = MaterialTheme.shapes.extraSmall
|
||||
) {
|
||||
Column {
|
||||
IconButton(onClick = onSwapClicked, enabled = isValidScore) {
|
||||
Icon(Icons.Outlined.SwapHoriz, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
|
||||
CenteredTextField(
|
||||
scoreB,
|
||||
"0",
|
||||
focusStateB,
|
||||
requestFocusB
|
||||
) {
|
||||
updateFocusStateB(it.isFocused)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Row {
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("1") {
|
||||
digitClicked("1")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("2") {
|
||||
digitClicked("2")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("3") {
|
||||
digitClicked("3")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("+100") {
|
||||
addSub100Clicked(100)
|
||||
}
|
||||
}
|
||||
}
|
||||
Row {
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("4") {
|
||||
digitClicked("4")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("5") {
|
||||
digitClicked("5")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("6") {
|
||||
digitClicked("6")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("-100") {
|
||||
addSub100Clicked(-100)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("7") {
|
||||
digitClicked("7")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("8") {
|
||||
digitClicked("8")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("9") {
|
||||
digitClicked("9")
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
val deletePressed by interactionSource.collectIsPressedAsState()
|
||||
|
||||
deleteButtonPressedState(deletePressed)
|
||||
|
||||
KeyboardIconButton(
|
||||
icon = Icons.AutoMirrored.Outlined.Backspace,
|
||||
interactionSource = interactionSource
|
||||
) {}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardIconButton(Icons.Outlined.KeyboardHide) {
|
||||
hideKeyboardClicked()
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("0") {
|
||||
digitClicked("0")
|
||||
}
|
||||
}
|
||||
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardTextButton("+/-") {
|
||||
negateClicked()
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
KeyboardIconButton(Icons.Outlined.Check, isValidScore) {
|
||||
submitClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun KeyboardTextButton(text: String, onClicked: () -> Unit) {
|
||||
|
||||
val configuration = LocalConfiguration.current
|
||||
|
||||
val screenWidth = configuration.screenWidthDp.dp
|
||||
|
||||
val style = if (screenWidth < 350.dp) {
|
||||
MaterialTheme.typography.labelSmall
|
||||
} else {
|
||||
MaterialTheme.typography.labelLarge
|
||||
}
|
||||
|
||||
ElevatedButton(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(50.dp)
|
||||
.padding(2.dp),
|
||||
onClick = { onClicked() },
|
||||
) { Text(text, style = style) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun KeyboardIconButton(
|
||||
icon: ImageVector,
|
||||
enabled: Boolean = true,
|
||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
onClicked: () -> Unit
|
||||
) {
|
||||
|
||||
ElevatedButton(
|
||||
onClick = { onClicked() },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(50.dp)
|
||||
.padding(2.dp),
|
||||
enabled = enabled,
|
||||
interactionSource = interactionSource
|
||||
) {
|
||||
Icon(
|
||||
icon,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CenteredTextField(
|
||||
value: String,
|
||||
placeholder: String,
|
||||
focused: Boolean,
|
||||
focusRequester: FocusRequester? = null,
|
||||
onFocusStateChanged: (FocusState) -> Unit
|
||||
) {
|
||||
|
||||
val modifier = if (focusRequester != null) {
|
||||
Modifier.focusRequester(focusRequester)
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
CompositionLocalProvider(LocalTextInputService provides null) {
|
||||
TextField(
|
||||
value = value,
|
||||
onValueChange = { },
|
||||
placeholder = {
|
||||
if (!focused) {
|
||||
Text(
|
||||
placeholder,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
},
|
||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
|
||||
singleLine = true,
|
||||
readOnly = true,
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.onFocusChanged {
|
||||
onFocusStateChanged(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (focused) {
|
||||
val cursorColor = MaterialTheme.colorScheme.onSurface
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "blinkingCursor")
|
||||
val alpha by infiniteTransition.animateFloat(
|
||||
0f,
|
||||
cursorColor.alpha,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(500),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
), label = "blinkingCursor"
|
||||
)
|
||||
Row {
|
||||
|
||||
Text(text = value, color = cursorColor.copy(alpha = 0f))
|
||||
HorizontalDivider(
|
||||
modifier = Modifier
|
||||
.padding(start = 3.dp, top = 15.dp, bottom = 15.dp)
|
||||
.width(1.dp)
|
||||
.fillMaxHeight(),
|
||||
color = cursorColor.copy(alpha = alpha)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
fun KeyboardViewPreview() {
|
||||
AppTheme {
|
||||
Surface {
|
||||
KeyboardView(
|
||||
"10",
|
||||
"190",
|
||||
FocusRequester(),
|
||||
FocusRequester(),
|
||||
isValidScore = false,
|
||||
focusStateA = true,
|
||||
focusStateB = false,
|
||||
updateFocusStateA = {},
|
||||
updateFocusStateB = {},
|
||||
digitClicked = {},
|
||||
addSub100Clicked = {},
|
||||
negateClicked = {},
|
||||
submitClicked = {},
|
||||
hideKeyboardClicked = {},
|
||||
onSwapClicked = {},
|
||||
deleteButtonPressedState = {})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package me.zobrist.tichucounter.ui.counter
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
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 kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
|
||||
@Composable
|
||||
fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
LazyColumn(state = lazyListState, modifier = modifier) {
|
||||
itemsIndexed(rounds) { index, item ->
|
||||
RoundListItem(item, index)
|
||||
}
|
||||
|
||||
scope.launch {
|
||||
lazyListState.animateScrollToItem(rounds.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RoundListItem(round: Round, index: Int) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(all = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = round.scoreA.toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.weight(5f),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
text = (index + 1).toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.weight(1f),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
text = round.scoreB.toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.weight(5f),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
fun RoundListViewPreview() {
|
||||
val rounds = listOf(
|
||||
Round(1, 10, 90),
|
||||
Round(1, 5, 95),
|
||||
Round(1, 100, 0),
|
||||
Round(1, 125, -25),
|
||||
Round(1, 50, 50)
|
||||
)
|
||||
|
||||
AppTheme {
|
||||
Surface {
|
||||
RoundListView(rounds, Modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package me.zobrist.tichucounter.ui.counter
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
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
|
||||
|
||||
@Composable
|
||||
fun TeamNamesView(
|
||||
nameA: String,
|
||||
nameB: String,
|
||||
nameSuggestionsA: List<String>,
|
||||
nameSuggestionsB: List<String>,
|
||||
updateA: (String) -> Unit,
|
||||
updateB: (String) -> Unit
|
||||
) {
|
||||
|
||||
val containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)
|
||||
val color = TextFieldDefaults.colors(
|
||||
focusedContainerColor = containerColor,
|
||||
unfocusedContainerColor = containerColor,
|
||||
disabledContainerColor = containerColor,
|
||||
)
|
||||
|
||||
Row {
|
||||
|
||||
TypeaheadTextField(
|
||||
value = nameA,
|
||||
items = nameSuggestionsA,
|
||||
onValueChange = { updateA(it) },
|
||||
modifier = Modifier.weight(1f),
|
||||
colors = color,
|
||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center)
|
||||
)
|
||||
|
||||
TypeaheadTextField(
|
||||
value = nameB,
|
||||
items = nameSuggestionsB,
|
||||
onValueChange = { updateB(it) },
|
||||
modifier = Modifier.weight(1f),
|
||||
colors = color,
|
||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center)
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
private fun TeamNamesViewPreview() {
|
||||
AppTheme {
|
||||
TeamNamesView("TeamA", "TeamB", listOf("Test1", "Test3"), listOf("Test3", "Test5"), {}, {})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package me.zobrist.tichucounter.ui.counter
|
||||
|
||||
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.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
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
|
||||
|
||||
@Composable
|
||||
fun TeamScoresView(scoreA: Int, scoreB: Int) {
|
||||
|
||||
ElevatedCard(elevation = CardDefaults.elevatedCardElevation(3.dp)) {
|
||||
Row {
|
||||
Text(
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
text = scoreA.toString(),
|
||||
modifier = Modifier
|
||||
.weight(5f)
|
||||
.padding(6.dp),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Text(
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
text = scoreB.toString(),
|
||||
modifier = Modifier
|
||||
.weight(5f)
|
||||
.padding(6.dp),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
private fun TeamScoresViewPreview() {
|
||||
AppTheme {
|
||||
Surface {
|
||||
TeamScoresView(10, 90)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
package me.zobrist.tichucounter.ui.history
|
||||
|
||||
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
import androidx.compose.material.icons.outlined.DeleteForever
|
||||
import androidx.compose.material.icons.outlined.RestartAlt
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Badge
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.SnackbarResult
|
||||
import androidx.compose.material3.SwipeToDismissBox
|
||||
import androidx.compose.material3.SwipeToDismissBoxValue
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.rememberSwipeToDismissBoxState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||
import androidx.compose.ui.Alignment.Companion.TopEnd
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.R
|
||||
import me.zobrist.tichucounter.data.GameWithScores
|
||||
import me.zobrist.tichucounter.data.entity.Game
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.domain.getTotalPoints
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
@Composable
|
||||
fun HistoryList(
|
||||
viewModel: HistoryViewModel,
|
||||
snackbarHostState: SnackbarHostState,
|
||||
navigateToCalculator: () -> Unit,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val lazyListState = rememberLazyListState()
|
||||
var showDeleteDialog by remember { mutableStateOf(false) }
|
||||
|
||||
|
||||
DeleteConfirmDialog(showDeleteDialog) {
|
||||
showDeleteDialog = false
|
||||
if (it) {
|
||||
viewModel.deleteAllInactiveGames()
|
||||
}
|
||||
}
|
||||
|
||||
val deletedMessage = stringResource(id = R.string.delete_success)
|
||||
val deletedActionLabel = stringResource(id = R.string.undo_question)
|
||||
|
||||
val activatedMessage = stringResource(id = R.string.activated_success)
|
||||
val activatedActionLabel = stringResource(id = R.string.to_calculator_question)
|
||||
|
||||
HistoryList(
|
||||
games = viewModel.gameAndHistory,
|
||||
onOpenClicked = {
|
||||
scope.launch {
|
||||
viewModel.activateGame(it)
|
||||
lazyListState.animateScrollToItem(0)
|
||||
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
val result = snackbarHostState.showSnackbar(
|
||||
message = activatedMessage,
|
||||
actionLabel = activatedActionLabel,
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
|
||||
if (result == SnackbarResult.ActionPerformed) {
|
||||
navigateToCalculator()
|
||||
}
|
||||
}
|
||||
},
|
||||
onDeleteClicked = {
|
||||
scope.launch {
|
||||
viewModel.deleteGame(it)
|
||||
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
val result = snackbarHostState.showSnackbar(
|
||||
message = deletedMessage,
|
||||
actionLabel = deletedActionLabel,
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
|
||||
if (result == SnackbarResult.Dismissed) {
|
||||
viewModel.deleteGame(it)
|
||||
} else {
|
||||
viewModel.restoreLastDeletedGame()
|
||||
}
|
||||
}
|
||||
},
|
||||
onDeleteAllClicked = { showDeleteDialog = true },
|
||||
lazyListState = lazyListState
|
||||
)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun DeleteConfirmDialog(show: Boolean = true, onExecuted: (Boolean) -> Unit = {}) {
|
||||
if (show) {
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { onExecuted(false) },
|
||||
dismissButton = {
|
||||
TextButton({ onExecuted(false) }) {
|
||||
Text(stringResource(R.string.cancel))
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton({ onExecuted(true) }) {
|
||||
Text(stringResource(R.string.ok))
|
||||
}
|
||||
},
|
||||
title = { Text(stringResource(R.string.delete_inactive_title)) },
|
||||
text = { Text(stringResource(R.string.delete_inactive_text)) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun HistoryList(
|
||||
games: List<GameWithScores>,
|
||||
onOpenClicked: (gameId: Long) -> Unit,
|
||||
onDeleteClicked: (gameId: Long) -> Unit,
|
||||
onDeleteAllClicked: () -> Unit,
|
||||
lazyListState: LazyListState = LazyListState(),
|
||||
) {
|
||||
Row {
|
||||
LazyColumn(state = lazyListState) {
|
||||
items(
|
||||
items = games,
|
||||
key = { it.hashCode() }) {
|
||||
if (it.game.active) {
|
||||
HistoryListItem(
|
||||
it,
|
||||
Modifier
|
||||
.animateItemPlacement()
|
||||
.padding(2.dp)
|
||||
)
|
||||
} else {
|
||||
DismissibleHistoryListItem(
|
||||
it,
|
||||
Modifier.animateItemPlacement(),
|
||||
onOpenClicked,
|
||||
onDeleteClicked
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
Button(enabled = games.count() > 1,
|
||||
modifier = Modifier
|
||||
.padding(start = 4.dp, end = 4.dp, top = 10.dp)
|
||||
.align(CenterVertically)
|
||||
.fillMaxWidth()
|
||||
.animateItemPlacement(),
|
||||
onClick = { onDeleteAllClicked() }) {
|
||||
Icon(imageVector = Icons.Outlined.DeleteForever, contentDescription = null)
|
||||
Text(text = stringResource(id = R.string.deleteAll))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DismissibleHistoryListItem(
|
||||
game: GameWithScores,
|
||||
modifier: Modifier = Modifier,
|
||||
onOpenClicked: (gameId: Long) -> Unit,
|
||||
onDeleteClicked: (gameId: Long) -> Unit,
|
||||
) {
|
||||
|
||||
val density = LocalDensity.current
|
||||
val dismissState =
|
||||
rememberSwipeToDismissBoxState(positionalThreshold = { with(density) { 100.dp.toPx() } },
|
||||
|
||||
confirmValueChange = {
|
||||
if (it == SwipeToDismissBoxValue.EndToStart) {
|
||||
onDeleteClicked(game.game.uid)
|
||||
}
|
||||
if (it == SwipeToDismissBoxValue.StartToEnd) {
|
||||
onOpenClicked(game.game.uid)
|
||||
}
|
||||
true
|
||||
})
|
||||
|
||||
SwipeToDismissBox(
|
||||
modifier = modifier,
|
||||
state = dismissState,
|
||||
enableDismissFromEndToStart = true,
|
||||
enableDismissFromStartToEnd = true,
|
||||
backgroundContent = {
|
||||
ItemBackground(dismissState.targetValue)
|
||||
}, content = {
|
||||
HistoryListItem(game = game, modifier = Modifier.padding(2.dp))
|
||||
})
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ItemBackground(
|
||||
dismissBoxValue: SwipeToDismissBoxValue
|
||||
) {
|
||||
val backgroundColor by animateColorAsState(
|
||||
when (dismissBoxValue) {
|
||||
SwipeToDismissBoxValue.EndToStart -> MaterialTheme.colorScheme.error
|
||||
SwipeToDismissBoxValue.StartToEnd -> MaterialTheme.colorScheme.primary
|
||||
else -> MaterialTheme.colorScheme.background
|
||||
|
||||
}, label = ""
|
||||
)
|
||||
val textColor by animateColorAsState(
|
||||
when (dismissBoxValue) {
|
||||
SwipeToDismissBoxValue.EndToStart -> MaterialTheme.colorScheme.onError
|
||||
SwipeToDismissBoxValue.StartToEnd -> MaterialTheme.colorScheme.onPrimary
|
||||
else -> MaterialTheme.colorScheme.onBackground
|
||||
|
||||
}, label = ""
|
||||
)
|
||||
val scale by animateFloatAsState(
|
||||
if (dismissBoxValue == SwipeToDismissBoxValue.Settled) 0.75f else 1f, label = ""
|
||||
)
|
||||
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.padding(top = 2.dp, bottom = 2.dp)
|
||||
.background(backgroundColor)
|
||||
.padding(horizontal = 10.dp),
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.align(Alignment.CenterStart)
|
||||
) {
|
||||
Icon(
|
||||
Icons.Outlined.RestartAlt,
|
||||
contentDescription = null,
|
||||
tint = textColor,
|
||||
modifier = Modifier.scale(scale),
|
||||
)
|
||||
Text(text = stringResource(id = R.string.continue_play), color = textColor)
|
||||
}
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.align(Alignment.CenterEnd)
|
||||
|
||||
) {
|
||||
Icon(
|
||||
Icons.Outlined.Delete,
|
||||
contentDescription = null,
|
||||
tint = textColor,
|
||||
modifier = Modifier.scale(scale),
|
||||
)
|
||||
Text(text = stringResource(id = R.string.delete), color = textColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Preview
|
||||
@Composable
|
||||
private fun BackgroundPreview() {
|
||||
Column {
|
||||
Box(modifier = Modifier.height(60.dp))
|
||||
{
|
||||
ItemBackground(SwipeToDismissBoxValue.Settled)
|
||||
}
|
||||
Box(modifier = Modifier.height(60.dp))
|
||||
{
|
||||
ItemBackground(SwipeToDismissBoxValue.EndToStart)
|
||||
}
|
||||
Box(modifier = Modifier.height(60.dp))
|
||||
{
|
||||
ItemBackground(SwipeToDismissBoxValue.StartToEnd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun HistoryListItem(
|
||||
game: GameWithScores, modifier: Modifier = Modifier
|
||||
) {
|
||||
val format =
|
||||
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
|
||||
|
||||
val totalScores = game.getTotalPoints()
|
||||
|
||||
Card(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
Row(
|
||||
Modifier.padding(all = 12.dp)
|
||||
) {
|
||||
Box(modifier = modifier.fillMaxSize()) {
|
||||
Column {
|
||||
Text(
|
||||
text = game.game.nameA + " vs " + game.game.nameB,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.headlineSmall
|
||||
)
|
||||
Text(
|
||||
text = totalScores.first.toString() + " : " + totalScores.second.toString(),
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
Spacer(modifier = Modifier.padding(5.dp))
|
||||
Text(
|
||||
text = format.format(game.game.modified),
|
||||
style = MaterialTheme.typography.labelSmall
|
||||
)
|
||||
}
|
||||
if (game.game.active) {
|
||||
Badge(
|
||||
modifier = Modifier.align(TopEnd),
|
||||
contentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
containerColor = MaterialTheme.colorScheme.primary
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.active),
|
||||
style = MaterialTheme.typography.labelSmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun HistoryListPreview() {
|
||||
val tempData = listOf(
|
||||
GameWithScores(
|
||||
Game(true, "abcsdf sdaf asdf sdf ", "defsadf asdf sadf ", Date(), Date()),
|
||||
listOf(Round(1, 550, 500))
|
||||
), GameWithScores(
|
||||
Game(false, "ADTH", "dogfg", Date(), Date()), listOf(Round(2, 20, 60))
|
||||
), GameWithScores(
|
||||
Game(false, "TeamA3 langer Name", "TeamB3", Date(), Date()), listOf(Round(3, 30, 70))
|
||||
), GameWithScores(
|
||||
Game(false, "TeamA4", "TeamB4", Date(), Date()), listOf(Round(4, 40, 80))
|
||||
), GameWithScores(
|
||||
Game(false, "TeamA5", "TeamB5", Date(), Date()), listOf(Round(5, 50, 90))
|
||||
)
|
||||
)
|
||||
HistoryList(tempData, {}, {}, {})
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package me.zobrist.tichucounter.ui.history
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.data.GameWithScores
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@HiltViewModel
|
||||
class HistoryViewModel @Inject constructor(
|
||||
private val gameRepository: GameRepository
|
||||
) : ViewModel() {
|
||||
|
||||
var gameAndHistory by mutableStateOf(emptyList<GameWithScores>())
|
||||
private set
|
||||
|
||||
private var fullList: List<GameWithScores> = emptyList()
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
|
||||
gameRepository.getAllWithRoundFlow().collect { games ->
|
||||
fullList =
|
||||
games.sortedBy { it.game.modified }.sortedBy { it.game.active }.reversed()
|
||||
gameAndHistory = fullList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteGame(gameId: Long) {
|
||||
viewModelScope.launch {
|
||||
gameRepository.deleteGame(gameId)
|
||||
}
|
||||
}
|
||||
|
||||
fun restoreLastDeletedGame() {
|
||||
viewModelScope.launch {
|
||||
gameRepository.restoreLastDeletedGame()
|
||||
}
|
||||
}
|
||||
|
||||
fun activateGame(gameId: Long) {
|
||||
viewModelScope.launch {
|
||||
gameRepository.setActive(gameId)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun deleteAllInactiveGames() {
|
||||
viewModelScope.launch {
|
||||
gameRepository.deleteAllInactive()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package me.zobrist.tichucounter.ui.layout
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.List
|
||||
import androidx.compose.material.icons.outlined.Calculate
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalDrawerSheet
|
||||
import androidx.compose.material3.NavigationDrawerItem
|
||||
import androidx.compose.material3.NavigationDrawerItemDefaults
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import me.zobrist.tichucounter.R
|
||||
import me.zobrist.tichucounter.domain.DrawerItem
|
||||
import me.zobrist.tichucounter.domain.Route
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
|
||||
@Composable
|
||||
fun DrawerContent(
|
||||
drawerItems: List<DrawerItem>,
|
||||
selectedDrawerItem: DrawerItem,
|
||||
onElementClicked: (Route) -> Unit
|
||||
) {
|
||||
|
||||
ModalDrawerSheet {
|
||||
|
||||
Text(
|
||||
modifier = Modifier.padding(start = 10.dp, top = 10.dp),
|
||||
text = stringResource(R.string.app_name),
|
||||
style = MaterialTheme.typography.headlineSmall
|
||||
)
|
||||
HorizontalDivider(modifier = Modifier.padding(10.dp))
|
||||
|
||||
drawerItems.forEach { screen ->
|
||||
NavigationDrawerItem(
|
||||
icon = { Icon(screen.menuIcon, contentDescription = null) },
|
||||
label = { Text(screen.menuName) },
|
||||
selected = screen == selectedDrawerItem,
|
||||
onClick = { onElementClicked(screen.route) },
|
||||
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
fun DrawerContentPreview() {
|
||||
|
||||
val counter = DrawerItem(Route.COUNTER, Icons.Outlined.Calculate, "Counter")
|
||||
val history = DrawerItem(Route.HISTORY, Icons.AutoMirrored.Outlined.List, "History")
|
||||
val settings = DrawerItem(Route.SETTINGS, Icons.Outlined.Settings, "Settings")
|
||||
AppTheme {
|
||||
Surface {
|
||||
DrawerContent(
|
||||
listOf(counter, history, settings),
|
||||
counter
|
||||
) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package me.zobrist.tichucounter.ui.layout
|
||||
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import me.zobrist.tichucounter.domain.TopBarAction
|
||||
import me.zobrist.tichucounter.domain.TopBarState
|
||||
|
||||
@Composable
|
||||
fun TopBar(topBarState: TopBarState) {
|
||||
TopBar(
|
||||
topBarState.title,
|
||||
topBarState.icon,
|
||||
topBarState.onNavigate,
|
||||
topBarState.actions
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun TopBar(
|
||||
title: String,
|
||||
icon: ImageVector,
|
||||
navigateAction: () -> Unit,
|
||||
actions: List<TopBarAction>
|
||||
) {
|
||||
TopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
title,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navigateAction() }) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = "Localized description"
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
actions.forEach {
|
||||
IconButton(onClick = { it.action() }, enabled = it.isActive) {
|
||||
Icon(
|
||||
imageVector = it.imageVector,
|
||||
contentDescription = null,
|
||||
)
|
||||
it.composeCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package me.zobrist.tichucounter.ui.settings
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.clickable
|
||||
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.outlined.ArrowDropDown
|
||||
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
|
||||
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.KeepScreenOn
|
||||
import me.zobrist.tichucounter.domain.Language
|
||||
import me.zobrist.tichucounter.domain.Theme
|
||||
import me.zobrist.tichucounter.ui.AppTheme
|
||||
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
||||
|
||||
|
||||
val languageMap = mapOf(
|
||||
Language.DEFAULT to R.string.android_default_text,
|
||||
Language.ENGLISH to R.string.english,
|
||||
Language.GERMAN to R.string.german
|
||||
)
|
||||
|
||||
val themeMap = mapOf(
|
||||
Theme.DEFAULT to R.string.android_default_text,
|
||||
Theme.DARK to R.string.dark,
|
||||
Theme.LIGHT to R.string.light
|
||||
)
|
||||
|
||||
val victoryPointsList = listOf(500, 1000, 1500, 2000)
|
||||
|
||||
@Composable
|
||||
fun SettingsView(viewModel: SettingsViewModel) {
|
||||
SettingsView(
|
||||
viewModel.screenOn.value,
|
||||
viewModel.language,
|
||||
viewModel.theme,
|
||||
viewModel.victoryPoints,
|
||||
{ viewModel.updateScreenOn(it) },
|
||||
{ viewModel.updateLanguage(it) },
|
||||
{ viewModel.updateTheme(it) },
|
||||
{ viewModel.updateVictoryPoints(it) })
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsView(
|
||||
valueScreenOn: Boolean = true,
|
||||
valueLanguage: Language = Language.ENGLISH,
|
||||
valueTheme: Theme = Theme.DARK,
|
||||
valueVictoryPoints: Int = 1000,
|
||||
updateScreenOn: (KeepScreenOn) -> Unit = {},
|
||||
updateLanguage: (Language) -> Unit = {},
|
||||
updateTheme: (Theme) -> Unit = {},
|
||||
updateVictoryPoints: (Int) -> Unit = {}
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.padding(20.dp)
|
||||
) {
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.display),
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
|
||||
BooleanSetting(
|
||||
stringResource(R.string.keep_screen_on),
|
||||
valueScreenOn
|
||||
) { updateScreenOn(if (it) KeepScreenOn.ON else KeepScreenOn.OFF) }
|
||||
|
||||
StringSetting(
|
||||
stringResource(R.string.choose_language_text),
|
||||
languageMap,
|
||||
valueLanguage,
|
||||
) { updateLanguage(it) }
|
||||
|
||||
StringSetting(
|
||||
stringResource(R.string.choose_theme_text),
|
||||
themeMap,
|
||||
valueTheme,
|
||||
) { updateTheme(it) }
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.game),
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
|
||||
|
||||
ListSetting(
|
||||
stringResource(R.string.victory_points),
|
||||
victoryPointsList,
|
||||
valueVictoryPoints
|
||||
) { updateVictoryPoints(it) }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BooleanSetting(name: String, value: Boolean, updateValue: (Boolean) -> Unit) {
|
||||
|
||||
Row(
|
||||
Modifier
|
||||
.padding(bottom = 15.dp, top = 5.dp)
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
Column(Modifier.weight(5f)) {
|
||||
Text(
|
||||
name,
|
||||
maxLines = 1,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
Text(
|
||||
stringResource(if (value) R.string.on else R.string.off),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
|
||||
}
|
||||
Column(Modifier.weight(1f))
|
||||
{
|
||||
Switch(
|
||||
checked = value,
|
||||
modifier = Modifier.align(End),
|
||||
onCheckedChange = { updateValue(it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T> StringSetting(name: String, map: Map<T, Int>, selected: T, onSelected: (T) -> Unit) {
|
||||
|
||||
val translated = map.map { it.key to stringResource(it.value) }.toMap()
|
||||
val getValue = map.map { stringResource(it.value) to it.key }.toMap()
|
||||
|
||||
ListSetting(
|
||||
name,
|
||||
translated.values,
|
||||
translated[selected]
|
||||
) { getValue[it]?.let { it1 -> onSelected(it1) } }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T> ListSetting(name: String, list: Collection<T>, selected: T, onSelected: (T) -> Unit) {
|
||||
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 15.dp, top = 5.dp)
|
||||
.clickable { expanded = true }) {
|
||||
Column(Modifier.weight(5f)) {
|
||||
Text(name, style = MaterialTheme.typography.bodyLarge, overflow = TextOverflow.Ellipsis)
|
||||
Text(
|
||||
selected.toString(),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
}
|
||||
|
||||
Column(Modifier.weight(1f)) {
|
||||
Icon(
|
||||
Icons.Outlined.ArrowDropDown,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.align(End)
|
||||
)
|
||||
|
||||
DropDownMenu(
|
||||
list,
|
||||
selected,
|
||||
expanded,
|
||||
) {
|
||||
expanded = false
|
||||
it?.let { onSelected(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview(name = "Light Mode")
|
||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||
@Composable
|
||||
fun SettingsViewPreview() {
|
||||
|
||||
AppTheme {
|
||||
Surface {
|
||||
SettingsView()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package me.zobrist.tichucounter.ui.settings
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
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 javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class SettingsViewModel @Inject constructor(private val settings: SettingsAdapter) : ViewModel() {
|
||||
|
||||
|
||||
var language by mutableStateOf(settings.language.value)
|
||||
private set
|
||||
|
||||
var theme by mutableStateOf(settings.theme.value)
|
||||
private set
|
||||
|
||||
var screenOn by mutableStateOf(settings.keepScreenOn.value)
|
||||
private set
|
||||
|
||||
var victoryPoints by mutableIntStateOf(settings.victoryPoints.value)
|
||||
private set
|
||||
|
||||
fun updateLanguage(language: Language) {
|
||||
settings.language.value = language
|
||||
this.language = language
|
||||
}
|
||||
|
||||
fun updateTheme(theme: Theme) {
|
||||
settings.theme.value = theme
|
||||
this.theme = theme
|
||||
}
|
||||
|
||||
fun updateScreenOn(value: KeepScreenOn) {
|
||||
settings.keepScreenOn.value = value
|
||||
screenOn = value
|
||||
}
|
||||
|
||||
fun updateVictoryPoints(value: Int) {
|
||||
settings.victoryPoints.value = value
|
||||
victoryPoints = value
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 3.8 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,321 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/left"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/right"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewNames"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nameTeamA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:gravity="center"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/team_a"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nameTeamB"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:gravity="center"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/team_b"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewScore"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/scoreA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/scoreB"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollViewHistory"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="16dp"
|
||||
android:clickable="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/historyA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/historyB"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/right"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/left">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputTeamA"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:gravity="center"
|
||||
android:hint="0"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberSigned" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputTeamB"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:gravity="center"
|
||||
android:hint="0"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberSigned" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow1"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonAdd100"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="+100" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow2"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="4" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button5"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="5" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button6"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="6" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSub100"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="-100" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow3"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button7"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="7" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button8"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="8" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button9"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="9" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/buttonBack"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:cropToPadding="false"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/back"
|
||||
android:contentDescription="TODO" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow4"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonInv"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:text="+/-" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button0"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:text="0" />
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/submit"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/checkmark"
|
||||
android:contentDescription="TODO" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -1,323 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewNames"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nameTeamA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:gravity="center"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/team_a"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nameTeamB"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:gravity="center"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/team_b"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewScore"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewNames">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/scoreA"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/scoreB"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/scrollViewHistory" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollViewHistory"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/viewInput"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewScore">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/historyA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/historyB"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
|
||||
<View
|
||||
android:id="@+id/divider6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/viewScore" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/ButtonRow1">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputTeamA"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:gravity="center"
|
||||
android:hint="0"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberSigned" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputTeamB"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:gravity="center"
|
||||
android:hint="0"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberSigned" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow1"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/ButtonRow2">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonAdd100"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="+100" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow2"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/ButtonRow3">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="4" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button5"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="5" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button6"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="6" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSub100"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="-100" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow3"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toTopOf="@+id/ButtonRow4">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button7"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="7" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button8"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="8" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button9"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="9" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/buttonBack"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:cropToPadding="false"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/back"
|
||||
android:contentDescription="TODO" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ButtonRow4"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:layout_editor_absoluteX="1dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonInv"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:text="+/-" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button0"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:text="0" />
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/submit"
|
||||
style='style="?android:attr/buttonBarButtonStyle'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/checkmark"
|
||||
android:contentDescription="TODO" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="me.zobrist.tichucounter.MainActivity">
|
||||
<item
|
||||
android:id="@+id/action_undo"
|
||||
android:icon="@android:drawable/ic_menu_revert"
|
||||
android:orderInCategory="5"
|
||||
android:title="@string/undo" />
|
||||
<item
|
||||
android:id="@+id/action_clear"
|
||||
android:checkable="false"
|
||||
android:orderInCategory="10"
|
||||
android:title="@string/clear"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_theme"
|
||||
android:orderInCategory="15"
|
||||
android:title="@string/choose_theme_text" />
|
||||
<item
|
||||
android:id="@+id/action_screenOn"
|
||||
android:checkable="true"
|
||||
android:orderInCategory="20"
|
||||
android:title="@string/keep_screen_on" />
|
||||
</menu>
|
||||
@@ -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"/>
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<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"/>
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<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,10 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="keep_screen_on">Bildschirm eingeschaltet lassen</string>
|
||||
<string name="confirmClear">Möchten Sie das laufende Spiel wirklich löschen?</string>
|
||||
<string name="yes">Ja</string>
|
||||
<string name="no">Nein</string>
|
||||
<string name="choose_language_text">Sprache wählen</string>
|
||||
<string name="android_default_text">Android Standard</string>
|
||||
<string name="english">Englisch</string>
|
||||
<string name="german">Deutsch</string>
|
||||
<string name="light">Hell</string>
|
||||
<string name="dark">Dunkel</string>
|
||||
<string name="menu_history">Verlauf</string>
|
||||
<string name="menu_settings">Einstellungen</string>
|
||||
<string name="on">Ein</string>
|
||||
<string name="off">Aus</string>
|
||||
<string name="new_game">Neues Spiel</string>
|
||||
<string name="delete_inactive_title">Verlauf löschen</string>
|
||||
<string name="delete_inactive_text">Wirklich den gesamten Verlauf löschen? Diese Aktion kann nicht rückgängig gemacht werden.</string>
|
||||
<string name="cancel">Abbrechen</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="delete">Löschen</string>
|
||||
<string name="deleteAll">Alle löschen</string>
|
||||
<string name="active">Aktives Spiel</string>
|
||||
<string name="inactive">Vergangene Spiele</string>
|
||||
<string name="menu_counter">Counter</string>
|
||||
<string name="menu_about">About</string>
|
||||
<string name="contact_us">Schreib uns</string>
|
||||
<string name="continue_play">Weiterspielen</string>
|
||||
<string name="delete_success">Spiel gelöscht.</string>
|
||||
<string name="undo_question">RÜCKGÄNGIG</string>
|
||||
<string name="activated_success">Spiel aktiviert.</string>
|
||||
<string name="to_calculator_question">WEITERSPIELEN</string>
|
||||
<string name="display">Anzeige</string>
|
||||
<string name="game">Spiel</string>
|
||||
<string name="victory_points">Siegespunkte</string>
|
||||
<string name="victory_title">%1$s hat gewonnen</string>
|
||||
<string name="draw_message">Sieht aus, als ob ihr ein neues Spiel starten solltet, um das endgültig zu klären.</string>
|
||||
<string name="draw_title">Unentschieden</string>
|
||||
<string name="victory_message">Herzliche Gratulation! Wie wäre es mit einer Revanche?</string>
|
||||
<string name="abort">Abbrechen</string>
|
||||
</resources>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="clear">Neus Spil starte</string>
|
||||
<string name="undo">Letschti Rundi lösche</string>
|
||||
<string name="choose_theme_text">Usgsehe ändere</string>
|
||||
<string name="keep_screen_on">Bildschirm igschalted la</string>
|
||||
<string name="confirmClear">Wosch ds loufende Spil würklech lösche?</string>
|
||||
<string name="yes">Ja</string>
|
||||
<string name="no">Nei</string>
|
||||
</resources>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">@color/ic_launcher_background</color>
|
||||
<color name="colorPrimaryDark">#830000</color>
|
||||
<color name="colorAccent">#F57F17</color>
|
||||
</resources>
|
||||
@@ -1,14 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name" translatable="false">Tichu Counter</string>
|
||||
<!-- Strings used for fragments for navigation -->
|
||||
|
||||
<string name="team_a" translatable="false">Team A</string>
|
||||
<string name="team_b" translatable="false">Team B</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="keep_screen_on">Keep screen on</string>
|
||||
<string name="confirmClear">Do you really want to delete the current game?</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
<string name="choose_language_text">Choose language</string>
|
||||
<string name="android_default_text">Android Default</string>
|
||||
<string name="english">English</string>
|
||||
<string name="german">German</string>
|
||||
<string name="light">Light</string>
|
||||
<string name="dark">Dark</string>
|
||||
|
||||
<string name="menu_history">History</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="on">On</string>
|
||||
<string name="off">Off</string>
|
||||
<string name="new_game">New Game</string>
|
||||
<string name="delete_inactive_title">Delete history</string>
|
||||
<string name="delete_inactive_text">You really want to delete the history? This action can\'t be undone.</string>
|
||||
<string name="cancel">Cancel</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="contact_us">Contact us</string>
|
||||
<string name="play_store" translatable="false">Play Store</string>
|
||||
<string name="continue_play">Continue game</string>
|
||||
<string name="delete_success">Game deleted.</string>
|
||||
<string name="undo_question">UNDO</string>
|
||||
<string name="activated_success">Game activated.</string>
|
||||
<string name="to_calculator_question">CONTINUE PLAYING</string>
|
||||
<string name="display">Display</string>
|
||||
<string name="game">Game</string>
|
||||
<string name="victory_points">Victory points</string>
|
||||
<string name="victory_title">%1$s won the game</string>
|
||||
<string name="draw_message">Looks like you should start a new game to settle this for good.</string>
|
||||
<string name="draw_title">Draw</string>
|
||||
<string name="victory_message">Congratulations! How about a rematch?</string>
|
||||
<string name="abort">Abort</string>
|
||||
</resources>
|
||||
@@ -1,20 +1,3 @@
|
||||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</resources>
|
||||
5
app/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar" />
|
||||
|
||||
</resources>
|
||||
6
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
|
||||
</cloud-backup>
|
||||
</data-extraction-rules>
|
||||
5
app/src/main/res/xml/locales_config.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<locale android:name="en" />
|
||||
<locale android:name="de" />
|
||||
</locale-config>
|
||||