This commit is contained in:
pegasko 2025-06-07 23:55:31 +03:00
commit f106d7c736
91 changed files with 6492 additions and 0 deletions

661
LICENSE Normal file
View file

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 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 Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are 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.
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.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
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 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 work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero 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 your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
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 AGPL, see
<https://www.gnu.org/licenses/>.

7
NOTICE Normal file
View file

@ -0,0 +1,7 @@
Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
This notice must be kept among all subsequent and related projects.

46
README.md Normal file
View file

@ -0,0 +1,46 @@
# Yeeemp
![Yeeemp](images/ic-round-256.png)
Tag-based event tracker for rawr, uwu and merp
# Gallery
![gallery](images/composite.png)
# Features
* Multiple separate queues for your events
* Each event has tags, comment and date with time
* Tags are unique within each queue and support search-input when editing event
* Database export and import based on Documents API
# License
Yeeemp - tag based event counter
Copyright (C) 2024-2025 pegasko
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
# Notice
Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.

16
Yeeemp/.gitignore vendored Normal file
View file

@ -0,0 +1,16 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
.idea/*

1
Yeeemp/app/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

70
Yeeemp/app/build.gradle Normal file
View file

@ -0,0 +1,70 @@
plugins {
id 'com.android.application'
}
android {
namespace 'art.pegasko.yeeemp'
compileSdk 34
defaultConfig {
applicationId "art.pegasko.yeeemp"
minSdk 21
targetSdk 34
versionCode 1006
versionName "1.006"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled = true
shrinkResources = true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix = '.debug'
debuggable = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
dataBinding = true
}
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.6.0'
implementation 'androidx.navigation:navigation-ui:2.6.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.8.0'
implementation platform('androidx.compose:compose-bom:2023.08.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.activity:activity:1.8.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2023.08.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}

21
Yeeemp/app/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Yeeemp"
tools:targetApi="31">
<activity
android:name=".ui.activity.QueueListActivity"
android:exported="true"
android:theme="@style/Theme.Yeeemp.Green">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activity.EventEditActivity"
android:theme="@style/Theme.Yeeemp.Red"
android:exported="false" />
<activity
android:name=".ui.activity.EventListActivity"
android:exported="false"
android:theme="@style/Theme.Yeeemp.Blue" />
</application>
</manifest>

View file

@ -0,0 +1,46 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public interface Event {
int getId();
long getTimestamp();
void setTimestamp(long timestamp);
String getComment();
void setComment(String comment);
void addTag(Tag tag);
void removeTag(Tag tag);
void removeTags();
Tag[] getTags();
}

View file

@ -0,0 +1,34 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public interface EventMaker {
Event create();
void delete(Event event);
Event getById(int id);
}

View file

@ -0,0 +1,76 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
import androidx.annotation.Nullable;
public class EventOrder {
public static String orderToString(@Nullable Order order) {
if (order == null) {
return null;
}
switch (order) {
case ID_ASC:
return "id_asc";
case ID_DESC:
return "id_desc";
case TIMESTAMP_ASC:
return "timestamp_asc";
case TIMESTAMP_DESC:
return "timestamp_desc";
default:
throw new RuntimeException("Not implemented for " + order);
}
}
public static Order orderFromString(@Nullable String order) {
if (order == null) {
return null;
}
switch (order) {
case "id_asc":
return Order.ID_ASC;
case "id_desc":
return Order.ID_DESC;
case "timestamp_asc":
return Order.TIMESTAMP_ASC;
case "timestamp_desc":
return Order.TIMESTAMP_DESC;
default:
return Order.ID_ASC;
// throw new RuntimeException("Not implemented for " + order);
}
}
public enum Order {
ID_ASC,
ID_DESC,
TIMESTAMP_ASC,
TIMESTAMP_DESC,
}
}

View file

@ -0,0 +1,44 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public interface Queue {
int getId();
String getName();
void setName(String name);
Event[] getEvents(EventOrder.Order order);
int getEventCount();
void addEvent(Event event);
void removeEvent(Event event);
TagStat[] getGlobalTags();
}

View file

@ -0,0 +1,36 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public interface QueueMaker {
Queue getById(int id);
Queue create();
void delete(Queue queue);
Queue[] list(QueueOrder.Order order);
}

View file

@ -0,0 +1,65 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
import androidx.annotation.Nullable;
public class QueueOrder {
public static String orderToString(@Nullable Order order) {
if (order == null) {
return null;
}
switch (order) {
case ID:
return "id";
case NAME:
return "name";
default:
throw new RuntimeException("Not implemented for " + order);
}
}
public static Order orderFromString(@Nullable String order) {
if (order == null) {
return null;
}
switch (order) {
case "id":
return Order.ID;
case "name":
return Order.NAME;
default:
throw new RuntimeException("Not implemented for " + order);
}
}
public enum Order {
ID,
NAME,
}
}

View file

@ -0,0 +1,32 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public interface Tag {
int getId();
String getName();
}

View file

@ -0,0 +1,30 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public interface TagMaker {
Tag getOrCreateInQueue(Queue queue, String name);
}

View file

@ -0,0 +1,31 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public class TagStat {
public Tag tag;
public int count;
}

View file

@ -0,0 +1,56 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.base;
public abstract class Wrapper {
private static Wrapper instance;
public static Wrapper instance() {
return Wrapper.instance;
}
public static void setInstance(Wrapper instance) {
Wrapper.instance = instance;
}
public static QueueMaker getQueueMaker() {
return Wrapper.instance().queueMaker();
}
public static EventMaker getEventMaker() {
return Wrapper.instance().eventMaker();
}
public static TagMaker getTagMaker() {
return Wrapper.instance().tagMaker();
}
public abstract QueueMaker queueMaker();
public abstract EventMaker eventMaker();
public abstract TagMaker tagMaker();
}

View file

@ -0,0 +1,169 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import art.pegasko.yeeemp.base.EventMaker;
import art.pegasko.yeeemp.base.Wrapper;
import art.pegasko.yeeemp.base.QueueMaker;
import art.pegasko.yeeemp.base.TagMaker;
public class DBWrapper extends Wrapper {
public static final String TAG = DBWrapper.class.getSimpleName();
public static final boolean DEBUG = false;
public DBWrapper(Context context) {
this.db = openDB(context, DB_PATH);
this.queueMaker = new QueueMakerImpl(this.db);
this.eventMaker = new EventMakerImpl(this.db);
this.tagMaker = new TagMakerImpl(this.db);
}
// Fields
SQLiteDatabase db;
QueueMaker queueMaker;
EventMaker eventMaker;
TagMaker tagMaker;
public QueueMaker queueMaker() {
return this.queueMaker;
}
public EventMaker eventMaker() {
return this.eventMaker;
}
public TagMaker tagMaker() {
return this.tagMaker;
}
/**
* SQLite initializer script
*/
// @formatter:off
private static final String[] INIT_SQL = new String[] {
"CREATE TABLE IF NOT EXISTS tag (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" queue_id INTEGER," +
" name TEXT" +
");",
"CREATE INDEX IF NOT EXISTS tag__queue_id ON tag(queue_id);",
"CREATE INDEX IF NOT EXISTS tag__name ON tag(name);",
"CREATE TABLE IF NOT EXISTS event (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" timestamp INTEGER," +
" comment TEXT" +
");",
"CREATE TABLE IF NOT EXISTS queue (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" name TEXT" +
");",
"CREATE TABLE IF NOT EXISTS event_tag (" +
" event_id INTEGER," +
" tag_id INTEGER" +
");",
"CREATE INDEX IF NOT EXISTS event_tag__event_id_tag_id ON event_tag(event_id, tag_id);",
"CREATE INDEX IF NOT EXISTS event_tag__event_id ON event_tag(event_id);",
"CREATE INDEX IF NOT EXISTS event_tag__tag_id ON event_tag(tag_id);",
"CREATE TABLE IF NOT EXISTS queue_event (" +
" queue_id INTEGER," +
" event_id INTEGER" +
");",
"CREATE INDEX IF NOT EXISTS queue_event__event_id_tag_id ON queue_event(queue_id, event_id);",
"CREATE INDEX IF NOT EXISTS queue_event__event_id ON queue_event(queue_id);",
"CREATE INDEX IF NOT EXISTS queue_event__tag_id ON queue_event(event_id);"
};
private static String DB_PATH = "database.db";
/**
* Initialize database object
*
* @param db
*/
private static void initDB(SQLiteDatabase db) {
try {
Log.d(TAG, "Creating database");
for (String query: INIT_SQL) {
Log.d(TAG, query);
db.execSQL(query);
}
Log.d(TAG, "Database created");
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
}
/**
* Get internal database path
*/
static File getDBPath(Context context) {
return new File(context.getFilesDir(), DB_PATH);
}
/**
* @return opened and initialized database
*/
private static SQLiteDatabase openDB(Context context, String dbPath) {
if (DBWrapper.DEBUG) {
try {
new File(context.getFilesDir(), dbPath).delete();
} catch (Exception e) {
Log.wtf(TAG, e);
}
}
File path = getDBPath(context);
SQLiteDatabase db;
if (!path.exists()) {
db = SQLiteDatabase.openDatabase(path.getPath(), null, SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.CREATE_IF_NECESSARY);
} else {
db = SQLiteDatabase.openDatabase(path.getPath(), null, SQLiteDatabase.OPEN_READWRITE);
}
initDB(db);
return db;
}
}

View file

@ -0,0 +1,128 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import art.pegasko.yeeemp.base.Wrapper;
import art.pegasko.yeeemp.ui.activity.Utils;
// TODO: Better data management API
public class DataUtils {
public static final String DATE_FORMAT = "yyyy-MM-dd-HH-mm-ss";
public static String formatTs(long timestamp) {
SimpleDateFormat sdf = new SimpleDateFormat(DataUtils.DATE_FORMAT);
return sdf.format(timestamp);
}
private static void copyStream(InputStream fis, OutputStream fos) throws IOException {
byte[] buffer = new byte[1024];
int lengthRead;
while ((lengthRead = fis.read(buffer)) > 0) {
fos.write(buffer, 0, lengthRead);
fos.flush();
}
}
/* just copy internal db to external storage */
public static void exportDatabase(Context context, Uri uri) throws Exception {
File internalFile = DBWrapper.getDBPath(context);
InputStream fis = new FileInputStream(internalFile);
OutputStream fos = context.getContentResolver().openOutputStream(uri);
copyStream(fis, fos);
fis.close();
fos.close();
}
/* just copy external db to internal storage */
public static void importDatabase(Context context, Uri uri) throws Exception {
File internalFile = DBWrapper.getDBPath(context);
InputStream fis = context.getContentResolver().openInputStream(uri);
OutputStream fos = new FileOutputStream(internalFile);
copyStream(fis, fos);
fis.close();
fos.close();
}
public static void backupDatabase(Context context) throws IOException {
File internalFile = DBWrapper.getDBPath(context);
File backupFile = new File(context.getFilesDir(), "backup.db");
FileInputStream fis = new FileInputStream(internalFile);
FileOutputStream fos = new FileOutputStream(backupFile);
copyStream(fis, fos);
fis.close();
fos.close();
}
public static void restoreDatabase(Context context) throws IOException {
File internalFile = DBWrapper.getDBPath(context);
File backupFile = new File(context.getFilesDir(), "backup.db");
FileInputStream fis = new FileInputStream(backupFile);
FileOutputStream fos = new FileOutputStream(internalFile);
copyStream(fis, fos);
fis.close();
fos.close();
}
public static void deleteBackupDatabase(Context context) throws IOException {
File backupFile = new File(context.getFilesDir(), "backup.db");
backupFile.delete();
}
public static void closeDatabase() {
// Drop current database
((DBWrapper) DBWrapper.instance()).db.close();
Wrapper.setInstance(null);
}
public static void deleteDatabase(Context context) throws IOException {
File internalFile = DBWrapper.getDBPath(context);
internalFile.delete();
}
}

View file

