Compare commits
1 Commits
2.3.4
...
feature/#3
| Author | SHA1 | Date | |
|---|---|---|---|
| d1b4ab1e8c |
@@ -30,11 +30,15 @@ jobs:
|
|||||||
- name: Build abb
|
- name: Build abb
|
||||||
run: ./gradlew bundleRelease
|
run: ./gradlew bundleRelease
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- name: Deploy latest to Nextcloud
|
||||||
with:
|
run: |
|
||||||
name: app-release
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.apk"
|
||||||
retention-days: 10
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.aab"
|
||||||
path: app/build/outputs/**/release/app-release.*
|
|
||||||
|
- name: Deploy tagged build to Nextcloud
|
||||||
|
run: |
|
||||||
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.apk"
|
||||||
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.aab"
|
||||||
|
|
||||||
- uses: https://github.com/ravsamhq/notify-slack-action@v2
|
- uses: https://github.com/ravsamhq/notify-slack-action@v2
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,4 +15,3 @@
|
|||||||
.idea
|
.idea
|
||||||
keystore.properties
|
keystore.properties
|
||||||
version.properties
|
version.properties
|
||||||
.vscode/
|
|
||||||
|
|||||||
674
LICENCE
674
LICENCE
@@ -1,674 +0,0 @@
|
|||||||
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>.
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# 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)
|
|
||||||
@@ -3,7 +3,6 @@ plugins {
|
|||||||
id 'kotlin-android'
|
id 'kotlin-android'
|
||||||
id 'com.google.dagger.hilt.android'
|
id 'com.google.dagger.hilt.android'
|
||||||
id 'kotlin-kapt'
|
id 'kotlin-kapt'
|
||||||
id 'com.google.devtools.ksp'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a variable called keystorePropertiesFile, and initialize it to your
|
// Create a variable called keystorePropertiesFile, and initialize it to your
|
||||||
@@ -17,7 +16,7 @@ def keystoreProperties = new Properties()
|
|||||||
def versionProperties = new Properties()
|
def versionProperties = new Properties()
|
||||||
|
|
||||||
def versionMajor = 2
|
def versionMajor = 2
|
||||||
def versionMinor = 3
|
def versionMinor = 2
|
||||||
|
|
||||||
// Load your keystore.properties file into the keystoreProperties object.
|
// Load your keystore.properties file into the keystoreProperties object.
|
||||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||||
@@ -25,12 +24,12 @@ versionProperties.load(new FileInputStream(versionPropertiesFile))
|
|||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 36
|
compileSdkVersion 33
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "me.zobrist.tichucounter"
|
applicationId "me.zobrist.tichucounter"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 36
|
targetSdkVersion 33
|
||||||
versionCode versionProperties["versionCode"].toInteger()
|
versionCode versionProperties["versionCode"].toInteger()
|
||||||
versionName "${versionMajor}.${versionMinor}.${versionProperties["versionCode"].toInteger()}"
|
versionName "${versionMajor}.${versionMinor}.${versionProperties["versionCode"].toInteger()}"
|
||||||
resourceConfigurations += ['de', 'en']
|
resourceConfigurations += ['de', 'en']
|
||||||
@@ -64,11 +63,12 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
|
viewBinding = true
|
||||||
compose = true
|
compose = true
|
||||||
}
|
}
|
||||||
|
|
||||||
composeOptions {
|
composeOptions {
|
||||||
kotlinCompilerExtensionVersion = "1.5.14"
|
kotlinCompilerExtensionVersion = "1.4.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
@@ -89,44 +89,44 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.core:core-ktx:1.13.1'
|
implementation 'androidx.core:core-ktx:1.10.1'
|
||||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation "androidx.compose.material3:material3:1.2.1"
|
implementation "androidx.compose.material3:material3:1.1.0"
|
||||||
implementation 'com.google.android.play:review:2.0.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.android.play:review-ktx:2.0.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.code.gson:gson:2.10.1'
|
implementation 'com.google.code.gson:gson:2.9.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.7.7'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.4'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.8.2'
|
implementation 'androidx.fragment:fragment-ktx:1.5.7'
|
||||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
implementation 'androidx.recyclerview:recyclerview:1.3.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4'
|
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
|
||||||
implementation 'androidx.compose.material:material-icons-extended:1.6.8'
|
implementation 'androidx.compose.material:material-icons-extended:1.4.3'
|
||||||
implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0"
|
implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0"
|
||||||
implementation 'androidx.activity:activity-compose:1.9.1'
|
implementation 'androidx.activity:activity-compose:1.7.2'
|
||||||
implementation "androidx.compose.ui:ui:1.6.8"
|
implementation "androidx.compose.ui:ui:1.4.3"
|
||||||
implementation "androidx.compose.ui:ui-tooling-preview:1.6.8"
|
implementation "androidx.compose.ui:ui-tooling-preview:1.4.3"
|
||||||
implementation "androidx.compose.runtime:runtime-livedata:1.6.8"
|
implementation "androidx.compose.runtime:runtime-livedata:1.4.3"
|
||||||
implementation "androidx.navigation:navigation-compose:2.7.7"
|
implementation "androidx.navigation:navigation-compose:2.5.3"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
implementation "com.google.dagger:hilt-android:2.51.1"
|
implementation "com.google.dagger:hilt-android:2.44"
|
||||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.6.8"
|
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.4.3"
|
||||||
debugImplementation "androidx.compose.ui:ui-tooling:1.6.8"
|
debugImplementation "androidx.compose.ui:ui-tooling:1.4.3"
|
||||||
debugImplementation "androidx.compose.ui:ui-test-manifest:1.6.8"
|
debugImplementation "androidx.compose.ui:ui-test-manifest:1.4.3"
|
||||||
kapt "com.google.dagger:hilt-compiler:2.51.1"
|
kapt "com.google.dagger:hilt-compiler:2.44"
|
||||||
annotationProcessor "androidx.room:room-compiler:2.6.1"
|
implementation "androidx.room:room-runtime:2.5.1"
|
||||||
implementation "androidx.room:room-runtime:2.6.1"
|
annotationProcessor "androidx.room:room-compiler:2.5.1"
|
||||||
ksp "androidx.room:room-compiler:2.6.1"
|
kapt "androidx.room:room-compiler:2.5.1"
|
||||||
implementation "androidx.room:room-ktx:2.6.1"
|
implementation "androidx.room:room-ktx:2.5.1"
|
||||||
implementation "androidx.multidex:multidex:2.0.1"
|
implementation "androidx.multidex:multidex:2.0.1"
|
||||||
api "androidx.navigation:navigation-fragment-ktx:2.7.7"
|
api "androidx.navigation:navigation-fragment-ktx:2.5.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow references to generated code
|
// Allow references to generated code
|
||||||
|
|||||||
@@ -6,61 +6,28 @@ import androidx.activity.compose.setContent
|
|||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.List
|
import androidx.compose.material.icons.filled.*
|
||||||
import androidx.compose.material.icons.automirrored.outlined.Redo
|
import androidx.compose.material.icons.outlined.*
|
||||||
import androidx.compose.material.icons.automirrored.outlined.Undo
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.material.icons.outlined.Calculate
|
import androidx.compose.runtime.*
|
||||||
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.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.zobrist.tichucounter.domain.DrawerItem
|
import me.zobrist.tichucounter.domain.*
|
||||||
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.AppTheme
|
||||||
import me.zobrist.tichucounter.ui.MainViewModel
|
import me.zobrist.tichucounter.ui.MainViewModel
|
||||||
import me.zobrist.tichucounter.ui.about.AboutView
|
import me.zobrist.tichucounter.ui.about.AboutView
|
||||||
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
||||||
import me.zobrist.tichucounter.ui.counter.Counter
|
import me.zobrist.tichucounter.ui.counter.*
|
||||||
import me.zobrist.tichucounter.ui.counter.CounterViewModel
|
|
||||||
import me.zobrist.tichucounter.ui.history.HistoryList
|
import me.zobrist.tichucounter.ui.history.HistoryList
|
||||||
import me.zobrist.tichucounter.ui.history.HistoryViewModel
|
import me.zobrist.tichucounter.ui.history.HistoryViewModel
|
||||||
import me.zobrist.tichucounter.ui.layout.DrawerContent
|
import me.zobrist.tichucounter.ui.layout.DrawerContent
|
||||||
@@ -70,59 +37,21 @@ import me.zobrist.tichucounter.ui.settings.SettingsViewModel
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity(), ISystemSettingsChangeListener {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var settingsAdapter: SettingsAdapter
|
lateinit var settingsAdapter: SettingsAdapter
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var repository: GameRepository
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var reviewService: ReviewService
|
|
||||||
|
|
||||||
private val counterViewModel: CounterViewModel by viewModels()
|
private val counterViewModel: CounterViewModel by viewModels()
|
||||||
private val historyViewModel: HistoryViewModel by viewModels()
|
private val historyViewModel: HistoryViewModel by viewModels()
|
||||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||||
private val mainViewModel: MainViewModel by viewModels()
|
private val mainViewModel: MainViewModel by viewModels()
|
||||||
|
|
||||||
private var requestReview: Boolean = false
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
changeTheme(settingsAdapter.theme.value)
|
settingsAdapter.registerOnChangeListener(this)
|
||||||
setKeepScreenOn(settingsAdapter.keepScreenOn.value)
|
|
||||||
changeLanguage(settingsAdapter.language.value)
|
|
||||||
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
|
||||||
settingsAdapter.theme.collect {
|
|
||||||
changeTheme(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lifecycleScope.launch {
|
|
||||||
settingsAdapter.keepScreenOn.collect {
|
|
||||||
setKeepScreenOn(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lifecycleScope.launch {
|
|
||||||
settingsAdapter.language.collect {
|
|
||||||
changeLanguage(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
|
||||||
settingsAdapter.gameFinished.collect {
|
|
||||||
if (!requestReview) {
|
|
||||||
requestReview = true
|
|
||||||
return@collect
|
|
||||||
}
|
|
||||||
if (it) {
|
|
||||||
reviewService.request()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
@@ -133,11 +62,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeLanguage(language: Language) {
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
settingsAdapter.unregisterOnChangeListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLanguageChanged(language: Language) {
|
||||||
AppCompatDelegate.setApplicationLocales(language.value)
|
AppCompatDelegate.setApplicationLocales(language.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeTheme(theme: Theme) {
|
override fun onThemeChanged(theme: Theme) {
|
||||||
val themeValue = when (theme) {
|
val themeValue = when (theme) {
|
||||||
Theme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
|
Theme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
Theme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
|
Theme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
@@ -146,7 +80,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
AppCompatDelegate.setDefaultNightMode(themeValue)
|
AppCompatDelegate.setDefaultNightMode(themeValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setKeepScreenOn(keepOn: KeepScreenOn) {
|
override fun onScreenOnChanged(keepOn: KeepScreenOn) {
|
||||||
if (keepOn.value) {
|
if (keepOn.value) {
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
} else {
|
} else {
|
||||||
@@ -166,11 +100,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Icons.Outlined.Calculate,
|
Icons.Outlined.Calculate,
|
||||||
stringResource(R.string.menu_counter)
|
stringResource(R.string.menu_counter)
|
||||||
),
|
),
|
||||||
DrawerItem(
|
DrawerItem(Route.HISTORY, Icons.Outlined.List, stringResource(R.string.menu_history)),
|
||||||
Route.HISTORY,
|
|
||||||
Icons.AutoMirrored.Outlined.List,
|
|
||||||
stringResource(R.string.menu_history)
|
|
||||||
),
|
|
||||||
DrawerItem(
|
DrawerItem(
|
||||||
Route.SETTINGS,
|
Route.SETTINGS,
|
||||||
Icons.Outlined.Settings,
|
Icons.Outlined.Settings,
|
||||||
@@ -221,10 +151,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
var topBarState by remember { mutableStateOf(TopBarState()) }
|
var topBarState by remember { mutableStateOf(TopBarState()) }
|
||||||
val snackbarHostState by remember { mutableStateOf(SnackbarHostState()) }
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
snackbarHost = { SnackbarHost(snackbarHostState) },
|
|
||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
if (showFab) {
|
if (showFab) {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
@@ -240,7 +168,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
startDestination = Route.COUNTER.name,
|
startDestination = Route.COUNTER.name,
|
||||||
modifier = Modifier.padding(paddings)
|
modifier = Modifier.padding(paddings)
|
||||||
) {
|
) {
|
||||||
this.composable(Route.COUNTER.name) {
|
composable(Route.COUNTER) {
|
||||||
|
|
||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
@@ -248,11 +176,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
title = stringResource(R.string.app_name),
|
title = stringResource(R.string.app_name),
|
||||||
actions = (listOf(
|
actions = (listOf(
|
||||||
TopBarAction(
|
TopBarAction(
|
||||||
Icons.AutoMirrored.Outlined.Undo,
|
Icons.Outlined.Undo,
|
||||||
mainViewModel.isUndoActionActive,
|
mainViewModel.isUndoActionActive,
|
||||||
{ mainViewModel.undoLastRound() }),
|
{ mainViewModel.undoLastRound() }),
|
||||||
TopBarAction(
|
TopBarAction(
|
||||||
Icons.AutoMirrored.Outlined.Redo,
|
Icons.Outlined.Redo,
|
||||||
mainViewModel.isRedoActionActive,
|
mainViewModel.isRedoActionActive,
|
||||||
{ mainViewModel.redoLastRound() }),
|
{ mainViewModel.redoLastRound() }),
|
||||||
TopBarAction(
|
TopBarAction(
|
||||||
@@ -260,16 +188,15 @@ class MainActivity : AppCompatActivity() {
|
|||||||
mainViewModel.activeGameHasRounds,
|
mainViewModel.activeGameHasRounds,
|
||||||
{ expanded = true }
|
{ expanded = true }
|
||||||
) {
|
) {
|
||||||
val newGameTranslated = stringResource(R.string.new_game)
|
|
||||||
DropDownMenu(
|
DropDownMenu(
|
||||||
listOf(newGameTranslated),
|
mapOf("new" to R.string.newGame),
|
||||||
"",
|
"",
|
||||||
expanded,
|
expanded,
|
||||||
) {
|
) {
|
||||||
expanded = false
|
expanded = false
|
||||||
it?.let {
|
it?.let {
|
||||||
when (it) {
|
when (it) {
|
||||||
newGameTranslated -> lifecycleScope.launch { repository.newGame() }
|
"new" -> mainViewModel.newGame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,23 +212,20 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
Counter(counterViewModel)
|
Counter(counterViewModel)
|
||||||
}
|
}
|
||||||
composable(Route.HISTORY.name) {
|
composable(Route.HISTORY) {
|
||||||
topBarState =
|
topBarState =
|
||||||
TopBarState(title = stringResource(R.string.menu_history)) { scope.launch { drawerState.open() } }
|
TopBarState(title = stringResource(R.string.menu_history)) { scope.launch { drawerState.open() } }
|
||||||
|
|
||||||
HistoryList(
|
HistoryList(historyViewModel) { navController.navigate(Route.COUNTER) }
|
||||||
historyViewModel,
|
|
||||||
snackbarHostState
|
|
||||||
) { navController.navigate(Route.COUNTER) }
|
|
||||||
}
|
}
|
||||||
composable(Route.SETTINGS.name) {
|
composable(Route.SETTINGS) {
|
||||||
topBarState =
|
topBarState =
|
||||||
TopBarState(title = stringResource(R.string.menu_settings)) { scope.launch { drawerState.open() } }
|
TopBarState(title = stringResource(R.string.menu_settings)) { scope.launch { drawerState.open() } }
|
||||||
|
|
||||||
SettingsView(settingsViewModel)
|
SettingsView(settingsViewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
composable(Route.ABOUT.name) {
|
composable(Route.ABOUT) {
|
||||||
topBarState =
|
topBarState =
|
||||||
TopBarState(title = stringResource(R.string.menu_about)) { scope.launch { drawerState.open() } }
|
TopBarState(title = stringResource(R.string.menu_about)) { scope.launch { drawerState.open() } }
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package me.zobrist.tichucounter.data
|
package me.zobrist.tichucounter.data
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.*
|
||||||
import androidx.room.Query
|
|
||||||
import androidx.room.Transaction
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import me.zobrist.tichucounter.data.entity.Game
|
import me.zobrist.tichucounter.data.entity.Game
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.zobrist.tichucounter.data
|
package me.zobrist.tichucounter.data
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.*
|
||||||
import androidx.room.Query
|
|
||||||
import me.zobrist.tichucounter.data.entity.Round
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
package me.zobrist.tichucounter.domain
|
package me.zobrist.tichucounter.domain
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.navigation.NamedNavArgument
|
||||||
|
import androidx.navigation.NavBackStackEntry
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
|
import androidx.navigation.NavDeepLink
|
||||||
|
import androidx.navigation.NavGraphBuilder
|
||||||
|
import androidx.navigation.compose.composable
|
||||||
|
|
||||||
fun NavController.navigate(route: Route) {
|
fun NavController.navigate(route: Route) {
|
||||||
this.navigate(route.name) {
|
this.navigate(route.name) {
|
||||||
@@ -17,3 +23,12 @@ fun NavController.navigate(route: Route) {
|
|||||||
restoreState = true
|
restoreState = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun NavGraphBuilder.composable(
|
||||||
|
route: Route,
|
||||||
|
arguments: List<NamedNavArgument> = emptyList(),
|
||||||
|
deepLinks: List<NavDeepLink> = emptyList(),
|
||||||
|
content: @Composable (NavBackStackEntry) -> Unit
|
||||||
|
) {
|
||||||
|
this.composable(route.name, arguments, deepLinks, content)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,6 @@ import android.content.Context
|
|||||||
import androidx.core.os.LocaleListCompat
|
import androidx.core.os.LocaleListCompat
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
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.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@@ -20,93 +16,143 @@ enum class Language(val value: LocaleListCompat) {
|
|||||||
|
|
||||||
enum class KeepScreenOn(val value: Boolean) { ON(true), OFF(false) }
|
enum class KeepScreenOn(val value: Boolean) { ON(true), OFF(false) }
|
||||||
|
|
||||||
typealias VictoryPoints = Int
|
enum class CounterListView { BY_ROUND, CONTINUOUS }
|
||||||
typealias GameWon = Boolean
|
|
||||||
|
|
||||||
|
interface ISystemSettingsChangeListener {
|
||||||
|
fun onLanguageChanged(language: Language)
|
||||||
|
fun onThemeChanged(theme: Theme)
|
||||||
|
fun onScreenOnChanged(keepOn: KeepScreenOn)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IDisplaySettingsChangeListener {
|
||||||
|
fun onCounterListViewChanged(listView: CounterListView)
|
||||||
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class SettingsAdapter @Inject constructor(@ApplicationContext private val context: Context) {
|
class SettingsAdapter @Inject constructor(@ApplicationContext private val context: Context) {
|
||||||
|
|
||||||
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
private var systemListenerList = mutableListOf<ISystemSettingsChangeListener>()
|
||||||
|
private var displayListenerList = mutableListOf<IDisplaySettingsChangeListener>()
|
||||||
|
|
||||||
val language = MutableStateFlow(Language.DEFAULT)
|
|
||||||
|
|
||||||
val theme = MutableStateFlow(Theme.DEFAULT)
|
var language: Language
|
||||||
|
private set
|
||||||
|
|
||||||
val keepScreenOn = MutableStateFlow(KeepScreenOn.OFF)
|
var theme: Theme
|
||||||
|
private set
|
||||||
|
|
||||||
val victoryPoints = MutableStateFlow(0)
|
var keepScreenOn: KeepScreenOn
|
||||||
|
private set
|
||||||
|
|
||||||
val gameFinished = MutableStateFlow(false)
|
var counterListView: CounterListView
|
||||||
|
private set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
language.value = try {
|
language = try {
|
||||||
enumValueOf(sharedPreferences.getString(Language::class.simpleName, null)!!)
|
enumValueOf(sharedPreferences.getString(Language::class.simpleName, null)!!)
|
||||||
} catch (_: NullPointerException) {
|
} catch (_: NullPointerException) {
|
||||||
Language.DEFAULT
|
Language.DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
theme.value = try {
|
theme = try {
|
||||||
enumValueOf(sharedPreferences.getString(Theme::class.simpleName, null)!!)
|
enumValueOf(sharedPreferences.getString(Theme::class.simpleName, null)!!)
|
||||||
} catch (_: java.lang.Exception) {
|
} catch (_: java.lang.Exception) {
|
||||||
Theme.DEFAULT
|
Theme.DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
keepScreenOn.value = try {
|
keepScreenOn = try {
|
||||||
enumValueOf(sharedPreferences.getString(KeepScreenOn::class.simpleName, null)!!)
|
enumValueOf(sharedPreferences.getString(KeepScreenOn::class.simpleName, null)!!)
|
||||||
} catch (_: java.lang.Exception) {
|
} catch (_: java.lang.Exception) {
|
||||||
KeepScreenOn.OFF
|
KeepScreenOn.OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
victoryPoints.value = sharedPreferences.getInt(VictoryPoints::class.simpleName, 1000)
|
counterListView = try {
|
||||||
|
enumValueOf(sharedPreferences.getString(CounterListView::class.simpleName, null)!!)
|
||||||
gameFinished.value = sharedPreferences.getBoolean(GameWon::class.simpleName, false)
|
} catch (_: java.lang.Exception) {
|
||||||
|
CounterListView.BY_ROUND
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
language.collect {
|
|
||||||
updatePreference(Language::class.simpleName, it.name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
fun registerOnChangeListener(listener: ISystemSettingsChangeListener) {
|
||||||
theme.collect {
|
systemListenerList.add(listener)
|
||||||
updatePreference(Theme::class.simpleName, it.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
listener.onThemeChanged(theme)
|
||||||
keepScreenOn.collect {
|
listener.onLanguageChanged(language)
|
||||||
updatePreference(KeepScreenOn::class.simpleName, it.name)
|
listener.onScreenOnChanged(keepScreenOn)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
fun registerOnChangeListener(listener: IDisplaySettingsChangeListener) {
|
||||||
victoryPoints.collect {
|
displayListenerList.add(listener)
|
||||||
updatePreference(VictoryPoints::class.simpleName, it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
listener.onCounterListViewChanged(counterListView)
|
||||||
gameFinished.collect {
|
}
|
||||||
updatePreference(GameWon::class.simpleName, it)
|
|
||||||
}
|
fun unregisterOnChangeListener(listener: ISystemSettingsChangeListener?) {
|
||||||
|
if (listener != null) {
|
||||||
|
systemListenerList.remove(listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun unregisterOnChangeListener(listener: IDisplaySettingsChangeListener?) {
|
||||||
|
if (listener != null) {
|
||||||
|
displayListenerList.remove(listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setLanguage(language: Language) {
|
||||||
|
this.language = language
|
||||||
|
updatePreference(Language::class.simpleName, language.name)
|
||||||
|
notifyListeners(language)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTheme(theme: Theme) {
|
||||||
|
this.theme = theme
|
||||||
|
updatePreference(Theme::class.simpleName, theme.name)
|
||||||
|
notifyListeners(theme)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setKeepScreenOn(setting: KeepScreenOn) {
|
||||||
|
this.keepScreenOn = setting
|
||||||
|
updatePreference(KeepScreenOn::class.simpleName, setting.name)
|
||||||
|
notifyListeners(setting)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setCounterViewList(setting: CounterListView) {
|
||||||
|
this.counterListView = setting
|
||||||
|
updatePreference(CounterListView::class.simpleName, setting.name)
|
||||||
|
notifyListeners(setting)
|
||||||
|
}
|
||||||
|
|
||||||
private fun updatePreference(name: String?, value: String) {
|
private fun updatePreference(name: String?, value: String) {
|
||||||
val editor = sharedPreferences.edit()
|
val editor = sharedPreferences.edit()
|
||||||
editor.putString(name, value)
|
editor.putString(name, value)
|
||||||
editor.apply()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePreference(name: String?, value: Boolean) {
|
private fun notifyListeners(language: Language) {
|
||||||
val editor = sharedPreferences.edit()
|
systemListenerList.forEach {
|
||||||
editor.putBoolean(name, value)
|
it.onLanguageChanged(language)
|
||||||
editor.apply()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePreference(name: String?, value: Int) {
|
private fun notifyListeners(theme: Theme) {
|
||||||
val editor = sharedPreferences.edit()
|
systemListenerList.forEach {
|
||||||
editor.putInt(name, value)
|
it.onThemeChanged(theme)
|
||||||
editor.apply()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun notifyListeners(keepScreenOn: KeepScreenOn) {
|
||||||
|
systemListenerList.forEach {
|
||||||
|
it.onScreenOnChanged(keepScreenOn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifyListeners(counterListView: CounterListView) {
|
||||||
|
displayListenerList.forEach {
|
||||||
|
it.onCounterListViewChanged(counterListView)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ package me.zobrist.tichucounter.repository
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.take
|
import kotlinx.coroutines.flow.take
|
||||||
@@ -24,10 +23,6 @@ class GameRepository @Inject constructor(
|
|||||||
|
|
||||||
private var activeGame: Game = Game(true, "TeamA", "TeamB", Date(), Date())
|
private var activeGame: Game = Game(true, "TeamA", "TeamB", Date(), Date())
|
||||||
|
|
||||||
private val newGameFlow = MutableStateFlow(Game())
|
|
||||||
|
|
||||||
private var deletedGame: GameWithScores? = null
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
gameDao.getActiveAsFlow().collect {
|
gameDao.getActiveAsFlow().collect {
|
||||||
@@ -44,7 +39,6 @@ class GameRepository @Inject constructor(
|
|||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
val id = gameDao.insert(Game(true, activeGame.nameA, activeGame.nameB, Date(), Date()))
|
val id = gameDao.insert(Game(true, activeGame.nameA, activeGame.nameB, Date(), Date()))
|
||||||
setActive(id)
|
setActive(id)
|
||||||
newGameFlow.value = gameDao.getGameById(id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,33 +99,14 @@ class GameRepository @Inject constructor(
|
|||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val game = gameDao.getGameById(uid)
|
val game = gameDao.getGameById(uid)
|
||||||
val rounds = roundDao.getAllForGame(game.uid)
|
|
||||||
|
|
||||||
deletedGame = GameWithScores(game, rounds)
|
|
||||||
|
|
||||||
gameDao.delete(game)
|
gameDao.delete(game)
|
||||||
|
val rounds = roundDao.getAllForGame(game.uid)
|
||||||
roundDao.delete(rounds)
|
roundDao.delete(rounds)
|
||||||
} catch (_: NullPointerException) {
|
} 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() {
|
suspend fun deleteAllInactive() {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
@@ -159,8 +134,4 @@ class GameRepository @Inject constructor(
|
|||||||
fun getDistinctTeamNames(): Flow<List<String>> {
|
fun getDistinctTeamNames(): Flow<List<String>> {
|
||||||
return gameDao.getDistinctTeamNames()
|
return gameDao.getDistinctTeamNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNewGameStarted(): Flow<Game> {
|
|
||||||
return newGameFlow
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.zobrist.tichucounter.data.entity.Game
|
|
||||||
import me.zobrist.tichucounter.data.entity.Round
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
import me.zobrist.tichucounter.repository.GameRepository
|
import me.zobrist.tichucounter.repository.GameRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -30,8 +29,6 @@ class MainViewModel @Inject constructor(
|
|||||||
var activeGameHasRounds by mutableStateOf(false)
|
var activeGameHasRounds by mutableStateOf(false)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private var newGame: Game? = null
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|
||||||
@@ -48,16 +45,6 @@ class MainViewModel @Inject constructor(
|
|||||||
expectedRoundCount = it.rounds.count()
|
expectedRoundCount = it.rounds.count()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModelScope.launch {
|
|
||||||
gameRepository.getNewGameStarted().collect {
|
|
||||||
if (newGame == null) {
|
|
||||||
newGame = it
|
|
||||||
return@collect
|
|
||||||
}
|
|
||||||
redoRounds.clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun undoLastRound() {
|
fun undoLastRound() {
|
||||||
@@ -82,4 +69,11 @@ class MainViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun newGame() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
redoRounds.clear()
|
||||||
|
gameRepository.newGame()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,29 +7,25 @@ import androidx.compose.material3.DropdownMenuItem
|
|||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> DropDownMenu(
|
fun <T> DropDownMenu(map: Map<T, Int>, selected: T, expanded: Boolean, onSelected: (T?) -> Unit) {
|
||||||
list: Collection<T>,
|
|
||||||
selected: T,
|
|
||||||
expanded: Boolean,
|
|
||||||
onSelected: (T?) -> Unit
|
|
||||||
) {
|
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
expanded = expanded,
|
expanded = expanded,
|
||||||
onDismissRequest = { onSelected(null) }
|
onDismissRequest = { onSelected(null) }
|
||||||
) {
|
) {
|
||||||
list.forEach {
|
map.forEach {
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
onClick = {
|
onClick = {
|
||||||
onSelected(it)
|
onSelected(it.key)
|
||||||
},
|
},
|
||||||
trailingIcon = {
|
trailingIcon = {
|
||||||
if (it == selected) {
|
if (it.key == selected) {
|
||||||
Icon(Icons.Outlined.Check, null)
|
Icon(Icons.Outlined.Check, null)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
text = { Text(it.toString()) },
|
text = { Text(stringResource(it.value)) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import androidx.compose.material3.TextField
|
|||||||
import androidx.compose.material3.TextFieldColors
|
import androidx.compose.material3.TextFieldColors
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.onFocusChanged
|
import androidx.compose.ui.focus.onFocusChanged
|
||||||
import androidx.compose.ui.input.key.Key
|
import androidx.compose.ui.input.key.Key
|
||||||
@@ -26,7 +26,7 @@ import androidx.compose.ui.platform.LocalFocusManager
|
|||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun TypeaheadTextField(
|
fun TypeaheadTextField(
|
||||||
value: String,
|
value: String,
|
||||||
@@ -46,7 +46,7 @@ fun TypeaheadTextField(
|
|||||||
onExpandedChange = {}
|
onExpandedChange = {}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var dropDownWidth by remember { mutableIntStateOf(0) }
|
var dropDownWidth by remember { mutableStateOf(0) }
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
value = value,
|
value = value,
|
||||||
|
|||||||
@@ -3,24 +3,16 @@ package me.zobrist.tichucounter.ui.counter
|
|||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
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.Surface
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.TextButton
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import me.zobrist.tichucounter.R
|
|
||||||
import me.zobrist.tichucounter.data.entity.Round
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
import me.zobrist.tichucounter.ui.AppTheme
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
|
|
||||||
@@ -28,21 +20,9 @@ import me.zobrist.tichucounter.ui.AppTheme
|
|||||||
@Composable
|
@Composable
|
||||||
fun Counter(viewModel: ICounterViewModel = PreviewViewModel()) {
|
fun Counter(viewModel: ICounterViewModel = PreviewViewModel()) {
|
||||||
|
|
||||||
var orientation by remember { mutableIntStateOf(Configuration.ORIENTATION_PORTRAIT) }
|
var orientation by remember { mutableStateOf(Configuration.ORIENTATION_PORTRAIT) }
|
||||||
orientation = LocalConfiguration.current.orientation
|
orientation = LocalConfiguration.current.orientation
|
||||||
|
|
||||||
if (viewModel.showVictoryDialog) {
|
|
||||||
GameVictoryDialog(
|
|
||||||
viewModel.totalScoreA,
|
|
||||||
viewModel.totalScoreB,
|
|
||||||
viewModel.teamNameA,
|
|
||||||
viewModel.teamNameB,
|
|
||||||
{ viewModel.victoryDialogExecuted(false) })
|
|
||||||
{
|
|
||||||
viewModel.victoryDialogExecuted(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Surface {
|
Surface {
|
||||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
Landscape(viewModel)
|
Landscape(viewModel)
|
||||||
@@ -72,6 +52,7 @@ fun Landscape(viewModel: ICounterViewModel) {
|
|||||||
|
|
||||||
RoundListView(
|
RoundListView(
|
||||||
viewModel.roundScoreList,
|
viewModel.roundScoreList,
|
||||||
|
viewModel.sumUpScores,
|
||||||
Modifier.weight(1f)
|
Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -103,6 +84,7 @@ fun Portrait(viewModel: ICounterViewModel) {
|
|||||||
|
|
||||||
RoundListView(
|
RoundListView(
|
||||||
viewModel.roundScoreList,
|
viewModel.roundScoreList,
|
||||||
|
viewModel.sumUpScores,
|
||||||
Modifier.weight(1f)
|
Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -122,54 +104,6 @@ fun CounterViewPreview() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
internal class PreviewViewModel : ICounterViewModel {
|
||||||
override var roundScoreList: List<Round> =
|
override var roundScoreList: List<Round> =
|
||||||
listOf(Round(1, 10, 90), Round(1, 50, 50), Round(1, 70, 30))
|
listOf(Round(1, 10, 90), Round(1, 50, 50), Round(1, 70, 30))
|
||||||
@@ -177,6 +111,7 @@ internal class PreviewViewModel : ICounterViewModel {
|
|||||||
override var totalScoreB: Int = 750
|
override var totalScoreB: Int = 750
|
||||||
override var teamNameA: String = "Team A"
|
override var teamNameA: String = "Team A"
|
||||||
override var teamNameB: String = "Team B"
|
override var teamNameB: String = "Team B"
|
||||||
|
override val sumUpScores: Boolean = false
|
||||||
override var currentScoreA: String = ""
|
override var currentScoreA: String = ""
|
||||||
override var currentScoreB: String = "45"
|
override var currentScoreB: String = "45"
|
||||||
override var isValidRound: Boolean = false
|
override var isValidRound: Boolean = false
|
||||||
@@ -191,7 +126,6 @@ internal class PreviewViewModel : ICounterViewModel {
|
|||||||
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
||||||
override val teamNameSuggestionsB: List<String> =
|
override val teamNameSuggestionsB: List<String> =
|
||||||
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
||||||
override var showVictoryDialog: Boolean = false
|
|
||||||
|
|
||||||
override fun focusLastInput() {
|
override fun focusLastInput() {
|
||||||
}
|
}
|
||||||
@@ -224,9 +158,6 @@ internal class PreviewViewModel : ICounterViewModel {
|
|||||||
override fun updateNameB(value: String) {
|
override fun updateNameB(value: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun victoryDialogExecuted(result: Boolean) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateFocusStateA(state: Boolean) {
|
override fun updateFocusStateA(state: Boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
@@ -11,12 +10,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
|||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.zobrist.tichucounter.data.entity.Game
|
|
||||||
import me.zobrist.tichucounter.data.entity.Round
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
import me.zobrist.tichucounter.domain.SettingsAdapter
|
import me.zobrist.tichucounter.domain.*
|
||||||
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 me.zobrist.tichucounter.repository.GameRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -56,36 +51,38 @@ interface ICounterViewModel : IKeyBoardViewModel {
|
|||||||
val roundScoreList: List<Round>
|
val roundScoreList: List<Round>
|
||||||
val totalScoreA: Int
|
val totalScoreA: Int
|
||||||
val totalScoreB: Int
|
val totalScoreB: Int
|
||||||
|
val sumUpScores: Boolean
|
||||||
val teamNameA: String
|
val teamNameA: String
|
||||||
val teamNameB: String
|
val teamNameB: String
|
||||||
val teamNameSuggestionsA: List<String>
|
val teamNameSuggestionsA: List<String>
|
||||||
val teamNameSuggestionsB: List<String>
|
val teamNameSuggestionsB: List<String>
|
||||||
val showVictoryDialog: Boolean
|
|
||||||
|
|
||||||
fun updateNameA(value: String)
|
fun updateNameA(value: String)
|
||||||
fun updateNameB(value: String)
|
fun updateNameB(value: String)
|
||||||
fun victoryDialogExecuted(result: Boolean)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class CounterViewModel @Inject constructor(
|
class CounterViewModel @Inject constructor(
|
||||||
private val gameRepository: GameRepository,
|
private val gameRepository: GameRepository,
|
||||||
private val settings: SettingsAdapter
|
private val settingsAdapter: SettingsAdapter
|
||||||
) :
|
) :
|
||||||
ViewModel(), ICounterViewModel {
|
ViewModel(), ICounterViewModel, IDisplaySettingsChangeListener {
|
||||||
|
|
||||||
override var roundScoreList by mutableStateOf(emptyList<Round>())
|
override var roundScoreList by mutableStateOf(emptyList<Round>())
|
||||||
private set
|
private set
|
||||||
|
|
||||||
override var totalScoreA by mutableIntStateOf(0)
|
override var totalScoreA by mutableStateOf(0)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
override var totalScoreB by mutableIntStateOf(0)
|
override var totalScoreB by mutableStateOf(0)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
override var teamNameA by mutableStateOf("")
|
override var teamNameA by mutableStateOf("")
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
override var sumUpScores by mutableStateOf(false)
|
||||||
|
private set
|
||||||
|
|
||||||
override var teamNameB by mutableStateOf("")
|
override var teamNameB by mutableStateOf("")
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@@ -118,8 +115,6 @@ class CounterViewModel @Inject constructor(
|
|||||||
|
|
||||||
override var teamNameSuggestionsB by mutableStateOf(listOf<String>())
|
override var teamNameSuggestionsB by mutableStateOf(listOf<String>())
|
||||||
private set
|
private set
|
||||||
override var showVictoryDialog by mutableStateOf(false)
|
|
||||||
private set
|
|
||||||
|
|
||||||
override var activeValue: String
|
override var activeValue: String
|
||||||
get() {
|
get() {
|
||||||
@@ -162,18 +157,11 @@ class CounterViewModel @Inject constructor(
|
|||||||
|
|
||||||
private var distinctTeamNames = listOf<String>()
|
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 {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
gameRepository.getActiveGameFlow().collect {
|
gameRepository.getActiveGameFlow().collect {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
|
|
||||||
val score = it.getTotalPoints()
|
val score = it.getTotalPoints()
|
||||||
|
|
||||||
roundScoreList = it.rounds
|
roundScoreList = it.rounds
|
||||||
@@ -185,30 +173,6 @@ class CounterViewModel @Inject constructor(
|
|||||||
|
|
||||||
buildTeamNameSuggestions()
|
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,17 +184,12 @@ class CounterViewModel @Inject constructor(
|
|||||||
buildTeamNameSuggestions()
|
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
|
settingsAdapter.registerOnChangeListener(this)
|
||||||
settings.gameFinished.value = settings.gameFinished.value && gameWon
|
}
|
||||||
}
|
|
||||||
}
|
override fun onCleared() {
|
||||||
|
settingsAdapter.unregisterOnChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun focusLastInput() {
|
override fun focusLastInput() {
|
||||||
@@ -339,17 +298,6 @@ class CounterViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun victoryDialogExecuted(result: Boolean) {
|
|
||||||
showVictoryDialog = false
|
|
||||||
settings.gameFinished.value = true
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
viewModelScope.launch {
|
|
||||||
gameRepository.newGame()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateFocusStateA(state: Boolean) {
|
override fun updateFocusStateA(state: Boolean) {
|
||||||
isAFocused = state
|
isAFocused = state
|
||||||
if (state) {
|
if (state) {
|
||||||
@@ -423,4 +371,8 @@ class CounterViewModel @Inject constructor(
|
|||||||
|
|
||||||
return filtered.sorted().sortedBy { it.length }.take(10)
|
return filtered.sorted().sortedBy { it.length }.take(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCounterListViewChanged(listView: CounterListView) {
|
||||||
|
sumUpScores = listView == CounterListView.CONTINUOUS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,41 +1,17 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.animation.core.RepeatMode
|
import androidx.compose.animation.core.*
|
||||||
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.MutableInteractionSource
|
||||||
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.*
|
||||||
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.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.Backspace
|
import androidx.compose.material.icons.outlined.Backspace
|
||||||
import androidx.compose.material.icons.outlined.Check
|
import androidx.compose.material.icons.outlined.Check
|
||||||
import androidx.compose.material.icons.outlined.KeyboardHide
|
import androidx.compose.material.icons.outlined.KeyboardHide
|
||||||
import androidx.compose.material.icons.outlined.SwapHoriz
|
import androidx.compose.material.icons.outlined.SwapHoriz
|
||||||
import androidx.compose.material3.ElevatedButton
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.runtime.*
|
||||||
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.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
@@ -44,7 +20,6 @@ import androidx.compose.ui.focus.focusRequester
|
|||||||
import androidx.compose.ui.focus.onFocusChanged
|
import androidx.compose.ui.focus.onFocusChanged
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.platform.LocalTextInputService
|
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@@ -198,7 +173,7 @@ fun KeyboardView(
|
|||||||
deleteButtonPressedState(deletePressed)
|
deleteButtonPressedState(deletePressed)
|
||||||
|
|
||||||
KeyboardIconButton(
|
KeyboardIconButton(
|
||||||
icon = Icons.AutoMirrored.Outlined.Backspace,
|
icon = Icons.Outlined.Backspace,
|
||||||
interactionSource = interactionSource
|
interactionSource = interactionSource
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
@@ -292,45 +267,42 @@ fun CenteredTextField(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box(contentAlignment = Alignment.Center) {
|
Box(contentAlignment = Alignment.Center) {
|
||||||
CompositionLocalProvider(LocalTextInputService provides null) {
|
TextField(
|
||||||
TextField(
|
value = value,
|
||||||
value = value,
|
onValueChange = { },
|
||||||
onValueChange = { },
|
placeholder = {
|
||||||
placeholder = {
|
if (!focused) {
|
||||||
if (!focused) {
|
Text(
|
||||||
Text(
|
placeholder,
|
||||||
placeholder,
|
textAlign = TextAlign.Center,
|
||||||
textAlign = TextAlign.Center,
|
modifier = Modifier.fillMaxWidth()
|
||||||
modifier = Modifier.fillMaxWidth()
|
)
|
||||||
)
|
}
|
||||||
}
|
},
|
||||||
},
|
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
|
||||||
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
|
singleLine = true,
|
||||||
singleLine = true,
|
readOnly = true,
|
||||||
readOnly = true,
|
modifier = modifier
|
||||||
modifier = modifier
|
.fillMaxWidth()
|
||||||
.fillMaxWidth()
|
.onFocusChanged {
|
||||||
.onFocusChanged {
|
onFocusStateChanged(it)
|
||||||
onFocusStateChanged(it)
|
}
|
||||||
}
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (focused) {
|
if (focused) {
|
||||||
val cursorColor = MaterialTheme.colorScheme.onSurface
|
val cursorColor = MaterialTheme.colorScheme.onSurface
|
||||||
val infiniteTransition = rememberInfiniteTransition(label = "blinkingCursor")
|
val infiniteTransition = rememberInfiniteTransition()
|
||||||
val alpha by infiniteTransition.animateFloat(
|
val alpha by infiniteTransition.animateFloat(
|
||||||
0f,
|
0f,
|
||||||
cursorColor.alpha,
|
cursorColor.alpha,
|
||||||
animationSpec = infiniteRepeatable(
|
animationSpec = infiniteRepeatable(
|
||||||
animation = tween(500),
|
animation = tween(500),
|
||||||
repeatMode = RepeatMode.Reverse
|
repeatMode = RepeatMode.Reverse
|
||||||
), label = "blinkingCursor"
|
)
|
||||||
)
|
)
|
||||||
Row {
|
Row {
|
||||||
|
|
||||||
Text(text = value, color = cursorColor.copy(alpha = 0f))
|
Text(text = value, color = cursorColor.copy(alpha = 0f))
|
||||||
HorizontalDivider(
|
Divider(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = 3.dp, top = 15.dp, bottom = 15.dp)
|
.padding(start = 3.dp, top = 15.dp, bottom = 15.dp)
|
||||||
.width(1.dp)
|
.width(1.dp)
|
||||||
|
|||||||
@@ -21,13 +21,22 @@ import me.zobrist.tichucounter.data.entity.Round
|
|||||||
import me.zobrist.tichucounter.ui.AppTheme
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
fun RoundListView(rounds: List<Round>, sumUpRounds: Boolean = false, modifier: Modifier) {
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
var sumA = 0
|
||||||
|
var sumB = 0
|
||||||
|
|
||||||
LazyColumn(state = lazyListState, modifier = modifier) {
|
LazyColumn(state = lazyListState, modifier = modifier) {
|
||||||
itemsIndexed(rounds) { index, item ->
|
itemsIndexed(rounds) { index, item ->
|
||||||
RoundListItem(item, index)
|
if (sumUpRounds) {
|
||||||
|
sumA += item.scoreA
|
||||||
|
sumB += item.scoreB
|
||||||
|
RoundListItem(sumA, sumB, index)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
RoundListItem(item.scoreA, item.scoreB, index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
@@ -37,14 +46,14 @@ fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RoundListItem(round: Round, index: Int) {
|
private fun RoundListItem(scoreA: Int, scoreB: Int, index: Int) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(all = 4.dp)
|
.padding(all = 4.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = round.scoreA.toString(),
|
text = scoreA.toString(),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
modifier = Modifier.weight(5f),
|
modifier = Modifier.weight(5f),
|
||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
@@ -56,7 +65,7 @@ private fun RoundListItem(round: Round, index: Int) {
|
|||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = round.scoreB.toString(),
|
text = scoreB.toString(),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
modifier = Modifier.weight(5f),
|
modifier = Modifier.weight(5f),
|
||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
@@ -78,7 +87,7 @@ fun RoundListViewPreview() {
|
|||||||
|
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface {
|
Surface {
|
||||||
RoundListView(rounds, Modifier)
|
RoundListView(rounds, true, Modifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material3.LocalTextStyle
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.material3.TextFieldDefaults
|
|
||||||
import androidx.compose.material3.surfaceColorAtElevation
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
|||||||
@@ -1,64 +1,44 @@
|
|||||||
package me.zobrist.tichucounter.ui.history
|
package me.zobrist.tichucounter.ui.history
|
||||||
|
|
||||||
|
|
||||||
import androidx.compose.animation.animateColorAsState
|
import androidx.compose.foundation.clickable
|
||||||
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.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.wrapContentSize
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
|
||||||
import androidx.compose.material.icons.Icons
|
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.DeleteForever
|
||||||
import androidx.compose.material.icons.outlined.RestartAlt
|
import androidx.compose.material.icons.outlined.MoreVert
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Badge
|
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
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.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.material3.rememberSwipeToDismissBoxState
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||||
import androidx.compose.ui.Alignment.Companion.TopEnd
|
|
||||||
import androidx.compose.ui.Modifier
|
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.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import me.zobrist.tichucounter.R
|
import me.zobrist.tichucounter.R
|
||||||
import me.zobrist.tichucounter.data.GameWithScores
|
import me.zobrist.tichucounter.data.GameWithScores
|
||||||
import me.zobrist.tichucounter.data.entity.Game
|
import me.zobrist.tichucounter.data.entity.Game
|
||||||
import me.zobrist.tichucounter.data.entity.Round
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
import me.zobrist.tichucounter.domain.getTotalPoints
|
import me.zobrist.tichucounter.domain.getTotalPoints
|
||||||
|
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
@@ -67,13 +47,10 @@ import java.util.Locale
|
|||||||
@Composable
|
@Composable
|
||||||
fun HistoryList(
|
fun HistoryList(
|
||||||
viewModel: HistoryViewModel,
|
viewModel: HistoryViewModel,
|
||||||
snackbarHostState: SnackbarHostState,
|
navigateToCalculator: () -> Unit
|
||||||
navigateToCalculator: () -> Unit,
|
|
||||||
) {
|
) {
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val lazyListState = rememberLazyListState()
|
|
||||||
var showDeleteDialog by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
|
var showDeleteDialog by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
DeleteConfirmDialog(showDeleteDialog) {
|
DeleteConfirmDialog(showDeleteDialog) {
|
||||||
showDeleteDialog = false
|
showDeleteDialog = false
|
||||||
@@ -82,51 +59,14 @@ fun HistoryList(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
HistoryList(
|
||||||
games = viewModel.gameAndHistory,
|
viewModel.gameAndHistory,
|
||||||
onOpenClicked = {
|
{
|
||||||
scope.launch {
|
viewModel.activateGame(it)
|
||||||
viewModel.activateGame(it)
|
navigateToCalculator()
|
||||||
lazyListState.animateScrollToItem(0)
|
|
||||||
|
|
||||||
snackbarHostState.currentSnackbarData?.dismiss()
|
|
||||||
val result = snackbarHostState.showSnackbar(
|
|
||||||
message = activatedMessage,
|
|
||||||
actionLabel = activatedActionLabel,
|
|
||||||
duration = SnackbarDuration.Short
|
|
||||||
)
|
|
||||||
|
|
||||||
if (result == SnackbarResult.ActionPerformed) {
|
|
||||||
navigateToCalculator()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onDeleteClicked = {
|
{ viewModel.deleteGame(it) },
|
||||||
scope.launch {
|
{ showDeleteDialog = true },
|
||||||
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
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,12 +78,14 @@ fun DeleteConfirmDialog(show: Boolean = true, onExecuted: (Boolean) -> Unit = {}
|
|||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { onExecuted(false) },
|
onDismissRequest = { onExecuted(false) },
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton({ onExecuted(false) }) {
|
TextButton({ onExecuted(false) })
|
||||||
|
{
|
||||||
Text(stringResource(R.string.cancel))
|
Text(stringResource(R.string.cancel))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton({ onExecuted(true) }) {
|
TextButton({ onExecuted(true) })
|
||||||
|
{
|
||||||
Text(stringResource(R.string.ok))
|
Text(stringResource(R.string.ok))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -153,217 +95,133 @@ fun DeleteConfirmDialog(show: Boolean = true, onExecuted: (Boolean) -> Unit = {}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HistoryList(
|
fun HistoryList(
|
||||||
games: List<GameWithScores>,
|
games: List<GameWithScores>,
|
||||||
onOpenClicked: (gameId: Long) -> Unit,
|
onOpenClicked: (GameId: Long) -> Unit,
|
||||||
onDeleteClicked: (gameId: Long) -> Unit,
|
onDeleteClicked: (GameId: Long) -> Unit,
|
||||||
onDeleteAllClicked: () -> Unit,
|
onDeleteAllClicked: () -> Unit
|
||||||
lazyListState: LazyListState = LazyListState(),
|
|
||||||
) {
|
) {
|
||||||
Row {
|
Row {
|
||||||
LazyColumn(state = lazyListState) {
|
LazyColumn {
|
||||||
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 {
|
item {
|
||||||
Button(enabled = games.count() > 1,
|
Text(
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(start = 10.dp, end = 10.dp),
|
||||||
.padding(start = 4.dp, end = 4.dp, top = 10.dp)
|
text = stringResource(R.string.active),
|
||||||
.align(CenterVertically)
|
style = MaterialTheme.typography.headlineSmall
|
||||||
.fillMaxWidth()
|
)
|
||||||
.animateItemPlacement(),
|
}
|
||||||
onClick = { onDeleteAllClicked() }) {
|
items(games.filter { it.game.active }) {
|
||||||
Icon(imageVector = Icons.Outlined.DeleteForever, contentDescription = null)
|
HistoryListItem(it, onOpenClicked, onDeleteClicked)
|
||||||
Text(text = stringResource(id = R.string.deleteAll))
|
}
|
||||||
|
|
||||||
|
if (games.count() > 1) {
|
||||||
|
item {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 10.dp, end = 10.dp, top = 10.dp),
|
||||||
|
text = stringResource(R.string.inactive),
|
||||||
|
style = MaterialTheme.typography.headlineSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
items(games.filter { !it.game.active }) {
|
||||||
|
HistoryListItem(it, onOpenClicked, onDeleteClicked)
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
Button(
|
||||||
|
enabled = games.count() > 1,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(start = 4.dp, end = 4.dp, top = 10.dp)
|
||||||
|
.align(CenterVertically)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
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
|
@Composable
|
||||||
fun HistoryListItem(
|
fun HistoryListItem(
|
||||||
game: GameWithScores, modifier: Modifier = Modifier
|
game: GameWithScores,
|
||||||
|
onOpenClicked: (GameId: Long) -> Unit,
|
||||||
|
onDeleteClicked: (GameId: Long) -> Unit
|
||||||
) {
|
) {
|
||||||
val format =
|
val format =
|
||||||
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
|
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
|
||||||
|
|
||||||
|
|
||||||
|
val cardColor = if (game.game.active) {
|
||||||
|
CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
CardDefaults.cardColors()
|
||||||
|
}
|
||||||
|
|
||||||
val totalScores = game.getTotalPoints()
|
val totalScores = game.getTotalPoints()
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
.padding(all = 4.dp)
|
||||||
|
.clickable { onOpenClicked(game.game.uid) },
|
||||||
|
colors = cardColor
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
Modifier.padding(all = 12.dp)
|
Modifier
|
||||||
|
.padding(all = 12.dp)
|
||||||
) {
|
) {
|
||||||
Box(modifier = modifier.fillMaxSize()) {
|
Column(Modifier.weight(4f)) {
|
||||||
Column {
|
Text(
|
||||||
Text(
|
text = game.game.nameA + " vs " + game.game.nameB,
|
||||||
text = game.game.nameA + " vs " + game.game.nameB,
|
maxLines = 1,
|
||||||
maxLines = 1,
|
overflow = TextOverflow.Ellipsis,
|
||||||
overflow = TextOverflow.Ellipsis,
|
style = MaterialTheme.typography.headlineSmall
|
||||||
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(
|
||||||
|
Modifier
|
||||||
|
.wrapContentSize()
|
||||||
|
.width(40.dp)
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (!game.game.active) {
|
||||||
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(start = 20.dp, bottom = 20.dp)
|
||||||
|
.clickable { expanded = true },
|
||||||
|
imageVector = Icons.Outlined.MoreVert,
|
||||||
|
contentDescription = null
|
||||||
)
|
)
|
||||||
Text(
|
|
||||||
text = totalScores.first.toString() + " : " + totalScores.second.toString(),
|
|
||||||
style = MaterialTheme.typography.bodyLarge
|
DropDownMenu(
|
||||||
)
|
mapOf("delete" to R.string.delete),
|
||||||
Spacer(modifier = Modifier.padding(5.dp))
|
"",
|
||||||
Text(
|
expanded,
|
||||||
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(
|
expanded = false
|
||||||
text = stringResource(id = R.string.active),
|
it?.let {
|
||||||
style = MaterialTheme.typography.labelSmall
|
when (it) {
|
||||||
)
|
"delete" -> onDeleteClicked(game.game.uid)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,17 +234,25 @@ fun HistoryListItem(
|
|||||||
private fun HistoryListPreview() {
|
private fun HistoryListPreview() {
|
||||||
val tempData = listOf(
|
val tempData = listOf(
|
||||||
GameWithScores(
|
GameWithScores(
|
||||||
Game(true, "abcsdf sdaf asdf sdf ", "defsadf asdf sadf ", Date(), Date()),
|
Game(true, "abc", "def", Date(), Date()),
|
||||||
listOf(Round(1, 550, 500))
|
listOf(Round(1, 550, 500))
|
||||||
), GameWithScores(
|
),
|
||||||
Game(false, "ADTH", "dogfg", Date(), Date()), listOf(Round(2, 20, 60))
|
GameWithScores(
|
||||||
), GameWithScores(
|
Game(false, "ADTH", "dogfg", Date(), Date()),
|
||||||
Game(false, "TeamA3 langer Name", "TeamB3", Date(), Date()), listOf(Round(3, 30, 70))
|
listOf(Round(2, 20, 60))
|
||||||
), GameWithScores(
|
),
|
||||||
Game(false, "TeamA4", "TeamB4", Date(), Date()), listOf(Round(4, 40, 80))
|
GameWithScores(
|
||||||
), GameWithScores(
|
Game(false, "TeamA3 langer Name", "TeamB3", Date(), Date()),
|
||||||
Game(false, "TeamA5", "TeamB5", Date(), Date()), listOf(Round(5, 50, 90))
|
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, {}, {}, {})
|
HistoryList(tempData, {}, {}) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,12 @@ class HistoryViewModel @Inject constructor(
|
|||||||
var gameAndHistory by mutableStateOf(emptyList<GameWithScores>())
|
var gameAndHistory by mutableStateOf(emptyList<GameWithScores>())
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private var fullList: List<GameWithScores> = emptyList()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|
||||||
gameRepository.getAllWithRoundFlow().collect { games ->
|
gameRepository.getAllWithRoundFlow().collect { games ->
|
||||||
fullList =
|
gameAndHistory =
|
||||||
games.sortedBy { it.game.modified }.sortedBy { it.game.active }.reversed()
|
games.sortedBy { it.game.modified }.sortedBy { it.game.active }.reversed()
|
||||||
gameAndHistory = fullList
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,12 +36,6 @@ class HistoryViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun restoreLastDeletedGame() {
|
|
||||||
viewModelScope.launch {
|
|
||||||
gameRepository.restoreLastDeletedGame()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun activateGame(gameId: Long) {
|
fun activateGame(gameId: Long) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
gameRepository.setActive(gameId)
|
gameRepository.setActive(gameId)
|
||||||
|
|||||||
@@ -1,28 +1,20 @@
|
|||||||
package me.zobrist.tichucounter.ui.layout
|
package me.zobrist.tichucounter.ui.layout
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.List
|
import androidx.compose.material.icons.filled.*
|
||||||
import androidx.compose.material.icons.outlined.Calculate
|
import androidx.compose.material.icons.outlined.*
|
||||||
import androidx.compose.material.icons.outlined.Settings
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.runtime.*
|
||||||
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.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import me.zobrist.tichucounter.R
|
import me.zobrist.tichucounter.R
|
||||||
import me.zobrist.tichucounter.domain.DrawerItem
|
import me.zobrist.tichucounter.domain.*
|
||||||
import me.zobrist.tichucounter.domain.Route
|
|
||||||
import me.zobrist.tichucounter.ui.AppTheme
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
|
import me.zobrist.tichucounter.ui.counter.*
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DrawerContent(
|
fun DrawerContent(
|
||||||
@@ -38,7 +30,7 @@ fun DrawerContent(
|
|||||||
text = stringResource(R.string.app_name),
|
text = stringResource(R.string.app_name),
|
||||||
style = MaterialTheme.typography.headlineSmall
|
style = MaterialTheme.typography.headlineSmall
|
||||||
)
|
)
|
||||||
HorizontalDivider(modifier = Modifier.padding(10.dp))
|
Divider(modifier = Modifier.padding(10.dp))
|
||||||
|
|
||||||
drawerItems.forEach { screen ->
|
drawerItems.forEach { screen ->
|
||||||
NavigationDrawerItem(
|
NavigationDrawerItem(
|
||||||
@@ -58,7 +50,7 @@ fun DrawerContent(
|
|||||||
fun DrawerContentPreview() {
|
fun DrawerContentPreview() {
|
||||||
|
|
||||||
val counter = DrawerItem(Route.COUNTER, Icons.Outlined.Calculate, "Counter")
|
val counter = DrawerItem(Route.COUNTER, Icons.Outlined.Calculate, "Counter")
|
||||||
val history = DrawerItem(Route.HISTORY, Icons.AutoMirrored.Outlined.List, "History")
|
val history = DrawerItem(Route.HISTORY, Icons.Outlined.List, "History")
|
||||||
val settings = DrawerItem(Route.SETTINGS, Icons.Outlined.Settings, "Settings")
|
val settings = DrawerItem(Route.SETTINGS, Icons.Outlined.Settings, "Settings")
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface {
|
Surface {
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package me.zobrist.tichucounter.ui.layout
|
package me.zobrist.tichucounter.ui.layout
|
||||||
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.*
|
||||||
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.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import me.zobrist.tichucounter.R
|
import me.zobrist.tichucounter.R
|
||||||
|
import me.zobrist.tichucounter.domain.CounterListView
|
||||||
import me.zobrist.tichucounter.domain.KeepScreenOn
|
import me.zobrist.tichucounter.domain.KeepScreenOn
|
||||||
import me.zobrist.tichucounter.domain.Language
|
import me.zobrist.tichucounter.domain.Language
|
||||||
import me.zobrist.tichucounter.domain.Theme
|
import me.zobrist.tichucounter.domain.Theme
|
||||||
@@ -44,7 +45,11 @@ val themeMap = mapOf(
|
|||||||
Theme.LIGHT to R.string.light
|
Theme.LIGHT to R.string.light
|
||||||
)
|
)
|
||||||
|
|
||||||
val victoryPointsList = listOf(500, 1000, 1500, 2000)
|
val counterListViewMap = mapOf(
|
||||||
|
CounterListView.BY_ROUND to R.string.by_round,
|
||||||
|
CounterListView.CONTINUOUS to R.string.continuous,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsView(viewModel: SettingsViewModel) {
|
fun SettingsView(viewModel: SettingsViewModel) {
|
||||||
@@ -52,11 +57,11 @@ fun SettingsView(viewModel: SettingsViewModel) {
|
|||||||
viewModel.screenOn.value,
|
viewModel.screenOn.value,
|
||||||
viewModel.language,
|
viewModel.language,
|
||||||
viewModel.theme,
|
viewModel.theme,
|
||||||
viewModel.victoryPoints,
|
viewModel.counterListView,
|
||||||
{ viewModel.updateScreenOn(it) },
|
{ viewModel.updateScreenOn(it) },
|
||||||
{ viewModel.updateLanguage(it) },
|
{ viewModel.updateLanguage(it) },
|
||||||
{ viewModel.updateTheme(it) },
|
{ viewModel.updateTheme(it) },
|
||||||
{ viewModel.updateVictoryPoints(it) })
|
{ viewModel.updateCounterListView(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -64,22 +69,13 @@ fun SettingsView(
|
|||||||
valueScreenOn: Boolean = true,
|
valueScreenOn: Boolean = true,
|
||||||
valueLanguage: Language = Language.ENGLISH,
|
valueLanguage: Language = Language.ENGLISH,
|
||||||
valueTheme: Theme = Theme.DARK,
|
valueTheme: Theme = Theme.DARK,
|
||||||
valueVictoryPoints: Int = 1000,
|
valueCounterListView: CounterListView = CounterListView.BY_ROUND,
|
||||||
updateScreenOn: (KeepScreenOn) -> Unit = {},
|
updateScreenOn: (KeepScreenOn) -> Unit = {},
|
||||||
updateLanguage: (Language) -> Unit = {},
|
updateLanguage: (Language) -> Unit = {},
|
||||||
updateTheme: (Theme) -> Unit = {},
|
updateTheme: (Theme) -> Unit = {},
|
||||||
updateVictoryPoints: (Int) -> Unit = {}
|
updateCounterListView: (CounterListView) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
Column(
|
Column {
|
||||||
Modifier
|
|
||||||
.padding(20.dp)
|
|
||||||
) {
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.display),
|
|
||||||
style = MaterialTheme.typography.headlineMedium
|
|
||||||
)
|
|
||||||
|
|
||||||
BooleanSetting(
|
BooleanSetting(
|
||||||
stringResource(R.string.keep_screen_on),
|
stringResource(R.string.keep_screen_on),
|
||||||
valueScreenOn
|
valueScreenOn
|
||||||
@@ -97,17 +93,13 @@ fun SettingsView(
|
|||||||
valueTheme,
|
valueTheme,
|
||||||
) { updateTheme(it) }
|
) { updateTheme(it) }
|
||||||
|
|
||||||
Text(
|
StringSetting(
|
||||||
text = stringResource(R.string.game),
|
stringResource(R.string.counter_mode),
|
||||||
style = MaterialTheme.typography.headlineMedium
|
counterListViewMap,
|
||||||
)
|
valueCounterListView,
|
||||||
|
) { updateCounterListView(it) }
|
||||||
|
|
||||||
|
|
||||||
ListSetting(
|
|
||||||
stringResource(R.string.victory_points),
|
|
||||||
victoryPointsList,
|
|
||||||
valueVictoryPoints
|
|
||||||
) { updateVictoryPoints(it) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +108,7 @@ fun BooleanSetting(name: String, value: Boolean, updateValue: (Boolean) -> Unit)
|
|||||||
|
|
||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.padding(bottom = 15.dp, top = 5.dp)
|
.padding(20.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
Column(Modifier.weight(5f)) {
|
Column(Modifier.weight(5f)) {
|
||||||
@@ -145,32 +137,21 @@ fun BooleanSetting(name: String, value: Boolean, updateValue: (Boolean) -> Unit)
|
|||||||
@Composable
|
@Composable
|
||||||
fun <T> StringSetting(name: String, map: Map<T, Int>, selected: T, onSelected: (T) -> Unit) {
|
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) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(bottom = 15.dp, top = 5.dp)
|
.padding(20.dp)
|
||||||
.clickable { expanded = true }) {
|
.clickable { expanded = true }) {
|
||||||
Column(Modifier.weight(5f)) {
|
Column(Modifier.weight(5f)) {
|
||||||
Text(name, style = MaterialTheme.typography.bodyLarge, overflow = TextOverflow.Ellipsis)
|
Text(name, style = MaterialTheme.typography.bodyLarge, overflow = TextOverflow.Ellipsis)
|
||||||
Text(
|
map[selected]?.let {
|
||||||
selected.toString(),
|
Text(
|
||||||
style = MaterialTheme.typography.labelLarge
|
stringResource(it),
|
||||||
)
|
style = MaterialTheme.typography.labelLarge
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(Modifier.weight(1f)) {
|
Column(Modifier.weight(1f)) {
|
||||||
@@ -179,15 +160,15 @@ fun <T> ListSetting(name: String, list: Collection<T>, selected: T, onSelected:
|
|||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.align(End)
|
modifier = Modifier.align(End)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
DropDownMenu(
|
DropDownMenu(
|
||||||
list,
|
map,
|
||||||
selected,
|
selected,
|
||||||
expanded,
|
expanded,
|
||||||
) {
|
) {
|
||||||
expanded = false
|
expanded = false
|
||||||
it?.let { onSelected(it) }
|
it?.let { onSelected(it) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,3 +185,20 @@ fun SettingsViewPreview() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Preview(name = "Light Mode")
|
||||||
|
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||||
|
@Composable
|
||||||
|
fun StringSettingPreview() {
|
||||||
|
|
||||||
|
AppTheme {
|
||||||
|
Surface {
|
||||||
|
DropDownMenu(
|
||||||
|
themeMap,
|
||||||
|
Theme.LIGHT,
|
||||||
|
true,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +1,47 @@
|
|||||||
package me.zobrist.tichucounter.ui.settings
|
package me.zobrist.tichucounter.ui.settings
|
||||||
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import me.zobrist.tichucounter.domain.KeepScreenOn
|
import me.zobrist.tichucounter.domain.*
|
||||||
import me.zobrist.tichucounter.domain.Language
|
|
||||||
import me.zobrist.tichucounter.domain.SettingsAdapter
|
|
||||||
import me.zobrist.tichucounter.domain.Theme
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class SettingsViewModel @Inject constructor(private val settings: SettingsAdapter) : ViewModel() {
|
class SettingsViewModel @Inject constructor(private val settings: SettingsAdapter) : ViewModel() {
|
||||||
|
|
||||||
|
|
||||||
var language by mutableStateOf(settings.language.value)
|
var language by mutableStateOf(settings.language)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var theme by mutableStateOf(settings.theme.value)
|
var theme by mutableStateOf(settings.theme)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var screenOn by mutableStateOf(settings.keepScreenOn.value)
|
var screenOn by mutableStateOf(settings.keepScreenOn)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var victoryPoints by mutableIntStateOf(settings.victoryPoints.value)
|
var counterListView by mutableStateOf(settings.counterListView)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun updateLanguage(language: Language) {
|
fun updateLanguage(language: Language) {
|
||||||
settings.language.value = language
|
settings.setLanguage(language)
|
||||||
this.language = language
|
this.language = settings.language
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTheme(theme: Theme) {
|
fun updateTheme(theme: Theme) {
|
||||||
settings.theme.value = theme
|
settings.setTheme(theme)
|
||||||
this.theme = theme
|
this.theme = settings.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateScreenOn(value: KeepScreenOn) {
|
fun updateScreenOn(value: KeepScreenOn) {
|
||||||
settings.keepScreenOn.value = value
|
settings.setKeepScreenOn(value)
|
||||||
screenOn = value
|
screenOn = settings.keepScreenOn
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateVictoryPoints(value: Int) {
|
fun updateCounterListView(value: CounterListView) {
|
||||||
settings.victoryPoints.value = value
|
settings.setCounterViewList(value)
|
||||||
victoryPoints = value
|
counterListView = settings.counterListView
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<string name="menu_settings">Einstellungen</string>
|
<string name="menu_settings">Einstellungen</string>
|
||||||
<string name="on">Ein</string>
|
<string name="on">Ein</string>
|
||||||
<string name="off">Aus</string>
|
<string name="off">Aus</string>
|
||||||
<string name="new_game">Neues Spiel</string>
|
<string name="newGame">Neues Spiel</string>
|
||||||
<string name="delete_inactive_title">Verlauf löschen</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="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="cancel">Abbrechen</string>
|
||||||
@@ -24,17 +24,5 @@
|
|||||||
<string name="menu_counter">Counter</string>
|
<string name="menu_counter">Counter</string>
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
<string name="contact_us">Schreib uns</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>
|
</resources>
|
||||||
@@ -15,9 +15,9 @@
|
|||||||
<string name="menu_settings">Settings</string>
|
<string name="menu_settings">Settings</string>
|
||||||
<string name="on">On</string>
|
<string name="on">On</string>
|
||||||
<string name="off">Off</string>
|
<string name="off">Off</string>
|
||||||
<string name="new_game">New Game</string>
|
<string name="newGame">New Game</string>
|
||||||
<string name="delete_inactive_title">Delete history</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="delete_inactive_text">You really want to delete the the history? This action can\'t be undone.</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="delete">Delete</string>
|
<string name="delete">Delete</string>
|
||||||
@@ -26,19 +26,9 @@
|
|||||||
<string name="inactive">Old Games</string>
|
<string name="inactive">Old Games</string>
|
||||||
<string name="menu_counter">Counter</string>
|
<string name="menu_counter">Counter</string>
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
|
<string name="by_round">Display Single Round</string>
|
||||||
|
<string name="continuous">Sum up rounds</string>
|
||||||
|
<string name="counter_mode">Counter Mode</string>
|
||||||
<string name="contact_us">Contact us</string>
|
<string name="contact_us">Contact us</string>
|
||||||
<string name="play_store" translatable="false">Play Store</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>
|
</resources>
|
||||||
11
build.gradle
11
build.gradle
@@ -1,12 +1,12 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.9.24"
|
ext.kotlin_version = "1.8.21"
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.11.0'
|
classpath 'com.android.tools.build:gradle:8.0.2'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
@@ -15,9 +15,8 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.google.dagger.hilt.android' version '2.51.1' apply false
|
id 'com.google.dagger.hilt.android' version '2.44' apply false
|
||||||
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
|
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
|
||||||
id 'com.google.devtools.ksp' version '1.9.24-1.0.20' apply false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@@ -26,3 +25,7 @@ allprojects {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user