Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7f8d3e3b9 | ||
|
|
6095a3d485 | ||
|
|
8771c8fd1b | ||
|
|
51d774b6aa | ||
|
|
879bf98ed1 | ||
|
|
cb283b7d62 | ||
|
|
e988bfdd2e | ||
|
|
49f61892da | ||
|
|
2aa831baa5 | ||
|
|
ef04471a05 | ||
|
|
baec0f3838 | ||
|
|
8101c44dc1 | ||
|
|
aef5b962b5 | ||
|
|
28dca0716a | ||
|
|
0807eebeb2 | ||
|
|
b17a0dc4cb | ||
|
|
1ada6304a4 | ||
|
|
e16e8e3bbe | ||
|
|
1e0368e467 | ||
|
|
4dcf90dcfc | ||
|
|
94ff869bd5 | ||
|
|
435f548698 | ||
|
|
660c3b509a | ||
|
|
6e8960a707 | ||
|
|
c5f836d65c | ||
|
|
3f46872fec | ||
|
|
8192490e93 | ||
|
|
53510746a6 | ||
|
|
0a71c725bb | ||
|
|
2d95cee5a6 | ||
|
|
d1904901b1 | ||
|
|
fc9f12d102 | ||
|
|
dc53b433f6 | ||
|
|
8331a44d15 | ||
|
|
307b0e1736 | ||
|
|
2fb0987de3 | ||
|
|
27bc84bac9 | ||
|
|
e1179e3144 | ||
|
|
032c1bc797 | ||
|
|
b83b0db7a5 | ||
|
|
6723a0732b | ||
|
|
efba165546 | ||
|
|
4e3fbb70ef | ||
|
|
e3331119a0 | ||
|
|
4addc7245d | ||
|
|
0c6a31f4e6 | ||
|
|
7e783104c9 | ||
|
|
486e6a337a | ||
|
|
c13a9d7815 | ||
|
|
c49d7858c3 | ||
|
|
578ca0f38f | ||
|
|
bd5bd798c1 | ||
|
|
91e627ced6 | ||
|
|
0819cbab73 | ||
|
|
dddac71bc6 | ||
|
|
2d4850c0e8 | ||
|
|
a466ad8bcd | ||
|
|
1121365dfb | ||
|
|
212df7fa9b | ||
|
|
5e01ebae7d | ||
|
|
2e2b33ca55 | ||
|
|
2d1a25bbc3 | ||
|
|
4737e763ea | ||
|
|
8c93093b6b | ||
|
|
0977d30729 | ||
|
|
f02b22d8bd | ||
|
|
6cf4a067fb | ||
|
|
3fa009d3e9 | ||
|
|
0222ee5cfc | ||
|
|
e8c8a2a6c1 | ||
|
|
7c75174e26 | ||
|
|
c687d912b3 | ||
|
|
6b017d116f | ||
|
|
c8c3b6de96 | ||
|
|
b832be9556 | ||
|
|
817f3a0e7d | ||
|
|
7d25f7e600 | ||
|
|
8dcb4d1997 | ||
|
|
ba2cf523bd | ||
|
|
c268ee8ccd | ||
|
|
72905f4180 | ||
|
|
a7bb250a64 | ||
|
|
c153b582e7 |
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-06-22T07:39:53.690794081Z">
|
<DropdownSelection timestamp="2025-07-09T09:45:05.074315845Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="Default" identifier="serial=10.0.0.189:40463;connection=ffec9c3f" />
|
<DeviceId pluginId="LocalEmulator" identifier="path=/home/white/.android/avd/Pixel_8.avd" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -16,3 +16,4 @@
|
|||||||
## Скриншоты:
|
## Скриншоты:
|
||||||
<img src="images/1.png" width="300"><img src="images/2.png" width="300"><img src="images/3.png" width="300"><img src="images/4.png" width="300"><img src="images/5.png" width="300">
|
<img src="images/1.png" width="300"><img src="images/2.png" width="300"><img src="images/3.png" width="300"><img src="images/4.png" width="300"><img src="images/5.png" width="300">
|
||||||
<img src="images/6.png" width="300">
|
<img src="images/6.png" width="300">
|
||||||
|
<img src="images/7.png" width="300">
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.cherret.zaprett"
|
namespace = "com.cherret.zaprett"
|
||||||
compileSdk = 35
|
compileSdk = 36
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.cherret.zaprett"
|
applicationId = "com.cherret.zaprett"
|
||||||
minSdk = 30
|
minSdk = 29
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 13
|
versionCode = 19
|
||||||
versionName = "2.1"
|
versionName = "2.7"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
ndk {
|
ndk {
|
||||||
@@ -76,18 +76,19 @@ tasks.preBuild {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("androidx.compose.material3:material3:1.3.1")
|
implementation(libs.compose.material3)
|
||||||
implementation("androidx.compose.material3:material3-window-size-class:1.3.1")
|
implementation(libs.compose.material3.window.size)
|
||||||
implementation("androidx.compose.material3:material3-adaptive-navigation-suite:1.4.0-alpha10")
|
implementation(libs.compose.material3.adaptive.nav)
|
||||||
implementation("androidx.navigation:navigation-compose:2.8.9")
|
implementation(libs.navigation.compose)
|
||||||
implementation("androidx.compose.material:material-icons-extended:1.7.8")
|
implementation(libs.compose.icons)
|
||||||
implementation ("com.github.topjohnwu.libsu:core:6.0.0")
|
implementation(libs.libsu.core)
|
||||||
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.14")
|
implementation(libs.okhttp)
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
|
implementation(libs.serialization.json)
|
||||||
implementation(platform("com.google.firebase:firebase-bom:33.12.0"))
|
implementation(platform(libs.firebase.bom))
|
||||||
implementation("com.google.firebase:firebase-analytics")
|
implementation(libs.firebase.analytics)
|
||||||
implementation("com.google.firebase:firebase-crashlytics")
|
implementation(libs.firebase.crashlytics)
|
||||||
implementation("androidx.fragment:fragment-compose:1.8.8")
|
implementation(libs.fragment.compose)
|
||||||
|
implementation(libs.coil.compose)
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||||
implementation(libs.androidx.activity.compose)
|
implementation(libs.androidx.activity.compose)
|
||||||
|
|||||||
@@ -13,7 +13,10 @@
|
|||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||||
|
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||||
|
tools:ignore="QueryAllPackagesPermission" />
|
||||||
<application
|
<application
|
||||||
|
android:requestLegacyExternalStorage="true"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
@@ -40,12 +43,16 @@
|
|||||||
android:theme="@style/Theme.Zaprett">
|
android:theme="@style/Theme.Zaprett">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<service
|
<service
|
||||||
android:name=".QSTileService"
|
android:name=".utils.QSTileService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/qs_name"
|
android:label="@string/qs_name"
|
||||||
android:icon="@drawable/ic_launcher_monochrome"
|
android:icon="@drawable/ic_launcher_monochrome"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.cherret.zaprett
|
package com.cherret.zaprett
|
||||||
|
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
@@ -18,9 +18,9 @@ import androidx.activity.viewModels
|
|||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Dashboard
|
|
||||||
import androidx.compose.material.icons.filled.Dns
|
|
||||||
import androidx.compose.material.icons.filled.Home
|
import androidx.compose.material.icons.filled.Home
|
||||||
|
import androidx.compose.material.icons.filled.Lan
|
||||||
|
import androidx.compose.material.icons.filled.MultipleStop
|
||||||
import androidx.compose.material.icons.filled.Settings
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -30,13 +30,13 @@ import androidx.compose.material3.Scaffold
|
|||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
@@ -47,22 +47,23 @@ import androidx.navigation.compose.currentBackStackEntryAsState
|
|||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import androidx.navigation.navArgument
|
import androidx.navigation.navArgument
|
||||||
import com.cherret.zaprett.ui.screen.HomeScreen
|
import com.cherret.zaprett.ui.screen.HomeScreen
|
||||||
import com.cherret.zaprett.ui.screen.RepoScreen
|
|
||||||
import com.cherret.zaprett.ui.screen.HostsScreen
|
import com.cherret.zaprett.ui.screen.HostsScreen
|
||||||
|
import com.cherret.zaprett.ui.screen.RepoScreen
|
||||||
import com.cherret.zaprett.ui.screen.SettingsScreen
|
import com.cherret.zaprett.ui.screen.SettingsScreen
|
||||||
import com.cherret.zaprett.ui.screen.StrategyScreen
|
import com.cherret.zaprett.ui.screen.StrategyScreen
|
||||||
import com.cherret.zaprett.ui.theme.ZaprettTheme
|
import com.cherret.zaprett.ui.theme.ZaprettTheme
|
||||||
import com.cherret.zaprett.ui.viewmodel.HomeViewModel
|
import com.cherret.zaprett.ui.viewmodel.HomeViewModel
|
||||||
import com.cherret.zaprett.ui.viewmodel.HostRepoViewModel
|
import com.cherret.zaprett.ui.viewmodel.HostRepoViewModel
|
||||||
import com.cherret.zaprett.ui.viewmodel.StrategyRepoViewModel
|
import com.cherret.zaprett.ui.viewmodel.StrategyRepoViewModel
|
||||||
|
import com.cherret.zaprett.utils.checkModuleInstallation
|
||||||
import com.google.firebase.Firebase
|
import com.google.firebase.Firebase
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import com.google.firebase.analytics.analytics
|
import com.google.firebase.analytics.analytics
|
||||||
|
|
||||||
sealed class Screen(val route: String, @StringRes val nameResId: Int, val icon: ImageVector) {
|
sealed class Screen(val route: String, @StringRes val nameResId: Int, val icon: ImageVector) {
|
||||||
object home : Screen("home", R.string.title_home, Icons.Default.Home)
|
object home : Screen("home", R.string.title_home, Icons.Default.Home)
|
||||||
object hosts : Screen("hosts", R.string.title_hosts, Icons.Default.Dashboard)
|
object hosts : Screen("hosts", R.string.title_hosts, Icons.Default.Lan)
|
||||||
object strategies : Screen("strategies", R.string.title_strategies, Icons.Default.Dns)
|
object strategies : Screen("strategies", R.string.title_strategies, Icons.Default.MultipleStop)
|
||||||
object settings : Screen("settings", R.string.title_settings, Icons.Default.Settings)
|
object settings : Screen("settings", R.string.title_settings, Icons.Default.Settings)
|
||||||
}
|
}
|
||||||
val topLevelRoutes = listOf(Screen.home, Screen.hosts, Screen.strategies, Screen.settings)
|
val topLevelRoutes = listOf(Screen.home, Screen.hosts, Screen.strategies, Screen.settings)
|
||||||
@@ -86,7 +87,34 @@ class MainActivity : ComponentActivity() {
|
|||||||
setContent {
|
setContent {
|
||||||
ZaprettTheme {
|
ZaprettTheme {
|
||||||
val sharedPreferences = remember { getSharedPreferences("settings", MODE_PRIVATE) }
|
val sharedPreferences = remember { getSharedPreferences("settings", MODE_PRIVATE) }
|
||||||
var showStoragePermissionDialog by remember { mutableStateOf(!Environment.isExternalStorageManager()) }
|
LaunchedEffect(Unit) {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
checkModuleInstallation { result ->
|
||||||
|
if (getSharedPreferences(
|
||||||
|
"settings",
|
||||||
|
Context.MODE_PRIVATE
|
||||||
|
).getBoolean("use_module", false) && !result
|
||||||
|
) sharedPreferences.edit {
|
||||||
|
putBoolean(
|
||||||
|
"use_module",
|
||||||
|
false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var showStoragePermissionDialog by remember {
|
||||||
|
mutableStateOf(
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
!Environment.isExternalStorageManager()
|
||||||
|
} else {
|
||||||
|
ContextCompat.checkSelfPermission(
|
||||||
|
this,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
) != PackageManager.PERMISSION_GRANTED
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
var showNotificationPermissionDialog by remember {
|
var showNotificationPermissionDialog by remember {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
|
||||||
@@ -101,10 +129,20 @@ class MainActivity : ComponentActivity() {
|
|||||||
title = stringResource(R.string.error_no_storage_title),
|
title = stringResource(R.string.error_no_storage_title),
|
||||||
message = stringResource(R.string.error_no_storage_message),
|
message = stringResource(R.string.error_no_storage_message),
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
val uri = Uri.fromParts("package", packageName, null)
|
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
|
||||||
intent.data = uri
|
val uri = Uri.fromParts("package", packageName, null)
|
||||||
startActivity(intent)
|
intent.data = uri
|
||||||
|
startActivity(intent)
|
||||||
|
} else {
|
||||||
|
requestPermissions(
|
||||||
|
arrayOf(
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
),
|
||||||
|
100
|
||||||
|
)
|
||||||
|
}
|
||||||
showStoragePermissionDialog = false
|
showStoragePermissionDialog = false
|
||||||
},
|
},
|
||||||
onDismiss = { showStoragePermissionDialog = false }
|
onDismiss = { showStoragePermissionDialog = false }
|
||||||
@@ -133,6 +171,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BottomBar() {
|
fun BottomBar() {
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
|
|||||||
@@ -1,331 +0,0 @@
|
|||||||
package com.cherret.zaprett
|
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.os.Environment
|
|
||||||
import android.util.Log
|
|
||||||
import com.topjohnwu.superuser.Shell
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileInputStream
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.Properties
|
|
||||||
import androidx.core.content.edit
|
|
||||||
|
|
||||||
fun checkRoot(callback: (Boolean) -> Unit) {
|
|
||||||
Shell.cmd("ls /").submit { result ->
|
|
||||||
callback(result.isSuccess)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun checkModuleInstallation(callback: (Boolean) -> Unit) {
|
|
||||||
Shell.cmd("zaprett").submit { result ->
|
|
||||||
callback(result.out.toString().contains("zaprett"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getStatus(callback: (Boolean) -> Unit) {
|
|
||||||
Shell.cmd("zaprett status").submit { result ->
|
|
||||||
callback(result.out.toString().contains("working"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun startService(callback: (Boolean) -> Unit) {
|
|
||||||
Shell.cmd("zaprett start").submit { result ->
|
|
||||||
callback(result.isSuccess)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stopService(callback: (Boolean) -> Unit) {
|
|
||||||
Shell.cmd("zaprett stop").submit { result ->
|
|
||||||
callback(result.isSuccess)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun restartService(callback: (Boolean) -> Unit) {
|
|
||||||
Shell.cmd("zaprett restart").submit { result ->
|
|
||||||
callback(result.isSuccess)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getModuleVersion(callback: (String) -> Unit) {
|
|
||||||
Shell.cmd("zaprett module-ver").submit { result ->
|
|
||||||
if (result.out.isNotEmpty()) callback(result.out.first()) else "undefined"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getBinVersion(callback: (String) -> Unit) {
|
|
||||||
Shell.cmd("zaprett bin-ver").submit { result ->
|
|
||||||
if (result.out.isNotEmpty()) callback(result.out.first()) else "undefined"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getConfigFile(): File {
|
|
||||||
return File(Environment.getExternalStorageDirectory(), "zaprett/config")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setStartOnBoot(startOnBoot: Boolean) {
|
|
||||||
val configFile = getConfigFile()
|
|
||||||
if (configFile.exists()) {
|
|
||||||
val props = Properties()
|
|
||||||
try {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
props.setProperty("autorestart", startOnBoot.toString())
|
|
||||||
FileOutputStream(configFile).use { output ->
|
|
||||||
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getStartOnBoot(): Boolean {
|
|
||||||
val configFile = getConfigFile()
|
|
||||||
val props = Properties()
|
|
||||||
return try {
|
|
||||||
if (configFile.exists()) {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
props.getProperty("autorestart", "false").toBoolean()
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} catch (_: IOException) {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getZaprettPath(): String {
|
|
||||||
val props = Properties()
|
|
||||||
val configFile = getConfigFile()
|
|
||||||
if (configFile.exists()) {
|
|
||||||
return try {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
props.getProperty("zaprettdir", Environment.getExternalStorageDirectory().path + "/zaprett")
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Environment.getExternalStorageDirectory().path + "/zaprett"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAllLists(): Array<String> {
|
|
||||||
val listsDir = File("${getZaprettPath()}/lists/")
|
|
||||||
if (listsDir.exists() && listsDir.isDirectory) {
|
|
||||||
val onlyNames = listsDir.list() ?: return emptyArray()
|
|
||||||
return onlyNames.map { "$listsDir/$it" }.toTypedArray()
|
|
||||||
}
|
|
||||||
return emptyArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAllNfqwsStrategies(): Array<String> {
|
|
||||||
val listsDir = File("${getZaprettPath()}/strategies/nfqws")
|
|
||||||
if (listsDir.exists() && listsDir.isDirectory) {
|
|
||||||
val onlyNames = listsDir.list() ?: return emptyArray()
|
|
||||||
return onlyNames.map { "$listsDir/$it" }.toTypedArray()
|
|
||||||
}
|
|
||||||
return emptyArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAllByeDPIStrategies(): Array<String> {
|
|
||||||
val listsDir = File("${getZaprettPath()}/strategies/byedpi")
|
|
||||||
if (listsDir.exists() && listsDir.isDirectory) {
|
|
||||||
val onlyNames = listsDir.list() ?: return emptyArray()
|
|
||||||
return onlyNames.map { "$listsDir/$it" }.toTypedArray()
|
|
||||||
}
|
|
||||||
return emptyArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getActiveLists(sharedPreferences: SharedPreferences): Array<String> {
|
|
||||||
if (sharedPreferences.getBoolean("use_module", false)) {
|
|
||||||
val configFile = File("${getZaprettPath()}/config")
|
|
||||||
if (configFile.exists()) {
|
|
||||||
val props = Properties()
|
|
||||||
return try {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
val activeLists = props.getProperty("activelists", "")
|
|
||||||
Log.d("Active lists", activeLists)
|
|
||||||
if (activeLists.isNotEmpty()) activeLists.split(",")
|
|
||||||
.toTypedArray() else emptyArray()
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return emptyArray()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return sharedPreferences.getStringSet("lists", emptySet())?.toTypedArray() ?: emptyArray()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getActiveNfqwsStrategies(): Array<String> {
|
|
||||||
val configFile = File("${getZaprettPath()}/config")
|
|
||||||
if (configFile.exists()) {
|
|
||||||
val props = Properties()
|
|
||||||
return try {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
val activeStrategies = props.getProperty("strategy", "")
|
|
||||||
Log.d("Active strategies", activeStrategies)
|
|
||||||
if (activeStrategies.isNotEmpty()) activeStrategies.split(",").toTypedArray() else emptyArray()
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return emptyArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getActiveByeDPIStrategies(sharedPreferences: SharedPreferences): Array<String> {
|
|
||||||
val path = sharedPreferences.getString("active_strategy", "")
|
|
||||||
if (!path.isNullOrBlank() && File(path).exists()) {
|
|
||||||
return arrayOf(path)
|
|
||||||
}
|
|
||||||
return emptyArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getActiveStrategy(sharedPreferences: SharedPreferences): List<String> {
|
|
||||||
val path = sharedPreferences.getString("active_strategy", "")
|
|
||||||
if (!path.isNullOrBlank() && File(path).exists()) {
|
|
||||||
return File(path).readLines()
|
|
||||||
}
|
|
||||||
return emptyList()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun enableList(path: String, sharedPreferences: SharedPreferences) {
|
|
||||||
if (sharedPreferences.getBoolean("use_module", false)) {
|
|
||||||
val props = Properties()
|
|
||||||
val configFile = getConfigFile()
|
|
||||||
try {
|
|
||||||
if (configFile.exists()) {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val activeLists = props.getProperty("activelists", "")
|
|
||||||
.split(",")
|
|
||||||
.filter { it.isNotBlank() }
|
|
||||||
.toMutableList()
|
|
||||||
if (path !in activeLists) {
|
|
||||||
activeLists.add(path)
|
|
||||||
}
|
|
||||||
props.setProperty("activelists", activeLists.joinToString(","))
|
|
||||||
FileOutputStream(configFile).use { output ->
|
|
||||||
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
val currentSet = sharedPreferences.getStringSet("lists", emptySet())?.toMutableSet() ?: mutableSetOf()
|
|
||||||
if (path !in currentSet) {
|
|
||||||
currentSet.add(path)
|
|
||||||
sharedPreferences.edit { putStringSet("lists", currentSet) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun enableStrategy(path: String, sharedPreferences: SharedPreferences) {
|
|
||||||
if (sharedPreferences.getBoolean("use_module", false)) {
|
|
||||||
val props = Properties()
|
|
||||||
val configFile = getConfigFile()
|
|
||||||
try {
|
|
||||||
if (configFile.exists()) {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val activeStrategies = props.getProperty("strategy", "")
|
|
||||||
.split(",")
|
|
||||||
.filter { it.isNotBlank() }
|
|
||||||
.toMutableList()
|
|
||||||
if (path !in activeStrategies) {
|
|
||||||
activeStrategies.add(path)
|
|
||||||
}
|
|
||||||
props.setProperty("strategy", activeStrategies.joinToString(","))
|
|
||||||
FileOutputStream(configFile).use { output ->
|
|
||||||
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sharedPreferences.edit { putString("active_strategy", path) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun disableList(path: String, sharedPreferences: SharedPreferences) {
|
|
||||||
if (sharedPreferences.getBoolean("use_module", false)) {
|
|
||||||
val props = Properties()
|
|
||||||
val configFile = getConfigFile()
|
|
||||||
try {
|
|
||||||
if (configFile.exists()) {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val activeLists = props.getProperty("activelists", "")
|
|
||||||
.split(",")
|
|
||||||
.filter { it.isNotBlank() }
|
|
||||||
.toMutableList()
|
|
||||||
if (path in activeLists) {
|
|
||||||
activeLists.remove(path)
|
|
||||||
}
|
|
||||||
props.setProperty("activelists", activeLists.joinToString(","))
|
|
||||||
FileOutputStream(configFile).use { output ->
|
|
||||||
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
val currentSet = sharedPreferences.getStringSet("lists", emptySet())?.toMutableSet() ?: mutableSetOf()
|
|
||||||
if (path in currentSet) {
|
|
||||||
currentSet.remove(path)
|
|
||||||
sharedPreferences.edit { putStringSet("lists", currentSet) }
|
|
||||||
}
|
|
||||||
if (currentSet.isEmpty()) {
|
|
||||||
sharedPreferences.edit { remove("lists") }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun disableStrategy(path: String, sharedPreferences: SharedPreferences) {
|
|
||||||
if (sharedPreferences.getBoolean("use_module", false)) {
|
|
||||||
val props = Properties()
|
|
||||||
val configFile = getConfigFile()
|
|
||||||
try {
|
|
||||||
if (configFile.exists()) {
|
|
||||||
FileInputStream(configFile).use { input ->
|
|
||||||
props.load(input)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val activeStrategies = props.getProperty("strategy", "")
|
|
||||||
.split(",")
|
|
||||||
.filter { it.isNotBlank() }
|
|
||||||
.toMutableList()
|
|
||||||
if (path in activeStrategies) {
|
|
||||||
activeStrategies.remove(path)
|
|
||||||
}
|
|
||||||
props.setProperty("strategy", activeStrategies.joinToString(","))
|
|
||||||
FileOutputStream(configFile).use { output ->
|
|
||||||
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw RuntimeException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sharedPreferences.edit { remove("active_strategy") }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.cherret.zaprett
|
|
||||||
|
|
||||||
import android.service.quicksettings.Tile
|
|
||||||
import android.service.quicksettings.TileService
|
|
||||||
|
|
||||||
class QSTileService: TileService() {
|
|
||||||
override fun onTileAdded() {
|
|
||||||
super.onTileAdded()
|
|
||||||
updateStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStartListening() {
|
|
||||||
super.onStartListening()
|
|
||||||
updateStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick() {
|
|
||||||
super.onClick()
|
|
||||||
if (qsTile.state == Tile.STATE_INACTIVE) {
|
|
||||||
qsTile.subtitle = getString(R.string.qs_starting)
|
|
||||||
qsTile.state = Tile.STATE_UNAVAILABLE
|
|
||||||
qsTile.updateTile()
|
|
||||||
startService {}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qsTile.subtitle = getString(R.string.qs_stopping)
|
|
||||||
qsTile.state = Tile.STATE_UNAVAILABLE
|
|
||||||
qsTile.updateTile()
|
|
||||||
stopService {}
|
|
||||||
}
|
|
||||||
updateStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateStatus() {
|
|
||||||
if (getSharedPreferences("settings", MODE_PRIVATE).getBoolean("use_module", false)) {
|
|
||||||
getStatus {
|
|
||||||
if (it) {
|
|
||||||
qsTile.label = getString(R.string.qs_name)
|
|
||||||
qsTile.subtitle = getString(R.string.qs_working)
|
|
||||||
qsTile.state = Tile.STATE_ACTIVE
|
|
||||||
qsTile.updateTile()
|
|
||||||
} else {
|
|
||||||
qsTile.label = getString(R.string.qs_name)
|
|
||||||
qsTile.subtitle = getString(R.string.qs_not_working)
|
|
||||||
qsTile.state = Tile.STATE_INACTIVE
|
|
||||||
qsTile.updateTile()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qsTile.label = getString(R.string.qs_name)
|
|
||||||
qsTile.subtitle = getString(R.string.qs_not_available)
|
|
||||||
qsTile.state = Tile.STATE_UNAVAILABLE
|
|
||||||
qsTile.updateTile()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,14 +10,19 @@ import android.content.SharedPreferences
|
|||||||
import android.net.VpnService
|
import android.net.VpnService
|
||||||
import android.os.ParcelFileDescriptor
|
import android.os.ParcelFileDescriptor
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import com.cherret.zaprett.MainActivity
|
import com.cherret.zaprett.MainActivity
|
||||||
import com.cherret.zaprett.R
|
import com.cherret.zaprett.R
|
||||||
import com.cherret.zaprett.getActiveStrategy
|
import com.cherret.zaprett.data.ServiceStatus
|
||||||
|
import com.cherret.zaprett.utils.getActiveExcludeLists
|
||||||
|
import com.cherret.zaprett.utils.getActiveLists
|
||||||
|
import com.cherret.zaprett.utils.getActiveStrategy
|
||||||
|
import com.cherret.zaprett.utils.getAppsListMode
|
||||||
|
import com.cherret.zaprett.utils.getHostListMode
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class ByeDpiVpnService : VpnService() {
|
class ByeDpiVpnService : VpnService() {
|
||||||
@@ -40,6 +45,7 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
super.onStartCommand(intent, flags, startId)
|
super.onStartCommand(intent, flags, startId)
|
||||||
return when (intent?.action) {
|
return when (intent?.action) {
|
||||||
"START_VPN" -> {
|
"START_VPN" -> {
|
||||||
|
startForeground(NOTIFICATION_ID, createNotification())
|
||||||
setupProxy()
|
setupProxy()
|
||||||
START_STICKY
|
START_STICKY
|
||||||
}
|
}
|
||||||
@@ -98,23 +104,14 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupProxy() {
|
private fun setupProxy() {
|
||||||
if (getActiveStrategy(sharedPreferences).isNotEmpty()) {
|
try {
|
||||||
startForeground(NOTIFICATION_ID, createNotification())
|
startSocksProxy()
|
||||||
try {
|
startByeDpi()
|
||||||
startSocksProxy()
|
status = ServiceStatus.Connected
|
||||||
startByeDpi()
|
} catch (e: Exception) {
|
||||||
status = ServiceStatus.Connected
|
Log.e("proxy", "Failed to start")
|
||||||
} catch (e: Exception) {
|
status = ServiceStatus.Failed
|
||||||
Log.e("proxy", "Failed to start")
|
stopSelf()
|
||||||
status = ServiceStatus.Failed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Toast.makeText(
|
|
||||||
this@ByeDpiVpnService,
|
|
||||||
getString(R.string.toast_no_strategy_selected),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,11 +127,30 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
.addDnsServer(dns)
|
.addDnsServer(dns)
|
||||||
.addRoute("0.0.0.0", 0)
|
.addRoute("0.0.0.0", 0)
|
||||||
.setMetered(false)
|
.setMetered(false)
|
||||||
.addDisallowedApplication(applicationContext.packageName)
|
|
||||||
if (ipv6) {
|
if (ipv6) {
|
||||||
builder.addAddress("fd00::1", 128)
|
builder.addAddress("fd00::1", 128)
|
||||||
.addRoute("::", 0)
|
.addRoute("::", 0)
|
||||||
}
|
}
|
||||||
|
val appList = getAppsListMode(sharedPreferences)
|
||||||
|
when (appList) {
|
||||||
|
"blacklist" -> {
|
||||||
|
builder.addDisallowedApplication(applicationContext.packageName)
|
||||||
|
val blacklist = sharedPreferences.getStringSet("blacklist", emptySet())?: emptySet()
|
||||||
|
blacklist.forEach {
|
||||||
|
builder.addDisallowedApplication(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"whitelist" -> {
|
||||||
|
val whitelist = sharedPreferences.getStringSet("whitelist", emptySet())?: emptySet()
|
||||||
|
whitelist.forEach {
|
||||||
|
builder.addAllowedApplication(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
builder.addDisallowedApplication(applicationContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.d("builder", builder.toString())
|
||||||
vpnInterface = builder.establish()
|
vpnInterface = builder.establish()
|
||||||
val tun2socksConfig = """
|
val tun2socksConfig = """
|
||||||
| misc:
|
| misc:
|
||||||
@@ -169,29 +185,56 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
private fun startByeDpi() {
|
private fun startByeDpi() {
|
||||||
val socksIp = sharedPreferences.getString("ip", "127.0.0.1")?: "127.0.0.1"
|
val socksIp = sharedPreferences.getString("ip", "127.0.0.1")?: "127.0.0.1"
|
||||||
val socksPort = sharedPreferences.getString("port", "1080")?: "1080"
|
val socksPort = sharedPreferences.getString("port", "1080")?: "1080"
|
||||||
val listSet = sharedPreferences.getStringSet("lists", emptySet())?: emptySet()
|
val listSet = if (getHostListMode(sharedPreferences) == "whitelist") getActiveLists(sharedPreferences) else getActiveExcludeLists(sharedPreferences)
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val args = parseArgs(socksIp, socksPort, getActiveStrategy(sharedPreferences), listSet)
|
val args = parseArgs(socksIp, socksPort, getActiveStrategy(sharedPreferences), prepareList(listSet), sharedPreferences)
|
||||||
val result = NativeBridge().startProxy(args)
|
val result = NativeBridge().startProxy(args)
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
println("Failed to start byedpi proxy")
|
Log.d("proxy","Failed to start byedpi proxy")
|
||||||
} else {
|
} else {
|
||||||
println("Byedpi proxy started successfully")
|
Log.d("proxy", "Byedpi proxy started successfully")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private suspend fun prepareList(actlists: Array<String>): String {
|
||||||
|
if (actlists.isNotEmpty()) {
|
||||||
|
val lists: Array<File> = actlists.map { File(it) }.toTypedArray()
|
||||||
|
val hostlist = withContext(Dispatchers.IO) {
|
||||||
|
File.createTempFile("hostlist", ".txt", cacheDir)
|
||||||
|
}.apply { deleteOnExit() }
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
hostlist.printWriter().use { out ->
|
||||||
|
lists.forEach {
|
||||||
|
it.bufferedReader().useLines {
|
||||||
|
it.forEach {
|
||||||
|
out.println(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hostlist.absolutePath
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
fun parseArgs(ip: String, port: String, rawArgs: List<String>, listSet: Set<String>): Array<String> {
|
private fun parseArgs(ip: String, port: String, rawArgs: List<String>, list : String, sharedPreferences: SharedPreferences): Array<String> {
|
||||||
val regex = Regex("""--?\S+(?:=(?:[^"'\s]+|"[^"]*"|'[^']*'))?|[^\s]+""")
|
val regex = Regex("""--?\S+(?:=(?:[^"'\s]+|"[^"]*"|'[^']*'))?|[^\s]+""")
|
||||||
val parsedArgs = rawArgs
|
val parsedArgs = rawArgs
|
||||||
.flatMap { args -> regex.findAll(args).map { it.value } }
|
.flatMap { args -> regex.findAll(args).map { it.value } }
|
||||||
.toMutableList()
|
.flatMap { arg ->
|
||||||
if (listSet.isNotEmpty()) {
|
if (getHostListMode(sharedPreferences) == "whitelist") {
|
||||||
for (path in listSet) {
|
when {
|
||||||
parsedArgs.add("--hosts")
|
arg == "\$hostlist" && list.isNotEmpty() -> listOf("-H", list)
|
||||||
parsedArgs.add(path)
|
arg == "\$hostlist" && list.isEmpty() -> emptyList()
|
||||||
|
else -> listOf(arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
listOf("-H", list, "-An", arg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
.toMutableList()
|
||||||
return arrayOf("ciadpi", "--ip", ip, "--port", port) + parsedArgs
|
return arrayOf("ciadpi", "--ip", ip, "--port", port) + parsedArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.cherret.zaprett.data;
|
||||||
|
enum class AppListType {
|
||||||
|
Blacklist,
|
||||||
|
Whitelist
|
||||||
|
}
|
||||||
5
app/src/main/java/com/cherret/zaprett/data/ItemType.kt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package com.cherret.zaprett.data
|
||||||
|
|
||||||
|
enum class ItemType {
|
||||||
|
byedpi, nfqws, list, list_exclude
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cherret.zaprett.byedpi
|
package com.cherret.zaprett.data
|
||||||
|
|
||||||
enum class ServiceStatus {
|
enum class ServiceStatus {
|
||||||
Disconnected,
|
Disconnected,
|
||||||
@@ -10,14 +10,17 @@ import androidx.compose.animation.expandVertically
|
|||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.shrinkVertically
|
import androidx.compose.animation.shrinkVertically
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.wrapContentHeight
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@@ -49,6 +52,7 @@ import androidx.compose.runtime.collectAsState
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
||||||
@@ -75,6 +79,7 @@ fun HomeScreen(viewModel: HomeViewModel = viewModel(), vpnLauncher: ActivityResu
|
|||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
val cardText = viewModel.cardText
|
val cardText = viewModel.cardText
|
||||||
|
val cardIcon = viewModel.cardIcon;
|
||||||
val changeLog = viewModel.changeLog
|
val changeLog = viewModel.changeLog
|
||||||
val newVersion = viewModel.newVersion
|
val newVersion = viewModel.newVersion
|
||||||
val updateAvailable = viewModel.updateAvailable
|
val updateAvailable = viewModel.updateAvailable
|
||||||
@@ -119,7 +124,7 @@ fun HomeScreen(viewModel: HomeViewModel = viewModel(), vpnLauncher: ActivityResu
|
|||||||
Column(modifier = Modifier
|
Column(modifier = Modifier
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.verticalScroll(rememberScrollState())) {
|
.verticalScroll(rememberScrollState())) {
|
||||||
ServiceStatusCard(viewModel, cardText, snackbarHostState, scope)
|
ServiceStatusCard(viewModel, cardText, cardIcon, snackbarHostState, scope)
|
||||||
UpdateCard(updateAvailable) { viewModel.showUpdateDialog() }
|
UpdateCard(updateAvailable) { viewModel.showUpdateDialog() }
|
||||||
if (showUpdateDialog) {
|
if (showUpdateDialog) {
|
||||||
UpdateDialog(viewModel, changeLog.value.orEmpty(), newVersion) { viewModel.dismissUpdateDialog() }
|
UpdateDialog(viewModel, changeLog.value.orEmpty(), newVersion) { viewModel.dismissUpdateDialog() }
|
||||||
@@ -137,25 +142,44 @@ fun HomeScreen(viewModel: HomeViewModel = viewModel(), vpnLauncher: ActivityResu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ServiceStatusCard(viewModel: HomeViewModel, cardText: MutableState<Int>, snackbarHostState: SnackbarHostState, scope: CoroutineScope) {
|
private fun ServiceStatusCard(viewModel: HomeViewModel, cardText: MutableState<Int>, cardIcon : MutableState<ImageVector>, snackbarHostState: SnackbarHostState, scope: CoroutineScope) {
|
||||||
ElevatedCard(
|
ElevatedCard(
|
||||||
elevation = CardDefaults.cardElevation(6.dp),
|
elevation = CardDefaults.cardElevation(6.dp),
|
||||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primary),
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primary),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(start = 10.dp, top = 25.dp, end = 10.dp)
|
.padding(start = 10.dp, top = 25.dp, end = 10.dp)
|
||||||
.width(240.dp)
|
//.height(150.dp)
|
||||||
.height(150.dp),
|
.wrapContentHeight(),
|
||||||
onClick = { viewModel.onCardClick() }
|
onClick = { viewModel.onCardClick() }
|
||||||
) {
|
) {
|
||||||
Text(
|
Row (
|
||||||
text = stringResource(cardText.value),
|
|
||||||
fontFamily = FontFamily(Font(R.font.unbounded, FontWeight.Normal)),
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxSize()
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
textAlign = TextAlign.Center
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
Icon(
|
||||||
|
painter = rememberVectorPainter(cardIcon.value),
|
||||||
|
modifier = Modifier
|
||||||
|
.width(60.dp)
|
||||||
|
.height(60.dp),
|
||||||
|
contentDescription = "icon"
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(cardText.value),
|
||||||
|
fontFamily = FontFamily(Font(R.font.unbounded, FontWeight.Normal)),
|
||||||
|
fontSize = 16.sp,
|
||||||
|
//maxLines = 3,
|
||||||
|
//overflow = TextOverflow.Ellipsis,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp),
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.cherret.zaprett.ui.screen
|
package com.cherret.zaprett.ui.screen
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
@@ -9,6 +11,7 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
@@ -29,6 +32,9 @@ import androidx.compose.material3.HorizontalDivider
|
|||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.SegmentedButton
|
||||||
|
import androidx.compose.material3.SegmentedButtonDefaults
|
||||||
|
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
||||||
import androidx.compose.material3.SnackbarHost
|
import androidx.compose.material3.SnackbarHost
|
||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
@@ -38,9 +44,11 @@ import androidx.compose.material3.pulltorefresh.PullToRefreshBox
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -57,11 +65,13 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.cherret.zaprett.R
|
import com.cherret.zaprett.R
|
||||||
import com.cherret.zaprett.ui.viewmodel.HostsViewModel
|
import com.cherret.zaprett.ui.viewmodel.HostsViewModel
|
||||||
|
import com.cherret.zaprett.utils.getHostListMode
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun HostsScreen(navController: NavController, viewModel: HostsViewModel = viewModel()) {
|
fun HostsScreen(navController: NavController, viewModel: HostsViewModel = viewModel()) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
val allLists = viewModel.allItems
|
val allLists = viewModel.allItems
|
||||||
@@ -70,7 +80,9 @@ fun HostsScreen(navController: NavController, viewModel: HostsViewModel = viewMo
|
|||||||
val filePickerLauncher = rememberLauncherForActivityResult(
|
val filePickerLauncher = rememberLauncherForActivityResult(
|
||||||
contract = ActivityResultContracts.OpenDocument()
|
contract = ActivityResultContracts.OpenDocument()
|
||||||
) { uri ->
|
) { uri ->
|
||||||
uri?.let { viewModel.copySelectedFile(context, "/lists", it) }
|
uri?.let {
|
||||||
|
if (getHostListMode(prefs) == "whitelist") viewModel.copySelectedFile(context, "/lists/include", it)
|
||||||
|
else viewModel.copySelectedFile(context, "/lists/exclude", it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
@@ -102,6 +114,9 @@ fun HostsScreen(navController: NavController, viewModel: HostsViewModel = viewMo
|
|||||||
contentPadding = paddingValues,
|
contentPadding = paddingValues,
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
|
item {
|
||||||
|
ListTypeChoose(viewModel, prefs)
|
||||||
|
}
|
||||||
when {
|
when {
|
||||||
allLists.isEmpty() -> {
|
allLists.isEmpty() -> {
|
||||||
item {
|
item {
|
||||||
@@ -215,6 +230,38 @@ private fun FloatingMenu(navController: NavController, launcher: ActivityResultL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ListTypeChoose(viewModel: HostsViewModel, prefs : SharedPreferences) {
|
||||||
|
val listType = remember { mutableStateOf(getHostListMode(prefs))}
|
||||||
|
val options = listOf(stringResource(R.string.title_whitelist), stringResource(R.string.title_blacklist))
|
||||||
|
val selectedIndex = if (listType.value == "whitelist") 0 else 1
|
||||||
|
|
||||||
|
SingleChoiceSegmentedButtonRow (
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
) {
|
||||||
|
options.forEachIndexed { index, label ->
|
||||||
|
SegmentedButton(
|
||||||
|
shape = SegmentedButtonDefaults.itemShape(
|
||||||
|
index = index,
|
||||||
|
count = options.size
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
listType.value = if (index == 0) "whitelist" else "blacklist"
|
||||||
|
viewModel.setListType(listType.value)
|
||||||
|
},
|
||||||
|
selected = index == selectedIndex,
|
||||||
|
label = {
|
||||||
|
Text(
|
||||||
|
label
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private fun addHost(launcher: ActivityResultLauncher<Array<String>>) {
|
private fun addHost(launcher: ActivityResultLauncher<Array<String>>) {
|
||||||
launcher.launch(arrayOf("text/plain"))
|
launcher.launch(arrayOf("text/plain"))
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,19 @@ package com.cherret.zaprett.ui.screen
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.net.Uri
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.selection.selectable
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||||
|
import androidx.compose.material.icons.filled.AttachMoney
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
@@ -16,27 +23,40 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.text.font.Font
|
import androidx.compose.ui.text.font.Font
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.compose.ui.window.Dialog
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import coil3.compose.AsyncImage
|
||||||
|
import coil3.request.ImageRequest
|
||||||
import com.cherret.zaprett.BuildConfig
|
import com.cherret.zaprett.BuildConfig
|
||||||
import com.cherret.zaprett.byedpi.ByeDpiVpnService
|
import com.cherret.zaprett.byedpi.ByeDpiVpnService
|
||||||
import com.cherret.zaprett.R
|
import com.cherret.zaprett.R
|
||||||
import com.cherret.zaprett.byedpi.ServiceStatus
|
import com.cherret.zaprett.data.ServiceStatus
|
||||||
import com.cherret.zaprett.checkModuleInstallation
|
import com.cherret.zaprett.data.AppListType
|
||||||
import com.cherret.zaprett.checkRoot
|
import com.cherret.zaprett.ui.viewmodel.SettingsViewModel
|
||||||
import com.cherret.zaprett.getStartOnBoot
|
import com.cherret.zaprett.utils.checkModuleInstallation
|
||||||
import com.cherret.zaprett.setStartOnBoot
|
import com.cherret.zaprett.utils.checkRoot
|
||||||
|
import com.cherret.zaprett.utils.getAppsListMode
|
||||||
|
import com.cherret.zaprett.utils.getStartOnBoot
|
||||||
|
import com.cherret.zaprett.utils.setAppsListMode
|
||||||
|
import com.cherret.zaprett.utils.setStartOnBoot
|
||||||
|
import com.cherret.zaprett.utils.stopService
|
||||||
|
import androidx.core.content.edit
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen() {
|
fun SettingsScreen(viewModel : SettingsViewModel = viewModel()) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val sharedPreferences = remember { context.getSharedPreferences("settings", Context.MODE_PRIVATE) }
|
val sharedPreferences = remember { context.getSharedPreferences("settings", Context.MODE_PRIVATE) }
|
||||||
val editor = remember { sharedPreferences.edit() }
|
val editor = remember { sharedPreferences.edit() }
|
||||||
|
|
||||||
val useModule = remember { mutableStateOf(sharedPreferences.getBoolean("use_module", false)) }
|
val useModule = remember { mutableStateOf(sharedPreferences.getBoolean("use_module", false)) }
|
||||||
val updateOnBoot = remember { mutableStateOf(sharedPreferences.getBoolean("update_on_boot", false)) }
|
val updateOnBoot = remember { mutableStateOf(sharedPreferences.getBoolean("update_on_boot", false)) }
|
||||||
val autoRestart = remember { mutableStateOf(getStartOnBoot()) }
|
val autoRestart = remember { mutableStateOf(getStartOnBoot()) }
|
||||||
@@ -52,6 +72,10 @@ fun SettingsScreen() {
|
|||||||
val showPortDialog = remember { mutableStateOf(false) }
|
val showPortDialog = remember { mutableStateOf(false) }
|
||||||
val showDNSDialog = remember { mutableStateOf(false) }
|
val showDNSDialog = remember { mutableStateOf(false) }
|
||||||
val textDialogValue = remember { mutableStateOf("") }
|
val textDialogValue = remember { mutableStateOf("") }
|
||||||
|
val showWhiteDialog = remember { mutableStateOf(false) }
|
||||||
|
val showBlackDialog = remember { mutableStateOf(false) }
|
||||||
|
val showAppsListsSheet = remember { mutableStateOf(false) }
|
||||||
|
val showSystemApps = remember { mutableStateOf(sharedPreferences.getBoolean("show_system_apps", false)) }
|
||||||
|
|
||||||
val settingsList = listOf(
|
val settingsList = listOf(
|
||||||
Setting.Section(stringResource(R.string.general_section)),
|
Setting.Section(stringResource(R.string.general_section)),
|
||||||
@@ -66,7 +90,10 @@ fun SettingsScreen() {
|
|||||||
openNoRootDialog = openNoRootDialog,
|
openNoRootDialog = openNoRootDialog,
|
||||||
openNoModuleDialog = openNoModuleDialog
|
openNoModuleDialog = openNoModuleDialog
|
||||||
) { success ->
|
) { success ->
|
||||||
if (success) useModule.value = isChecked
|
if (success) {
|
||||||
|
useModule.value = isChecked
|
||||||
|
if (!isChecked) stopService { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@@ -78,13 +105,6 @@ fun SettingsScreen() {
|
|||||||
editor.putBoolean("update_on_boot", it).apply()
|
editor.putBoolean("update_on_boot", it).apply()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
Setting.Toggle(
|
|
||||||
title = stringResource(R.string.btn_autorestart),
|
|
||||||
checked = autoRestart.value,
|
|
||||||
onToggle = {
|
|
||||||
if (handleAutoRestart(context, it)) autoRestart.value = it
|
|
||||||
}
|
|
||||||
),
|
|
||||||
Setting.Toggle(
|
Setting.Toggle(
|
||||||
title = stringResource(R.string.btn_autoupdate),
|
title = stringResource(R.string.btn_autoupdate),
|
||||||
checked = autoUpdate.value,
|
checked = autoUpdate.value,
|
||||||
@@ -104,17 +124,38 @@ fun SettingsScreen() {
|
|||||||
Setting.Action(
|
Setting.Action(
|
||||||
title = stringResource(R.string.btn_repository_url_lists),
|
title = stringResource(R.string.btn_repository_url_lists),
|
||||||
onClick = {
|
onClick = {
|
||||||
textDialogValue.value = sharedPreferences.getString("hosts_repo_url", "https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/hosts.json") ?: "https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/hosts.json"
|
textDialogValue.value = sharedPreferences.getString("hosts_repo_url", "https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/hosts.json") ?: "https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/hosts.json"
|
||||||
showHostsRepoUrlDialog.value = true
|
showHostsRepoUrlDialog.value = true
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
Setting.Action(
|
Setting.Action(
|
||||||
title = stringResource(R.string.btn_repository_url_strategies),
|
title = stringResource(R.string.btn_repository_url_strategies),
|
||||||
onClick = {
|
onClick = {
|
||||||
textDialogValue.value = sharedPreferences.getString("strategy_repo_url", "https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/strategies.json") ?: "https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/strategies.json"
|
textDialogValue.value = sharedPreferences.getString("strategy_repo_url", "https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/strategies.json") ?: "https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/strategies.json"
|
||||||
showStrategyRepoUrlDialog.value = true
|
showStrategyRepoUrlDialog.value = true
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
Setting.Section(
|
||||||
|
title = stringResource(R.string.shared_section)
|
||||||
|
),
|
||||||
|
Setting.Action(
|
||||||
|
title = stringResource(R.string.btn_applist),
|
||||||
|
onClick = {
|
||||||
|
showAppsListsSheet.value = true
|
||||||
|
}
|
||||||
|
),
|
||||||
|
Setting.Action(
|
||||||
|
title = stringResource(R.string.btn_whitelist),
|
||||||
|
onClick = {
|
||||||
|
showWhiteDialog.value = true
|
||||||
|
}
|
||||||
|
),
|
||||||
|
Setting.Action(
|
||||||
|
title = stringResource(R.string.btn_blacklist),
|
||||||
|
onClick = {
|
||||||
|
showBlackDialog.value = true
|
||||||
|
}
|
||||||
|
),
|
||||||
Setting.Section(stringResource(R.string.byedpi_section)),
|
Setting.Section(stringResource(R.string.byedpi_section)),
|
||||||
Setting.Toggle(
|
Setting.Toggle(
|
||||||
title = stringResource(R.string.btn_ipv6),
|
title = stringResource(R.string.btn_ipv6),
|
||||||
@@ -144,6 +185,16 @@ fun SettingsScreen() {
|
|||||||
textDialogValue.value = sharedPreferences.getString("dns", "8.8.8.8") ?: "8.8.8.8"
|
textDialogValue.value = sharedPreferences.getString("dns", "8.8.8.8") ?: "8.8.8.8"
|
||||||
showDNSDialog.value = true
|
showDNSDialog.value = true
|
||||||
}
|
}
|
||||||
|
),
|
||||||
|
Setting.Section(
|
||||||
|
title = stringResource(R.string.zapret_section)
|
||||||
|
),
|
||||||
|
Setting.Toggle(
|
||||||
|
title = stringResource(R.string.btn_autorestart),
|
||||||
|
checked = autoRestart.value,
|
||||||
|
onToggle = {
|
||||||
|
if (handleAutoRestart(context, it)) autoRestart.value = it
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -197,6 +248,42 @@ fun SettingsScreen() {
|
|||||||
}, onDismiss = { showDNSDialog.value = false })
|
}, onDismiss = { showDNSDialog.value = false })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showWhiteDialog.value) {
|
||||||
|
ChooseAppsDialog(
|
||||||
|
onDismissRequest = {
|
||||||
|
showWhiteDialog.value = false
|
||||||
|
viewModel.clearList()
|
||||||
|
},
|
||||||
|
viewModel = viewModel,
|
||||||
|
listType = AppListType.Whitelist,
|
||||||
|
sharedPreferences,
|
||||||
|
showSystemApps
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showBlackDialog.value) {
|
||||||
|
ChooseAppsDialog(
|
||||||
|
onDismissRequest = {
|
||||||
|
showBlackDialog.value = false
|
||||||
|
viewModel.clearList()
|
||||||
|
},
|
||||||
|
viewModel = viewModel,
|
||||||
|
listType = AppListType.Blacklist,
|
||||||
|
sharedPreferences,
|
||||||
|
showSystemApps
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showAppsListsSheet.value) {
|
||||||
|
ListBottomSheet(
|
||||||
|
onDismissRequest = {
|
||||||
|
showAppsListsSheet.value = false
|
||||||
|
},
|
||||||
|
prefs = sharedPreferences,
|
||||||
|
context
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
@@ -310,7 +397,89 @@ private fun SettingsTextItem(title: String, onClick: () -> Unit) {
|
|||||||
text = title,
|
text = title,
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
Icon(imageVector = Icons.AutoMirrored.Default.ArrowForward, contentDescription = "test")
|
Icon(imageVector = Icons.AutoMirrored.Default.ArrowForward, contentDescription = null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
private fun ListBottomSheet(
|
||||||
|
onDismissRequest: () -> Unit,
|
||||||
|
prefs : SharedPreferences,
|
||||||
|
context: Context
|
||||||
|
){
|
||||||
|
val selectedOption = remember { mutableStateOf(getAppsListMode(prefs)) }
|
||||||
|
ModalBottomSheet(
|
||||||
|
onDismissRequest = { onDismissRequest() }
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(200.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp)
|
||||||
|
.selectable(
|
||||||
|
selected = selectedOption.value=="none",
|
||||||
|
onClick = {
|
||||||
|
setAppsListMode(prefs, "none")
|
||||||
|
selectedOption.value = "none"
|
||||||
|
},
|
||||||
|
role = Role.RadioButton
|
||||||
|
),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
RadioButton(
|
||||||
|
selected = selectedOption.value.equals("none"),
|
||||||
|
onClick = null
|
||||||
|
)
|
||||||
|
Text(stringResource(R.string.radio_disabed), modifier = Modifier.padding(start = 8.dp))
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp)
|
||||||
|
.selectable(
|
||||||
|
selected = selectedOption.value=="whitelist",
|
||||||
|
onClick = {
|
||||||
|
setAppsListMode(prefs, "whitelist")
|
||||||
|
selectedOption.value = "whitelist"
|
||||||
|
},
|
||||||
|
role = Role.RadioButton
|
||||||
|
),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
RadioButton(
|
||||||
|
selected = selectedOption.value.equals("whitelist"),
|
||||||
|
onClick = null
|
||||||
|
)
|
||||||
|
Text(stringResource(R.string.title_whitelist), modifier = Modifier.padding(start = 8.dp))
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp)
|
||||||
|
.selectable(
|
||||||
|
selected = selectedOption.value=="blacklist",
|
||||||
|
onClick = {
|
||||||
|
setAppsListMode(prefs, "blacklist")
|
||||||
|
selectedOption.value = "blacklist"
|
||||||
|
},
|
||||||
|
role = Role.RadioButton
|
||||||
|
),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
RadioButton(
|
||||||
|
selected = selectedOption.value.equals("blacklist"),
|
||||||
|
onClick = null
|
||||||
|
)
|
||||||
|
Text(stringResource(R.string.title_blacklist), modifier = Modifier.padding(start = 8.dp))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,6 +512,9 @@ private fun useModule(context: Context, checked: Boolean, updateOnBoot: MutableS
|
|||||||
}
|
}
|
||||||
editor.remove("lists").apply()
|
editor.remove("lists").apply()
|
||||||
editor.remove("active_strategy").apply()
|
editor.remove("active_strategy").apply()
|
||||||
|
editor.remove("applist").apply()
|
||||||
|
editor.remove("whitelist").apply()
|
||||||
|
editor.remove("blacklist").apply()
|
||||||
updateOnBoot.value = true
|
updateOnBoot.value = true
|
||||||
callback(true)
|
callback(true)
|
||||||
} else {
|
} else {
|
||||||
@@ -426,16 +598,210 @@ private fun TextDialog(title: String, message: String, initialText: String, onCo
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AboutDialog(onDismiss: () -> Unit) {
|
private fun AboutDialog(onDismiss: () -> Unit) {
|
||||||
|
val context = LocalContext.current
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
title = { Text(text = stringResource(R.string.about_title)) },
|
title = { Text(text = stringResource(R.string.about_title)) },
|
||||||
icon = {Icon(painterResource(R.drawable.ic_launcher_monochrome), contentDescription = stringResource(R.string.app_name), modifier = Modifier
|
icon = {Icon(painterResource(R.drawable.ic_launcher_monochrome), contentDescription = stringResource(R.string.app_name), modifier = Modifier
|
||||||
.size(64.dp))},
|
.size(64.dp))},
|
||||||
text = { Text(text = stringResource(R.string.about_text, BuildConfig.VERSION_NAME)) },
|
text = {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(R.string.about_text, BuildConfig.VERSION_NAME))
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
IconButton(onClick = {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW,
|
||||||
|
"https://github.com/CherretGit/zaprett-app".toUri())
|
||||||
|
context.startActivity(intent)
|
||||||
|
}) {
|
||||||
|
Icon(painterResource(R.drawable.github), "GitHub")
|
||||||
|
}
|
||||||
|
IconButton(onClick = {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW,
|
||||||
|
"https://t.me/zaprett_module".toUri())
|
||||||
|
context.startActivity(intent)
|
||||||
|
}) {
|
||||||
|
Icon(painterResource(R.drawable.telegram), "Telegram")
|
||||||
|
}
|
||||||
|
IconButton(onClick = {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW,
|
||||||
|
"https://matrix.to/#/#zaprett-group:matrix.cherret.ru".toUri())
|
||||||
|
context.startActivity(intent)
|
||||||
|
}) {
|
||||||
|
Icon(painterResource(R.drawable.matrix), "Matrix")
|
||||||
|
}
|
||||||
|
IconButton(onClick = {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW,
|
||||||
|
"https://pay.cloudtips.ru/p/672192fd".toUri())
|
||||||
|
context.startActivity(intent)
|
||||||
|
}) {
|
||||||
|
Icon(Icons.Default.AttachMoney, "Donate")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
confirmButton = { }
|
confirmButton = { }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ChooseAppsDialog(
|
||||||
|
onDismissRequest: () -> Unit,
|
||||||
|
viewModel: SettingsViewModel,
|
||||||
|
listType: AppListType,
|
||||||
|
prefs: SharedPreferences,
|
||||||
|
showSystemApps : MutableState<Boolean>
|
||||||
|
) {
|
||||||
|
val appsList by viewModel.appsList.collectAsState()
|
||||||
|
val selectedPackages by viewModel.selectedPackages.collectAsState()
|
||||||
|
var searchQuery by remember { mutableStateOf("") }
|
||||||
|
val filteredList = remember(searchQuery, appsList) {
|
||||||
|
if (searchQuery.isBlank()) appsList
|
||||||
|
else appsList.filter { it.contains(searchQuery, ignoreCase = true) }
|
||||||
|
}
|
||||||
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
val title = if (listType == AppListType.Whitelist) stringResource(R.string.title_whitelist) else stringResource(R.string.title_blacklist)
|
||||||
|
LaunchedEffect(listType) {
|
||||||
|
viewModel.setListType(listType)
|
||||||
|
}
|
||||||
|
Dialog(onDismissRequest = onDismissRequest) {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier
|
||||||
|
.wrapContentHeight()
|
||||||
|
.padding(16.dp),
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.wrapContentHeight()
|
||||||
|
.fillMaxWidth()) {
|
||||||
|
Row(modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = title,
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 24.sp
|
||||||
|
)
|
||||||
|
Box {
|
||||||
|
IconButton(onClick = { expanded = !expanded }) {
|
||||||
|
Icon(Icons.Default.MoreVert, contentDescription = "More options")
|
||||||
|
}
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = expanded,
|
||||||
|
onDismissRequest = { expanded = false }
|
||||||
|
) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.btn_show_system_apps),
|
||||||
|
fontSize = 12.sp,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
Checkbox(
|
||||||
|
checked = showSystemApps.value,
|
||||||
|
onCheckedChange = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
prefs.edit { putBoolean("show_system_apps", !showSystemApps.value) }
|
||||||
|
showSystemApps.value = !showSystemApps.value
|
||||||
|
viewModel.refreshApplications()
|
||||||
|
expanded = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = searchQuery,
|
||||||
|
onValueChange = { searchQuery = it },
|
||||||
|
placeholder = { Text(stringResource(R.string.search_field)) },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.heightIn(max = 400.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
) {
|
||||||
|
items(filteredList) {
|
||||||
|
AppItem(viewModel(), it, selectedPackages.contains(it), { isChecked ->
|
||||||
|
if (isChecked){ viewModel.addToList(listType, it) }
|
||||||
|
else { viewModel.removeFromList(listType, it) }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = 8.dp, end = 8.dp),
|
||||||
|
horizontalArrangement = Arrangement.End,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
TextButton(
|
||||||
|
onClick = { onDismissRequest() },
|
||||||
|
modifier = Modifier.padding(8.dp, top = 4.dp),
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(R.string.btn_continue))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun AppItem(viewModel: SettingsViewModel, packageName : String, enabled : Boolean, onCheckedChange: (Boolean) -> Unit) {
|
||||||
|
var bitmap by remember { mutableStateOf<Drawable?>(null) }
|
||||||
|
LaunchedEffect(packageName) {
|
||||||
|
bitmap = viewModel.getAppIconBitmap(packageName)
|
||||||
|
}
|
||||||
|
Row (
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(48.dp)
|
||||||
|
.padding(horizontal = 8.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
AsyncImage(
|
||||||
|
model = bitmap,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(4.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = viewModel.getApplicationName(packageName) ?: "unknown",
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
fontSize = 18.sp
|
||||||
|
)
|
||||||
|
Switch(
|
||||||
|
checked = enabled,
|
||||||
|
onCheckedChange = onCheckedChange
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sealed class Setting {
|
sealed class Setting {
|
||||||
data class Toggle(val title: String, val checked: Boolean, val onToggle: (Boolean) -> Unit) : Setting()
|
data class Toggle(val title: String, val checked: Boolean, val onToggle: (Boolean) -> Unit) : Setting()
|
||||||
data class Action(val title: String, val onClick: () -> Unit) : Setting()
|
data class Action(val title: String, val onClick: () -> Unit) : Setting()
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.cherret.zaprett.ui.viewmodel
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.provider.OpenableColumns
|
import android.provider.OpenableColumns
|
||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
@@ -11,10 +13,11 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.mutableStateMapOf
|
import androidx.compose.runtime.mutableStateMapOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import com.cherret.zaprett.R
|
import com.cherret.zaprett.R
|
||||||
import com.cherret.zaprett.getZaprettPath
|
import com.cherret.zaprett.utils.getZaprettPath
|
||||||
import com.cherret.zaprett.restartService
|
import com.cherret.zaprett.utils.restartService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -61,7 +64,11 @@ abstract class BaseListsViewModel(application: Application) : AndroidViewModel(a
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun copySelectedFile(context: Context, path: String, uri: Uri) {
|
fun copySelectedFile(context: Context, path: String, uri: Uri) {
|
||||||
if (!Environment.isExternalStorageManager()) return
|
//if (!Environment.isExternalStorageManager()) return
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){
|
||||||
|
if (!Environment.isExternalStorageManager()) return
|
||||||
|
}
|
||||||
|
else if (ContextCompat.checkSelfPermission(context, android.Manifest.permission.READ_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) return
|
||||||
val contentResolver = context.contentResolver
|
val contentResolver = context.contentResolver
|
||||||
val fileName = contentResolver.query(uri, null, null, null, null)?.use { cursor ->
|
val fileName = contentResolver.query(uri, null, null, null, null)?.use { cursor ->
|
||||||
val nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
|
val nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
|
||||||
@@ -72,9 +79,29 @@ abstract class BaseListsViewModel(application: Application) : AndroidViewModel(a
|
|||||||
if (!directory.exists()) {
|
if (!directory.exists()) {
|
||||||
directory.mkdirs()
|
directory.mkdirs()
|
||||||
}
|
}
|
||||||
val outputFile = File(getZaprettPath() + path, fileName)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
val outputFile = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
if (Environment.isExternalStorageManager()) {
|
||||||
|
val outputDir = File(getZaprettPath() + path)
|
||||||
|
if (!outputDir.exists()) {
|
||||||
|
outputDir.mkdirs()
|
||||||
|
}
|
||||||
|
File(outputDir, fileName)
|
||||||
|
} else {
|
||||||
|
val outputDir = File(context.filesDir, path)
|
||||||
|
if (!outputDir.exists()) {
|
||||||
|
outputDir.mkdirs()
|
||||||
|
}
|
||||||
|
File(outputDir, fileName)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val outputDir = File(context.filesDir, path)
|
||||||
|
if (!outputDir.exists()) {
|
||||||
|
outputDir.mkdirs()
|
||||||
|
}
|
||||||
|
File(outputDir, fileName)
|
||||||
|
}
|
||||||
contentResolver.openInputStream(uri)?.use { inputStream ->
|
contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||||
FileOutputStream(outputFile).use { outputStream ->
|
FileOutputStream(outputFile).use { outputStream ->
|
||||||
inputStream.copyTo(outputStream)
|
inputStream.copyTo(outputStream)
|
||||||
|
|||||||
@@ -9,18 +9,19 @@ import androidx.compose.runtime.mutableStateMapOf
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.cherret.zaprett.RepoItemInfo
|
import com.cherret.zaprett.utils.RepoItemInfo
|
||||||
import com.cherret.zaprett.R
|
import com.cherret.zaprett.R
|
||||||
import com.cherret.zaprett.download
|
import com.cherret.zaprett.data.ItemType
|
||||||
import com.cherret.zaprett.getFileSha256
|
import com.cherret.zaprett.utils.download
|
||||||
import com.cherret.zaprett.getZaprettPath
|
import com.cherret.zaprett.utils.getFileSha256
|
||||||
import com.cherret.zaprett.registerDownloadListenerHost
|
import com.cherret.zaprett.utils.getHostListMode
|
||||||
import com.cherret.zaprett.restartService
|
import com.cherret.zaprett.utils.getZaprettPath
|
||||||
|
import com.cherret.zaprett.utils.registerDownloadListenerHost
|
||||||
|
import com.cherret.zaprett.utils.restartService
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(application) {
|
abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
val context = application.applicationContext
|
val context = application.applicationContext
|
||||||
val sharedPreferences: SharedPreferences = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
val sharedPreferences: SharedPreferences = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||||
@@ -44,12 +45,13 @@ abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(ap
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val safeList = list ?: emptyList()
|
val safeList = list ?: emptyList()
|
||||||
val useModule = sharedPreferences.getBoolean("use_module", false)
|
val useModule = sharedPreferences.getBoolean("use_module", false)
|
||||||
|
val listType = getHostListMode(sharedPreferences)
|
||||||
val filteredList = safeList.filter { item ->
|
val filteredList = safeList.filter { item ->
|
||||||
when (item.type) {
|
when (item.type) {
|
||||||
"list" -> true
|
ItemType.list -> listType == "whitelist"
|
||||||
"nfqws" -> useModule
|
ItemType.list_exclude -> listType == "blacklist"
|
||||||
"byedpi" -> !useModule
|
ItemType.nfqws -> useModule
|
||||||
else -> false
|
ItemType.byedpi -> !useModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hostLists.value = filteredList
|
hostLists.value = filteredList
|
||||||
@@ -74,9 +76,10 @@ abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(ap
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val sourceFile = File(uri.path!!)
|
val sourceFile = File(uri.path!!)
|
||||||
val targetDir = when (item.type) {
|
val targetDir = when (item.type) {
|
||||||
"byedpi" -> File(getZaprettPath(), "strategies/byedpi")
|
ItemType.byedpi -> File(getZaprettPath(), "strategies/byedpi")
|
||||||
"nfqws" -> File(getZaprettPath(), "strategies/nfqws")
|
ItemType.nfqws -> File(getZaprettPath(), "strategies/nfqws")
|
||||||
else -> File(getZaprettPath(), "lists")
|
ItemType.list -> File(getZaprettPath(), "lists/include")
|
||||||
|
ItemType.list_exclude -> File(getZaprettPath(), "lists/exclude")
|
||||||
}
|
}
|
||||||
val targetFile = File(targetDir, uri.lastPathSegment!!)
|
val targetFile = File(targetDir, uri.lastPathSegment!!)
|
||||||
sourceFile.copyTo(targetFile, overwrite = true)
|
sourceFile.copyTo(targetFile, overwrite = true)
|
||||||
@@ -94,9 +97,10 @@ abstract class BaseRepoViewModel(application: Application) : AndroidViewModel(ap
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val sourceFile = File(uri.path!!)
|
val sourceFile = File(uri.path!!)
|
||||||
val targetDir = when (item.type) {
|
val targetDir = when (item.type) {
|
||||||
"byedpi" -> File(getZaprettPath(), "strategies/byedpi")
|
ItemType.byedpi -> File(getZaprettPath(), "strategies/byedpi")
|
||||||
"nfqws" -> File(getZaprettPath(), "strategies/nfqws")
|
ItemType.nfqws -> File(getZaprettPath(), "strategies/nfqws")
|
||||||
else -> File(getZaprettPath(), "lists")
|
ItemType.list -> File(getZaprettPath(), "lists/include")
|
||||||
|
ItemType.list_exclude -> File(getZaprettPath(), "lists/exclude")
|
||||||
}
|
}
|
||||||
val targetFile = File(targetDir, uri.lastPathSegment!!)
|
val targetFile = File(targetDir, uri.lastPathSegment!!)
|
||||||
sourceFile.copyTo(targetFile, overwrite = true)
|
sourceFile.copyTo(targetFile, overwrite = true)
|
||||||
|
|||||||
@@ -3,25 +3,33 @@ package com.cherret.zaprett.ui.viewmodel
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.provider.Settings
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.Help
|
||||||
|
import androidx.compose.material.icons.filled.Cancel
|
||||||
|
import androidx.compose.material.icons.filled.CheckCircle
|
||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import com.cherret.zaprett.byedpi.ByeDpiVpnService
|
|
||||||
import com.cherret.zaprett.R
|
import com.cherret.zaprett.R
|
||||||
import com.cherret.zaprett.byedpi.ServiceStatus
|
import com.cherret.zaprett.byedpi.ByeDpiVpnService
|
||||||
import com.cherret.zaprett.download
|
import com.cherret.zaprett.data.ServiceStatus
|
||||||
import com.cherret.zaprett.getBinVersion
|
import com.cherret.zaprett.utils.download
|
||||||
import com.cherret.zaprett.getChangelog
|
import com.cherret.zaprett.utils.getActiveStrategy
|
||||||
import com.cherret.zaprett.getModuleVersion
|
import com.cherret.zaprett.utils.getBinVersion
|
||||||
import com.cherret.zaprett.getStatus
|
import com.cherret.zaprett.utils.getChangelog
|
||||||
import com.cherret.zaprett.getUpdate
|
import com.cherret.zaprett.utils.getModuleVersion
|
||||||
import com.cherret.zaprett.installApk
|
import com.cherret.zaprett.utils.getStatus
|
||||||
import com.cherret.zaprett.registerDownloadListener
|
import com.cherret.zaprett.utils.getUpdate
|
||||||
import com.cherret.zaprett.restartService
|
import com.cherret.zaprett.utils.installApk
|
||||||
import com.cherret.zaprett.startService
|
import com.cherret.zaprett.utils.registerDownloadListener
|
||||||
import com.cherret.zaprett.stopService
|
import com.cherret.zaprett.utils.restartService
|
||||||
|
import com.cherret.zaprett.utils.startService
|
||||||
|
import com.cherret.zaprett.utils.stopService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
@@ -34,6 +42,8 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
val requestVpnPermission = _requestVpnPermission.asStateFlow()
|
val requestVpnPermission = _requestVpnPermission.asStateFlow()
|
||||||
var cardText = mutableIntStateOf(R.string.status_not_availible) // MVP temporarily(maybe)
|
var cardText = mutableIntStateOf(R.string.status_not_availible) // MVP temporarily(maybe)
|
||||||
private set
|
private set
|
||||||
|
var cardIcon = mutableStateOf(Icons.AutoMirrored.Filled.Help)
|
||||||
|
private set
|
||||||
|
|
||||||
var moduleVer = mutableStateOf(context.getString(R.string.unknown_text))
|
var moduleVer = mutableStateOf(context.getString(R.string.unknown_text))
|
||||||
private set
|
private set
|
||||||
@@ -41,7 +51,7 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
var nfqwsVer = mutableStateOf(context.getString(R.string.unknown_text))
|
var nfqwsVer = mutableStateOf(context.getString(R.string.unknown_text))
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var byedpiVer = mutableStateOf("0.17.1")
|
var byedpiVer = mutableStateOf("0.17.2")
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var serviceMode = mutableIntStateOf(R.string.service_mode_ciadpi)
|
var serviceMode = mutableIntStateOf(R.string.service_mode_ciadpi)
|
||||||
@@ -77,21 +87,49 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
fun checkServiceStatus() {
|
fun checkServiceStatus() {
|
||||||
if (prefs.getBoolean("use_module", false) && prefs.getBoolean("update_on_boot", false)) {
|
if (prefs.getBoolean("use_module", false) && prefs.getBoolean("update_on_boot", false)) {
|
||||||
getStatus { isEnabled ->
|
getStatus { isEnabled ->
|
||||||
cardText.intValue = if (isEnabled) R.string.status_enabled else R.string.status_disabled
|
if (isEnabled){
|
||||||
|
cardText.intValue = R.string.status_enabled
|
||||||
|
cardIcon.value = Icons.Filled.CheckCircle
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cardText.intValue = R.string.status_disabled
|
||||||
|
cardIcon.value = Icons.Filled.Cancel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cardText.value = if (ByeDpiVpnService.status == ServiceStatus.Connected) R.string.status_enabled else R.string.status_disabled
|
if (ByeDpiVpnService.status == ServiceStatus.Connected){
|
||||||
|
cardText.intValue = R.string.status_enabled
|
||||||
|
cardIcon.value = Icons.Filled.CheckCircle
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cardText.intValue = R.string.status_disabled
|
||||||
|
cardIcon.value = Icons.Filled.Cancel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onCardClick() {
|
fun onCardClick() {
|
||||||
if (prefs.getBoolean("use_module", false)) {
|
if (prefs.getBoolean("use_module", false)) {
|
||||||
getStatus { isEnabled ->
|
getStatus { isEnabled ->
|
||||||
cardText.value = if (isEnabled) R.string.status_enabled else R.string.status_disabled
|
if (isEnabled){
|
||||||
|
cardText.intValue = R.string.status_enabled
|
||||||
|
cardIcon.value = Icons.Filled.CheckCircle
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cardText.intValue = R.string.status_disabled
|
||||||
|
cardIcon.value = Icons.Filled.Cancel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cardText.value = if (ByeDpiVpnService.status == ServiceStatus.Connected) R.string.status_enabled else R.string.status_disabled
|
if (ByeDpiVpnService.status == ServiceStatus.Connected){
|
||||||
|
cardText.intValue = R.string.status_enabled
|
||||||
|
cardIcon.value = Icons.Filled.CheckCircle
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cardText.intValue = R.string.status_disabled
|
||||||
|
cardIcon.value = Icons.Filled.Cancel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,10 +151,19 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ByeDpiVpnService.status == ServiceStatus.Disconnected || ByeDpiVpnService.status == ServiceStatus.Failed) {
|
if (ByeDpiVpnService.status == ServiceStatus.Disconnected || ByeDpiVpnService.status == ServiceStatus.Failed) {
|
||||||
scope.launch {
|
if (getActiveStrategy(prefs).isNotEmpty()) {
|
||||||
snackbarHostState.showSnackbar(context.getString(R.string.snack_starting_service))
|
scope.launch {
|
||||||
|
snackbarHostState.showSnackbar(context.getString(R.string.snack_starting_service))
|
||||||
|
}
|
||||||
|
_requestVpnPermission.value = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
context.getString(R.string.toast_no_strategy_selected),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
_requestVpnPermission.value = true
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
@@ -196,9 +243,17 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
|
|
||||||
fun onUpdateConfirm() {
|
fun onUpdateConfirm() {
|
||||||
showUpdateDialog.value = false
|
showUpdateDialog.value = false
|
||||||
val id = download(context, downloadUrl.value.orEmpty())
|
if (context.packageManager.canRequestPackageInstalls()){
|
||||||
registerDownloadListener(context, id) { uri ->
|
val id = download(context, downloadUrl.value.orEmpty())
|
||||||
installApk(context, uri)
|
registerDownloadListener(context, id) { uri ->
|
||||||
|
installApk(context, uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val packageUri = Uri.fromParts("package", context.packageName, null)
|
||||||
|
val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageUri).addFlags(
|
||||||
|
Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
package com.cherret.zaprett.ui.viewmodel
|
package com.cherret.zaprett.ui.viewmodel
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import androidx.lifecycle.viewModelScope
|
import com.cherret.zaprett.utils.RepoItemInfo
|
||||||
import com.cherret.zaprett.RepoItemInfo
|
import com.cherret.zaprett.utils.getAllLists
|
||||||
import com.cherret.zaprett.download
|
import com.cherret.zaprett.utils.getHostList
|
||||||
import com.cherret.zaprett.getAllLists
|
|
||||||
import com.cherret.zaprett.getHostList
|
|
||||||
import com.cherret.zaprett.getZaprettPath
|
|
||||||
import com.cherret.zaprett.registerDownloadListenerHost
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class HostRepoViewModel(application: Application): BaseRepoViewModel(application) {
|
class HostRepoViewModel(application: Application): BaseRepoViewModel(application) {
|
||||||
override fun getInstalledLists(): Array<String> = getAllLists()
|
override fun getInstalledLists(): Array<String> = getAllLists()
|
||||||
|
|||||||
@@ -3,18 +3,26 @@ package com.cherret.zaprett.ui.viewmodel
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import com.cherret.zaprett.disableList
|
import com.cherret.zaprett.utils.disableList
|
||||||
import com.cherret.zaprett.enableList
|
import com.cherret.zaprett.utils.enableList
|
||||||
import com.cherret.zaprett.getActiveLists
|
import com.cherret.zaprett.utils.getActiveExcludeLists
|
||||||
import com.cherret.zaprett.getAllLists
|
import com.cherret.zaprett.utils.getActiveLists
|
||||||
import com.cherret.zaprett.getStatus
|
import com.cherret.zaprett.utils.getAllExcludeLists
|
||||||
|
import com.cherret.zaprett.utils.getAllLists
|
||||||
|
import com.cherret.zaprett.utils.getHostListMode
|
||||||
|
import com.cherret.zaprett.utils.getStatus
|
||||||
|
import com.cherret.zaprett.utils.setHostListMode
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class HostsViewModel(application: Application): BaseListsViewModel(application) {
|
class HostsViewModel(application: Application): BaseListsViewModel(application) {
|
||||||
private val sharedPreferences = application.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
private val sharedPreferences = application.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||||
override fun loadAllItems(): Array<String> = getAllLists()
|
override fun loadAllItems(): Array<String> =
|
||||||
override fun loadActiveItems(): Array<String> = getActiveLists(sharedPreferences)
|
if (getHostListMode(sharedPreferences) == "whitelist") getAllLists()
|
||||||
|
else getAllExcludeLists()
|
||||||
|
override fun loadActiveItems(): Array<String> =
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") getActiveLists(sharedPreferences)
|
||||||
|
else getActiveExcludeLists(sharedPreferences)
|
||||||
|
|
||||||
override fun deleteItem(item: String, snackbarHostState: SnackbarHostState, scope: CoroutineScope) {
|
override fun deleteItem(item: String, snackbarHostState: SnackbarHostState, scope: CoroutineScope) {
|
||||||
val wasChecked = checked[item] == true
|
val wasChecked = checked[item] == true
|
||||||
@@ -45,4 +53,9 @@ class HostsViewModel(application: Application): BaseListsViewModel(application)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun setListType(type : String) {
|
||||||
|
setHostListMode(sharedPreferences, type)
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.cherret.zaprett.ui.viewmodel
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.Context.MODE_PRIVATE
|
||||||
|
import android.content.pm.ApplicationInfo
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import androidx.lifecycle.AndroidViewModel
|
||||||
|
import com.cherret.zaprett.data.AppListType
|
||||||
|
import com.cherret.zaprett.utils.addPackageToList
|
||||||
|
import com.cherret.zaprett.utils.getAppList
|
||||||
|
import com.cherret.zaprett.utils.removePackageFromList
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
class SettingsViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
|
private val context = application
|
||||||
|
private val prefs = context.getSharedPreferences("settings", MODE_PRIVATE)
|
||||||
|
private val _appsList = MutableStateFlow<List<String>>(emptyList())
|
||||||
|
val appsList: StateFlow<List<String>> = _appsList
|
||||||
|
private val _selectedPackages = MutableStateFlow<Set<String>>(emptySet())
|
||||||
|
val selectedPackages: StateFlow<Set<String>> = _selectedPackages.asStateFlow()
|
||||||
|
private val _currentListType = MutableStateFlow(AppListType.Whitelist)
|
||||||
|
|
||||||
|
init {
|
||||||
|
refreshApplications()
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getAppIconBitmap(packageName: String): Drawable? = withContext(Dispatchers.IO) {
|
||||||
|
val pm: PackageManager = context.packageManager
|
||||||
|
val drawable: Drawable = try {
|
||||||
|
pm.getApplicationIcon(packageName)
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
return@withContext null
|
||||||
|
}
|
||||||
|
return@withContext drawable
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getApplicationName(packageName: String) : String? {
|
||||||
|
val pm: PackageManager = context.packageManager
|
||||||
|
return try {
|
||||||
|
val applicationInfo = pm.getApplicationInfo(packageName, 0)
|
||||||
|
pm.getApplicationLabel(applicationInfo).toString()
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setListType(type: AppListType) {
|
||||||
|
_currentListType.value = type
|
||||||
|
refreshApplications()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearList() {
|
||||||
|
_appsList.value = emptyList()
|
||||||
|
_selectedPackages.value = emptySet()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun refreshApplications() {
|
||||||
|
val packages = if (prefs.getBoolean("show_system_apps", false)){
|
||||||
|
context.packageManager.getInstalledPackages(PackageManager.GET_META_DATA)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
context.packageManager.getInstalledPackages(PackageManager.GET_META_DATA).filter { pkgInfo ->
|
||||||
|
(pkgInfo.applicationInfo!!.flags and ApplicationInfo.FLAG_SYSTEM) == 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val allPackages = packages.map { it.packageName }
|
||||||
|
val listType = _currentListType.value
|
||||||
|
|
||||||
|
val result = when (listType) {
|
||||||
|
AppListType.Whitelist -> {
|
||||||
|
val whitelistSet = getAppList(AppListType.Whitelist, prefs, context)
|
||||||
|
val (whitelisted, others) = allPackages.partition { it in whitelistSet }
|
||||||
|
_selectedPackages.value = whitelistSet
|
||||||
|
(whitelisted + others).filter { it != context.packageName }
|
||||||
|
}
|
||||||
|
AppListType.Blacklist -> {
|
||||||
|
val blacklistSet = getAppList(AppListType.Blacklist, prefs, context)
|
||||||
|
val (blacklisted, others) = allPackages.partition { it in blacklistSet }
|
||||||
|
_selectedPackages.value = blacklistSet
|
||||||
|
(blacklisted + others).filter { it != context.packageName }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_appsList.value = result
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addToList(listType: AppListType, packageName: String) {
|
||||||
|
addPackageToList(listType, packageName, prefs, context)
|
||||||
|
selectedPackages.value.plus(packageName)
|
||||||
|
refreshApplications()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeFromList(listType: AppListType, packageName: String) {
|
||||||
|
removePackageFromList(listType, packageName, prefs, context)
|
||||||
|
selectedPackages.value.minus(packageName)
|
||||||
|
refreshApplications()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.cherret.zaprett.ui.viewmodel
|
package com.cherret.zaprett.ui.viewmodel
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.cherret.zaprett.RepoItemInfo
|
import com.cherret.zaprett.utils.RepoItemInfo
|
||||||
import com.cherret.zaprett.getAllByeDPIStrategies
|
import com.cherret.zaprett.utils.getAllByeDPIStrategies
|
||||||
import com.cherret.zaprett.getAllNfqwsStrategies
|
import com.cherret.zaprett.utils.getAllNfqwsStrategies
|
||||||
import com.cherret.zaprett.getStrategiesList
|
import com.cherret.zaprett.utils.getStrategiesList
|
||||||
|
|
||||||
class StrategyRepoViewModel(application: Application): BaseRepoViewModel(application) {
|
class StrategyRepoViewModel(application: Application): BaseRepoViewModel(application) {
|
||||||
override fun getInstalledLists(): Array<String> =
|
override fun getInstalledLists(): Array<String> =
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import android.content.Context
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import com.cherret.zaprett.byedpi.ByeDpiVpnService
|
import com.cherret.zaprett.byedpi.ByeDpiVpnService
|
||||||
import com.cherret.zaprett.byedpi.ServiceStatus
|
import com.cherret.zaprett.data.ServiceStatus
|
||||||
import com.cherret.zaprett.disableStrategy
|
import com.cherret.zaprett.utils.disableStrategy
|
||||||
import com.cherret.zaprett.enableStrategy
|
import com.cherret.zaprett.utils.enableStrategy
|
||||||
import com.cherret.zaprett.getActiveByeDPIStrategies
|
import com.cherret.zaprett.utils.getActiveByeDPIStrategies
|
||||||
import com.cherret.zaprett.getActiveNfqwsStrategies
|
import com.cherret.zaprett.utils.getActiveNfqwsStrategies
|
||||||
import com.cherret.zaprett.getAllByeDPIStrategies
|
import com.cherret.zaprett.utils.getAllByeDPIStrategies
|
||||||
import com.cherret.zaprett.getAllNfqwsStrategies
|
import com.cherret.zaprett.utils.getAllNfqwsStrategies
|
||||||
import com.cherret.zaprett.getStatus
|
import com.cherret.zaprett.utils.getStatus
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|||||||
664
app/src/main/java/com/cherret/zaprett/utils/Module.kt
Normal file
@@ -0,0 +1,664 @@
|
|||||||
|
package com.cherret.zaprett.utils
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Context.MODE_PRIVATE
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Environment
|
||||||
|
import android.util.Log
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.Properties
|
||||||
|
import androidx.core.content.edit
|
||||||
|
import com.cherret.zaprett.data.AppListType
|
||||||
|
|
||||||
|
fun checkRoot(callback: (Boolean) -> Unit) {
|
||||||
|
Shell.getShell().isRoot.let { callback(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkModuleInstallation(callback: (Boolean) -> Unit) {
|
||||||
|
Shell.cmd("zaprett").submit { result ->
|
||||||
|
callback(result.out.toString().contains("zaprett"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getStatus(callback: (Boolean) -> Unit) {
|
||||||
|
Shell.cmd("zaprett status").submit { result ->
|
||||||
|
callback(result.out.toString().contains("working"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun startService(callback: (Boolean) -> Unit) {
|
||||||
|
Shell.cmd("zaprett start").submit { result ->
|
||||||
|
callback(result.isSuccess)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stopService(callback: (Boolean) -> Unit) {
|
||||||
|
Shell.cmd("zaprett stop").submit { result ->
|
||||||
|
callback(result.isSuccess)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun restartService(callback: (Boolean) -> Unit) {
|
||||||
|
Shell.cmd("zaprett restart").submit { result ->
|
||||||
|
callback(result.isSuccess)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getModuleVersion(callback: (String) -> Unit) {
|
||||||
|
Shell.cmd("zaprett module-ver").submit { result ->
|
||||||
|
if (result.out.isNotEmpty()) callback(result.out.first()) else "undefined"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBinVersion(callback: (String) -> Unit) {
|
||||||
|
Shell.cmd("zaprett bin-ver").submit { result ->
|
||||||
|
if (result.out.isNotEmpty()) callback(result.out.first()) else "undefined"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getConfigFile(): File {
|
||||||
|
return File(Environment.getExternalStorageDirectory(), "zaprett/config")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setStartOnBoot(startOnBoot: Boolean) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
props.setProperty("start_on_boot", startOnBoot.toString())
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getStartOnBoot(): Boolean {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
val props = Properties()
|
||||||
|
return try {
|
||||||
|
if (configFile.exists()) {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
props.getProperty("start_on_boot", "false").toBoolean()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
} catch (_: IOException) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getZaprettPath(): String {
|
||||||
|
val props = Properties()
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
return try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
props.getProperty("zaprettdir", Environment.getExternalStorageDirectory().path + "/zaprett")
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Environment.getExternalStorageDirectory().path + "/zaprett"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAllLists(): Array<String> {
|
||||||
|
val listsDir = File("${getZaprettPath()}/lists/include")
|
||||||
|
return listsDir.listFiles { file -> file.isFile }
|
||||||
|
?.map { it.absolutePath }
|
||||||
|
?.toTypedArray()
|
||||||
|
?: emptyArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAllExcludeLists(): Array<String> {
|
||||||
|
val listsDir = File("${getZaprettPath()}/lists/exclude/")
|
||||||
|
return listsDir.listFiles { file -> file.isFile }
|
||||||
|
?.map { it.absolutePath }
|
||||||
|
?.toTypedArray()
|
||||||
|
?: emptyArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAllNfqwsStrategies(): Array<String> {
|
||||||
|
val listsDir = File("${getZaprettPath()}/strategies/nfqws")
|
||||||
|
return listsDir.listFiles { file -> file.isFile }
|
||||||
|
?.map { it.absolutePath }
|
||||||
|
?.toTypedArray()
|
||||||
|
?: emptyArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAllByeDPIStrategies(): Array<String> {
|
||||||
|
val listsDir = File("${getZaprettPath()}/strategies/byedpi")
|
||||||
|
return listsDir.listFiles { file -> file.isFile }
|
||||||
|
?.map { it.absolutePath }
|
||||||
|
?.toTypedArray()
|
||||||
|
?: emptyArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getActiveLists(sharedPreferences: SharedPreferences): Array<String> {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
return try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
val activeLists = props.getProperty("active_lists", "")
|
||||||
|
Log.d("Active lists", activeLists)
|
||||||
|
if (activeLists.isNotEmpty()) activeLists.split(",")
|
||||||
|
.toTypedArray() else emptyArray()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return emptyArray()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return sharedPreferences.getStringSet("lists", emptySet())?.toTypedArray() ?: emptyArray()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun getActiveExcludeLists(sharedPreferences: SharedPreferences): Array<String> {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
return try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
val activeLists = props.getProperty("active_exclude_lists", "")
|
||||||
|
if (activeLists.isNotEmpty()) activeLists.split(",")
|
||||||
|
.toTypedArray() else emptyArray()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return emptyArray()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return sharedPreferences.getStringSet("exclude_lists", emptySet())?.toTypedArray() ?: emptyArray()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getActiveNfqwsStrategies(): Array<String> {
|
||||||
|
val configFile = File("${getZaprettPath()}/config")
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
return try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
val activeStrategies = props.getProperty("strategy", "")
|
||||||
|
Log.d("Active strategies", activeStrategies)
|
||||||
|
if (activeStrategies.isNotEmpty()) activeStrategies.split(",").toTypedArray() else emptyArray()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return emptyArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getActiveByeDPIStrategies(sharedPreferences: SharedPreferences): Array<String> {
|
||||||
|
val path = sharedPreferences.getString("active_strategy", "")
|
||||||
|
if (!path.isNullOrBlank() && File(path).exists()) {
|
||||||
|
return arrayOf(path)
|
||||||
|
}
|
||||||
|
return emptyArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getActiveStrategy(sharedPreferences: SharedPreferences): List<String> {
|
||||||
|
val path = sharedPreferences.getString("active_strategy", "")
|
||||||
|
if (!path.isNullOrBlank() && File(path).exists()) {
|
||||||
|
return File(path).readLines()
|
||||||
|
}
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun enableList(path: String, sharedPreferences: SharedPreferences) {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
try {
|
||||||
|
val props = Properties()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val activeLists = props.getProperty(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "active_lists"
|
||||||
|
else "active_exclude_lists",
|
||||||
|
"")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (path !in activeLists) {
|
||||||
|
activeLists.add(path)
|
||||||
|
}
|
||||||
|
props.setProperty(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "active_lists"
|
||||||
|
else "active_exclude_lists",
|
||||||
|
activeLists.joinToString(",")
|
||||||
|
)
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val currentSet = sharedPreferences.getStringSet(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "lists"
|
||||||
|
else "exclude_lists", emptySet())?.toMutableSet() ?: mutableSetOf()
|
||||||
|
if (path !in currentSet) {
|
||||||
|
currentSet.add(path)
|
||||||
|
sharedPreferences.edit { putStringSet(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "lists"
|
||||||
|
else "exclude_lists", currentSet) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun enableStrategy(path: String, sharedPreferences: SharedPreferences) {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
val props = Properties()
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
try {
|
||||||
|
if (configFile.exists()) {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val activeStrategies = props.getProperty("strategy", "")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (path !in activeStrategies) {
|
||||||
|
activeStrategies.add(path)
|
||||||
|
}
|
||||||
|
props.setProperty("strategy", activeStrategies.joinToString(","))
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sharedPreferences.edit { putString("active_strategy", path) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun disableList(path: String, sharedPreferences: SharedPreferences) {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
val props = Properties()
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
try {
|
||||||
|
if (configFile.exists()) {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val activeLists = props.getProperty(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "active_lists"
|
||||||
|
else "active_exclude_lists",
|
||||||
|
"")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (path in activeLists) {
|
||||||
|
activeLists.remove(path)
|
||||||
|
}
|
||||||
|
props.setProperty(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "active_lists"
|
||||||
|
else "active_exclude_lists",
|
||||||
|
activeLists.joinToString(",")
|
||||||
|
)
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val currentSet = sharedPreferences.getStringSet(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "lists"
|
||||||
|
else "exclude_lists", emptySet())?.toMutableSet() ?: mutableSetOf()
|
||||||
|
if (path in currentSet) {
|
||||||
|
currentSet.remove(path)
|
||||||
|
sharedPreferences.edit { putStringSet(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "lists"
|
||||||
|
else "exclude_lists", currentSet) }
|
||||||
|
}
|
||||||
|
if (currentSet.isEmpty()) {
|
||||||
|
sharedPreferences.edit { remove(
|
||||||
|
if (getHostListMode(sharedPreferences) == "whitelist") "lists"
|
||||||
|
else "exclude_lists"
|
||||||
|
) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun disableStrategy(path: String, sharedPreferences: SharedPreferences) {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
val props = Properties()
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
try {
|
||||||
|
if (configFile.exists()) {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val activeStrategies = props.getProperty("strategy", "")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (path in activeStrategies) {
|
||||||
|
activeStrategies.remove(path)
|
||||||
|
}
|
||||||
|
props.setProperty("strategy", activeStrategies.joinToString(","))
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sharedPreferences.edit { remove("active_strategy") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addPackageToList(listType: AppListType, packageName: String, prefs : SharedPreferences, context : Context) {
|
||||||
|
if (prefs.getBoolean("use_module", false)){
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
try {
|
||||||
|
val props = Properties()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Whitelist) {
|
||||||
|
val whitelist = props.getProperty("whitelist", "")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (packageName !in whitelist) {
|
||||||
|
whitelist.add(packageName)
|
||||||
|
}
|
||||||
|
props.setProperty("whitelist", whitelist.joinToString(","))
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Blacklist) {
|
||||||
|
val blacklist = props.getProperty("blacklist", "")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (packageName !in blacklist) {
|
||||||
|
blacklist.add(packageName)
|
||||||
|
}
|
||||||
|
props.setProperty("blacklist", blacklist.joinToString(","))
|
||||||
|
}
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val prefs = context.getSharedPreferences("settings", MODE_PRIVATE)
|
||||||
|
if (listType == AppListType.Whitelist){
|
||||||
|
val set = prefs.getStringSet("whitelist", emptySet())?.toMutableSet() ?: mutableSetOf()
|
||||||
|
set.add(packageName)
|
||||||
|
prefs.edit().putStringSet("whitelist", set).apply()
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Blacklist){
|
||||||
|
val set = prefs.getStringSet("blacklist", emptySet())?.toMutableSet() ?: mutableSetOf()
|
||||||
|
set.add(packageName)
|
||||||
|
prefs.edit().putStringSet("blacklist", set).apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removePackageFromList(listType: AppListType, packageName: String, prefs: SharedPreferences, context: Context) {
|
||||||
|
if (prefs.getBoolean("use_module", false)){
|
||||||
|
val props = Properties()
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
try {
|
||||||
|
if (configFile.exists()) {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Whitelist){
|
||||||
|
val whitelist = props.getProperty("whitelist", "")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (packageName in whitelist) {
|
||||||
|
whitelist.remove(packageName)
|
||||||
|
}
|
||||||
|
props.setProperty("whitelist", whitelist.joinToString(","))
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Blacklist) {
|
||||||
|
val blacklist = props.getProperty("blacklist", "")
|
||||||
|
.split(",")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.toMutableList()
|
||||||
|
if (packageName in blacklist) {
|
||||||
|
blacklist.remove(packageName)
|
||||||
|
}
|
||||||
|
props.setProperty("blacklist", blacklist.joinToString(","))
|
||||||
|
}
|
||||||
|
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val prefs = context.getSharedPreferences("settings", MODE_PRIVATE)
|
||||||
|
if (listType == AppListType.Whitelist) {
|
||||||
|
val set = prefs.getStringSet("whitelist", emptySet())?.toMutableSet() ?: mutableSetOf()
|
||||||
|
set.remove(packageName)
|
||||||
|
prefs.edit().putStringSet("whitelist", set).apply()
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Blacklist) {
|
||||||
|
val set = prefs.getStringSet("blacklist", emptySet())?.toMutableSet() ?: mutableSetOf()
|
||||||
|
set.remove(packageName)
|
||||||
|
prefs.edit().putStringSet("blacklist", set).apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isInList(listType: AppListType, packageName: String, prefs: SharedPreferences, context: Context) : Boolean {
|
||||||
|
if (prefs.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Whitelist) {
|
||||||
|
val whitelist = props.getProperty("whitelist", "")
|
||||||
|
return if (whitelist.isNotEmpty()) whitelist.split(",")
|
||||||
|
.toTypedArray().contains(packageName) else false
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Blacklist) {
|
||||||
|
val blacklist = props.getProperty("blacklist", "")
|
||||||
|
return if (blacklist.isNotEmpty()) blacklist.split(",")
|
||||||
|
.toTypedArray().contains(packageName) else false
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val prefs = context.getSharedPreferences("settings", MODE_PRIVATE)
|
||||||
|
if(listType == AppListType.Whitelist){
|
||||||
|
val whitelist = prefs.getStringSet("whitelist", emptySet()) ?: emptySet()
|
||||||
|
return packageName in whitelist
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val blacklist = prefs.getStringSet("blacklist", emptySet()) ?: emptySet()
|
||||||
|
return packageName in blacklist
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAppList(listType: AppListType, sharedPreferences : SharedPreferences, context : Context) : Set<String> {
|
||||||
|
if (sharedPreferences.getBoolean("use_module", false)) {
|
||||||
|
val configFile = File("${getZaprettPath()}/config")
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Whitelist) {
|
||||||
|
val whitelist = props.getProperty("whitelist", "")
|
||||||
|
return if (whitelist.isNotEmpty()) whitelist.split(",")
|
||||||
|
.toSet() else emptySet()
|
||||||
|
}
|
||||||
|
if (listType == AppListType.Blacklist) {
|
||||||
|
val blacklist = props.getProperty("blacklist", "")
|
||||||
|
return if (blacklist.isNotEmpty()) blacklist.split(",")
|
||||||
|
.toSet() else emptySet()
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return emptySet()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return if (listType == AppListType.Whitelist) context.getSharedPreferences("settings", MODE_PRIVATE)
|
||||||
|
.getStringSet("whitelist", emptySet()) ?: emptySet()
|
||||||
|
else context.getSharedPreferences("settings", MODE_PRIVATE)
|
||||||
|
.getStringSet("blacklist", emptySet()) ?: emptySet()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAppsListMode(prefs : SharedPreferences) : String {
|
||||||
|
if(prefs.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
val applist = props.getProperty("app_list", "")!!
|
||||||
|
Log.d("App list", "Equals to $applist")
|
||||||
|
return if (applist == "whitelist" || applist == "blacklist" || applist == "none") applist
|
||||||
|
else "none"
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return prefs.getString("applist", "")!!
|
||||||
|
}
|
||||||
|
return "none"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setAppsListMode(prefs: SharedPreferences, mode: String) {
|
||||||
|
if (prefs.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
val props = Properties()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
props.setProperty("app_list", mode)
|
||||||
|
try {
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prefs.edit { putString("app-list", mode) }
|
||||||
|
}
|
||||||
|
Log.d("App List", "Changed to $mode")
|
||||||
|
}
|
||||||
|
fun setHostListMode(prefs: SharedPreferences, mode: String) {
|
||||||
|
if (prefs.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
val props = Properties()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
props.setProperty("list_type", mode)
|
||||||
|
try {
|
||||||
|
FileOutputStream(configFile).use { output ->
|
||||||
|
props.store(output, "Don't place '/' in end of directory! Example: /sdcard")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prefs.edit { putString("list_type", mode) }
|
||||||
|
}
|
||||||
|
Log.d("App List", "Changed to $mode")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getHostListMode(prefs : SharedPreferences) : String {
|
||||||
|
if(prefs.getBoolean("use_module", false)) {
|
||||||
|
val configFile = getConfigFile()
|
||||||
|
if (configFile.exists()) {
|
||||||
|
val props = Properties()
|
||||||
|
try {
|
||||||
|
FileInputStream(configFile).use { input ->
|
||||||
|
props.load(input)
|
||||||
|
}
|
||||||
|
val hostlist = props.getProperty("list_type", "whitelist")!!
|
||||||
|
return if (hostlist == "whitelist" || hostlist == "blacklist") hostlist
|
||||||
|
else "whitelist"
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return prefs.getString("list_type", "whitelist")!!
|
||||||
|
}
|
||||||
|
return "whitelist"
|
||||||
|
}
|
||||||
86
app/src/main/java/com/cherret/zaprett/utils/QSTileService.kt
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
package com.cherret.zaprett.utils
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.service.quicksettings.Tile
|
||||||
|
import android.service.quicksettings.TileService
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import com.cherret.zaprett.R
|
||||||
|
import com.cherret.zaprett.byedpi.ByeDpiVpnService
|
||||||
|
import com.cherret.zaprett.data.ServiceStatus
|
||||||
|
|
||||||
|
class QSTileService: TileService() {
|
||||||
|
private lateinit var prefs: SharedPreferences
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
prefs = applicationContext.getSharedPreferences("settings", MODE_PRIVATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTileAdded() {
|
||||||
|
super.onTileAdded()
|
||||||
|
updateStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStartListening() {
|
||||||
|
super.onStartListening()
|
||||||
|
updateStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick() {
|
||||||
|
super.onClick()
|
||||||
|
if (qsTile.state == Tile.STATE_INACTIVE) {
|
||||||
|
qsTile.subtitle = getString(R.string.qs_starting)
|
||||||
|
qsTile.state = Tile.STATE_UNAVAILABLE
|
||||||
|
qsTile.updateTile()
|
||||||
|
if (prefs.getBoolean("use_module", false)){
|
||||||
|
startService {}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ContextCompat.startForegroundService(applicationContext, Intent(applicationContext, ByeDpiVpnService::class.java).apply { action = "START_VPN" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qsTile.subtitle = getString(R.string.qs_stopping)
|
||||||
|
qsTile.state = Tile.STATE_UNAVAILABLE
|
||||||
|
qsTile.updateTile()
|
||||||
|
if (prefs.getBoolean("use_module", false)){
|
||||||
|
stopService {}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
applicationContext.startService(Intent(applicationContext, ByeDpiVpnService::class.java).apply { action = "STOP_VPN" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateStatus() {
|
||||||
|
if (prefs.getBoolean("use_module", false)) {
|
||||||
|
getStatus {
|
||||||
|
if (it) {
|
||||||
|
qsTile.label = getString(R.string.qs_name)
|
||||||
|
qsTile.subtitle = getString(R.string.qs_working)
|
||||||
|
qsTile.state = Tile.STATE_ACTIVE
|
||||||
|
qsTile.updateTile()
|
||||||
|
} else {
|
||||||
|
qsTile.label = getString(R.string.qs_name)
|
||||||
|
qsTile.subtitle = getString(R.string.qs_not_working)
|
||||||
|
qsTile.state = Tile.STATE_INACTIVE
|
||||||
|
qsTile.updateTile()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (ByeDpiVpnService.status == ServiceStatus.Connected) {
|
||||||
|
qsTile.label = getString(R.string.qs_name)
|
||||||
|
qsTile.subtitle = getString(R.string.qs_working)
|
||||||
|
qsTile.state = Tile.STATE_ACTIVE
|
||||||
|
qsTile.updateTile()
|
||||||
|
} else {
|
||||||
|
qsTile.label = getString(R.string.qs_name)
|
||||||
|
qsTile.subtitle = getString(R.string.qs_not_working)
|
||||||
|
qsTile.state = Tile.STATE_INACTIVE
|
||||||
|
qsTile.updateTile()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cherret.zaprett
|
package com.cherret.zaprett.utils
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.DownloadManager
|
import android.app.DownloadManager
|
||||||
@@ -11,6 +11,7 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import com.cherret.zaprett.data.ItemType
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
@@ -26,7 +27,7 @@ private val client = OkHttpClient()
|
|||||||
private val json = Json { ignoreUnknownKeys = true }
|
private val json = Json { ignoreUnknownKeys = true }
|
||||||
|
|
||||||
fun getHostList(sharedPreferences: SharedPreferences, callback: (List<RepoItemInfo>?) -> Unit) {
|
fun getHostList(sharedPreferences: SharedPreferences, callback: (List<RepoItemInfo>?) -> Unit) {
|
||||||
val request = Request.Builder().url(sharedPreferences.getString("hosts_repo_url","https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/hosts.json")?: "https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/hosts.json").build()
|
val request = Request.Builder().url(sharedPreferences.getString("hosts_repo_url","https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/hosts.json")?: "https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/hosts.json").build()
|
||||||
client.newCall(request).enqueue(object : Callback {
|
client.newCall(request).enqueue(object : Callback {
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@@ -46,7 +47,7 @@ fun getHostList(sharedPreferences: SharedPreferences, callback: (List<RepoItemIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getStrategiesList(sharedPreferences: SharedPreferences, callback: (List<RepoItemInfo>?) -> Unit) {
|
fun getStrategiesList(sharedPreferences: SharedPreferences, callback: (List<RepoItemInfo>?) -> Unit) {
|
||||||
val request = Request.Builder().url(sharedPreferences.getString("strategies_repo_url", "https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/strategies.json")?: "https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/strategies.json").build()
|
val request = Request.Builder().url(sharedPreferences.getString("strategies_repo_url", "https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/strategies.json")?: "https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/strategies.json").build()
|
||||||
client.newCall(request).enqueue(object : Callback {
|
client.newCall(request).enqueue(object : Callback {
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@@ -113,7 +114,7 @@ data class RepoItemInfo(
|
|||||||
val name: String,
|
val name: String,
|
||||||
val author: String,
|
val author: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
val type: String? = null,
|
val type: ItemType,
|
||||||
val hash: String,
|
val hash: String,
|
||||||
val url: String
|
val url: String
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cherret.zaprett
|
package com.cherret.zaprett.utils
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.DownloadManager
|
import android.app.DownloadManager
|
||||||
@@ -9,10 +9,10 @@ import android.content.IntentFilter
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.provider.Settings
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import com.cherret.zaprett.BuildConfig
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
@@ -93,11 +93,6 @@ fun installApk(context: Context, uri: Uri) {
|
|||||||
}
|
}
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
val packageUri = Uri.fromParts("package", context.packageName, null)
|
|
||||||
val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageUri)
|
|
||||||
context.startActivity(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerDownloadListener(context: Context, downloadId: Long, onDownloaded: (Uri) -> Unit) {// AI Generated
|
fun registerDownloadListener(context: Context, downloadId: Long, onDownloaded: (Uri) -> Unit) {// AI Generated
|
||||||
@@ -129,4 +124,4 @@ data class UpdateInfo(
|
|||||||
val versionCode: Int?,
|
val versionCode: Int?,
|
||||||
val downloadUrl: String?,
|
val downloadUrl: String?,
|
||||||
val changelogUrl: String?
|
val changelogUrl: String?
|
||||||
)
|
)
|
||||||
9
app/src/main/res/drawable/github.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,0.297c-6.63,0 -12,5.373 -12,12 0,5.303 3.438,9.8 8.205,11.385 0.6,0.113 0.82,-0.258 0.82,-0.577 0,-0.285 -0.01,-1.04 -0.015,-2.04 -3.338,0.724 -4.042,-1.61 -4.042,-1.61C4.422,18.07 3.633,17.7 3.633,17.7c-1.087,-0.744 0.084,-0.729 0.084,-0.729 1.205,0.084 1.838,1.236 1.838,1.236 1.07,1.835 2.809,1.305 3.495,0.998 0.108,-0.776 0.417,-1.305 0.76,-1.605 -2.665,-0.3 -5.466,-1.332 -5.466,-5.93 0,-1.31 0.465,-2.38 1.235,-3.22 -0.135,-0.303 -0.54,-1.523 0.105,-3.176 0,0 1.005,-0.322 3.3,1.23 0.96,-0.267 1.98,-0.399 3,-0.405 1.02,0.006 2.04,0.138 3,0.405 2.28,-1.552 3.285,-1.23 3.285,-1.23 0.645,1.653 0.24,2.873 0.12,3.176 0.765,0.84 1.23,1.91 1.23,3.22 0,4.61 -2.805,5.625 -5.475,5.92 0.42,0.36 0.81,1.096 0.81,2.22 0,1.606 -0.015,2.896 -0.015,3.286 0,0.315 0.21,0.69 0.825,0.57C20.565,22.092 24,17.592 24,12.297c0,-6.627 -5.373,-12 -12,-12"/>
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/matrix.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M0.632,0.55v22.9L2.28,23.45L2.28,24L0,24L0,0h2.28v0.55zM7.675,7.81v1.157h0.033c0.309,-0.443 0.683,-0.784 1.117,-1.024 0.433,-0.245 0.936,-0.365 1.5,-0.365 0.54,0 1.033,0.107 1.481,0.314 0.448,0.208 0.785,0.582 1.02,1.108 0.254,-0.374 0.6,-0.706 1.034,-0.992 0.434,-0.287 0.95,-0.43 1.546,-0.43 0.453,0 0.872,0.056 1.26,0.167 0.388,0.11 0.716,0.286 0.993,0.53 0.276,0.245 0.489,0.559 0.646,0.951 0.152,0.392 0.23,0.863 0.23,1.417v5.728h-2.349L16.186,11.52c0,-0.286 -0.01,-0.559 -0.032,-0.812a1.755,1.755 0,0 0,-0.18 -0.66,1.106 1.106,0 0,0 -0.438,-0.448c-0.194,-0.11 -0.457,-0.166 -0.785,-0.166 -0.332,0 -0.6,0.064 -0.803,0.189a1.38,1.38 0,0 0,-0.48 0.499,1.946 1.946,0 0,0 -0.231,0.696 5.56,5.56 0,0 0,-0.06 0.785v4.768h-2.35v-4.8c0,-0.254 -0.004,-0.503 -0.018,-0.752a2.074,2.074 0,0 0,-0.143 -0.688,1.052 1.052,0 0,0 -0.415,-0.503c-0.194,-0.125 -0.476,-0.19 -0.854,-0.19 -0.111,0 -0.259,0.024 -0.439,0.074 -0.18,0.051 -0.36,0.143 -0.53,0.282 -0.171,0.138 -0.319,0.337 -0.439,0.595 -0.12,0.259 -0.18,0.6 -0.18,1.02v4.966L5.46,16.375L5.46,7.81zM23.368,23.45L23.368,0.55L21.72,0.55L21.72,0L24,0v24h-2.28v-0.55z"/>
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/telegram.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M11.944,0A12,12 0,0 0,0 12a12,12 0,0 0,12 12,12 12,0 0,0 12,-12A12,12 0,0 0,12 0a12,12 0,0 0,-0.056 0zM16.906,7.224c0.1,-0.002 0.321,0.023 0.465,0.14a0.506,0.506 0,0 1,0.171 0.325c0.016,0.093 0.036,0.306 0.02,0.472 -0.18,1.898 -0.962,6.502 -1.36,8.627 -0.168,0.9 -0.499,1.201 -0.82,1.23 -0.696,0.065 -1.225,-0.46 -1.9,-0.902 -1.056,-0.693 -1.653,-1.124 -2.678,-1.8 -1.185,-0.78 -0.417,-1.21 0.258,-1.91 0.177,-0.184 3.247,-2.977 3.307,-3.23 0.007,-0.032 0.014,-0.15 -0.056,-0.212s-0.174,-0.041 -0.249,-0.024c-0.106,0.024 -1.793,1.14 -5.061,3.345 -0.48,0.33 -0.913,0.49 -1.302,0.48 -0.428,-0.008 -1.252,-0.241 -1.865,-0.44 -0.752,-0.245 -1.349,-0.374 -1.297,-0.789 0.027,-0.216 0.325,-0.437 0.893,-0.663 3.498,-1.524 5.83,-2.529 6.998,-3.014 3.332,-1.386 4.025,-1.627 4.476,-1.635z"/>
|
||||||
|
</vector>
|
||||||
@@ -40,9 +40,9 @@
|
|||||||
<string name="btn_update_host">Обновить</string>
|
<string name="btn_update_host">Обновить</string>
|
||||||
<string name="btn_installing_host">Установка</string>
|
<string name="btn_installing_host">Установка</string>
|
||||||
<string name="btn_updating_host">Обновление</string>
|
<string name="btn_updating_host">Обновление</string>
|
||||||
<string name="btn_installed_host">Установленно</string>
|
<string name="btn_installed_host">Установлено</string>
|
||||||
<string name="btn_autorestart">Переодически перезапускать сервис</string>
|
<string name="btn_autorestart">Периодически перезапускать сервис</string>
|
||||||
<string name="btn_autoupdate">Авто обновление</string>
|
<string name="btn_autoupdate">Автообновление</string>
|
||||||
<string name="btn_send_firebase_analytics">Отправлять аналитику Firebase</string>
|
<string name="btn_send_firebase_analytics">Отправлять аналитику Firebase</string>
|
||||||
<string name="btn_repository_url_lists">URL репозитория хостов</string>
|
<string name="btn_repository_url_lists">URL репозитория хостов</string>
|
||||||
<string name="hint_enter_repository_url_lists">Введите URL репозитория хостов</string>
|
<string name="hint_enter_repository_url_lists">Введите URL репозитория хостов</string>
|
||||||
@@ -67,7 +67,6 @@
|
|||||||
<string name="btn_show_full_path">Показывать полный путь к листу</string>
|
<string name="btn_show_full_path">Показывать полный путь к листу</string>
|
||||||
<string name="pls_reboot_snack">Перезагрузите устройство для вступления изменений в силу</string>
|
<string name="pls_reboot_snack">Перезагрузите устройство для вступления изменений в силу</string>
|
||||||
<string name="pls_restart_snack">Перезапустите zaprett для вступления изменений в силу</string>
|
<string name="pls_restart_snack">Перезапустите zaprett для вступления изменений в силу</string>
|
||||||
<string name="qs_name">Zaprett</string>
|
|
||||||
<string name="qs_starting">Запуск…</string>
|
<string name="qs_starting">Запуск…</string>
|
||||||
<string name="qs_stopping">Остановка…</string>
|
<string name="qs_stopping">Остановка…</string>
|
||||||
<string name="module_version">Версия модуля</string>
|
<string name="module_version">Версия модуля</string>
|
||||||
@@ -79,5 +78,15 @@
|
|||||||
<string name="qs_working">Работает</string>
|
<string name="qs_working">Работает</string>
|
||||||
<string name="qs_not_working">Не работает</string>
|
<string name="qs_not_working">Не работает</string>
|
||||||
<string name="about_title">О приложении</string>
|
<string name="about_title">О приложении</string>
|
||||||
<string name="about_text">Zaprett app от Cherret, egor-white\nВерсия: %1$s</string>
|
<string name="about_text">zaprett app от Cherret, egor-white\nВерсия: %1$s</string>
|
||||||
|
<string name="btn_whitelist">Белый список приложений</string>
|
||||||
|
<string name="btn_blacklist">Чёрный список приложений</string>
|
||||||
|
<string name="shared_section">Общие настройки</string>
|
||||||
|
<string name="zapret_section">Настройки zapret</string>
|
||||||
|
<string name="title_whitelist">Белый список</string>
|
||||||
|
<string name="title_blacklist">Чёрный список</string>
|
||||||
|
<string name="btn_applist">Списки приложений</string>
|
||||||
|
<string name="radio_disabed">Выключено</string>
|
||||||
|
<string name="btn_show_system_apps">Показывать системные приложения</string>
|
||||||
|
<string name="search_field">Поиск…</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<string name="btn_show_full_path">Show full list\'s path</string>
|
<string name="btn_show_full_path">Show full list\'s path</string>
|
||||||
<string name="pls_reboot_snack">Reboot your device for the changes to take effect</string>
|
<string name="pls_reboot_snack">Reboot your device for the changes to take effect</string>
|
||||||
<string name="pls_restart_snack">Restart zaprett service for the changes to take effects</string>
|
<string name="pls_restart_snack">Restart zaprett service for the changes to take effects</string>
|
||||||
<string name="qs_name">Zaprett</string>
|
<string name="qs_name" translatable="false">zaprett</string>
|
||||||
<string name="qs_starting">Starting…</string>
|
<string name="qs_starting">Starting…</string>
|
||||||
<string name="qs_stopping">Stopping…</string>
|
<string name="qs_stopping">Stopping…</string>
|
||||||
<string name="module_version">Module version</string>
|
<string name="module_version">Module version</string>
|
||||||
@@ -82,5 +82,15 @@
|
|||||||
<string name="qs_working">Working</string>
|
<string name="qs_working">Working</string>
|
||||||
<string name="qs_not_working">Not working</string>
|
<string name="qs_not_working">Not working</string>
|
||||||
<string name="about_title">About app</string>
|
<string name="about_title">About app</string>
|
||||||
<string name="about_text">Zaprett App by Cherret, egor-white\nVersion: %1$s</string>
|
<string name="about_text">zaprett app by Cherret, egor-white\nVersion: %1$s</string>
|
||||||
|
<string name="btn_whitelist">App white list</string>
|
||||||
|
<string name="btn_blacklist">App black list</string>
|
||||||
|
<string name="shared_section">Shared settings</string>
|
||||||
|
<string name="zapret_section">zapret settings</string>
|
||||||
|
<string name="title_whitelist">White list</string>
|
||||||
|
<string name="title_blacklist">Black list</string>
|
||||||
|
<string name="btn_applist">Apps lists</string>
|
||||||
|
<string name="radio_disabed">Disabled</string>
|
||||||
|
<string name="btn_show_system_apps">Show system apps</string>
|
||||||
|
<string name="search_field">Search…</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
Исправление багов в фрагменте хостов
|
Добавление черных списков
|
||||||
Исправление сплющивания карточки информации о модуле
|
Исправление ошибок
|
||||||
Перенос версии byedpi в соответствующее место
|
|
||||||
|
Внимание! Эта версия приложения совместима с модулем версии 5.0+
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.10.1"
|
agp = "8.12.1"
|
||||||
kotlin = "2.0.21"
|
kotlin = "2.2.10"
|
||||||
coreKtx = "1.10.1"
|
coreKtx = "1.17.0"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.1.5"
|
junitVersion = "1.3.0"
|
||||||
espressoCore = "3.5.1"
|
espressoCore = "3.7.0"
|
||||||
lifecycleRuntimeKtx = "2.6.1"
|
lifecycleRuntimeKtx = "2.9.2"
|
||||||
activityCompose = "1.8.0"
|
activityCompose = "1.10.1"
|
||||||
composeBom = "2024.09.00"
|
composeBom = "2025.08.00"
|
||||||
lifecycleService = "2.9.1"
|
compose-material3 = "1.3.2"
|
||||||
|
compose-material3-adaptive = "1.4.0-beta02"
|
||||||
|
navigation = "2.9.3"
|
||||||
|
compose-icons = "1.7.8"
|
||||||
|
libsu = "6.0.0"
|
||||||
|
okhttp = "5.1.0"
|
||||||
|
serialization = "1.9.0"
|
||||||
|
firebase-bom = "34.1.0"
|
||||||
|
fragment-compose = "1.8.9"
|
||||||
|
coil3 = "3.3.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
@@ -25,6 +34,20 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
|
|||||||
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
|
compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "compose-material3" }
|
||||||
|
compose-material3-window-size = { group = "androidx.compose.material3", name = "material3-window-size-class", version.ref = "compose-material3" }
|
||||||
|
compose-material3-adaptive-nav = { group = "androidx.compose.material3", name = "material3-adaptive-navigation-suite", version.ref = "compose-material3-adaptive" }
|
||||||
|
navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" }
|
||||||
|
compose-icons = { group = "androidx.compose.material", name = "material-icons-extended", version.ref = "compose-icons" }
|
||||||
|
libsu-core = { group = "com.github.topjohnwu.libsu", name = "core", version.ref = "libsu" }
|
||||||
|
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
|
||||||
|
serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" }
|
||||||
|
firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebase-bom" }
|
||||||
|
firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics" }
|
||||||
|
firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics" }
|
||||||
|
fragment-compose = { group = "androidx.fragment", name = "fragment-compose", version.ref = "fragment-compose" }
|
||||||
|
coil-compose = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coil3" }
|
||||||
|
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Sat Mar 22 14:00:49 GMT+07:00 2025
|
#Sat Mar 22 14:00:49 GMT+07:00 2025
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
BIN
images/1.png
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 123 KiB |
BIN
images/2.png
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 118 KiB |
BIN
images/3.png
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 130 KiB |
BIN
images/4.png
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 89 KiB |
BIN
images/5.png
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 142 KiB |
BIN
images/6.png
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 113 KiB |
BIN
images/7.png
Normal file
|
After Width: | Height: | Size: 109 KiB |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": "2.1",
|
"version": "2.7",
|
||||||
"versionCode": 13,
|
"versionCode": 19,
|
||||||
"downloadUrl": "https://github.com/CherretGit/zaprett-app/releases/download/2_1/app-release.apk",
|
"downloadUrl": "https://github.com/CherretGit/zaprett-app/releases/download/2_7_0/app-release.apk",
|
||||||
"changelogUrl": "https://raw.githubusercontent.com/CherretGit/zaprett-app/refs/heads/main/changelog.md"
|
"changelogUrl": "https://raw.githubusercontent.com/CherretGit/zaprett-app/refs/heads/main/changelog.md"
|
||||||
}
|
}
|
||||||
|
|||||||