@ -0,0 +1,238 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.util.Log;
import androidx.annotation.NonNull;
import art.pegasko.yeeemp.base.Event;
import art.pegasko.yeeemp.base.Tag;
public class EventImpl implements Event {
public static final String TAG = EventImpl.class.getSimpleName();
private final SQLiteDatabase db;
private final int id;
private Tag[] cachedTags;
protected EventImpl(SQLiteDatabase db, int id) {
this.db = db;
this.id = id;
}
@Override
public int getId() {
return this.id;
}
@Override
public long getTimestamp() {
synchronized (this.db) {
Cursor cursor = db.query(
"event",
new String[] { "timestamp" },
"id = ?",
new String[] { Integer.toString(this.getId()) },
null,
null,
null
);
return Utils.getLongAndClose(cursor, 0);
}
}
@Override
public void setTimestamp(long timestamp) {
synchronized (this.db) {
ContentValues cv = new ContentValues();
cv.put("timestamp", timestamp);
db.update(
"event",
cv,
"id = ?",
new String[] { Integer.toString(this.getId()) }
);
}
}
@Override
public String getComment() {
synchronized (this.db) {
Cursor cursor = db.query(
"event",
new String[] { "comment" },
"id = ?",
new String[] { Integer.toString(this.getId()) },
null,
null,
null
);
return Utils.getStringAndClose(cursor, null);
}
}
@Override
public void setComment(String comment) {
synchronized (this.db) {
ContentValues cv = new ContentValues();
cv.put("comment", comment);
db.update(
"event",
cv,
"id = ?",
new String[] { Integer.toString(this.getId()) }
);
}
}
/**
* !synchronized
*/
protected boolean hasTag(Tag tag) {
synchronized (this.db) {
Cursor cursor = db.query(
"event_tag",
new String[] { "1" },
"event_id = ? AND tag_id = ?",
new String[] {
Integer.toString(this.getId()), Integer.toString(tag.getId())
},
null,
null,
null
);
return Utils.findResultAndClose(cursor);
}
}
@Override
public void addTag(Tag tag) {
synchronized (this.db) {
this.cachedTags = null;
if (tag == null) return;
if (this.hasTag(tag)) return;
try {
ContentValues cv = new ContentValues();
cv.put("event_id", this.getId());
cv.put("tag_id", tag.getId());
db.insertOrThrow("event_tag", null, cv);
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
}
}
@Override
public void removeTag(Tag tag) {
synchronized (this.db) {
this.cachedTags = null;
if (tag == null) return;
if (!this.hasTag(tag)) return;
try {
db.delete("event_tag", "event_id = ? AND tag_id = ?", new String[] {
Integer.toString(this.getId()), Integer.toString(tag.getId())
});
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
}
}
@Override
public void removeTags() {
synchronized (this.db) {
this.cachedTags = null;
try {
db.delete("event_tag", "event_id = ?", new String[] { Integer.toString(this.getId()) });
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
}
}
@Override
public Tag[] getTags() {
synchronized (this.db) {
if (this.cachedTags != null)
return this.cachedTags;
Cursor cursor = db.query(
"event_tag",
new String[] { "tag_id" },
"event_id = ?",
new String[] { Integer.toString(this.getId()) },
null,
null,
"tag_id desc"
);
if (cursor == null) {
return new Tag[0];
}
Tag[] tags = new Tag[cursor.getCount()];
int index = 0;
while (cursor.moveToNext()) {
tags[index++] = new TagImpl(this.db, cursor.getInt(0));
}
cursor.close();
return this.cachedTags = tags;
}
}
@NonNull
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Event{id=");
sb.append(this.getId());
sb.append(",timestamp=");
sb.append(this.getTimestamp());
sb.append(",comment=");
sb.append(this.getComment());
sb.append("}");
return sb.toString();
}
}

View file

@ -0,0 +1,106 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.util.Log;
import art.pegasko.yeeemp.base.Event;
import art.pegasko.yeeemp.base.EventMaker;
import art.pegasko.yeeemp.base.Queue;
public class EventMakerImpl implements EventMaker {
public static final String TAG = EventMakerImpl.class.getSimpleName();
private SQLiteDatabase db;
public EventMakerImpl(SQLiteDatabase db) {
this.db = db;
}
@Override
public Event getById(int id) {
synchronized (this.db) {
try {
Cursor cursor = db.query(
"event",
new String[] { "1" },
"id = ?",
new String[] { Integer.toString(id) },
null,
null,
null
);
if (Utils.findResultAndClose(cursor)) {
return new EventImpl(this.db, id);
}
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
return null;
}
}
@Override
public Event create() {
synchronized (this.db) {
try {
ContentValues cv = new ContentValues();
cv.put("id", (Integer) null);
long rowId = db.insertOrThrow("event", null, cv);
return new EventImpl(this.db, (int) rowId);
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
return null;
}
}
@Override
public void delete(Event event) {
synchronized (this.db) {
try {
// Delete queue <-> event
db.delete("queue_event", "event_id = ?", new String[] { Integer.toString(event.getId()) });
// Delete event <-> tag
db.delete("event_tag", "event_id = ?", new String[] { Integer.toString(event.getId()) });
// Delete event
db.delete("event", "id = ?", new String[] { Integer.toString(event.getId()) });
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
}
}
}

View file

@ -0,0 +1,41 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.Context;
import art.pegasko.yeeemp.base.Wrapper;
public class Init {
public static void initDB(Context context) {
if (Wrapper.instance() == null)
Wrapper.setInstance(new DBWrapper(context));
}
public static void reinitDB(Context context) {
Wrapper.setInstance(new DBWrapper(context));
}
}

View file

@ -0,0 +1,295 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.util.Log;
import androidx.annotation.NonNull;
import art.pegasko.yeeemp.base.Event;
import art.pegasko.yeeemp.base.EventOrder;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.TagStat;
public class QueueImpl implements Queue {
public static final String TAG = QueueImpl.class.getSimpleName();
private final SQLiteDatabase db;
private final int id;
protected QueueImpl(SQLiteDatabase db, int id) {
this.db = db;
this.id = id;
}
@Override
public int getId() {
return this.id;
}
@Override
public String getName() {
synchronized (this.db) {
Cursor cursor = db.query(
"queue",
new String[] { "name" },
"id = ?",
new String[] { Integer.toString(this.getId()) },
null,
null,
null
);
return Utils.getStringAndClose(cursor, null);
}
}
@Override
public void setName(String name) {
synchronized (this.db) {
ContentValues cv = new ContentValues();
cv.put("name", name);
db.update(
"queue",
cv,
"id = ?",
new String[] { Integer.toString(this.getId()) }
);
}
}
@Override
public Event[] getEvents(EventOrder.Order order) {
synchronized (this.db) {
Cursor cursor;
// Requires JOIN
if ((order == EventOrder.Order.TIMESTAMP_ASC) || (order == EventOrder.Order.TIMESTAMP_DESC)) {
String query = (
"select\n" +
" queue_event.event_id\n" +
"from\n" +
" queue_event\n" +
"left join\n" +
" event\n" +
"on\n" +
" queue_event.event_id = event.id\n" +
"where\n" +
" queue_event.queue_id = ?\n" +
"order by\n" +
" timestamp "
);
if (order == EventOrder.Order.TIMESTAMP_ASC) {
query += "asc";
} else {
query += "desc";
}
cursor = db.rawQuery(
query,
new String[] { Integer.toString(this.getId()) }
);
} else {
cursor = db.query(
"queue_event",
new String[] { "event_id" },
"queue_id = ?",
new String[] { Integer.toString(this.getId()) },
null,
null,
( order == EventOrder.Order.ID_ASC ?
"event_id asc" :
( order == EventOrder.Order.ID_DESC ?
"event_id desc" :
null
))
);
}
if (cursor == null) {
return new Event[0];
}
Event[] events = new Event[cursor.getCount()];
int index = 0;
while (cursor.moveToNext()) {
events[index++] = new EventImpl(this.db, cursor.getInt(0));
}
cursor.close();
return events;
}
}
@Override
public int getEventCount() {
synchronized (this.db) {
Cursor cursor = db.query(
"queue_event",
new String[] { "count(*)" },
"queue_id = ?",
new String[] { Integer.toString(this.getId()) },
null,
null,
null
);
return Utils.getIntAndClose(cursor, 0);
}
}
/**
* !synchronized
*/
protected boolean hasEvent(Event event) {
synchronized (this.db) {
Cursor cursor = db.query(
"queue_event",
new String[] { "1" },
"queue_id = ? AND event_id = ?",
new String[] { Integer.toString(this.getId()), Integer.toString(event.getId()) },
null,
null,
null
);
return Utils.findResultAndClose(cursor);
}
}
@Override
public void addEvent(Event event) {
synchronized (this.db) {
if (event == null) return;
if (this.hasEvent(event)) return;
try {
ContentValues cv = new ContentValues();
cv.put("queue_id", this.getId());
cv.put("event_id", event.getId());
db.insertOrThrow("queue_event", null, cv);
} catch (SQLiteException e) {
Log.w(TAG, e);
}
}
}
@Override
public void removeEvent(Event event) {
synchronized (this.db) {
if (event == null) return;
if (this.hasEvent(event)) return;
try {
db.delete(
"queue_event",
"queue_id = ? AND event_id = ?",
new String[] { Integer.toString(this.getId()), Integer.toString(event.getId()) }
);
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
}
}
@Override
public TagStat[] getGlobalTags() {
synchronized (this.db) {
Cursor cursor = db.rawQuery(
"select" +
" tag_id,\n" +
" count(*) as cnt\n" +
"from (\n" +
" select\n" +
" event_id,\n" +
" tag_id\n" +
" from (\n" +
" select\n" +
" event_tag.event_id as event_id,\n" +
" event_tag.tag_id as tag_id\n" +
" from (\n" +
" select\n" +
" event_id\n" +
" from\n" +
" queue_event\n" +
" where\n" +
" queue_id = ?\n" +
" ) as queue_event_temp\n" +
" inner join\n" +
" event_tag\n" +
" on\n" +
" (event_tag.event_id = queue_event_temp.event_id)\n" +
" )\n" +
" group by\n" +
" event_id,\n" +
" tag_id\n" +
")\n" +
"group by\n" +
" tag_id\n" +
"order by\n" +
" cnt desc",
new String[] { Integer.toString(this.getId()) }
);
if (cursor == null) {
return new TagStat[0];
}
TagStat[] tags = new TagStat[cursor.getCount()];
int index = 0;
while (cursor.moveToNext()) {
TagStat tagStat = new TagStat();
tags[index++] = tagStat;
tagStat.tag = new TagImpl(this.db, cursor.getInt(0));
tagStat.count = cursor.getInt(1);
}
return tags;
}
}
@NonNull
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Queue{id=");
sb.append(this.getId());
sb.append(",name=");
sb.append(this.getName());
sb.append("}");
return sb.toString();
}
}

View file

@ -0,0 +1,155 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.util.Log;
import art.pegasko.yeeemp.base.Event;
import art.pegasko.yeeemp.base.EventOrder;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.QueueMaker;
import art.pegasko.yeeemp.base.QueueOrder;
public class QueueMakerImpl implements QueueMaker {
public static final String TAG = EventMakerImpl.class.getSimpleName();
private SQLiteDatabase db;
public QueueMakerImpl(SQLiteDatabase db) {
this.db = db;
}
@Override
public Queue getById(int id) {
synchronized (this.db) {
try {
Cursor cursor = db.query(
"queue",
new String[] { "1" },
"id = ?",
new String[] { Integer.toString(id) },
null,
null,
null
);
if (Utils.findResultAndClose(cursor)) {
return new QueueImpl(this.db, id);
}
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
return null;
}
}
@Override
public Queue create() {
synchronized (this.db) {
try {
ContentValues cv = new ContentValues();
cv.put("id", (Integer) null);
long rowId = db.insertOrThrow("queue", null, cv);
return new QueueImpl(this.db, (int) rowId);
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
return null;
}
}
@Override
public Queue[] list(QueueOrder.Order order) {
synchronized (this.db) {
Cursor cursor = db.query(
"queue",
new String[] { "id" },
null,
null,
null,
null,
( order == QueueOrder.Order.ID ?
"rowid" :
( order == QueueOrder.Order.NAME ?
"name" :
null
))
);
if (cursor == null) {
return new Queue[0];
}
Queue[] queues = new Queue[cursor.getCount()];
int index = 0;
while (cursor.moveToNext()) {
queues[index++] = new QueueImpl(this.db, cursor.getInt(0));
}
cursor.close();
return queues;
}
}
@Override
public void delete(Queue queue) {
synchronized (this.db) {
// Drop events
try {
// TODO: Foreign key for cascade delete
for (Event event : queue.getEvents(EventOrder.Order.ID_DESC)) {
db.delete("event", "id = ?", new String[] { Integer.toString(event.getId()) });
}
} catch (SQLiteException e) {
Log.wtf(TAG, e);
return;
}
// Drop queue <-> event
try {
db.delete("queue_event", "queue_id = ?", new String[] { Integer.toString(queue.getId()) });
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
// Drop queue
try {
db.delete("queue", "id = ?", new String[] { Integer.toString(queue.getId()) });
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
}
}
}

View file

@ -0,0 +1,89 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import androidx.annotation.NonNull;
import art.pegasko.yeeemp.base.Tag;
import art.pegasko.yeeemp.base.Queue;
public class TagImpl implements Tag {
public static final String TAG = TagImpl.class.getSimpleName();
private final SQLiteDatabase db;
private final int id;
private String _cached_name;
protected TagImpl(SQLiteDatabase db, int id) {
this.db = db;
this.id = id;
}
@Override
public int getId() {
return this.id;
}
@Override
public String getName() {
synchronized (this.db) {
if (this._cached_name != null)
return this._cached_name;
Cursor cursor = db.query(
"tag",
new String[] { "name" },
"id = ?",
new String[] { Integer.toString(this.getId()) },
null,
null,
null
);
String result = Utils.getStringAndClose(cursor, null);
if (result != null) {
return this._cached_name = result;
}
return null;
}
}
@NonNull
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Tag{id=");
sb.append(this.getId());
sb.append(",name=");
sb.append(this.getName());
sb.append("}");
return sb.toString();
}
}

View file

@ -0,0 +1,105 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.util.Log;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.Tag;
import art.pegasko.yeeemp.base.TagMaker;
public class TagMakerImpl implements TagMaker {
public static final String TAG = TagMakerImpl.class.getSimpleName();
private SQLiteDatabase db;
public TagMakerImpl(SQLiteDatabase db) {
this.db = db;
}
/* !synchronized */
private Tag getExisting(Queue queue, String name) {
try {
Cursor cursor = db.query(
"tag",
new String[] { "id", "name" },
"queue_id = ? AND name = ?",
new String[] { Integer.toString(queue.getId()), name },
null,
null,
null
);
int id = Utils.getIntAndClose(cursor, -1);
if (id != -1) {
return new TagImpl(
db,
id
);
}
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
return null;
}
/* !synchronized */
private boolean create(Queue queue, String name) {
try {
ContentValues cv = new ContentValues();
cv.put("queue_id", queue.getId());
cv.put("name", name);
db.insertOrThrow("tag", null, cv);
} catch (SQLiteException e) {
Log.wtf(TAG, e);
return false;
}
return true;
}
@Override
public Tag getOrCreateInQueue(Queue queue, String name) {
synchronized (db) {
name = name.trim().toLowerCase();
// Try get existing
Tag existingTag = getExisting(queue, name);
if (existingTag != null)
return existingTag;
// Create new
create(queue, name);
// Finally get
return getExisting(queue, name);
}
}
}

View file

@ -0,0 +1,113 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.impl;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public class Utils {
public static boolean findResultAndClose(Cursor cursor) {
if (cursor == null)
return false;
boolean hasResult = cursor.moveToFirst();
if (!hasResult) {
cursor.close();
return false;
}
boolean result = cursor.getCount() != 0;
cursor.close();
return result;
}
public static int getIntAndClose(Cursor cursor, int def) {
if (cursor == null)
return def;
boolean hasResult = cursor.moveToFirst();
if (!hasResult) {
cursor.close();
return def;
}
if (cursor.getCount() == 0) {
cursor.close();
return def;
}
int result = cursor.getInt(0);
cursor.close();
return result;
}
public static long getLongAndClose(Cursor cursor, long def) {
if (cursor == null)
return def;
boolean hasResult = cursor.moveToFirst();
if (!hasResult) {
cursor.close();
return def;
}
if (cursor.getCount() == 0) {
cursor.close();
return def;
}
long result = cursor.getLong(0);
cursor.close();
return result;
}
public static String getStringAndClose(Cursor cursor, String def) {
if (cursor == null)
return def;
boolean hasResult = cursor.moveToFirst();
if (!hasResult) {
cursor.close();
return def;
}
if (cursor.getCount() == 0) {
cursor.close();
return def;
}
String result = cursor.getString(0);
cursor.close();
return result;
}
}

View file

@ -0,0 +1,55 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.okand.base;
import java.util.ArrayList;
import java.util.List;
import art.pegasko.yeeemp.base.Tag;
public class Event {
private int id;
private String comment;
private List<Tag> tags;
public Event() {
this.id = -1;
this.comment = null;
this.tags = new ArrayList<Tag>();
}
void setId(int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public static Event get(int id) {
return Potato.getInstance().getById(id);
}
}

View file

@ -0,0 +1,44 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.okand.base;
public abstract class Potato {
private static Potato instance;
public static Potato getInstance() {
return Potato.instance;
}
public void setInstance(Potato instance) {
Potato.instance = instance;
}
public abstract Event getById(int id);
public abstract void save(Event container);
public abstract void delete(Event container);
}

View file

@ -0,0 +1,46 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.okand.impl;
import art.pegasko.yeeemp.okand.base.Event;
import art.pegasko.yeeemp.okand.base.Potato;
public class DBPotato extends Potato {
@Override
public Event getById(int id) {
return null;
}
@Override
public void save(Event container) {
}
@Override
public void delete(Event container) {
}
}

View file

@ -0,0 +1,30 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
public class Common {
public static final String PREFS_NAME = "preferences";
}

View file

@ -0,0 +1,294 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.util.TimeUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.MultiAutoCompleteTextView;
import android.widget.TextView;
import android.widget.TimePicker;
import com.google.android.material.snackbar.Snackbar;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.Tag;
import art.pegasko.yeeemp.base.TagStat;
import art.pegasko.yeeemp.databinding.ActivityEventEditBinding;
import art.pegasko.yeeemp.R;
import art.pegasko.yeeemp.base.Event;
import art.pegasko.yeeemp.base.Wrapper;
import art.pegasko.yeeemp.impl.Init;
public class EventEditActivity extends AppCompatActivity {
public static final String TAG = EventEditActivity.class.getSimpleName();
private Queue queue;
private Event event;
private EventContainer eventContainer;
private ActivityEventEditBinding binding;
private TagStat[] tagStat;
/**
* Store values for edited or new event
*/
private static class EventContainer {
public String comment;
public long timestamp;
public ArrayList<String> tags;
public EventContainer() {
this.timestamp = System.currentTimeMillis();
this.tags = new ArrayList<String>();
this.comment = null;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Init.initDB(getApplicationContext());
// Get Queue ID from Intent
Bundle extras = getIntent().getExtras();
if (extras == null) {
Log.e(TAG, "Missing Intent arguments (queue_id)");
finish();
return;
}
int queue_id = extras.getInt("queue_id", -1);
if (queue_id == -1) {
Log.e(TAG, "Missing Intent arguments (queue_id)");
finish();
return;
}
queue = Wrapper.getQueueMaker().getById(queue_id);
if (queue == null) {
Log.e(TAG, "Missing Intent arguments (queue_id)");
finish();
return;
}
// New edit container
this.eventContainer = new EventContainer();
// Get Event ID from Intent (optional)
extras = getIntent().getExtras();
if (extras != null) {
int event_id = extras.getInt("event_id", -1);
if (event_id != -1) {
this.event = Wrapper.getEventMaker().getById(event_id);
this.eventContainer.timestamp = this.event.getTimestamp();
this.eventContainer.comment = this.event.getComment();
for (Tag tag : this.event.getTags()) {
this.eventContainer.tags.add(tag.getName());
}
}
}
binding = ActivityEventEditBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
getSupportActionBar().setTitle(queue.getName() + " / " + (event == null ? "Create" : "Edit") + " Event");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
if (this.eventContainer.timestamp != 0)
binding.eventEditContent.eventEditTimestamp.setText(Utils.formatTs(this.eventContainer.timestamp));
if (this.eventContainer.comment != null)
binding.eventEditContent.eventEditComment.setText(this.eventContainer.comment);
/* Comment Listeners */
// Request focus on click
this.binding.eventEditContent.eventEditContainerComment.setOnClickListener((View view) -> {
EventEditActivity.this.binding.eventEditContent.eventEditComment.requestFocus();
EventEditActivity.this.binding.eventEditContent.eventEditComment.setSelection(EventEditActivity.this.binding.eventEditContent.eventEditComment.getText().length());
InputMethodManager imm = (InputMethodManager) EventEditActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(EventEditActivity.this.binding.eventEditContent.eventEditComment, InputMethodManager.SHOW_IMPLICIT);
});
/* Timestamp Listeners */
binding.eventEditContent.eventEditContainerTimestamp.setOnClickListener((View view) -> {
Date date;
if (this.eventContainer.timestamp != 0) date = new Date(this.eventContainer.timestamp);
else date = new Date();
DatePickerDialog datePickerDialog = new DatePickerDialog(
view.getContext(),
(DatePicker datePicker, int year, int month, int day) -> {
TimePickerDialog timePickerDialog = new TimePickerDialog(
view.getContext(),
(TimePicker timePicker, int hour, int minute) -> {
Date newDate = new Date();
newDate.setYear(
year - 1900);
newDate.setMonth(
month);
newDate.setDate(
day);
newDate.setHours(
hour);
newDate.setMinutes(
minute);
newDate.setSeconds(
0);
this.eventContainer.timestamp = newDate.getTime();
binding.eventEditContent.eventEditTimestamp.setText(
Utils.formatTs(
this.eventContainer.timestamp));
},
date.getHours(),
date.getMinutes(),
true
);
timePickerDialog.show();
},
date.getYear() + 1900,
date.getMonth(),
date.getDate()
);
datePickerDialog.show();
});
/* FAB Listeners */
binding.fab.setOnLongClickListener((View view) -> {
Snackbar.make(view, "Save Event", Snackbar.LENGTH_LONG).setAnchorView(R.id.fab).setAction(
"Action",
null
).show();
return true;
});
binding.fab.setOnClickListener(view -> {
Utils.hapticTick(view);
// Finalize values
this.eventContainer.comment = this.binding.eventEditContent.eventEditComment.getText().toString().trim();
String[] tags = EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().toString().split(",");
tags = Utils.orderedDeduplicateIgnoreCaseAndTrim(tags);
this.eventContainer.tags.clear();
for (String tag : tags) {
this.eventContainer.tags.add(tag);
}
// Fill event
boolean hasEvent = this.event != null;
if (this.event == null) this.event = Wrapper.getEventMaker().create();
this.event.setTimestamp(this.eventContainer.timestamp);
this.event.removeTags();
for (String tag : this.eventContainer.tags) {
this.event.addTag(Wrapper.getTagMaker().getOrCreateInQueue(this.queue, tag));
}
this.event.setComment(this.eventContainer.comment);
if (!hasEvent) {
this.queue.addEvent(event);
}
finish();
});
/* Tags list + input */
this.tagStat = this.queue.getGlobalTags();
ArrayAdapter<TagStat> adapter = new EventEditTagsAdapter(
this,
android.R.layout.simple_dropdown_item_1line,
0,
new ArrayList<>(Arrays.asList(this.tagStat))
);
this.binding.eventEditContent.eventEditTags.setAdapter(adapter);
this.binding.eventEditContent.eventEditTags.setThreshold(1);
this.binding.eventEditContent.eventEditTags.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
this.binding.eventEditContent.eventEditTags.setOnItemClickListener((parent, view, position, id) -> {
String[] tags = EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().toString().split(",");
tags = Utils.orderedDeduplicateIgnoreCaseAndTrim(tags);
EventEditActivity.this.binding.eventEditContent.eventEditTags.setText(String.join(", ", tags) + ", ");
EventEditActivity.this.binding.eventEditContent.eventEditTags.setSelection(EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().length());
});
// Request focus on click
this.binding.eventEditContent.eventEditContainerTags.setOnClickListener((View view) -> {
this.binding.eventEditContent.eventEditTags.requestFocus();
this.binding.eventEditContent.eventEditTags.setSelection(EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().length());
InputMethodManager imm = (InputMethodManager) EventEditActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(EventEditActivity.this.binding.eventEditContent.eventEditTags, InputMethodManager.SHOW_IMPLICIT);
});
// Fill
this.binding.eventEditContent.eventEditTags.setText(String.join(", ", this.eventContainer.tags));
this.binding.eventEditContent.eventEditTags.setSelection(EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().length());
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
}

View file

@ -0,0 +1,242 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.TextView;
import java.util.ArrayList;
import art.pegasko.yeeemp.base.Tag;
import art.pegasko.yeeemp.base.TagStat;
public class EventEditTagsAdapter extends ArrayAdapter<TagStat> {
public static final String TAG = EventEditTagsAdapter.class.getSimpleName();
private ArrayList<TagStat> tags; // used by parent as container for filtered elements, changes as suer types
private ArrayList<TagStat> tagsAll; // used as container with backup of all unfiltered tags, does not change
private LayoutInflater inflater;
private final int viewResourceId;
private final int viewFieldId;
public EventEditTagsAdapter(Context context, int viewResourceId, int viewFieldId, ArrayList<TagStat> tags) {
super(context, viewResourceId, tags);
this.tags = tags;
this.tagsAll = (ArrayList<TagStat>) tags.clone();
this.viewResourceId = viewResourceId;
this.viewFieldId = viewFieldId;
this.inflater = LayoutInflater.from(context);
}
public View getView(int position, View tagView, ViewGroup parent) {
if (tagView == null)
tagView = inflater.inflate(this.viewResourceId, parent, false);
TextView text;
try {
if (this.viewFieldId == 0) {
text = (TextView) tagView;
} else {
text = tagView.findViewById(this.viewFieldId);
}
if (text == null) {
Log.e(TAG, "Failed attach text to view");
throw new RuntimeException("Failed attach text to view");
}
} catch (ClassCastException e) {
Log.e(TAG, "You must supply a resource ID for a TextView");
throw new RuntimeException("You must supply a resource ID for a TextView");
}
text.setText(tags.get(position).tag.getName() + " (" + tags.get(position).count + ")");
return tagView;
}
@Override
public Filter getFilter() {
return nameFilter;
}
private Filter nameFilter = new Filter() {
// TODO: Stop using mutable global
// Reusable filter result
private ArrayList<TagStat> tagsSuggestions = new ArrayList<TagStat>();
private String prevConstraint = null;
@Override
public String convertResultToString(Object resultValue) {
return ((TagStat) (resultValue)).tag.getName();
}
/**
* Check if constraint is reducing previous.
*
* Constraint (C) reduces previous (P) if `len(C) >= len(P)` and `C.startsWith(P)`.
*
* This is means that user has typed some text to the end of input field and matching items can be filtered
* from previous filter result.
* In the opposite case, the set of matching items grows and required full rebuild from scratch.
*/
private boolean checkIfPossibleReduceToConstraint(String prevConstraint, String constraint) {
if (prevConstraint == null)
return false;
return (constraint.length() >= prevConstraint.length()) && (constraint.startsWith(prevConstraint));
}
private String makeConstraintFromUserInput(CharSequence userInput) {
return userInput.toString().toLowerCase().trim();
}
private boolean hasChangedConstraint(String prevConstraint, String newConstraint) {
if (prevConstraint == null || newConstraint == null)
return true;
return !prevConstraint.equals(newConstraint);
}
private void reduceTagsSuggestions(TagMatcher matcher) {
for (int index = 0; index < tagsSuggestions.size(); ) {
if (!matcher.isMatch(tagsSuggestions.get(index).tag))
tagsSuggestions.remove(index);
else
index += 1;
}
}
private void filterTagsSuggestions(TagMatcher matcher) {
tagsSuggestions.clear();
for (TagStat tag : tagsAll) {
if (matcher.isMatch(tag.tag)) {
tagsSuggestions.add(tag);
}
}
}
private void prepareTagsSuggestions(CharSequence constraint) {
String newConstraint = makeConstraintFromUserInput(constraint);
TagMatcher matcher = new TagMatcher(newConstraint);
// TODO: Use better search strategy and optimize search in non-reducing mode
if (hasChangedConstraint(prevConstraint, newConstraint)) {
if (checkIfPossibleReduceToConstraint(prevConstraint, newConstraint))
reduceTagsSuggestions(matcher);
else
filterTagsSuggestions(matcher);
prevConstraint = newConstraint;
}
}
private void resetTagsSuggestions() {
prevConstraint = null;
tagsSuggestions.clear();
}
private FilterResults makeFilterResults() {
FilterResults filterResults = new FilterResults();
// TODO: Spank me for using global mutable instance for returning immutable result (causes concurrent modification when publishResults())
filterResults.values = tagsSuggestions;
filterResults.count = tagsSuggestions.size();
return filterResults;
}
private FilterResults makeEmptyFilterResults() {
return new FilterResults();
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
synchronized (this) {
if (constraint != null) {
prepareTagsSuggestions(constraint);
return makeFilterResults();
} else {
resetTagsSuggestions();
return makeEmptyFilterResults();
}
}
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
synchronized (this) {
if (results == null)
return;
if (results.values == null) {
clear();
notifyDataSetChanged();
return;
}
// TODO: Do not republish results if no data changed
ArrayList<TagStat> filteredList = (ArrayList<TagStat>) results.values;
clear();
for (TagStat c : filteredList) {
add(c);
}
notifyDataSetChanged();
}
}
/**
* Matcher to filter tags based on user-input constraint
*/
class TagMatcher {
private final String[] constraintParts;
public TagMatcher(String constraint) {
this.constraintParts = constraint.split(" +");
}
public boolean isMatch(Tag tag) {
String tagName = tag.getName();
int lastIndex = 0;
for (String seq : constraintParts) {
if (lastIndex >= tagName.length())
return false;
int newIndex = tagName.indexOf(seq, lastIndex);
if (newIndex == -1)
return false;
lastIndex = newIndex + seq.length();
}
return true;
}
}
};
}

View file

@ -0,0 +1,249 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar;
import java.util.Objects;
import art.pegasko.yeeemp.R;
import art.pegasko.yeeemp.base.EventOrder;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.Wrapper;
import art.pegasko.yeeemp.databinding.ActivityEventListBinding;
import art.pegasko.yeeemp.impl.Init;
public class EventListActivity extends AppCompatActivity {
public static final String TAG = EventListActivity.class.getSimpleName();
private static final String PREFS_UI_EVENT_ORDER = "ui-event-order";
private static final String PREFS_UI_EVENT_ORDER_DEFAULT = "id_desc";
private ActivityEventListBinding binding;
private RecyclerView eventList;
private EventRecyclerViewAdapter eventListAdapter;
private Queue queue;
private void updateList() {
runOnUiThread(() -> {
eventListAdapter.reloadItems();
});
}
private CharSequence getEventOrderDisplayString(@Nullable EventOrder.Order order) {
if (order == null) {
throw new RuntimeException("Order is null");
}
switch (order) {
case ID_ASC:
return "created ascending";
case ID_DESC:
return "created descending";
case TIMESTAMP_ASC:
return "date ascending";
case TIMESTAMP_DESC:
return "date descending";
default:
throw new RuntimeException("Not implemented for " + order);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Init.initDB(getApplicationContext());
// Get Queue ID from Intent
Bundle extras = getIntent().getExtras();
if (extras == null) {
Log.e(TAG, "Missing Intent arguments (queue_id)");
finish();
return;
}
int queue_id = extras.getInt("queue_id", -1);
if (queue_id == -1) {
Log.e(TAG, "Missing Intent arguments (queue_id)");
finish();
return;
}
queue = Wrapper.getQueueMaker().getById(queue_id);
if (queue == null) {
Log.e(TAG, "Missing Intent arguments (queue_id)");
finish();
return;
}
/* Bindings */
binding = ActivityEventListBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
getSupportActionBar().setTitle(getSupportActionBar().getTitle() + " / " + queue.getName());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
/* Menu handlers */
binding.toolbar.setOnMenuItemClickListener((MenuItem item) -> {
if (item.getItemId() == R.id.event_list_toolbar_menu_order) {
/* Get some options */
SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(Common.PREFS_NAME, MODE_PRIVATE);
EventOrder.Order order = EventOrder.orderFromString(prefs.getString(PREFS_UI_EVENT_ORDER, PREFS_UI_EVENT_ORDER_DEFAULT));
/* Construct options */
EventOrder.Order[] values = EventOrder.Order.class.getEnumConstants();
if (values == null) {
// How did we get here?
throw new RuntimeException("EventOrder.Order.class.getEnumConstants() is Empty");
}
CharSequence[] choices = new CharSequence[values.length];
int currentSelection = -1;
for (int i = 0; i < values.length; ++i) {
choices[i] = this.getEventOrderDisplayString(values[i]);
if (values[i] == order) {
currentSelection = i;
}
}
/* Build dialog */
AlertDialog.Builder builder = new AlertDialog.Builder(EventListActivity.this);
builder.setTitle("Order by ..");
builder.setSingleChoiceItems(
choices,
currentSelection,
(dialog, which) -> {
EventOrder.Order newOrder = values[which];
// Save option
prefs.edit().putString(PREFS_UI_EVENT_ORDER, EventOrder.orderToString(newOrder)).apply();
// Apply
EventListActivity.this.invalidateOptionsMenu();
eventListAdapter.setOrder(newOrder);
runOnUiThread(() -> {
eventListAdapter.reloadItems();
});
// Close dialog
dialog.dismiss();
}
);
builder.show();
return true;
}
return false;
});
/* Get some options */
SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(Common.PREFS_NAME, MODE_PRIVATE);
EventOrder.Order order = EventOrder.orderFromString(prefs.getString(PREFS_UI_EVENT_ORDER, PREFS_UI_EVENT_ORDER_DEFAULT));
/* Queue list */
eventListAdapter = new EventRecyclerViewAdapter(queue);
eventListAdapter.setOrder(order);
eventList = findViewById(R.id.content_event_list__list);
eventList.setLayoutManager(new LinearLayoutManager(this));
eventList.setAdapter(eventListAdapter);
/* FAB Listeners */
binding.fab.setOnLongClickListener((View view) -> {
Snackbar.make(view, "Create Event", Snackbar.LENGTH_LONG).setAnchorView(R.id.fab).setAction(
"Action",
null
).show();
return true;
});
binding.fab.setOnClickListener(view -> {
Utils.hapticTick(view);
Bundle extra = new Bundle();
extra.putInt("queue_id", this.queue.getId());
Intent intent = new Intent(view.getContext(), EventEditActivity.class);
intent.putExtras(extra);
view.getContext().startActivity(intent);
});
/* Fill lists */
updateList();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.event_list_toolbar_menu, menu);
/* Get some options */
SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(Common.PREFS_NAME, MODE_PRIVATE);
EventOrder.Order order = EventOrder.orderFromString(prefs.getString(PREFS_UI_EVENT_ORDER, PREFS_UI_EVENT_ORDER_DEFAULT));
// Set item text based on sort mode
MenuItem item = menu.findItem(R.id.event_list_toolbar_menu_order);
item.setTitle(Objects.requireNonNull(item.getTitle()).toString() + ": " + getEventOrderDisplayString(order).toString());
return true;
}
@Override
protected void onResume() {
super.onResume();
/* Ekchualle we returned from somewhere */
updateList();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
}

View file

@ -0,0 +1,175 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupMenu;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.concurrent.Executors;
import art.pegasko.yeeemp.R;
import art.pegasko.yeeemp.base.Event;
import art.pegasko.yeeemp.base.EventOrder;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.Tag;
import art.pegasko.yeeemp.base.Wrapper;
import art.pegasko.yeeemp.databinding.EventListItemBinding;
class EventRecyclerViewAdapter extends RecyclerView.Adapter<EventRecyclerViewAdapter.ViewHolder> {
public static final String TAG = EventRecyclerViewAdapter.class.getSimpleName();
private final Queue queue;
private Event[] events;
private EventOrder.Order order;
public EventRecyclerViewAdapter(Queue queue) {
super();
this.queue = queue;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
View view = (
LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.event_list_item, viewGroup, false)
);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
viewHolder.getBinding().eventListItemTags.removeAllViews();
Tag[] tags = this.events[position].getTags();
for (Tag tag : tags) {
TextView tagView = (TextView) (
LayoutInflater.from(viewHolder.getBinding().getRoot().getContext()).inflate(
R.layout.event_list_item_tag,
null,
false
)
);
tagView.setText(tag.getName());
viewHolder.getBinding().eventListItemTags.addView(tagView);
}
viewHolder.getBinding().eventListItemTimestamp.setText(Utils.formatTs(events[position].getTimestamp()));
String comment = events[position].getComment();
if (comment != null && !comment.isEmpty()) {
viewHolder.getBinding().eventListItemComment.setVisibility(View.VISIBLE);
viewHolder.getBinding().eventListItemComment.setText(comment);
} else {
viewHolder.getBinding().eventListItemComment.setVisibility(View.GONE);
viewHolder.getBinding().eventListItemComment.setText("");
}
viewHolder.getBinding().eventListItemItem.setOnLongClickListener((View view) -> {
PopupMenu popupMenu = new PopupMenu(view.getContext(), viewHolder.getBinding().eventListItemItem);
popupMenu.getMenuInflater().inflate(R.menu.event_list_item_action_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener((MenuItem menuItem) -> {
if (menuItem.getItemId() == R.id.event_list_item_action_menu_delete) {
new AlertDialog.Builder(view.getContext()).setTitle("Delete event").setMessage(
"Are you sure you want to delete this event?").setPositiveButton(
android.R.string.yes,
(dialog, which) -> {
Wrapper.getEventMaker().delete(
events[position]);
reloadItems();
}
).setNegativeButton(
android.R.string.no,
null
).setIcon(android.R.drawable.ic_dialog_alert).show();
}
return true;
});
popupMenu.show();
return true;
});
viewHolder.getBinding().eventListItemItem.setOnClickListener((View view) -> {
Utils.hapticTick(view);
Bundle extra = new Bundle();
extra.putInt("event_id", this.events[position].getId());
extra.putInt("queue_id", this.queue.getId());
Intent intent = new Intent(view.getContext(), EventEditActivity.class);
intent.putExtras(extra);
view.getContext().startActivity(intent);
});
}
@Override
public int getItemCount() {
return this.events.length;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
private EventListItemBinding binding;
public ViewHolder(@NonNull View itemView) {
super(itemView);
this.binding = EventListItemBinding.bind(itemView);
}
public EventListItemBinding getBinding() {
return this.binding;
}
}
public void reloadItems() {
Handler handler = new Handler(Looper.getMainLooper());
Executors.newSingleThreadExecutor().execute(() -> {
this.events = this.queue.getEvents(this.order);
handler.post(() -> {
this.notifyDataSetChanged();
});
});
}
public void setOrder(EventOrder.Order order) {
this.order = order;
}
}

View file

@ -0,0 +1,373 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import com.google.android.material.snackbar.Snackbar;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.Objects;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.QueueOrder;
import art.pegasko.yeeemp.base.Wrapper;
import art.pegasko.yeeemp.databinding.ActivityQueueListBinding;
import art.pegasko.yeeemp.R;
import art.pegasko.yeeemp.impl.DataUtils;
import art.pegasko.yeeemp.impl.Init;
public class QueueListActivity extends AppCompatActivity {
public static final String TAG = QueueListActivity.class.getSimpleName();
private static final int REQUEST_CODE_CREATE_FILE = 37;
private static final int REQUEST_CODE_OPEN_FILE = 19;
private static String PREFS_UI_QUEUE_ORDER = "ui-queue-order";
private static String PREFS_UI_QUEUE_ORDER_DEFAULT = "id";
private AppBarConfiguration appBarConfiguration;
private ActivityQueueListBinding binding;
private RecyclerView queueList;
private QueueRecyclerViewAdapter queueListAdapter;
private void updateList() {
runOnUiThread(() -> {
queueListAdapter.reloadItems();
});
}
private CharSequence getQueueOrderDisplayString(@Nullable QueueOrder.Order order) {
if (order == null) {
throw new RuntimeException("Order is null");
}
switch (order) {
case ID:
return "created";
case NAME:
return "name";
default:
throw new RuntimeException("Not implemented for " + order);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Init.initDB(getApplicationContext());
binding = ActivityQueueListBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
/* Toolbar menu */
binding.toolbar.inflateMenu(R.menu.queue_list_toolbar_menu);
// TODO: Better import / export / delete logic
binding.toolbar.setOnMenuItemClickListener((MenuItem item) -> {
if (item.getItemId() == R.id.queue_list_toolbar_menu_order) {
/* Get some options */
SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(Common.PREFS_NAME, MODE_PRIVATE);
QueueOrder.Order order = QueueOrder.orderFromString(prefs.getString(PREFS_UI_QUEUE_ORDER, PREFS_UI_QUEUE_ORDER_DEFAULT));
/* Construct options */
QueueOrder.Order[] values = QueueOrder.Order.class.getEnumConstants();
if (values == null) {
// How did we get here?
throw new RuntimeException("QueueOrder.Order.class.getEnumConstants() is Empty");
}
CharSequence[] choices = new CharSequence[values.length];
int currentSelection = -1;
for (int i = 0; i < values.length; ++i) {
choices[i] = this.getQueueOrderDisplayString(values[i]);
if (values[i] == order) {
currentSelection = i;
}
}
/* Build dialog */
AlertDialog.Builder builder = new AlertDialog.Builder(QueueListActivity.this);
builder.setTitle("Order by ..");
builder.setSingleChoiceItems(
choices,
currentSelection,
(dialog, which) -> {
QueueOrder.Order newOrder = values[which];
// Save option
prefs.edit().putString(PREFS_UI_QUEUE_ORDER, QueueOrder.orderToString(newOrder)).apply();
// Apply
QueueListActivity.this.invalidateOptionsMenu();
queueListAdapter.setOrder(newOrder);
runOnUiThread(() -> {
queueListAdapter.reloadItems();
});
// Close
dialog.dismiss();
}
);
builder.show();
return true;
} if (item.getItemId() == R.id.queue_list_toolbar_menu_export) {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_TITLE, "export_" + DataUtils.formatTs(System.currentTimeMillis()) + ".db");
startActivityForResult(intent, REQUEST_CODE_CREATE_FILE);
return true;
} else if (item.getItemId() == R.id.queue_list_toolbar_menu_import) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
startActivityForResult(intent, REQUEST_CODE_OPEN_FILE);
return true;
} else if (item.getItemId() == R.id.queue_list_toolbar_menu_delete) {
new AlertDialog
.Builder(QueueListActivity.this)
.setTitle("Confirm action")
.setMessage("Delete everything?")
.setCancelable(true)
.setPositiveButton("Yes", (DialogInterface dialog, int id) -> {
try {
Log.i(TAG, "Close before delete");
DataUtils.closeDatabase();
Log.i(TAG, "Deleting database");
DataUtils.deleteDatabase(getApplicationContext());
Log.i(TAG, "Reloading database");
Init.reinitDB(getApplicationContext());
updateList();
} catch (Exception e) {
Log.e(TAG, "Delete failed");
Log.wtf(TAG, e);
new AlertDialog
.Builder(QueueListActivity.this)
.setTitle("Delete failed")
.setMessage(e.getMessage())
.setCancelable(true)
.setNegativeButton("OK", (DialogInterface dialog2, int id2) -> { dialog2.cancel(); })
.show();
}
})
.setNegativeButton("Cancel", (DialogInterface dialog, int id) -> { dialog.cancel(); })
.show();
return true;
}
return false;
});
/* Get some options */
SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(Common.PREFS_NAME, MODE_PRIVATE);
QueueOrder.Order order = QueueOrder.orderFromString(prefs.getString(PREFS_UI_QUEUE_ORDER, PREFS_UI_QUEUE_ORDER_DEFAULT));
/* Queue list */
queueListAdapter = new QueueRecyclerViewAdapter();
queueListAdapter.setOrder(order);
queueList = findViewById(R.id.content_queue_list__list);
queueList.setLayoutManager(new LinearLayoutManager(this));
queueList.setAdapter(queueListAdapter);
/* FAB Listeners */
binding.fab.setOnLongClickListener((View view) -> {
Snackbar.make(view, "Create Queue", Snackbar.LENGTH_LONG).setAnchorView(R.id.fab).setAction(
"Action",
null
).show();
return true;
});
binding.fab.setOnClickListener(view -> {
Utils.hapticTick(view);
Queue q = Wrapper.getQueueMaker().create();
q.setName("New Queue");
updateList();
});
/* Fill lists */
updateList();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
super.onActivityResult(requestCode, resultCode, resultData);
if (requestCode == REQUEST_CODE_CREATE_FILE && resultCode == Activity.RESULT_OK) {
if (resultData != null) {
Uri uri = resultData.getData();
Log.i(TAG, "Exporting file to " + uri.toString());
try {
DataUtils.exportDatabase(getApplicationContext(), uri);
Toast.makeText(QueueListActivity.this, "Exported database", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.wtf(TAG, e);
new AlertDialog
.Builder(QueueListActivity.this)
.setTitle("Export failed")
.setMessage(e.getMessage())
.setCancelable(true)
.setNegativeButton("OK", (DialogInterface dialog, int id) -> { dialog.cancel(); })
.show();
}
}
} else if (requestCode == REQUEST_CODE_OPEN_FILE && resultCode == Activity.RESULT_OK) {
if (resultData != null) {
final Uri uri = resultData.getData();
new AlertDialog
.Builder(QueueListActivity.this)
.setTitle("Confirm action")
.setMessage("Import file as database? This will overwrite local database with external file without checking")
.setCancelable(true)
.setPositiveButton("Yes", (DialogInterface dialog, int id) -> {
Log.i(TAG, "Importing file from " + uri.toString());
try {
Log.i(TAG, "Close before restore");
DataUtils.closeDatabase();
Log.i(TAG, "Backup before restore");
DataUtils.backupDatabase(getApplicationContext());
Log.i(TAG, "Importing database");
DataUtils.importDatabase(getApplicationContext(), uri);
Toast.makeText(QueueListActivity.this, "Imported database", Toast.LENGTH_SHORT).show();
Log.i(TAG, "Reloading database");
Init.reinitDB(getApplicationContext());
updateList();
Log.i(TAG, "Delete backup");
DataUtils.deleteBackupDatabase(getApplicationContext());
} catch (Exception e) {
Log.e(TAG, "Import failed");
Log.wtf(TAG, e);
new AlertDialog
.Builder(QueueListActivity.this)
.setTitle("Import failed")
.setMessage(e.getMessage())
.setCancelable(true)
.setNegativeButton("OK", (DialogInterface dialog2, int id2) -> { dialog2.cancel(); })
.show();
try {
Log.i(TAG, "Trying to restore backup");
DataUtils.restoreDatabase(getApplicationContext());
Log.i(TAG, "Reloading database");
Init.reinitDB(getApplicationContext());
updateList();
Log.i(TAG, "Delete backup");
DataUtils.deleteBackupDatabase(getApplicationContext());
new AlertDialog
.Builder(QueueListActivity.this)
.setTitle("Info")
.setMessage("Restored backup")
.setCancelable(true)
.setNegativeButton("OK", (DialogInterface dialog2, int id2) -> { dialog2.cancel(); })
.show();
} catch (Exception e2) {
Log.e(TAG, "Restore backup failed");
Log.wtf(TAG, e2);
new AlertDialog
.Builder(QueueListActivity.this)
.setTitle("Restore backup failed")
.setMessage(e2.getMessage())
.setCancelable(true)
.setNegativeButton("OK", (DialogInterface dialog2, int id2) -> { dialog2.cancel(); })
.show();
}
}
})
.setNegativeButton("Cancel", (DialogInterface dialog, int id) -> { dialog.cancel(); })
.show();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.queue_list_toolbar_menu, menu);
/* Get some options */
SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(Common.PREFS_NAME, MODE_PRIVATE);
QueueOrder.Order order = QueueOrder.orderFromString(prefs.getString(PREFS_UI_QUEUE_ORDER, PREFS_UI_QUEUE_ORDER_DEFAULT));
// Set item text based on sort mode
MenuItem item = menu.findItem(R.id.queue_list_toolbar_menu_order);
item.setTitle(Objects.requireNonNull(item.getTitle()).toString() + ": " + getQueueOrderDisplayString(order).toString());
return true;
}
@Override
protected void onResume() {
super.onResume();
/* Ekchualle we returned from somewhere */
updateList();
}
}

View file

@ -0,0 +1,163 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.PopupMenu;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import art.pegasko.yeeemp.R;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.QueueOrder;
import art.pegasko.yeeemp.base.Wrapper;
import art.pegasko.yeeemp.databinding.QueueListItemBinding;
class QueueRecyclerViewAdapter extends RecyclerView.Adapter<QueueRecyclerViewAdapter.ViewHolder> {
public static final String TAG = QueueRecyclerViewAdapter.class.getSimpleName();
private Queue[] queues;
private QueueOrder.Order order;
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
View view = (
LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.queue_list_item, viewGroup, false)
);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
viewHolder.getBinding().queueListItemTitle.setText(queues[position].getName());
viewHolder.getBinding().queueListItemItem.setOnLongClickListener((View view) -> {
PopupMenu popupMenu = new PopupMenu(view.getContext(), viewHolder.getBinding().queueListItemItem);
popupMenu.getMenuInflater().inflate(R.menu.queue_list_item_action_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener((MenuItem menuItem) -> {
if (menuItem.getItemId() == R.id.queue_list_item_action_menu_delete) {
new AlertDialog.Builder(view.getContext()).setTitle("Delete queue").setMessage(
"Are you sure you want to delete " + queues[position].getName() + "?").setPositiveButton(
android.R.string.yes,
(dialog, which) -> {
Wrapper.getQueueMaker().delete(
queues[position]);
reloadItems();
}
).setNegativeButton(android.R.string.no, null).setIcon(android.R.drawable.ic_dialog_alert).show();
} else if (menuItem.getItemId() == R.id.queue_list_item_action_menu_rename) {
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder.setTitle("New name");
final EditText input = new EditText(view.getContext());
input.setInputType(InputType.TYPE_CLASS_TEXT);
input.setText(queues[position].getName());
builder.setView(input);
builder.setPositiveButton("OK", (dialog, which) -> {
String name = input.getText().toString().trim();
queues[position].setName(name);
reloadItems();
});
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
builder.show();
}
return true;
});
popupMenu.show();
return true;
});
viewHolder.getBinding().queueListItemItem.setOnClickListener((View view) -> {
Utils.hapticTick(view);
Bundle extra = new Bundle();
extra.putInt("queue_id", queues[position].getId());
Intent intent = new Intent(view.getContext(), EventListActivity.class);
intent.putExtras(extra);
view.getContext().startActivity(intent);
});
viewHolder.getBinding().queueListItemStats.setText(Integer.toString(queues[position].getEventCount()));
viewHolder.getBinding().queueListItemPlus.setOnClickListener((View view) -> {
Utils.hapticTick(view);
Bundle extra = new Bundle();
extra.putInt("queue_id", this.queues[position].getId());
Intent intent = new Intent(view.getContext(), EventEditActivity.class);
intent.putExtras(extra);
view.getContext().startActivity(intent);
});
}
@Override
public int getItemCount() {
return this.queues.length;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
private QueueListItemBinding binding;
public ViewHolder(@NonNull View itemView) {
super(itemView);
this.binding = QueueListItemBinding.bind(itemView);
}
public QueueListItemBinding getBinding() {
return this.binding;
}
}
public void reloadItems() {
this.queues = Wrapper.getQueueMaker().list(this.order);
this.notifyDataSetChanged();
}
public void setOrder(QueueOrder.Order order) {
this.order = order;
}
}

View file

@ -0,0 +1,99 @@
/**
* Yeeemp - tag based event counter
* Copyright (C) 2024-2025 pegasko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
*
* Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
*
* Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.
*/
package art.pegasko.yeeemp.ui.activity;
import android.content.Context;
import android.os.Build;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.view.HapticFeedbackConstants;
import android.view.View;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
public class Utils {
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static String formatTs(long timestamp) {
SimpleDateFormat sdf = new SimpleDateFormat(Utils.DATE_FORMAT);
return sdf.format(timestamp);
}
public static String[] orderedDeduplicateIgnoreCaseAndTrim(String[] items) {
Set<String> duplicates = new HashSet<String>();
ArrayList<String> reverseOrderedItems = new ArrayList<String>();
for (int index = items.length - 1; index >= 0; --index) {
String item = items[index].toLowerCase().trim();
if (!duplicates.contains(item) && !item.isEmpty()) {
duplicates.add(item);
reverseOrderedItems.add(item);
}
}
String[] finalItems = new String[reverseOrderedItems.size()];
for (int index = 0; index < finalItems.length; ++index) {
finalItems[finalItems.length - index - 1] = reverseOrderedItems.get(index);
}
return finalItems;
}
public static int positiveHashCode16(Object o) {
if (o == null)
return 0;
return Math.abs(o.hashCode()) & ((1 << 16) - 1);
}
public static void hapticTick(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Vibration muted, do nothing
if (!view.isHapticFeedbackEnabled()) {
return;
}
// Success only if haptics available and worked
if (view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)) {
return;
}
}
// Fallback to basic vibration
Vibrator vibrator = (Vibrator) view.getContext().getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator != null) {
// TODO: Respect silent mode
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
vibrator.vibrate(VibrationEffect.createOneShot(10, 50));
} else {
vibrator.vibrate(10);
}
}
}
}

View file

@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="135.47"
android:viewportHeight="135.47">
<path
android:pathData="M41.36,60.18 L51.8,75.4V62.98Z"
android:strokeWidth="0.999999"
android:fillColor="#76d767"/>
<path
android:pathData="m64.89,96.71 l-7.92,-10.01 0,-18.92 7.92,-2.12z"
android:strokeWidth="0.999999"
android:fillColor="#76d767"/>
<path
android:pathData="M94.11,60.18 L83.67,62.98V75.4Z"
android:strokeWidth="0.999999"
android:fillColor="#76d767"/>
<path
android:pathData="m70.58,96.71 l0,-31.05 7.92,2.12v18.92z"
android:strokeWidth="0.999999"
android:fillColor="#76d767"/>
<path
android:pathData="m41.36,55.08 l2.03,-7.57h48.7l2.03,7.57z"
android:strokeWidth="0.999999"
android:fillColor="#76d767"/>
</vector>

View file

@ -0,0 +1,13 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topRightRadius="@dimen/box_radius"
android:topLeftRadius="@dimen/box_radius"
android:bottomRightRadius="@dimen/box_radius"
android:bottomLeftRadius="@dimen/box_radius" />
<solid
android:color="@color/pegasko_black" />
</shape>

View file

@ -0,0 +1,13 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topRightRadius="@dimen/box_radius"
android:topLeftRadius="@dimen/box_radius"
android:bottomRightRadius="@dimen/box_radius"
android:bottomLeftRadius="@dimen/box_radius" />
<solid
android:color="@color/pegasko_red" />
</shape>

View file

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="135.47"
android:viewportHeight="135.47">
<path
android:pathData="M0,0h135.47v135.47h-135.47z"
android:strokeWidth="0.999997"
android:fillColor="#2e2e2e"
android:strokeColor="#00000000"
android:strokeLineCap="round"/>
</vector>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size
android:width="@dimen/tag_divider_width"
android:height="@dimen/tag_divider_height" />
<solid android:color="@android:color/transparent" />
</shape>

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.activity.EventEditActivity" >
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/pegasko_dark"
app:titleTextColor="@color/pegasko_white" />
</com.google.android.material.appbar.AppBarLayout>
<include android:id="@+id/event_edit_content" layout="@layout/content_event_edit" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginBottom="16dp"
app:srcCompat="@android:drawable/ic_menu_edit"
android:backgroundTint="@color/pegasko_red" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.activity.QueueListActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/pegasko_dark"
app:titleTextColor="@color/pegasko_white" />
</com.google.android.material.appbar.AppBarLayout>
<include android:id="@+id/event_list_content" layout="@layout/content_event_list"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginBottom="16dp"
app:srcCompat="@android:drawable/ic_input_add"
android:backgroundTint="@color/pegasko_blue" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.activity.QueueListActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:titleTextColor="@color/pegasko_white"
android:background="@color/pegasko_dark" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_queue_list"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginBottom="16dp"
app:srcCompat="@android:drawable/ic_input_add"
android:backgroundTint="@color/pegasko_green" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/pegasko_black"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/pegasko_black"
android:orientation="vertical">
<LinearLayout
android:id="@+id/event_edit_container_timestamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_box_margin"
android:background="@drawable/box_red"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_hint_margin"
android:paddingLeft="@dimen/event_edit_hint_padding_left"
android:text="Time"
android:textColor="@color/pegasko_black"
android:textSize="@dimen/event_edit_hint_text"
android:textStyle="bold" />
<TextView
android:id="@+id/event_edit_timestamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_timestamp_margin"
android:background="@drawable/box_black"
android:gravity="center"
android:padding="@dimen/event_edit_timestamp_padding"
android:text="Timestamp"
android:textColor="@color/pegasko_white"
android:textSize="@dimen/event_edit_timestamp_text" />
</LinearLayout>
<LinearLayout
android:id="@+id/event_edit_container_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_box_margin"
android:background="@drawable/box_red"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_hint_margin"
android:paddingLeft="@dimen/event_edit_hint_padding_left"
android:text="Comment"
android:textColor="@color/pegasko_black"
android:textSize="@dimen/event_edit_hint_text"
android:textStyle="bold" />
<EditText
android:id="@+id/event_edit_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_comment_margin"
android:background="@drawable/box_black"
android:cursorVisible="true"
android:gravity="start|left"
android:hint="comment"
android:inputType="textMultiLine"
android:padding="@dimen/event_edit_comment_padding"
android:scrollbars="vertical"
android:singleLine="false"
android:textColor="@color/pegasko_white"
android:textSize="@dimen/event_edit_comment_text">
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/event_edit_container_tags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_box_margin"
android:background="@drawable/box_red"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_hint_margin"
android:paddingLeft="@dimen/event_edit_hint_padding_left"
android:text="Tags"
android:textColor="@color/pegasko_black"
android:textSize="@dimen/event_edit_hint_text"
android:textStyle="bold" />
<MultiAutoCompleteTextView
android:id="@+id/event_edit_tags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_edit_tags_suggest_margin"
android:background="@drawable/box_black"
android:hint="tags"
android:padding="@dimen/event_edit_tags_suggest_padding"
android:textSize="@dimen/event_edit_tags_suggest_text">
</MultiAutoCompleteTextView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pegasko_black"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:padding="@dimen/queue_list_item_content_margin"
android:id="@+id/content_event_list__list" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pegasko_black"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:padding="@dimen/queue_list_item_content_margin"
android:id="@+id/content_queue_list__list" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/event_list_item_tag_padding"
android:layout_margin="@dimen/event_list_item_tag_margin"
android:background="@drawable/box_red"
android:textColor="@color/pegasko_black"
android:text="sample_tag" >
</TextView>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<LinearLayout
android:id="@+id/event_list_item__item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/queue_list_item_content_margin"
android:layout_weight="1"
android:background="@color/pegasko_blue"
android:gravity="center"
android:padding="@dimen/queue_list_item_main_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/event_list_item__timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_list_item_timestamp_margin"
android:fontFamily="monospace"
android:text="TextView"
android:textAlignment="viewStart"
android:textColor="@color/pegasko_white"
android:textSize="@dimen/event_list_item_timestamp_text"
android:textStyle="bold" />
<TextView
android:id="@+id/event_list_item__comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/event_list_item_comment_margin"
android:fontFamily="monospace"
android:text="TextView"
android:visibility="gone"
android:padding="@dimen/event_list_item_comment_padding"
android:textColor="@color/pegasko_white"
android:textSize="@dimen/event_list_item_comment_text"
android:background="@drawable/box_black"
android:textStyle="bold" />
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/event_list_item_tags"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/event_list_item_tags_margin"
android:padding="@dimen/event_list_item_tags_padding"
app:alignContent="flex_start"
app:alignItems="flex_start"
app:flexDirection="row"
app:flexWrap="wrap"
app:showDivider="beginning|middle"
app:dividerDrawable="@drawable/tag_divider"
app:justifyContent="flex_start" >
</com.google.android.flexbox.FlexboxLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/event_list_item_tag_padding"
android:layout_margin="@dimen/event_list_item_tag_margin"
android:background="@color/pegasko_black"
android:textColor="@color/pegasko_white"
android:text="sample_tag" >
</TextView>

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<LinearLayout
android:id="@+id/queue_list_item__item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/queue_list_item_content_margin"
android:layout_weight="1"
android:background="@color/pegasko_green"
android:gravity="center"
android:padding="@dimen/queue_list_item_main_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/queue_list_item__title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/queue_list_item_title_margin"
android:fontFamily="monospace"
android:text="TextView"
android:textAlignment="viewStart"
android:textColor="@color/pegasko_black"
android:textSize="@dimen/queue_list_item_title_text"
android:textStyle="bold" />
<TextView
android:id="@+id/queue_list_item__stats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/queue_list_item_subtitle_margin"
android:fontFamily="monospace"
android:text="TextView"
android:textAlignment="viewStart"
android:textColor="@color/pegasko_black"
android:textSize="@dimen/queue_list_item_subtitle"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/queue_list_item__plus"
android:layout_width="@dimen/queue_list_item_plus_width"
android:layout_height="match_parent"
android:layout_margin="@dimen/queue_list_item_content_margin"
android:background="@color/pegasko_green"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="+"
android:textAlignment="viewStart"
android:textColor="@color/pegasko_black"
android:textSize="@dimen/queue_list_item_plus_text"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/event_list_item_action_menu_delete"
android:title="Delete" />
</menu>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/event_list_toolbar_menu_order"
android:title="Order by" />
</menu>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/queue_list_item_action_menu_delete"
android:title="Delete" />
<item
android:id="@+id/queue_list_item_action_menu_rename"
android:title="Rename" />
</menu>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/queue_list_toolbar_menu_order"
android:title="Order by" />
<item
android:id="@+id/queue_list_toolbar_menu_export"
android:title="Export" />
<item
android:id="@+id/queue_list_toolbar_menu_import"
android:title="Import" />
<item
android:id="@+id/queue_list_toolbar_menu_delete"
android:title="Delete all" />
</menu>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">48dp</dimen>
</resources>

View file

@ -0,0 +1,19 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.Yeeemp.Green" parent="Theme.Yeeemp">
<item name="android:navigationBarColor">@color/pegasko_dark</item>
<item name="android:statusBarColor">@color/pegasko_dark</item>
<item name="android:windowLightStatusBar">false</item>
</style>
<style name="Theme.Yeeemp.Blue" parent="Theme.Yeeemp">
<item name="android:navigationBarColor">@color/pegasko_dark</item>
<item name="android:statusBarColor">@color/pegasko_dark</item>
<item name="android:windowLightStatusBar">false</item>
</style>
<style name="Theme.Yeeemp.Red" parent="Theme.Yeeemp">
<item name="android:navigationBarColor">@color/pegasko_dark</item>
<item name="android:statusBarColor">@color/pegasko_dark</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>

View file

@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">200dp</dimen>
</resources>

View file

@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">48dp</dimen>
</resources>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="pegasko_green">#FF76D767</color>
<color name="pegasko_red">#FFD76776</color>
<color name="pegasko_blue">#FF6776D7</color>
<color name="pegasko_dark_green">#FF66c757</color>
<color name="pegasko_dark_red">#FFc75766</color>
<color name="pegasko_dark_blue">#FF5766c7</color>
<color name="pegasko_black_green">#FF46a737</color>
<color name="pegasko_black_red">#FFa73746</color>
<color name="pegasko_black_blue">#FF3746a7</color>
<color name="pegasko_black">#FF141414</color>
<color name="pegasko_dark">#FF2e2e2e</color>
<color name="pegasko_white">#FFebebeb</color>
<color name="pegasko_light">#FFd1d1d1</color>
</resources>

View file

@ -0,0 +1,65 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
<dimen name="queue_list_item_size">80dp</dimen>
<dimen name="queue_list_item_padding">8dp</dimen>
<dimen name="queue_list_item_main_padding">8dp</dimen>
<dimen name="queue_list_item_title_text">24sp</dimen>
<dimen name="queue_list_item_title_margin">4dp</dimen>
<dimen name="queue_list_item_subtitle">12sp</dimen>
<dimen name="queue_list_item_subtitle_margin">2dp</dimen>
<dimen name="queue_list_item_plus_text">32sp</dimen>
<dimen name="queue_list_item_plus_width">80dp</dimen>
<dimen name="queue_list_item_content_margin">2dp</dimen>
<dimen name="event_list_item_timestamp_text">16sp</dimen>
<dimen name="event_list_item_timestamp_margin">4dp</dimen>
<dimen name="event_list_item_comment_text">12sp</dimen>
<dimen name="event_list_item_comment_margin">4dp</dimen>
<dimen name="event_list_item_comment_padding">4dp</dimen>
<dimen name="event_list_item_plus">32sp</dimen>
<dimen name="event_list_item_plus_width">80dp</dimen>
<dimen name="event_list_item_tags_margin">0dp</dimen>
<dimen name="event_list_item_tags_padding">0dp</dimen>
<dimen name="event_list_item_tag_padding">4dp</dimen>
<dimen name="event_list_item_tag_margin">0dp</dimen>
<dimen name="event_list_item_content_margin">2dp</dimen>
<dimen name="box_radius">2dp</dimen>
<dimen name="box_stroke">2dp</dimen>
<dimen name="tag_divider_width">4dp</dimen>
<dimen name="tag_divider_height">4dp</dimen>
<dimen name="event_edit_box_margin">2dp</dimen>
<dimen name="event_edit_hint_margin">0dp</dimen>
<dimen name="event_edit_hint_padding_left">2dp</dimen>
<dimen name="event_edit_hint_text">16sp</dimen>
<dimen name="event_edit_timestamp_margin">8dp</dimen>
<dimen name="event_edit_timestamp_padding">4dp</dimen>
<dimen name="event_edit_timestamp_text">24sp</dimen>
<dimen name="event_edit_comment_margin">8dp</dimen>
<dimen name="event_edit_comment_padding">4dp</dimen>
<dimen name="event_edit_comment_text">24sp</dimen>
<dimen name="event_edit_tags_margin">8dp</dimen>
<dimen name="event_edit_tags_padding">4dp</dimen>
<dimen name="event_edit_tags_text">24sp</dimen>
<dimen name="event_edit_tags_suggest_padding">4dp</dimen>
<dimen name="event_edit_tags_suggest_margin">8dp</dimen>
<dimen name="event_edit_tags_suggest_text">24sp</dimen>
</resources>

View file

@ -0,0 +1,3 @@
<resources>
<string name="app_name">Yeeemp</string>
</resources>

View file

@ -0,0 +1,59 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Yeeemp" parent="Theme.Material3.Dark.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/pegasko_white</item>
<item name="colorPrimaryVariant">@color/pegasko_light</item>
<item name="colorOnPrimary">@color/pegasko_light</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/pegasko_white</item>
<item name="colorSecondaryVariant">@color/pegasko_light</item>
<item name="colorOnSecondary">@color/pegasko_light</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">@color/pegasko_dark</item>
<item name="statusBarBackground">@color/pegasko_dark</item>
<item name="statusBarForeground">@color/pegasko_dark</item>
</style>
<!-- Green application theme. -->
<style name="Theme.Yeeemp.Green" parent="Theme.Yeeemp">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/pegasko_green</item>
<item name="colorPrimaryVariant">@color/pegasko_dark_green</item>
<item name="colorOnPrimary">@color/pegasko_dark_green</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/pegasko_green</item>
<item name="colorSecondaryVariant">@color/pegasko_dark_green</item>
<item name="colorOnSecondary">@color/pegasko_dark_green</item>
</style>
<!-- Blue application theme. -->
<style name="Theme.Yeeemp.Blue" parent="Theme.Yeeemp">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/pegasko_blue</item>
<item name="colorPrimaryVariant">@color/pegasko_dark_blue</item>
<item name="colorOnPrimary">@color/pegasko_dark_blue</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/pegasko_blue</item>
<item name="colorSecondaryVariant">@color/pegasko_dark_blue</item>
<item name="colorOnSecondary">@color/pegasko_dark_blue</item>
</style>
<!-- Red application theme. -->
<style name="Theme.Yeeemp.Red" parent="Theme.Yeeemp">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/pegasko_red</item>
<item name="colorPrimaryVariant">@color/pegasko_dark_red</item>
<item name="colorOnPrimary">@color/pegasko_dark_red</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/pegasko_red</item>
<item name="colorSecondaryVariant">@color/pegasko_dark_red</item>
<item name="colorOnSecondary">@color/pegasko_dark_red</item>
</style>
</resources>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>

4
Yeeemp/build.gradle Normal file
View file

@ -0,0 +1,4 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.2.2' apply false
}

21
Yeeemp/gradle.properties Normal file
View file

@ -0,0 +1,21 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

185
Yeeemp/gradlew vendored Executable file
View file

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
Yeeemp/gradlew.bat vendored Normal file
View file

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

17
Yeeemp/settings.gradle Normal file
View file

@ -0,0 +1,17 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Yeeemp"
include ':app'

83
icons/ic.svg Normal file
View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="512"
height="512"
viewBox="0 0 135.46666 135.46666"
version="1.1"
id="svg1"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
sodipodi:docname="ic_3.svg"
inkscape:export-filename="ic_1_foreground_plain.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"><title
id="title1">Yeeemp icon</title><sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="1.4142136"
inkscape:cx="145.664"
inkscape:cy="321.73359"
inkscape:window-width="1920"
inkscape:window-height="1024"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showguides="true"><sodipodi:guide
position="101.41926,67.733326"
orientation="0,-1"
id="guide10"
inkscape:locked="false" /><sodipodi:guide
position="67.733334,101.41925"
orientation="1,0"
id="guide11"
inkscape:locked="false" /></sodipodi:namedview><defs
id="defs1" /><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"><path
id="rect1"
style="fill:#2e2e2e;stroke-width:0.999997;stroke-linecap:round"
d="M 0,0 H 135.46666 V 135.46666 H 0 Z" /><path
id="path6"
style="fill:#76d767;fill-opacity:1;stroke-width:0.999999"
d="M 41.356132,60.181856 51.800456,75.4047 V 62.980652 Z" /><path
id="path3"
style="fill:#76d767;fill-opacity:1;stroke-width:0.999999"
d="m 64.889201,96.710125 -7.917287,-10.014718 1e-6,-18.918099 7.917287,-2.12121 z"
sodipodi:nodetypes="ccccc" /><path
id="path5"
style="fill:#76d767;fill-opacity:1;stroke-width:0.999999"
d="M 94.110535,60.181856 83.666211,62.980652 V 75.4047 Z" /><path
id="path4"
style="fill:#76d767;fill-opacity:1;stroke-width:0.999999"
d="m 70.577474,96.710125 1e-6,-31.054027 7.917286,2.12121 v 18.9181 z"
sodipodi:nodetypes="ccccc" /><path
id="rect7"
style="fill:#76d767;fill-opacity:1;stroke-width:0.999999"
d="m 41.356122,55.081745 2.02926,-7.574846 h 48.695913 l 2.029259,7.574847 z" /></g><metadata
id="metadata1"><rdf:RDF><cc:Work
rdf:about=""><cc:license
rdf:resource="http://creativecommons.org/licenses/by-nc-nd/4.0/" /><dc:title>Yeeemp icon</dc:title><dc:date>2024-06-13</dc:date><dc:creator><cc:Agent><dc:title>pegasko</dc:title></cc:Agent></dc:creator><dc:rights><cc:Agent><dc:title>pegasko</dc:title></cc:Agent></dc:rights><dc:publisher><cc:Agent><dc:title>pegasko</dc:title></cc:Agent></dc:publisher><dc:subject><rdf:Bag><rdf:li>icon</rdf:li></rdf:Bag></dc:subject><dc:contributor><cc:Agent><dc:title>pegasko</dc:title></cc:Agent></dc:contributor></cc:Work><cc:License
rdf:about="http://creativecommons.org/licenses/by-nc-nd/4.0/"><cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" /><cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" /><cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" /><cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" /><cc:prohibits
rdf:resource="http://creativecommons.org/ns#CommercialUse" /></cc:License></rdf:RDF></metadata></svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
images/composite.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
images/ic-round-256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

36
python/README.md Normal file
View file

@ -0,0 +1,36 @@
# Python utilities
this directory contans set of python modules / files useful for working with database files (inclusing creation, modification, e.t.c).
# yeeemp
primary file is `yeeemp.py` useful for ORM-based exploration of database files. includes tests.
# License
Yeeemp - tag based event counter
Copyright (C) 2024-2025 pegasko
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
# Notice
Notwithstanding the freedoms granted by the AGPL 3.0 license, the following restrictions apply:
Commercial usage of any kind of the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) is strictly prohibited.
Using the project source code and/or project build artifacts (binaries, executables, packages, archives, libraries and/or any other artifacts) for AI (Artificial Intelligence)/ML (Machine Learning)/NN (Neural Network) and/or any other kind of machine learning algorhitms and systems training is strictly prohibited.

287
python/test_yeeemp.py Normal file
View file

@ -0,0 +1,287 @@
import sqlite3
import typing
import yeeemp
def create_db():
conn = sqlite3.connect(':memory:')
# yeeemp.DBUtil.drop('test.db')
# conn = sqlite3.connect('test.db')
yeeemp.DBUtil.init(conn)
return conn
def test_queue_create():
with create_db() as conn:
root = yeeemp.Root(conn)
queue_list = root.list_queue()
assert len(queue_list) == 0, 'expected empty queue list'
queue = root.create_queue()
assert queue.get_id() == 1, ''
assert queue.get_name() is None, 'no name set by default'
queue.set_name('aboba')
assert queue.get_name() == 'aboba', ''
queue_list = root.list_queue()
assert len(queue_list) == 1, 'expected not empty queue list'
def test_queue_tag_create():
with create_db() as conn:
root = yeeemp.Root(conn)
queue = root.create_queue()
queue.set_name('aboba')
queue_tags = root.list_queue_tag(queue)
assert len(queue_tags) == 0, 'expected empty tags list for new queue'
tag = root.create_tag(queue, 'gato')
assert tag is not None, ''
tag_lookup = root.get_tag_by_name(queue, 'gato')
assert tag_lookup is not None, 'expected find created tag'
assert tag.get_id() == tag_lookup.get_id() is not None, 'expected tag id match'
tag = root.create_tag(queue, 'pato')
assert tag is not None, ''
tag = root.create_tag(queue, 'gato')
assert tag is None, 'expected fail on duplicating tags'
queue_tags = root.list_queue_tag(queue)
assert len(queue_tags) == 2, 'expected not empty tags list for new queue'
queue = root.create_queue()
queue.set_name('bebra')
queue_tags = root.list_queue_tag(queue)
assert len(queue_tags) == 0, 'expected empty tags list for new queue'
def create_tags(root: yeeemp.Root, queue: yeeemp.Queue, prefix: str, n: int) -> list[yeeemp.Tag]:
tags = []
for idx in range(n):
tags.append(root.create_tag(queue, f'{ prefix }_{ idx }'))
return tags
def force_create_tags(root: yeeemp.Root, queue: yeeemp.Queue, prefix: str, n: int) -> list[yeeemp.Tag]:
tags = []
for idx in range(n):
tags.append(root.force_create_tag(queue, f'{ prefix }_{ idx }'))
return tags
def subproc_event_add_tags(
root: yeeemp.Root,
queue: yeeemp.Queue,
event: yeeemp.Event,
tags: list[yeeemp.Tag],
):
for tag in tags:
root.join_event_tag(event, tag)
def subproc_event_drop_tags(
root: yeeemp.Root,
queue: yeeemp.Queue,
event: yeeemp.Event,
):
root.delete_event_tag_all(event)
def subproc_event_check_no_tags(
root: yeeemp.Root,
queue: yeeemp.Queue,
event: yeeemp.Event,
):
event_tags = root.list_event_tag(event)
assert len(event_tags) == 0, 'expected no tags'
def subproc_event_check_has_tags(
root: yeeemp.Root,
queue: yeeemp.Queue,
event: yeeemp.Event,
tags: list[yeeemp.Tag],
):
"Check has all specified tags"
event_tags = root.list_event_tag(event)
event_tag_set = set([ tag.get_name() for tag in event_tags ])
assert all([ tag.get_name() in event_tag_set for tag in tags ]), 'event missing expected tags'
def subproc_event_check_has_only_tags(
root: yeeemp.Root,
queue: yeeemp.Queue,
event: yeeemp.Event,
tags: list[yeeemp.Tag],
):
"Check has only specified tags"
event_tags = root.list_event_tag(event)
event_tag_set = set([ tag.get_name() for tag in event_tags ])
expected_tag_set = set([ tag.get_name() for tag in tags ])
assert all([ tag.get_name() in expected_tag_set for tag in event_tags ]), 'event has unexpected tags tags'
assert all([ tag.get_name() in event_tag_set for tag in tags ]), 'event missing expected tags tags'
def subproc_map_tags_sample(
master_prefix: str,
mapper: typing.Callable[[str, int], None]
):
# append event tags
prefixes = [
master_prefix + 'bread',
master_prefix + 'gato',
master_prefix + 'potato',
master_prefix + 'aboba',
master_prefix + 'stonks'
]
populations = [
1,
102,
9127,
0,
2,
]
for (prefix, population) in zip(prefixes, populations):
mapper(prefix, population)
def test_event_create():
with create_db() as conn:
root = yeeemp.Root(conn)
queue = root.create_queue()
queue.set_name('aboba')
queue_events = root.list_queue_event(queue)
assert len(queue_events) == 0, 'expected empty event list in new queue'
event = root.create_event()
queue_events = root.list_queue_event(queue)
assert len(queue_events) == 0, 'expected empty event list because event is not attached'
event.set_comment('uwu')
assert event.get_comment() == 'uwu'
event.set_comment('owo')
assert event.get_comment() == 'owo'
event.set_timestamp(1029384756)
assert event.get_timestamp() == 1029384756
event.set_timestamp(732)
assert event.get_timestamp() == 732
# append event to queue
root.join_queue_event(queue, event)
queue_events = root.list_queue_event(queue)
assert len(queue_events) == 1, 'expected not empty event list in queue'
# Add & delete tags repeatedly
def clean_add_tags(prefix, population):
tags = force_create_tags(
root=root,
queue=queue,
prefix=prefix,
n=population,
)
subproc_event_add_tags(
root,
queue,
event,
tags,
)
subproc_event_check_has_only_tags(
root,
queue,
event,
tags
)
subproc_event_drop_tags(root, queue, event)
subproc_map_tags_sample(
'owo_',
clean_add_tags
)
# Add new tags & expect persisting
prev_tags = None
def dirty_add_tags(prefix, population):
nonlocal prev_tags
tags = force_create_tags(
root=root,
queue=queue,
prefix=prefix,
n=population,
)
subproc_event_add_tags(
root,
queue,
event,
tags,
)
if prev_tags is not None:
subproc_event_check_has_tags(
root,
queue,
event,
prev_tags
)
prev_tags = tags
subproc_map_tags_sample(
'uwu_',
dirty_add_tags
)
# New event with other tags must not mess with other events
event = root.create_event()
root.join_queue_event(queue, event)
tags = force_create_tags(
root=root,
queue=queue,
prefix='rawr',
n=17,
)
subproc_event_add_tags(
root,
queue,
event,
tags,
)
subproc_event_check_has_only_tags(
root,
queue,
event,
tags
)

480
python/yeeemp.py Normal file
View file

@ -0,0 +1,480 @@
import traceback
import sqlite3
import os
class DBUtil:
def init(conn: sqlite3.Connection):
queries = [
"CREATE TABLE IF NOT EXISTS tag (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" queue_id INTEGER," +
" name TEXT" +
");",
"CREATE INDEX IF NOT EXISTS tag__queue_id ON tag(queue_id);",
"CREATE UNIQUE INDEX IF NOT EXISTS tag__queue_id_name ON tag(queue_id, name);",
"CREATE INDEX IF NOT EXISTS tag__name ON tag(name);",
"CREATE TABLE IF NOT EXISTS event (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" timestamp INTEGER," +
" comment TEXT" +
");",
"CREATE TABLE IF NOT EXISTS queue (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" name TEXT" +
");",
"CREATE TABLE IF NOT EXISTS event_tag (" +
" event_id INTEGER," +
" tag_id INTEGER" +
");",
"CREATE INDEX IF NOT EXISTS event_tag__event_id_tag_id ON event_tag(event_id, tag_id);",
"CREATE INDEX IF NOT EXISTS event_tag__event_id ON event_tag(event_id);",
"CREATE INDEX IF NOT EXISTS event_tag__tag_id ON event_tag(tag_id);",
"CREATE TABLE IF NOT EXISTS queue_event (" +
" queue_id INTEGER," +
" event_id INTEGER" +
");",
"CREATE INDEX IF NOT EXISTS queue_event__event_id_tag_id ON queue_event(queue_id, event_id);",
"CREATE INDEX IF NOT EXISTS queue_event__event_id ON queue_event(queue_id);",
"CREATE INDEX IF NOT EXISTS queue_event__tag_id ON queue_event(event_id);",
"VACUUM;"
]
for q in queries:
conn.execute(q)
def drop(file: str):
try:
os.remove(file)
except:
traceback.print_exc()
class Util:
def entity_create(
conn: sqlite3.Connection,
table: str,
key_list: list[str],
value_list: list,
) -> int:
if len(key_list) != len(value_list):
raise ValueError(f'len(key_list) != len(value_list): { len(key_list) } != { len(value_list) }')
if len(key_list) == 0:
cursor = conn.execute(f'INSERT OR IGNORE INTO { table } (id) VALUES (null)')
else:
cursor = conn.execute(f'INSERT OR IGNORE INTO { table } ({ ", ".join(key_list) }) VALUES ({ ", ".join("?" * len(key_list)) })', value_list)
if cursor.rowcount != 0:
return cursor.lastrowid
return None
def entity_delete(
conn: sqlite3.Connection,
table: str,
id: int,
):
conn.execute(f'DELETE FROM { table } WHERE id = ?', (id,))
def entity_list(
conn: sqlite3.Connection,
table: str,
):
query_result = conn.execute(f'SELECT id FROM { table }').fetchall()
if not query_result or not query_result[0]:
return []
return [ qr[0] for qr in query_result ]
def set_field(
conn: sqlite3.Connection,
table: str,
id: int,
name: str,
value
):
conn.execute(f'UPDATE { table } SET { name } = ? WHERE id = ?', (value, id,))
def get_field(
conn: sqlite3.Connection,
table: str,
id: int,
name: str
):
query_result = conn.execute(f'SELECT { name } FROM { table } WHERE id = ?', (id,)).fetchall()
if not query_result or not query_result[0]:
return None
return query_result[0][0]
def get_id_by_fields(
conn: sqlite3.Connection,
table: str,
key_list: list[str],
value_list: list,
):
query_result = conn.execute(f'SELECT id FROM { table } WHERE { " AND ".join(f"{ key } = ?" for key in key_list) }', value_list).fetchall()
if not query_result or not query_result[0]:
return None
return query_result[0][0]
def join_get(
conn: sqlite3.Connection,
table: str,
key_left: str,
key_right: str,
id_left: int,
) -> list[int]:
query_result = conn.execute(f'SELECT { key_right } FROM { table } WHERE { key_left } = ?', (id_left,)).fetchall()
if not query_result or not query_result[0]:
return []
return [ q[0] for q in query_result ]
def join_set(
conn: sqlite3.Connection,
table: str,
key_left: str,
key_right: str,
id_left: int,
id_right: int,
):
conn.execute(f'INSERT OR IGNORE INTO { table } ({ key_left }, { key_right }) VALUES (?, ?)', (id_left, id_right))
def join_delete(
conn: sqlite3.Connection,
table: str,
key_left: str,
key_right: str,
id_left: int,
id_right: int,
):
conn.execute(f'DELETE FROM { table } WHERE { key_left } = ? AND { key_right } = ?', (id_left, id_right))
def join_delete_all(
conn: sqlite3.Connection,
table: str,
key_left: str,
id_left: int,
):
conn.execute(f'DELETE FROM { table } WHERE { key_left } = ?', (id_left,))
def cleanup(
conn: sqlite3.Connection,
):
conn.executescript("""
-- Step 1: delete relations with noexistent queues
delete from queue_event where queue_id not in (select distinct id from queue);
-- Step 2: delete relations with noexistent events
delete from queue_event where event_id not in (select distinct id from event);
delete from event_tag where event_id not in (select distinct id from event);
-- Step 3: delete relations with noexistent tags
delete from event_tag where tag_id not in (select distinct id from tag);
-- Step 4: drop all unused events
delete from event where id not in (select distinct event_id from queue_event);
delete from event_tag where event_id not in (select distinct event_id from queue_event);
-- Step 5: drop all unused tags
delete from tag where id not in (select distinct tag_id from event_tag);
""")
class BaseEntity:
"""
Represents entity in database mapped to table.
Each entity has unique `id`.
"""
def __init__(
self,
conn: sqlite3.Connection,
id: int,
):
self.conn = conn
self.id = id
def get_conn(self) -> sqlite3.Connection:
return self.conn
def get_id(self) -> int:
return self.id
def get_table() -> str:
raise NotImplementedError()
class Queue(BaseEntity):
TABLE_NAME = 'queue'
def get_table(self):
return Queue.TABLE_NAME
def get_name(self) -> str:
return Util.get_field(self.get_conn(), Queue.TABLE_NAME, self.get_id(), 'name')
def set_name(self, name: str):
Util.set_field(self.get_conn(), Queue.TABLE_NAME, self.get_id(), 'name', name)
def __str__(self) -> str:
return f'Queue(id={ self.get_id() }, name="{ self.get_name() }")'
__repr__ = __str__
class Event(BaseEntity):
TABLE_NAME = 'event'
def get_table(self):
return Event.TABLE_NAME
def get_timestamp(self) -> int:
return Util.get_field(self.get_conn(), Event.TABLE_NAME, self.get_id(), 'timestamp')
def set_timestamp(self, timestamp: str):
Util.set_field(self.get_conn(), Event.TABLE_NAME, self.get_id(), 'timestamp', timestamp)
def get_comment(self) -> str:
return Util.get_field(self.get_conn(), Event.TABLE_NAME, self.get_id(), 'comment')
def set_comment(self, comment: str):
Util.set_field(self.get_conn(), Event.TABLE_NAME, self.get_id(), 'comment', comment)
def __str__(self) -> str:
return f'Event(id={ self.get_id() }, timestamp={ self.get_timestamp() }, comment="{ self.get_comment() }")'
__repr__ = __str__
class Tag(BaseEntity):
TABLE_NAME = 'tag'
def get_name(self) -> str:
return Util.get_field(self.get_conn(), Tag.TABLE_NAME, self.get_id(), 'name')
def get_queue_id(self) -> int:
return Util.get_field(self.get_conn(), Tag.TABLE_NAME, self.get_id(), 'queue_id')
def set_name(self, name: str):
Util.set_field(self.get_conn(), Tag.TABLE_NAME, self.get_id(), 'name', name)
def __str__(self) -> str:
return f'Tag(id={ self.get_id() }, name="{ self.get_name() }")'
__repr__ = __str__
class Root:
def _get_join_table(table_left: str, table_right: str) -> str:
return f'{ table_left }_{ table_right }'
def _get_id_key(table: str) -> str:
return f'{ table }_id'
def __init__(
self,
conn: sqlite3.Connection,
):
self.conn = conn
def get_conn(self) -> sqlite3.Connection:
return self.conn
def list_queue(self) -> list[Queue]:
ids = Util.entity_list(
self.conn,
Queue.TABLE_NAME,
)
return [
Queue(
self.conn,
id
)
for id in ids
]
def create_queue(self) -> Queue:
return Queue(
self.get_conn(),
Util.entity_create(
self.get_conn(),
Queue.TABLE_NAME,
[],
[],
)
)
def create_tag(self, queue: Queue, name: str) -> Tag:
id = Util.entity_create(
self.get_conn(),
Tag.TABLE_NAME,
[ Root._get_id_key(Queue.TABLE_NAME), 'name' ],
[ queue.get_id(), name ],
)
if id is None:
return None
return Tag(
self.get_conn(),
id,
)
def get_tag_by_name(self, queue: Queue, name: str) -> Tag:
id = Util.get_id_by_fields(
self.get_conn(),
Tag.TABLE_NAME,
[ 'queue_id', 'name' ],
[ queue.get_id(), name ],
)
return Tag(
self.get_conn(),
id,
)
def force_create_tag(self, queue: Queue, name: str) -> Tag:
tag = self.create_tag(queue, name)
if tag is None:
return self.get_tag_by_name(queue, name)
return tag
def list_queue_tag(self, queue: Queue) -> list[Tag]:
tag_ids = Util.join_get(
self.get_conn(),
'tag',
Root._get_id_key(Queue.TABLE_NAME),
'id',
queue.get_id(),
)
return [
Tag(
self.get_conn(),
tid,
)
for tid in tag_ids
]
def create_event(self) -> Event:
id = Util.entity_create(
self.get_conn(),
Event.TABLE_NAME,
[],
[],
)
return Event(
self.get_conn(),
id,
)
def join_queue_event(self, queue: Queue, event: Event):
Util.join_set(
self.get_conn(),
Root._get_join_table(Queue.TABLE_NAME, Event.TABLE_NAME),
Root._get_id_key(Queue.TABLE_NAME),
Root._get_id_key(Event.TABLE_NAME),
queue.get_id(),
event.get_id(),
)
def list_queue_event(self, queue: Queue) -> list[Event]:
ids = Util.join_get(
self.get_conn(),
Root._get_join_table(Queue.TABLE_NAME, Event.TABLE_NAME),
Root._get_id_key(Queue.TABLE_NAME),
Root._get_id_key(Event.TABLE_NAME),
queue.get_id(),
)
return [
Event(
self.get_conn(),
id,
)
for id in ids
]
def list_event_tag(self, event: Event) -> list[Tag]:
ids = Util.join_get(
self.get_conn(),
Root._get_join_table(Event.TABLE_NAME, Tag.TABLE_NAME),
Root._get_id_key(Event.TABLE_NAME),
Root._get_id_key(Tag.TABLE_NAME),
event.get_id(),
)
return [
Tag(
self.get_conn(),
id,
)
for id in ids
]
def join_event_tag(self, event: Event, tag: Tag):
Util.join_set(
self.get_conn(),
Root._get_join_table(Event.TABLE_NAME, Tag.TABLE_NAME),
Root._get_id_key(Event.TABLE_NAME),
Root._get_id_key(Tag.TABLE_NAME),
event.get_id(),
tag.get_id(),
)
def delete_queue_event(self, queue: Queue, event: Event):
Util.join_delete(
self.get_conn(),
Root._get_join_table(Queue.TABLE_NAME, Event.TABLE_NAME),
Root._get_id_key(Queue.TABLE_NAME),
Root._get_id_key(Event.TABLE_NAME),
queue.get_id(),
event.get_id(),
)
def delete_event_tag(self, event: Event, tag: Tag):
Util.join_delete(
self.get_conn(),
Root._get_join_table(Event.TABLE_NAME, Tag.TABLE_NAME),
Root._get_id_key(Event.TABLE_NAME),
Root._get_id_key(Tag.TABLE_NAME),
event.get_id(),
tag.get_id(),
)
def delete_event_tag_all(self, event: Event):
Util.join_delete_all(
self.get_conn(),
Root._get_join_table(Event.TABLE_NAME, Tag.TABLE_NAME),
Root._get_id_key(Event.TABLE_NAME),
event.get_id(),
)
def cleanup(self):
Util.cleanup(self.conn)