Commit all the project stuff
This commit is contained in:
parent
c957a0c4d8
commit
9818bc323b
|
@ -6,3 +6,5 @@
|
|||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
|
||||
/app/src/main/assets/sia
|
||||
|
|
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
|
@ -0,0 +1,107 @@
|
|||
**Disclaimer:** This is a free and open source project, but it relies on third-party assets and web-services for some functions to work. This project is not affiliated with any third-party entities in any other sense.
|
||||
|
||||
|
||||
# Yet Another Call Blocker
|
||||
|
||||
The goal of this project is to provide a free and open source application that can block unwanted calls or warn about probable intentions of the callers using a third-party crowdsourced phone number database (from some other proprietary app).
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
At this point of time the application is at the very early stages of development and has more of a proof-of-concept nature.
|
||||
|
||||
Currently implemented (more or less; with little to no UI for that):
|
||||
|
||||
* Offline phone number database: querying for data.
|
||||
* Getting delta updates for the database from third-party servers.
|
||||
* "Featured" offline database containing names for some popular (?) phone numbers.
|
||||
* Loading text reviews for specific phone numbers from third-party servers.
|
||||
|
||||
At the proof-of-concept stage are the following features:
|
||||
|
||||
* Showing a notification with some number info (positive/negative, category, number of negative reviews and such) when the phone's ringing.
|
||||
* Loading and displaying a list of reviews for a calling number (accessed by pressing the notification).
|
||||
|
||||
|
||||
## Available 3rd-party data
|
||||
|
||||
The following data is available in the main offline database:
|
||||
|
||||
* a phone number,
|
||||
* a category (telemarketers, dept collectors, scam, etc.),
|
||||
* a number of negative reviews,
|
||||
* a number of positive reviews,
|
||||
* a number of neutral reviews.
|
||||
|
||||
The "featured" database provides "names" (company names or short descriptions) for some (presumably) subset of numbers in the main database.
|
||||
|
||||
The third-party servers can be queried for a list of detailed user reviews for a specific phone number.
|
||||
A detailed review contains:
|
||||
|
||||
* A rating: positive, negative or neutral.
|
||||
* A category: each review may have a different one.
|
||||
* A title and a comment: the actual description the user left for the number.
|
||||
|
||||
The offline databases are extracted from the aforementioned third-party proprietary application.
|
||||
The main database may receive delta updates from the third-party servers.
|
||||
|
||||
|
||||
## Privacy
|
||||
|
||||
Protecting the user's privacy is the first concern during development. No personal data is sent to or otherwise shared with anyone.
|
||||
The only known possible data leaks are the following:
|
||||
|
||||
* Database update procedure leaks user's IP address to the update servers.
|
||||
The request also includes current database version (base or updated).
|
||||
* User review requests leak user's IP address coupled with the phone number in question.
|
||||
Shouldn't be a big deal unless you call it for a bunch of numbers in your phone book.
|
||||
|
||||
No other identifiable information is sent with the requests.
|
||||
|
||||
|
||||
## Rationale
|
||||
|
||||
Some may find the original application (whose DB and servers are used) hard to trust because of its proprietary nature (and also the use of firebase analytics and the like).
|
||||
But since the database behind that application is crowdsourced, some may find it acceptable (in a moral sense) to use that database in a separate open source application.
|
||||
Also, this project is meant to be non-commercial. So, there's that.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[AGPLv3](https://www.gnu.org/licenses/agpl-3.0.en.html).
|
||||
Third-party asset files are required for some functionality.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Any contributions are very welcome.
|
||||
|
||||
|
||||
## Building
|
||||
|
||||
Clone the project repo:
|
||||
|
||||
```
|
||||
git clone https://gitlab.com/xynngh/YetAnotherCallBlocker
|
||||
```
|
||||
|
||||
Clone the assets repo:
|
||||
|
||||
```
|
||||
git clone https://gitlab.com/xynngh/YetAnotherCallBlocker_data
|
||||
```
|
||||
|
||||
Sym-link the assets:
|
||||
|
||||
```
|
||||
cd YetAnotherCallBlocker/app/src/main/assets/
|
||||
ln -s ../../../../../YetAnotherCallBlocker_data/assets/sia .
|
||||
```
|
||||
|
||||
**or** copy the whole directory `YetAnotherCallBlocker_data/assets/sia` into `YetAnotherCallBlocker/app/src/main/assets/`.
|
||||
|
||||
Then you can build the app using Android Studio or using Gradle:
|
||||
|
||||
```
|
||||
./gradlew assemble
|
||||
```
|
|
@ -8,7 +8,6 @@ android {
|
|||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "0.0.1"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -16,9 +15,20 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.slf4j:slf4j-api:1.7.26'
|
||||
implementation 'com.github.tony19:logback-android:2.0.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.14.0'
|
||||
implementation 'commons-codec:commons-codec:1.12' // beware: a version included in Android is used instead
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation 'com.android.support:design:28.0.0'
|
||||
}
|
||||
|
|
|
@ -1,11 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="dummydomain.yetanothercallblocker">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_CALL_LOG" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme" />
|
||||
</manifest>
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".DummyActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ReviewsActivity"
|
||||
android:label="@string/title_activity_reviews"
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
|
||||
<receiver
|
||||
android:name=".CallReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PHONE_STATE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,11 @@
|
|||
<configuration>
|
||||
<appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender">
|
||||
<encoder>
|
||||
<pattern>%msg</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="TRACE">
|
||||
<appender-ref ref="logcat" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,20 @@
|
|||
package dummydomain.yetanothercallblocker;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
private static App instance;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static App getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package dummydomain.yetanothercallblocker;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.DatabaseSingleton;
|
||||
import dummydomain.yetanothercallblocker.sia.model.NumberInfo;
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabaseItem;
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabaseItem;
|
||||
|
||||
public class CallReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CallReceiver.class);
|
||||
|
||||
// TODO: handle in-call calls
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(intent.getAction())) return;
|
||||
|
||||
String telephonyExtraState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
|
||||
String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
|
||||
LOG.info("Received intent: action={}, extraState={}, incomingNumber={}",
|
||||
intent.getAction(), telephonyExtraState, incomingNumber);
|
||||
|
||||
if (TelephonyManager.EXTRA_STATE_RINGING.equals(telephonyExtraState)) {
|
||||
if (incomingNumber == null) return;
|
||||
|
||||
NotificationHelper.showIncomingCallNotification(context, getNumberInfo(incomingNumber));
|
||||
} else if(TelephonyManager.EXTRA_STATE_IDLE.equals(telephonyExtraState)) {
|
||||
NotificationHelper.hideIncomingCallNotification(context, incomingNumber);
|
||||
}
|
||||
}
|
||||
|
||||
protected NumberInfo getNumberInfo(String number) {
|
||||
LOG.debug("getNumberInfo({}) started", number);
|
||||
// TODO: check number format
|
||||
|
||||
CommunityDatabaseItem communityItem = DatabaseSingleton.getCommunityDatabase()
|
||||
.getDbItemByNumber(number);
|
||||
LOG.trace("getNumberInfo() communityItem={}", communityItem);
|
||||
|
||||
FeaturedDatabaseItem featuredItem = DatabaseSingleton.getFeaturedDatabase()
|
||||
.getDbItemByNumber(number);
|
||||
LOG.trace("getNumberInfo() featuredItem={}", featuredItem);
|
||||
|
||||
NumberInfo numberInfo = new NumberInfo();
|
||||
numberInfo.number = number;
|
||||
if (featuredItem != null) numberInfo.name = featuredItem.getName();
|
||||
|
||||
if (communityItem != null && communityItem.hasRatings()) {
|
||||
if (communityItem.getNegativeRatingsCount() > communityItem.getPositiveRatingsCount()
|
||||
+ communityItem.getNeutralRatingsCount()) {
|
||||
numberInfo.rating = NumberInfo.Rating.NEGATIVE;
|
||||
} else if (communityItem.getPositiveRatingsCount() > communityItem.getNeutralRatingsCount()
|
||||
+ communityItem.getNegativeRatingsCount()) {
|
||||
numberInfo.rating = NumberInfo.Rating.POSITIVE;
|
||||
} else if (communityItem.getNeutralRatingsCount() > communityItem.getPositiveRatingsCount()
|
||||
+ communityItem.getNegativeRatingsCount()) {
|
||||
numberInfo.rating = NumberInfo.Rating.NEUTRAL;
|
||||
}
|
||||
}
|
||||
numberInfo.communityDatabaseItem = communityItem;
|
||||
|
||||
LOG.trace("getNumberInfo() rating={}", numberInfo.rating);
|
||||
|
||||
return numberInfo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package dummydomain.yetanothercallblocker;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.DatabaseSingleton;
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabaseItem;
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabaseItem;
|
||||
|
||||
public class DummyActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_dummy);
|
||||
|
||||
PermissionHelper.checkPermissions(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
// TODO: handle
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_dummy, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onQueryDb(MenuItem item) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
CommunityDatabaseItem item = DatabaseSingleton.getCommunityDatabase()
|
||||
.getDbItemByNumber("74995861192");
|
||||
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void onQueryFeaturedDb(MenuItem item) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
FeaturedDatabaseItem item = DatabaseSingleton.getFeaturedDatabase()
|
||||
.getDbItemByNumber("74995861192");
|
||||
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void onUpdateDb(MenuItem item) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
DatabaseSingleton.getCommunityDatabase().updateSecondaryDb();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
Toast.makeText(DummyActivity.this, "Update finished; DB ver: "
|
||||
+ DatabaseSingleton.getCommunityDatabase().getEffectiveDbVersion(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void onTestLoadReviews(MenuItem item) {
|
||||
ReviewsActivity.startForNumber(this, "74995861192");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
package dummydomain.yetanothercallblocker;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
|
||||
import dummydomain.yetanothercallblocker.sia.model.NumberInfo;
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabaseItem;
|
||||
|
||||
public class NotificationHelper {
|
||||
|
||||
private static final String NOTIFICATION_TAG = "incomingCallNotification";
|
||||
private static final int NOTIFICATION_ID = 1;
|
||||
|
||||
private static final String CHANNEL_GROUP_ID_INCOMING_CALLS = "incoming_calls";
|
||||
private static final String CHANNEL_ID_POSITIVE_KNOWN = "positive_known_calls";
|
||||
private static final String CHANNEL_ID_POSITIVE = "positive_calls";
|
||||
private static final String CHANNEL_ID_NEUTRAL = "neutral_calls";
|
||||
private static final String CHANNEL_ID_UNKNOWN = "unknown_calls";
|
||||
private static final String CHANNEL_ID_NEGATIVE = "negative_calls";
|
||||
|
||||
public static void showIncomingCallNotification(Context context, NumberInfo numberInfo) {
|
||||
createNotificationChannels(context);
|
||||
|
||||
Notification notification = createIncomingCallNotification(context, numberInfo);
|
||||
|
||||
String tag = numberInfo.number != null ? NOTIFICATION_TAG + numberInfo.number : null;
|
||||
NotificationManagerCompat.from(context).notify(tag, NOTIFICATION_ID, notification);
|
||||
}
|
||||
|
||||
public static void hideIncomingCallNotification(Context context, String number) {
|
||||
String tag = number != null ? NOTIFICATION_TAG + number : null;
|
||||
NotificationManagerCompat.from(context).cancel(tag, NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
private static Notification createIncomingCallNotification(Context context, NumberInfo numberInfo) {
|
||||
String channelId;
|
||||
String title;
|
||||
String text = "";
|
||||
@DrawableRes int icon;
|
||||
@ColorInt int color;
|
||||
switch (numberInfo.rating) {
|
||||
case POSITIVE:
|
||||
channelId = numberInfo.known ? CHANNEL_ID_POSITIVE_KNOWN : CHANNEL_ID_POSITIVE;
|
||||
title = context.getString(R.string.notification_incoming_call_positive);
|
||||
icon = R.drawable.ic_thumb_up_black_24dp;
|
||||
color = 0xff00ff00;
|
||||
break;
|
||||
|
||||
case NEUTRAL:
|
||||
channelId = CHANNEL_ID_NEUTRAL;
|
||||
title = context.getString(R.string.notification_incoming_call_neutral);
|
||||
icon = R.drawable.ic_thumbs_up_down_black_24dp;
|
||||
color = 0xffffff60;
|
||||
break;
|
||||
|
||||
case NEGATIVE:
|
||||
channelId = CHANNEL_ID_NEGATIVE;
|
||||
title = context.getString(R.string.notification_incoming_call_negative);
|
||||
icon = R.drawable.ic_thumb_down_black_24dp;
|
||||
color = 0xffff0000;
|
||||
break;
|
||||
|
||||
default:
|
||||
channelId = CHANNEL_ID_UNKNOWN;
|
||||
title = context.getString(R.string.notification_incoming_call_unknown);
|
||||
icon = R.drawable.ic_thumbs_up_down_black_24dp;
|
||||
color = 0xffffff60;
|
||||
break;
|
||||
}
|
||||
|
||||
if (numberInfo.communityDatabaseItem != null) {
|
||||
CommunityDatabaseItem communityItem = numberInfo.communityDatabaseItem;
|
||||
|
||||
NumberCategory category = NumberCategory.getById(communityItem.getCategory());
|
||||
if (category != null && category != NumberCategory.NONE) {
|
||||
title += " - " + NumberCategory.getString(context, category);
|
||||
}
|
||||
|
||||
if (numberInfo.name != null) {
|
||||
text += numberInfo.name;
|
||||
}
|
||||
|
||||
if (communityItem.hasRatings()) {
|
||||
if (!text.isEmpty()) text += "; ";
|
||||
text += context.getString(R.string.notification_incoming_call_text_description,
|
||||
communityItem.getNegativeRatingsCount(), communityItem.getPositiveRatingsCount(),
|
||||
communityItem.getNeutralRatingsCount());
|
||||
}
|
||||
}
|
||||
|
||||
Intent intent = ReviewsActivity.getNumberIntent(context, numberInfo.number);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(context, channelId)
|
||||
.setSmallIcon(icon)
|
||||
.setColor(color)
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setCategory(NotificationCompat.CATEGORY_CALL)
|
||||
.setShowWhen(false)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) // TODO: check
|
||||
.setContentIntent(pendingIntent)
|
||||
.build();
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
private static void createNotificationChannels(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|
||||
|
||||
if (notificationManager.getNotificationChannel(CHANNEL_ID_POSITIVE_KNOWN) != null) {
|
||||
// already created
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationChannelGroup channelGroup = new NotificationChannelGroup(CHANNEL_GROUP_ID_INCOMING_CALLS,
|
||||
context.getString(R.string.notification_channel_group_name_incoming_calls));
|
||||
notificationManager.createNotificationChannelGroup(channelGroup);
|
||||
|
||||
List<NotificationChannel> channels = new ArrayList<>();
|
||||
|
||||
NotificationChannel channel;
|
||||
|
||||
channel = new NotificationChannel(
|
||||
CHANNEL_ID_POSITIVE_KNOWN, context.getString(R.string.notification_channel_name_positive_known),
|
||||
NotificationManager.IMPORTANCE_MIN
|
||||
);
|
||||
channel.setGroup(channelGroup.getId());
|
||||
channels.add(channel);
|
||||
|
||||
channel = new NotificationChannel(
|
||||
CHANNEL_ID_POSITIVE, context.getString(R.string.notification_channel_name_positive),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
channel.setGroup(channelGroup.getId());
|
||||
channels.add(channel);
|
||||
|
||||
channel = new NotificationChannel(
|
||||
CHANNEL_ID_NEUTRAL, context.getString(R.string.notification_channel_name_neutral),
|
||||
NotificationManager.IMPORTANCE_MIN
|
||||
);
|
||||
channel.setGroup(channelGroup.getId());
|
||||
channels.add(channel);
|
||||
|
||||
channel = new NotificationChannel(
|
||||
CHANNEL_ID_UNKNOWN, context.getString(R.string.notification_channel_name_unknown),
|
||||
NotificationManager.IMPORTANCE_MIN
|
||||
);
|
||||
channel.setGroup(channelGroup.getId());
|
||||
channels.add(channel);
|
||||
|
||||
channel = new NotificationChannel(
|
||||
CHANNEL_ID_NEGATIVE, context.getString(R.string.notification_channel_name_negative),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
channel.setGroup(channelGroup.getId());
|
||||
channels.add(channel);
|
||||
|
||||
notificationManager.createNotificationChannels(channels);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package dummydomain.yetanothercallblocker;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PermissionHelper {
|
||||
|
||||
private static final int PERMISSION_REQUEST_CODE = 1;
|
||||
|
||||
public static void checkPermissions(AppCompatActivity activity) {
|
||||
List<String> requiredPermissions = new ArrayList<>();
|
||||
requiredPermissions.add(Manifest.permission.READ_PHONE_STATE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
requiredPermissions.add(Manifest.permission.READ_CALL_LOG);
|
||||
}
|
||||
|
||||
List<String> missingPermissions = new ArrayList<>();
|
||||
|
||||
for (String permission : requiredPermissions) {
|
||||
if (ContextCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_DENIED) {
|
||||
missingPermissions.add(permission);
|
||||
}
|
||||
}
|
||||
|
||||
if (!missingPermissions.isEmpty()) {
|
||||
ActivityCompat.requestPermissions(activity,
|
||||
missingPermissions.toArray(new String[0]), PERMISSION_REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package dummydomain.yetanothercallblocker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.model.CommunityReview;
|
||||
import dummydomain.yetanothercallblocker.sia.model.CommunityReviewsLoader;
|
||||
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
|
||||
|
||||
public class ReviewsActivity extends AppCompatActivity {
|
||||
|
||||
private static final String PARAM_NUMBER = "param_number";
|
||||
|
||||
public static Intent getNumberIntent(Context context, String number) {
|
||||
Intent intent = new Intent(context, ReviewsActivity.class);
|
||||
intent.putExtra(PARAM_NUMBER, number);
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void startForNumber(Context context, String number) {
|
||||
context.startActivity(getNumberIntent(context, number));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_reviews);
|
||||
setSupportActionBar(findViewById(R.id.toolbar));
|
||||
|
||||
final String paramNumber = getIntent().getStringExtra(PARAM_NUMBER);
|
||||
|
||||
setText("Loading");
|
||||
|
||||
new AsyncTask<Void, Void, List<CommunityReview>>() {
|
||||
@Override
|
||||
protected List<CommunityReview> doInBackground(Void... voids) {
|
||||
return CommunityReviewsLoader.loadReviews(paramNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<CommunityReview> reviews) {
|
||||
setText(reviewsToString(ReviewsActivity.this, reviews));
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void setText(String mainPart) {
|
||||
TextView textView = findViewById(R.id.text_view);
|
||||
textView.setText(getHeader() + "\n\n" + mainPart);
|
||||
}
|
||||
|
||||
private String getHeader() {
|
||||
return "Reviews for " + getIntent().getStringExtra(PARAM_NUMBER);
|
||||
}
|
||||
|
||||
private static String reviewsToString(Context context, List<CommunityReview> reviews) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (CommunityReview review : reviews) {
|
||||
sb.append(review.getAuthor()).append('\n');
|
||||
sb.append(review.getRating()).append('\n');
|
||||
sb.append(NumberCategory.getString(context, review.getCategory())).append('\n');
|
||||
sb.append(review.getTitle()).append('\n');
|
||||
sb.append(review.getComment()).append('\n');
|
||||
sb.append('\n');
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package dummydomain.yetanothercallblocker.sia;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabase;
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabase;
|
||||
|
||||
public class DatabaseSingleton {
|
||||
|
||||
private static final CommunityDatabase COMMUNITY_DATABASE = new CommunityDatabase();
|
||||
private static final FeaturedDatabase FEATURED_DATABASE = new FeaturedDatabase();
|
||||
|
||||
public static CommunityDatabase getCommunityDatabase() {
|
||||
return COMMUNITY_DATABASE;
|
||||
}
|
||||
|
||||
public static FeaturedDatabase getFeaturedDatabase() {
|
||||
return FEATURED_DATABASE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package dummydomain.yetanothercallblocker.sia;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class SiaSettings {
|
||||
|
||||
private static final String PREF_BASE_DB_VERSION = "baseDbVersion";
|
||||
private static final String PREF_SECONDARY_DB_VERSION = "secondaryDbVersion";
|
||||
|
||||
private final SharedPreferences pref;
|
||||
|
||||
public SiaSettings(Context context) {
|
||||
pref = context.getSharedPreferences("sia_preferences", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public int getBaseDbVersion() {
|
||||
return pref.getInt(PREF_BASE_DB_VERSION, 0);
|
||||
}
|
||||
|
||||
public void setBaseDbVersion(int version) {
|
||||
pref.edit().putInt(PREF_BASE_DB_VERSION, version).apply();
|
||||
}
|
||||
|
||||
public int getSecondaryDbVersion() {
|
||||
return pref.getInt(PREF_SECONDARY_DB_VERSION, 0);
|
||||
}
|
||||
|
||||
public void setSecondaryDbVersion(int version) {
|
||||
pref.edit().putInt(PREF_SECONDARY_DB_VERSION, version).apply();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model;
|
||||
|
||||
public class CommunityReview {
|
||||
|
||||
private int id;
|
||||
|
||||
private NumberRating rating;
|
||||
private NumberCategory category;
|
||||
private String author;
|
||||
private String title;
|
||||
private String comment;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public NumberRating getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(NumberRating rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
public NumberCategory getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(NumberCategory category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommunityReview{" +
|
||||
"id=" + id +
|
||||
", rating=" + rating +
|
||||
", category=" + category +
|
||||
", author='" + author + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", comment='" + comment + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.network.WebService;
|
||||
|
||||
public class CommunityReviewsLoader {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CommunityReviewsLoader.class);
|
||||
|
||||
public static List<CommunityReview> loadReviews(String number) {
|
||||
LOG.debug("loadReviews({}) started", number);
|
||||
|
||||
if (number.startsWith("+")) {
|
||||
number = number.substring(1);
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("number", number);
|
||||
params.put("country", "RU"); // TODO: fix: hardcode
|
||||
|
||||
WebService.WSResponse response = WebService.callForJson(WebService.getGetReviewsUrlPart(), params);
|
||||
|
||||
List<CommunityReview> reviews = new ArrayList<>();
|
||||
|
||||
if (response == null || !response.getSuccessful()) {
|
||||
LOG.warn("loadReviews() response is not successful");
|
||||
return reviews;
|
||||
}
|
||||
|
||||
try {
|
||||
// response.getJsonObject():
|
||||
// "success": boolean
|
||||
// "nn": String number starting with "+"
|
||||
// "count": int number of items
|
||||
// "items": the following array
|
||||
|
||||
JSONArray items = response.getJsonObject().getJSONArray("items");
|
||||
for (int i = 0; i < items.length(); i++) {
|
||||
JSONObject item = items.getJSONObject(i);
|
||||
|
||||
CommunityReview review = new CommunityReview();
|
||||
review.setId(item.getInt("id"));
|
||||
review.setRating(NumberRating.getById(item.getInt("rating")));
|
||||
review.setCategory(NumberCategory.getById(item.getInt("category_id")));
|
||||
review.setAuthor(item.getString("nick"));
|
||||
review.setTitle(item.getString("title"));
|
||||
review.setComment(item.getString("comment"));
|
||||
|
||||
reviews.add(review);
|
||||
}
|
||||
|
||||
LOG.trace("loadReviews() loaded {} reviews", reviews.size());
|
||||
} catch (JSONException e) {
|
||||
LOG.error("loadReviews()", e);
|
||||
}
|
||||
return reviews;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
import dummydomain.yetanothercallblocker.R;
|
||||
|
||||
public enum NumberCategory {
|
||||
|
||||
NONE(0, R.string.sia_category_none),
|
||||
TELEMARKETER(1, R.string.sia_category_telemarketer),
|
||||
DEPT_COLLECTOR(2, R.string.sia_category_dept_collector),
|
||||
SILENT_CALL(3, R.string.sia_category_silent),
|
||||
NUISANCE_CALL(4, R.string.sia_category_nuisance),
|
||||
UNSOLICITED_CALL(5, R.string.sia_category_unsolicited),
|
||||
CALL_CENTER(6, R.string.sia_category_call_center),
|
||||
FAX_MACHINE(7, R.string.sia_category_fax),
|
||||
NON_PROFIT(8, R.string.sia_category_nonprofit),
|
||||
POLITICAL(9, R.string.sia_category_political),
|
||||
SCAM(10, R.string.sia_category_scam),
|
||||
PRANK(11, R.string.sia_category_prank),
|
||||
SMS(12, R.string.sia_category_sms),
|
||||
SURVEY(13, R.string.sia_category_survey),
|
||||
OTHER(14, R.string.sia_category_other),
|
||||
FINANCE_SERVICE(15, R.string.sia_category_financial_service),
|
||||
COMPANY(16, R.string.sia_category_company),
|
||||
SERVICE(17, R.string.sia_category_service),
|
||||
ROBOCALL(18, R.string.sia_category_robocall),
|
||||
// TODO: check: these are probably not present in the db
|
||||
SAFE_PERSONAL(100, R.string.sia_category_safe_personal),
|
||||
SAFE_COMPANY(101, R.string.sia_category_safe_company),
|
||||
SAFE_NONPROFIT(102, R.string.sia_category_safe_nonprofit);
|
||||
|
||||
private int id;
|
||||
private @StringRes int stringId;
|
||||
|
||||
NumberCategory(int id, int stringId) {
|
||||
this.id = id;
|
||||
this.stringId = stringId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public @StringRes int getStringId() {
|
||||
return stringId;
|
||||
}
|
||||
|
||||
public static NumberCategory getById(int id) {
|
||||
for (NumberCategory category : values()) {
|
||||
if (category.getId() == id) return category;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getString(Context context, NumberCategory category) {
|
||||
@StringRes int stringId = category != null
|
||||
? category.getStringId() : R.string.sia_category_none;
|
||||
|
||||
return context.getString(stringId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabaseItem;
|
||||
|
||||
public class NumberInfo {
|
||||
|
||||
public enum Rating {
|
||||
POSITIVE, NEUTRAL, NEGATIVE, UNKNOWN
|
||||
}
|
||||
|
||||
public String number;
|
||||
public String name;
|
||||
public boolean known;
|
||||
public Rating rating = Rating.UNKNOWN;
|
||||
public CommunityDatabaseItem communityDatabaseItem;
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model;
|
||||
|
||||
public enum NumberRating {
|
||||
|
||||
UNKNOWN(0),
|
||||
POSITIVE(1),
|
||||
NEGATIVE(2),
|
||||
NEUTRAL(3);
|
||||
|
||||
private int id;
|
||||
|
||||
NumberRating(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static NumberRating getById(int id) {
|
||||
for (NumberRating rating : values()) {
|
||||
if (rating.getId() == id) return rating;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.utils.Utils;
|
||||
|
||||
public abstract class AbstractDatabase<T extends AbstractDatabaseDataSlice<V>, V> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractDatabase.class);
|
||||
|
||||
protected int baseDatabaseVersion;
|
||||
protected int numberOfItems;
|
||||
|
||||
protected DatabaseDataSliceNode dbRootNode;
|
||||
|
||||
protected SparseArray<T> sliceCache = new SparseArray<>(); // TODO: cache cleaning
|
||||
|
||||
protected boolean loaded;
|
||||
protected boolean failedToLoad;
|
||||
|
||||
protected void checkLoaded() {
|
||||
if (loaded) return;
|
||||
if (failedToLoad) throw new IllegalStateException("The DB has failed to load");
|
||||
|
||||
LOG.debug("checkLoaded() loading DB");
|
||||
loaded = load();
|
||||
failedToLoad = !loaded;
|
||||
}
|
||||
|
||||
protected boolean load() {
|
||||
LOG.debug("load() loading DB");
|
||||
|
||||
if (loadInfoData() && loadSliceListData()) {
|
||||
LOG.info("load() loaded DB, baseDatabaseVersion={}, numberOfItems={}",
|
||||
this.baseDatabaseVersion, this.numberOfItems);
|
||||
return true;
|
||||
} else {
|
||||
LOG.warn("load() failed to load DB");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getAssetPathPrefix() {
|
||||
return "sia/";
|
||||
}
|
||||
|
||||
protected abstract String getAssetNamePrefix();
|
||||
|
||||
protected boolean loadInfoData() {
|
||||
LOG.debug("loadInfoData() started");
|
||||
|
||||
String fileName = getAssetPathPrefix() + getAssetNamePrefix() + "info.dat";
|
||||
try (InputStream is = Utils.getContext().getAssets().open(fileName);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is))) {
|
||||
|
||||
if (!"MDI".equals(bufferedReader.readLine())) {
|
||||
LOG.debug("loadInfoData() incorrect header");
|
||||
return false;
|
||||
}
|
||||
|
||||
// NB: SIA ignores Integer.parseInt() exceptions and falls back to 0
|
||||
|
||||
String dbVersionString = bufferedReader.readLine();
|
||||
int dbVersion = Integer.parseInt(dbVersionString);
|
||||
|
||||
String numberOfItemsString = bufferedReader.readLine();
|
||||
int numberOfItems = Integer.parseInt(numberOfItemsString);
|
||||
|
||||
this.baseDatabaseVersion = dbVersion;
|
||||
this.numberOfItems = numberOfItems;
|
||||
|
||||
LOG.debug("loadInfoData() loaded MDI, baseDatabaseVersion={}, numberOfItems={}",
|
||||
this.baseDatabaseVersion, this.numberOfItems);
|
||||
|
||||
loadInfoDataAfterLoadedHook();
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.error("loadInfoData() error during info file loading", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void loadInfoDataAfterLoadedHook() {}
|
||||
|
||||
protected boolean loadSliceListData() {
|
||||
LOG.debug("loadSliceListData() started");
|
||||
|
||||
String fileName = getAssetPathPrefix() + getAssetNamePrefix() + "list.dat";
|
||||
try (InputStream is = Utils.getContext().getAssets().open(fileName);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is))) {
|
||||
String nodes = bufferedReader.readLine();
|
||||
|
||||
dbRootNode = new DatabaseDataSliceNode();
|
||||
dbRootNode.init(nodes, 0);
|
||||
|
||||
LOG.info("loadSliceListData() loaded slice list data");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.error("loadSliceListData() error", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract V getDbItemByNumberInternal(long number);
|
||||
|
||||
public V getDbItemByNumber(String numberString) {
|
||||
LOG.info("getDbItemByNumber({}) started", numberString);
|
||||
|
||||
if (numberString == null || numberString.isEmpty()) return null;
|
||||
|
||||
if (numberString.startsWith("+")) {
|
||||
numberString = numberString.substring(1);
|
||||
}
|
||||
|
||||
long number;
|
||||
try {
|
||||
number = Long.parseLong(numberString);
|
||||
} catch (NumberFormatException e) {
|
||||
LOG.warn("getDbItemByNumber() couldn't parse number: " + numberString, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
checkLoaded();
|
||||
|
||||
LOG.debug("getDbItemByNumber() calling internal method for {}", number);
|
||||
return getDbItemByNumberInternal(number);
|
||||
}
|
||||
|
||||
protected abstract T createDbDataSlice();
|
||||
|
||||
protected T getDataSlice(long number) {
|
||||
LOG.debug("getDataSlice({}) started", number);
|
||||
|
||||
if (number <= 0) return null;
|
||||
|
||||
int sliceId = dbRootNode.getSliceId(0, String.valueOf(number));
|
||||
LOG.trace("getDataSlice() sliceId={}", sliceId);
|
||||
if (sliceId <= 0) return null;
|
||||
|
||||
T slice = sliceCache.get(sliceId);
|
||||
if (slice == null) {
|
||||
LOG.trace("getDataSlice() loading slice with sliceId={}", sliceId);
|
||||
|
||||
slice = createDbDataSlice();
|
||||
slice.loadFromAsset(Utils.getContext(), sliceId);
|
||||
|
||||
sliceCache.put(sliceId, slice);
|
||||
} else {
|
||||
LOG.trace("getDataSlice() found slice in cache");
|
||||
}
|
||||
return slice;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.utils.LittleEndianDataInputStream;
|
||||
|
||||
public abstract class AbstractDatabaseDataSlice<T> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractDatabaseDataSlice.class);
|
||||
|
||||
protected int dbVersion;
|
||||
|
||||
protected int numberOfItems;
|
||||
|
||||
protected long[] numbers;
|
||||
|
||||
protected long lastAccessTimestamp;
|
||||
|
||||
public int getDbVersion() {
|
||||
return this.dbVersion;
|
||||
}
|
||||
|
||||
public int getNumberOfItems() {
|
||||
return this.numberOfItems;
|
||||
}
|
||||
|
||||
public long getLastAccessTimestamp() {
|
||||
return this.lastAccessTimestamp;
|
||||
}
|
||||
|
||||
protected int indexOf(long number) {
|
||||
if (numberOfItems > 0) {
|
||||
int low = 0;
|
||||
int high = numberOfItems - 1;
|
||||
|
||||
while (low <= high) {
|
||||
int mid = (high + low) / 2;
|
||||
long num = numbers[mid];
|
||||
|
||||
if (num < number) {
|
||||
low = mid + 1;
|
||||
} else if (num > number) {
|
||||
high = mid - 1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public T getDbItemByNumber(long number) {
|
||||
// LOG.debug("getDbItemByNumber({}) started", number);
|
||||
|
||||
lastAccessTimestamp = System.currentTimeMillis();
|
||||
|
||||
int index = indexOf(number);
|
||||
// LOG.trace("getDbItemByNumber() index={}", index);
|
||||
if (index < 0) return null;
|
||||
|
||||
return getDbItemByNumberInternal(number, index);
|
||||
}
|
||||
|
||||
protected abstract T getDbItemByNumberInternal(long number, int index);
|
||||
|
||||
protected void loadFromStreamCheckHeader(String header) {}
|
||||
|
||||
protected void loadFromStreamReadPostHeaderData(LittleEndianDataInputStream stream) throws IOException {}
|
||||
|
||||
protected void loadFromStreamReadPostVersionData(LittleEndianDataInputStream stream) throws IOException {}
|
||||
|
||||
protected void loadFromStreamInitFields() {}
|
||||
|
||||
protected void loadFromStreamLoadFields(int index, LittleEndianDataInputStream stream) throws IOException {}
|
||||
|
||||
protected void loadFromStreamLoadExtras(LittleEndianDataInputStream stream) throws IOException {
|
||||
int numberOfExtras = stream.readInt();
|
||||
if (numberOfExtras != 0) {
|
||||
throw new IllegalStateException("Number of extras is not 0: " + numberOfExtras);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loadFromStream(BufferedInputStream inputStream) {
|
||||
LOG.debug("loadFromStream() started");
|
||||
|
||||
try {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
|
||||
this.dbVersion = 0;
|
||||
|
||||
LittleEndianDataInputStream stream = new LittleEndianDataInputStream(inputStream);
|
||||
|
||||
LOG.trace("loadFromStream() reading header");
|
||||
String headerString = stream.readUtf8StringChars(4);
|
||||
loadFromStreamCheckHeader(headerString);
|
||||
|
||||
LOG.trace("loadFromStream() reading post header data");
|
||||
loadFromStreamReadPostHeaderData(stream);
|
||||
|
||||
LOG.trace("loadFromStream() reading DB version");
|
||||
this.dbVersion = stream.readInt();
|
||||
LOG.trace("loadFromStream() DB version is {}", dbVersion);
|
||||
|
||||
LOG.trace("loadFromStream() reading post version data");
|
||||
loadFromStreamReadPostVersionData(stream);
|
||||
|
||||
LOG.trace("loadFromStream() reading number of items");
|
||||
this.numberOfItems = stream.readInt();
|
||||
LOG.trace("loadFromStream() number of items is {}", numberOfItems);
|
||||
|
||||
this.numbers = new long[this.numberOfItems];
|
||||
|
||||
loadFromStreamInitFields();
|
||||
|
||||
LOG.trace("loadFromStream() reading fields");
|
||||
for (int i = 0; i < this.numberOfItems; i++) {
|
||||
this.numbers[i] = stream.readLong();
|
||||
loadFromStreamLoadFields(i, stream);
|
||||
}
|
||||
LOG.trace("loadFromStream() finished reading fields");
|
||||
|
||||
LOG.trace("loadFromStream() reading CP");
|
||||
String dividerString = stream.readUtf8StringChars(2);
|
||||
if (!"CP".equalsIgnoreCase(dividerString)) {
|
||||
throw new IllegalStateException("CP not found. Found instead: " + dividerString);
|
||||
}
|
||||
|
||||
LOG.trace("loadFromStream() reading extras");
|
||||
loadFromStreamLoadExtras(stream);
|
||||
|
||||
LOG.trace("loadFromStream() reading endmark");
|
||||
String endmarkString = stream.readUtf8StringChars(6);
|
||||
if (!"MTZEND".equalsIgnoreCase(endmarkString)) {
|
||||
throw new IllegalStateException("Endmark not found. Found instead: " + endmarkString);
|
||||
}
|
||||
|
||||
LOG.debug("loadFromStream() loaded slice with {} items in {} ms",
|
||||
numberOfItems, System.currentTimeMillis() - currentTimeMillis);
|
||||
} catch (Exception e) {
|
||||
LOG.error("loadFromStream()", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getAssetPathPrefix() {
|
||||
return "sia/";
|
||||
}
|
||||
|
||||
protected abstract String getAssetNamePrefix();
|
||||
|
||||
public void loadFromAsset(Context context, int sliceId) {
|
||||
LOG.debug("loadFromAsset() started with sliceId={}", sliceId);
|
||||
|
||||
String assetName = getAssetPathPrefix() + getAssetNamePrefix() + String.valueOf(sliceId) + ".dat";
|
||||
LOG.trace("loadFromAsset() assetName={}", assetName);
|
||||
|
||||
try (InputStream is = context.getAssets().open(assetName);
|
||||
BufferedInputStream stream = new BufferedInputStream(is)) {
|
||||
|
||||
loadFromStream(stream);
|
||||
} catch (Exception e) {
|
||||
LOG.error("loadFromAsset()", e);
|
||||
}
|
||||
LOG.trace("loadFromAsset() finished");
|
||||
}
|
||||
|
||||
public void loadFromFile(String fileName) {
|
||||
LOG.debug("loadFromFile({}) started", fileName);
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(fileName);
|
||||
BufferedInputStream stream = new BufferedInputStream(fis)) {
|
||||
|
||||
loadFromStream(stream);
|
||||
} catch (Exception e) {
|
||||
LOG.error("loadFromFile()", e);
|
||||
}
|
||||
LOG.trace("loadFromFile() finished");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AbstractDatabaseDataSlice{" +
|
||||
"dbVersion=" + dbVersion +
|
||||
", numberOfItems=" + numberOfItems +
|
||||
", lastAccessTimestamp=" + lastAccessTimestamp +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,372 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.network.WebService;
|
||||
import dummydomain.yetanothercallblocker.sia.utils.Utils;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class CommunityDatabase extends AbstractDatabase<CommunityDatabaseDataSlice, CommunityDatabaseItem> {
|
||||
|
||||
private enum UpdateResult {
|
||||
UPDATED, NO_UPDATES, OUTDATED_APP, BAD_SECONDARY, UNKNOWN_ERROR
|
||||
}
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CommunityDatabase.class);
|
||||
|
||||
private int siaAppVersion = 114;
|
||||
|
||||
private SparseArray<CommunityDatabaseDataSlice> secondarySliceCache = new SparseArray<>();
|
||||
|
||||
private SparseArray<Boolean> existingSecondarySliceFiles = new SparseArray<>();
|
||||
|
||||
public int getEffectiveDbVersion() {
|
||||
checkLoaded();
|
||||
|
||||
int secondaryDbVersion = Utils.getSettings().getSecondaryDbVersion();
|
||||
return secondaryDbVersion > 0 ? secondaryDbVersion : baseDatabaseVersion;
|
||||
}
|
||||
|
||||
public int getSiaAppVersion() {
|
||||
return siaAppVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAssetNamePrefix() {
|
||||
return "data_slice_";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean load() {
|
||||
if (!super.load()) return false;
|
||||
|
||||
LOG.debug("load() started");
|
||||
|
||||
String fileName = getAssetPathPrefix() + "sia_info.dat";
|
||||
try (InputStream is = Utils.getContext().getAssets().open(fileName);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is))) {
|
||||
|
||||
if (!"SIA".equals(bufferedReader.readLine())) {
|
||||
LOG.debug("load() incorrect header");
|
||||
return false;
|
||||
}
|
||||
|
||||
String appVersionString = bufferedReader.readLine();
|
||||
siaAppVersion = Integer.parseInt(appVersionString);
|
||||
|
||||
LOG.debug("load() loaded extra info; siaAppVersion={}", this.siaAppVersion);
|
||||
} catch (Exception e) {
|
||||
LOG.debug("load() failed to load extra info", e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadInfoDataAfterLoadedHook() {
|
||||
int oldDbVersion = Utils.getSettings().getBaseDbVersion();
|
||||
if (baseDatabaseVersion != oldDbVersion) {
|
||||
LOG.info("loadInfoDataAfterLoadedHook() base version changed; resetting secondary DB;" +
|
||||
" oldDbVersion={}, baseDatabaseVersion={}", oldDbVersion, baseDatabaseVersion);
|
||||
resetSecondaryDatabase();
|
||||
Utils.getSettings().setBaseDbVersion(baseDatabaseVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommunityDatabaseItem getDbItemByNumberInternal(long number) {
|
||||
LOG.debug("getDbItemByNumberInternal({}) started", number);
|
||||
|
||||
CommunityDatabaseDataSlice secondarySlice = getSecondaryDataSlice(number);
|
||||
|
||||
CommunityDatabaseItem communityDatabaseItem = secondarySlice != null
|
||||
? secondarySlice.getDbItemByNumber(number) : null;
|
||||
|
||||
if (communityDatabaseItem == null) {
|
||||
LOG.trace("getDbItemByNumberInternal() not found in secondary DB");
|
||||
CommunityDatabaseDataSlice baseSlice = getDataSlice(number);
|
||||
communityDatabaseItem = baseSlice != null ? baseSlice.getDbItemByNumber(number) : null;
|
||||
}
|
||||
|
||||
LOG.trace("getDbItemByNumberInternal() communityDatabaseItem={}", communityDatabaseItem);
|
||||
|
||||
if (communityDatabaseItem != null && !communityDatabaseItem.hasRatings()) {
|
||||
communityDatabaseItem = null;
|
||||
}
|
||||
|
||||
return communityDatabaseItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommunityDatabaseDataSlice createDbDataSlice() {
|
||||
return new CommunityDatabaseDataSlice();
|
||||
}
|
||||
|
||||
private CommunityDatabaseDataSlice getSecondaryDataSlice(long number) {
|
||||
LOG.debug("getSecondaryDataSlice({}) started", number);
|
||||
|
||||
if (number <= 0) return null;
|
||||
|
||||
String numberString = String.valueOf(number);
|
||||
if (numberString.length() < 2) return null;
|
||||
|
||||
int sliceId = Integer.valueOf(numberString.substring(0, 2));
|
||||
LOG.trace("getSecondaryDataSlice() sliceId={}", sliceId);
|
||||
|
||||
CommunityDatabaseDataSlice communityDatabaseDataSlice = secondarySliceCache.get(sliceId);
|
||||
if (communityDatabaseDataSlice == null) {
|
||||
LOG.trace("getSecondaryDataSlice() trying to load slice with sliceId={}", sliceId);
|
||||
|
||||
communityDatabaseDataSlice = new CommunityDatabaseDataSlice();
|
||||
String path = getCachedSecondarySliceFilePath(sliceId);
|
||||
if (path != null) {
|
||||
LOG.trace("getSecondaryDataSlice() slice file exists, loading from: {}", path);
|
||||
communityDatabaseDataSlice.loadFromFile(path);
|
||||
} else {
|
||||
LOG.trace("getSecondaryDataSlice() slice file doesn't exist");
|
||||
}
|
||||
secondarySliceCache.put(sliceId, communityDatabaseDataSlice);
|
||||
} else {
|
||||
LOG.trace("getSecondaryDataSlice() found slice in cache");
|
||||
}
|
||||
return communityDatabaseDataSlice;
|
||||
}
|
||||
|
||||
private String getCachedSecondarySliceFilePath(int id) {
|
||||
String path = getSecondarySliceFilePath(id);
|
||||
Boolean exists = existingSecondarySliceFiles.get(id, null);
|
||||
if (exists == null) {
|
||||
exists = new File(path).exists();
|
||||
existingSecondarySliceFiles.put(id, exists);
|
||||
}
|
||||
return exists ? path : null;
|
||||
}
|
||||
|
||||
private String getSecondarySliceFilePath(int id) {
|
||||
File dir = Utils.getContext().getFilesDir();
|
||||
return dir.getAbsolutePath() + "/sia_updates_" + id + ".mtz";
|
||||
}
|
||||
|
||||
public void resetSecondaryDatabase() {
|
||||
LOG.debug("resetSecondaryDatabase() started");
|
||||
|
||||
FileFilter fileFilter = new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.getName().endsWith(".mtz");
|
||||
}
|
||||
};
|
||||
|
||||
for (File file : Utils.getContext().getFilesDir().listFiles(fileFilter)) {
|
||||
if (!file.delete()) {
|
||||
LOG.warn("resetSecondaryDatabase() failed to delete secondary DB file: {}", file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
secondarySliceCache.clear();
|
||||
existingSecondarySliceFiles.clear();
|
||||
Utils.getSettings().setSecondaryDbVersion(0);
|
||||
|
||||
LOG.info("resetSecondaryDatabase() secondary DB was reset");
|
||||
}
|
||||
|
||||
public void updateSecondaryDb() {
|
||||
LOG.info("updateSecondaryDb() started");
|
||||
|
||||
long startTimestamp = System.currentTimeMillis();
|
||||
|
||||
boolean updated = false;
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
UpdateResult result = updateSecondaryDbInternal();
|
||||
LOG.debug("updateSecondaryDb() internal update result: {}", result);
|
||||
if (result == UpdateResult.UPDATED) {
|
||||
updated = true;
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("updateSecondaryDb DB version after update: ", getEffectiveDbVersion());
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
LOG.info("updateSecondaryDb() new DB version: {}", getEffectiveDbVersion());
|
||||
}
|
||||
|
||||
LOG.info("updateSecondaryDb() finished in {} ms", System.currentTimeMillis() - startTimestamp);
|
||||
}
|
||||
|
||||
private UpdateResult updateSecondaryDbInternal() {
|
||||
LOG.debug("updateSecondaryDbInternal() started");
|
||||
|
||||
long startTimestamp = System.currentTimeMillis();
|
||||
|
||||
int effectiveDbVersion = getEffectiveDbVersion();
|
||||
LOG.debug("updateSecondaryDbInternal() effectiveDbVersion={}", effectiveDbVersion);
|
||||
|
||||
String dbVersionParam = "_dbVer=" + effectiveDbVersion;
|
||||
String urlPath = WebService.getGetDatabaseUrlPart() + "/cached?" + dbVersionParam;
|
||||
|
||||
try {
|
||||
Response response = WebService.call(urlPath, new HashMap<>());
|
||||
if (response != null) {
|
||||
ResponseBody body = response.body();
|
||||
MediaType contentType = body.contentType();
|
||||
LOG.debug("updateSecondaryDbInternal() response contentType={}", contentType);
|
||||
|
||||
if (contentType != null && "application".equals(contentType.type())) {
|
||||
LOG.trace("updateSecondaryDbInternal() saving response data to file");
|
||||
|
||||
File tempFile = File.createTempFile("mtz", "database", Utils.getContext().getCacheDir());
|
||||
|
||||
int totalRead = 0;
|
||||
try (InputStream in = body.byteStream();
|
||||
OutputStream out = new FileOutputStream(tempFile)) {
|
||||
byte[] buff = new byte[10240];
|
||||
|
||||
while (true) {
|
||||
int read = in.read(buff);
|
||||
if (read == -1) {
|
||||
break;
|
||||
}
|
||||
out.write(buff, 0, read);
|
||||
totalRead += read;
|
||||
}
|
||||
}
|
||||
|
||||
LOG.trace("updateSecondaryDbInternal() finished saving response data to file; totalRead={}", totalRead);
|
||||
|
||||
if (totalRead > 0) {
|
||||
try (FileInputStream fis = new FileInputStream(tempFile);
|
||||
BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(fis))) {
|
||||
LOG.trace("updateSecondaryDbInternal() loading slice from received data");
|
||||
CommunityDatabaseDataSlice slice = new CommunityDatabaseDataSlice();
|
||||
if (slice.loadFromStream(bis)) {
|
||||
LOG.trace("updateSecondaryDbInternal() distributing slice");
|
||||
updateSecondaryWithSlice(slice);
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG.trace("updateSecondaryDbInternal() finished processing slice");
|
||||
|
||||
if (!tempFile.delete()) {
|
||||
LOG.warn("updateSecondaryDbInternal() failed to delete tempFile ", tempFile);
|
||||
}
|
||||
|
||||
LOG.debug("updateSecondaryDbInternal() updated performed successfully in {} ms",
|
||||
System.currentTimeMillis() - startTimestamp);
|
||||
|
||||
return UpdateResult.UPDATED;
|
||||
} else {
|
||||
String responseString = body.string();
|
||||
LOG.debug("updateSecondaryDbInternal() responseString={}, elapsed time: {} ms",
|
||||
responseString, System.currentTimeMillis() - startTimestamp);
|
||||
|
||||
responseString = responseString.replaceAll("\n", "");
|
||||
if ("OAP".equals(responseString)) {
|
||||
LOG.trace("updateSecondaryDbInternal() server reported outdated app");
|
||||
// outdated app
|
||||
return UpdateResult.OUTDATED_APP;
|
||||
} else if ("NC".equals(responseString)) {
|
||||
LOG.trace("updateSecondaryDbInternal() server reported no updates");
|
||||
// "No checkAndUpdate available" - probably "up to date"
|
||||
return UpdateResult.NO_UPDATES;
|
||||
} else if ("OOD".equals(responseString)) {
|
||||
LOG.trace("updateSecondaryDbInternal() server suggests to reset secondary DB");
|
||||
// remove secondary DB and retry
|
||||
return UpdateResult.BAD_SECONDARY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG.warn("updateSecondaryDbInternal() response is null");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("updateSecondaryDbInternal() IOE", e);
|
||||
} catch (Exception e) {
|
||||
LOG.error("updateSecondaryDbInternal()", e);
|
||||
}
|
||||
return UpdateResult.UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
private boolean updateSecondaryWithSlice(CommunityDatabaseDataSlice dataSlice) {
|
||||
LOG.debug("updateSecondaryWithSlice() started");
|
||||
LOG.trace("updateSecondaryWithSlice() dataSlice={}", dataSlice);
|
||||
|
||||
long startTimestamp = System.currentTimeMillis();
|
||||
try {
|
||||
SparseArray<List<Integer>> shortSliceIdToIndexMap = new SparseArray<>();
|
||||
SparseArray<List<Integer>> shortSliceIdToIndexToDeleteMap = new SparseArray<>();
|
||||
dataSlice.fillIndexMaps(shortSliceIdToIndexMap, shortSliceIdToIndexToDeleteMap);
|
||||
|
||||
ArrayList<Integer> updatedIndexes = new ArrayList<>();
|
||||
for (int sliceId = 0; sliceId <= 99; sliceId++) {
|
||||
String filePath = getSecondarySliceFilePath(sliceId);
|
||||
|
||||
CommunityDatabaseDataSlice newSlice = new CommunityDatabaseDataSlice();
|
||||
if (newSlice.partialClone(dataSlice, sliceId, shortSliceIdToIndexMap, shortSliceIdToIndexToDeleteMap)) {
|
||||
CommunityDatabaseDataSlice sliceFromExistingFile = new CommunityDatabaseDataSlice();
|
||||
if (getCachedSecondarySliceFilePath(sliceId) != null) {
|
||||
sliceFromExistingFile.loadFromFile(filePath);
|
||||
}
|
||||
|
||||
try (BufferedOutputStream stream = new BufferedOutputStream(
|
||||
new FileOutputStream(filePath + ".update", false))) {
|
||||
sliceFromExistingFile.writeMerged(newSlice, stream);
|
||||
}
|
||||
|
||||
updatedIndexes.add(sliceId);
|
||||
|
||||
LOG.debug("updateSecondaryWithSlice() added {} items to sliceId={}", newSlice.getNumberOfItems(), sliceId);
|
||||
}
|
||||
}
|
||||
|
||||
LOG.debug("updateSecondaryWithSlice() update files created, renaming files");
|
||||
|
||||
for (int sliceId : updatedIndexes) {
|
||||
String filePath = getSecondarySliceFilePath(sliceId);
|
||||
|
||||
File updatedFile = new File(filePath + ".update");
|
||||
File oldFile = new File(filePath);
|
||||
if (oldFile.exists() && !oldFile.delete()) {
|
||||
throw new IllegalStateException("Can't delete " + filePath);
|
||||
}
|
||||
if (!updatedFile.renameTo(oldFile)) {
|
||||
throw new IllegalStateException("Can't replace slice " + updatedFile);
|
||||
}
|
||||
}
|
||||
|
||||
Utils.getSettings().setSecondaryDbVersion(dataSlice.getDbVersion());
|
||||
secondarySliceCache.clear();
|
||||
existingSecondarySliceFiles.clear();
|
||||
|
||||
LOG.debug("updateSecondaryWithSlice() finished in {} ms", System.currentTimeMillis() - startTimestamp);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.error("updateSecondaryWithSlice()", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.utils.LittleEndianDataInputStream;
|
||||
import dummydomain.yetanothercallblocker.sia.utils.LittleEndianDataOutputStream;
|
||||
|
||||
public class CommunityDatabaseDataSlice extends AbstractDatabaseDataSlice<CommunityDatabaseItem> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CommunityDatabaseDataSlice.class);
|
||||
|
||||
private byte[] positiveRatingsCounts;
|
||||
private byte[] negativeRatingsCounts;
|
||||
private byte[] neutralRatingsCounts;
|
||||
private byte[] unknownData;
|
||||
private byte[] categories;
|
||||
|
||||
private long[] numbersToDelete;
|
||||
|
||||
public void fillIndexMaps(SparseArray<List<Integer>> shortSliceIdToIndexMap,
|
||||
SparseArray<List<Integer>> shortSliceIdToIndexToDeleteMap) {
|
||||
for (int i = 0; i <= 99; i++) {
|
||||
shortSliceIdToIndexMap.put(i, new ArrayList<>());
|
||||
shortSliceIdToIndexToDeleteMap.put(i, new ArrayList<>());
|
||||
}
|
||||
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
String numberString = String.valueOf(numbers[i]);
|
||||
if (numberString.length() > 1) {
|
||||
int sliceId = Integer.valueOf(numberString.substring(0, 2));
|
||||
shortSliceIdToIndexMap.get(sliceId).add(i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < numbersToDelete.length; i++) {
|
||||
String numberString = String.valueOf(numbersToDelete[i]);
|
||||
if (numberString.length() > 1) {
|
||||
int sliceId = Integer.valueOf(numberString.substring(0, 2));
|
||||
shortSliceIdToIndexToDeleteMap.get(sliceId).add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean partialClone(CommunityDatabaseDataSlice source, int shortSliceId,
|
||||
SparseArray<List<Integer>> shortSliceIdToIndexMap,
|
||||
SparseArray<List<Integer>> shortSliceIdToIndexToDeleteMap) {
|
||||
List<Integer> numberIndexList = shortSliceIdToIndexMap.get(shortSliceId);
|
||||
this.numberOfItems = numberIndexList.size();
|
||||
this.dbVersion = source.dbVersion;
|
||||
this.numbers = new long[this.numberOfItems];
|
||||
this.positiveRatingsCounts = new byte[this.numberOfItems];
|
||||
this.negativeRatingsCounts = new byte[this.numberOfItems];
|
||||
this.neutralRatingsCounts = new byte[this.numberOfItems];
|
||||
this.unknownData = new byte[this.numberOfItems];
|
||||
this.categories = new byte[this.numberOfItems];
|
||||
for (int i = 0; i < this.numberOfItems; i++) {
|
||||
int index = numberIndexList.get(i);
|
||||
this.numbers[i] = source.numbers[index];
|
||||
this.positiveRatingsCounts[i] = source.positiveRatingsCounts[index];
|
||||
this.negativeRatingsCounts[i] = source.negativeRatingsCounts[index];
|
||||
this.neutralRatingsCounts[i] = source.neutralRatingsCounts[index];
|
||||
this.unknownData[i] = source.unknownData[index];
|
||||
this.categories[i] = source.categories[index];
|
||||
}
|
||||
|
||||
List<Integer> numbersToDeleteIndexList = shortSliceIdToIndexToDeleteMap.get(shortSliceId);
|
||||
this.numbersToDelete = new long[numbersToDeleteIndexList.size()];
|
||||
for (int i = 0; i < numbersToDelete.length; i++) {
|
||||
this.numbersToDelete[i] = source.numbersToDelete[numbersToDeleteIndexList.get(i)];
|
||||
}
|
||||
|
||||
return this.numberOfItems > 0 || numbersToDelete.length > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommunityDatabaseItem getDbItemByNumberInternal(long number, int index) {
|
||||
CommunityDatabaseItem communityDatabaseItem = new CommunityDatabaseItem();
|
||||
communityDatabaseItem.setNumber(numbers[index]);
|
||||
communityDatabaseItem.setPositiveRatingsCount(positiveRatingsCounts[index] & 255);
|
||||
communityDatabaseItem.setNegativeRatingsCount(negativeRatingsCounts[index] & 255);
|
||||
communityDatabaseItem.setNeutralRatingsCount(neutralRatingsCounts[index] & 255);
|
||||
communityDatabaseItem.setUnknownData(unknownData[index] & 255);
|
||||
communityDatabaseItem.setCategory(categories[index] & 255);
|
||||
return communityDatabaseItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamCheckHeader(String header) {
|
||||
if (!"MTZF".equalsIgnoreCase(header) && !"MTZD".equalsIgnoreCase(header)) {
|
||||
throw new IllegalStateException("Invalid header. Actual value: " + header);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamReadPostHeaderData(LittleEndianDataInputStream stream) throws IOException {
|
||||
byte b = stream.readByte(); // ignored
|
||||
LOG.trace("loadFromStreamReadPostHeaderData() b={}", b);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamReadPostVersionData(LittleEndianDataInputStream stream) throws IOException {
|
||||
String s = stream.readUtf8StringChars(2); // ignored
|
||||
int i = stream.readInt(); // ignored
|
||||
LOG.trace("loadFromStreamReadPostVersionData() s={}, i={}", s, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamInitFields() {
|
||||
positiveRatingsCounts = new byte[numberOfItems];
|
||||
negativeRatingsCounts = new byte[numberOfItems];
|
||||
neutralRatingsCounts = new byte[numberOfItems];
|
||||
unknownData = new byte[numberOfItems];
|
||||
categories = new byte[numberOfItems];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamLoadFields(int index, LittleEndianDataInputStream stream) throws IOException {
|
||||
positiveRatingsCounts[index] = stream.readByte();
|
||||
negativeRatingsCounts[index] = stream.readByte();
|
||||
neutralRatingsCounts[index] = stream.readByte();
|
||||
unknownData[index] = stream.readByte();
|
||||
categories[index] = stream.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamLoadExtras(LittleEndianDataInputStream stream) throws IOException {
|
||||
int numberOfItemsToDelete = stream.readInt();
|
||||
LOG.trace("loadFromStreamLoadExtras() numberOfItemsToDelete={}", numberOfItemsToDelete);
|
||||
|
||||
numbersToDelete = new long[numberOfItemsToDelete];
|
||||
for (int i = 0; i < numberOfItemsToDelete; i++) {
|
||||
numbersToDelete[i] = stream.readLong();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAssetNamePrefix() {
|
||||
return "data_slice_";
|
||||
}
|
||||
|
||||
public boolean writeMerged(CommunityDatabaseDataSlice newSlice, BufferedOutputStream outputStream) {
|
||||
LOG.debug("writeMerged() started with newSlice={}", newSlice);
|
||||
|
||||
try {
|
||||
int realNumberOfItems = 0;
|
||||
int newNumberOfItems = this.numberOfItems;
|
||||
if (newSlice != null) {
|
||||
if (this.numberOfItems > 0) {
|
||||
for (long n : newSlice.numbers) {
|
||||
if (indexOf(n) == -1) {
|
||||
newNumberOfItems++;
|
||||
}
|
||||
}
|
||||
for (long n : newSlice.numbersToDelete) {
|
||||
if (indexOf(n) == -1) {
|
||||
newNumberOfItems++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newNumberOfItems = newSlice.numberOfItems + newSlice.numbersToDelete.length;
|
||||
}
|
||||
}
|
||||
|
||||
LittleEndianDataOutputStream stream = new LittleEndianDataOutputStream(outputStream);
|
||||
stream.writeUtf8StringChars("MTZF");
|
||||
stream.writeByte((byte) 1);
|
||||
stream.writeInt(newSlice != null ? newSlice.dbVersion : this.dbVersion);
|
||||
stream.writeUtf8StringChars("ww");
|
||||
stream.writeInt(0);
|
||||
stream.writeInt(newNumberOfItems);
|
||||
|
||||
if (this.numberOfItems >= 0) {
|
||||
int sourceIndex = 0;
|
||||
int newIndex = 0;
|
||||
int newDeletedIndex = 0;
|
||||
do {
|
||||
long sourceNumber = sourceIndex < this.numberOfItems ? this.numbers[sourceIndex] : Long.MAX_VALUE;
|
||||
boolean replacesSourceNumber = false;
|
||||
if (newSlice != null) {
|
||||
while (true) {
|
||||
long newNumber = (newIndex >= newSlice.numbers.length || newSlice.numbers[newIndex] > sourceNumber) ? 0 : newSlice.numbers[newIndex];
|
||||
long newDeletedNumber = (newDeletedIndex >= newSlice.numbersToDelete.length || newSlice.numbersToDelete[newDeletedIndex] > sourceNumber) ? 0 : newSlice.numbersToDelete[newDeletedIndex];
|
||||
if (newNumber <= 0 || (newDeletedNumber != 0 && newNumber >= newDeletedNumber)) {
|
||||
if (newDeletedNumber <= 0) {
|
||||
break;
|
||||
}
|
||||
stream.writeLong(newSlice.numbersToDelete[newDeletedIndex]);
|
||||
byte zero = (byte) 0;
|
||||
stream.writeByte(zero);
|
||||
stream.writeByte(zero);
|
||||
stream.writeByte(zero);
|
||||
stream.writeByte(zero);
|
||||
stream.writeByte(zero);
|
||||
replacesSourceNumber = newSlice.numbersToDelete[newDeletedIndex] == sourceNumber;
|
||||
newDeletedIndex++;
|
||||
realNumberOfItems++;
|
||||
} else {
|
||||
stream.writeLong(newSlice.numbers[newIndex]);
|
||||
stream.writeByte(newSlice.positiveRatingsCounts[newIndex]);
|
||||
stream.writeByte(newSlice.negativeRatingsCounts[newIndex]);
|
||||
stream.writeByte(newSlice.neutralRatingsCounts[newIndex]);
|
||||
stream.writeByte(newSlice.unknownData[newIndex]);
|
||||
stream.writeByte(newSlice.categories[newIndex]);
|
||||
replacesSourceNumber = newSlice.numbers[newIndex] == sourceNumber;
|
||||
newIndex++;
|
||||
realNumberOfItems++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!replacesSourceNumber && sourceIndex < this.numberOfItems) {
|
||||
stream.writeLong(this.numbers[sourceIndex]);
|
||||
stream.writeByte(this.positiveRatingsCounts[sourceIndex]);
|
||||
stream.writeByte(this.negativeRatingsCounts[sourceIndex]);
|
||||
stream.writeByte(this.neutralRatingsCounts[sourceIndex]);
|
||||
stream.writeByte(this.unknownData[sourceIndex]);
|
||||
stream.writeByte(this.categories[sourceIndex]);
|
||||
realNumberOfItems++;
|
||||
}
|
||||
} while (sourceIndex++ != this.numberOfItems);
|
||||
}
|
||||
if (realNumberOfItems != newNumberOfItems) {
|
||||
LOG.error("writeMerged() realNumberOfItems={}, newNumberOfItems={}, dbVersion={}, newSlice.dbVersion={}",
|
||||
realNumberOfItems, newNumberOfItems, dbVersion, newSlice != null ? newSlice.dbVersion : 0);
|
||||
throw new IllegalStateException("writeMerged results in invalid realNumberOfItems!");
|
||||
}
|
||||
stream.writeUtf8StringChars("CP");
|
||||
stream.writeInt(0);
|
||||
stream.writeUtf8StringChars("MTZEND");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
LOG.error("writeMerged()", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
public class CommunityDatabaseItem {
|
||||
|
||||
private long number;
|
||||
|
||||
private int positiveRatingsCount;
|
||||
private int negativeRatingsCount;
|
||||
private int neutralRatingsCount;
|
||||
|
||||
private int unknownData;
|
||||
|
||||
private int category;
|
||||
|
||||
public long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(long j) {
|
||||
this.number = j;
|
||||
}
|
||||
|
||||
public int getPositiveRatingsCount() {
|
||||
return this.positiveRatingsCount;
|
||||
}
|
||||
|
||||
public void setPositiveRatingsCount(int c) {
|
||||
this.positiveRatingsCount = c;
|
||||
}
|
||||
|
||||
public int getNegativeRatingsCount() {
|
||||
return this.negativeRatingsCount;
|
||||
}
|
||||
|
||||
public void setNegativeRatingsCount(int c) {
|
||||
this.negativeRatingsCount = c;
|
||||
}
|
||||
|
||||
public int getNeutralRatingsCount() {
|
||||
return this.neutralRatingsCount;
|
||||
}
|
||||
|
||||
public void setNeutralRatingsCount(int c) {
|
||||
this.neutralRatingsCount = c;
|
||||
}
|
||||
|
||||
public int getUnknownData() {
|
||||
return unknownData;
|
||||
}
|
||||
|
||||
public void setUnknownData(int v) {
|
||||
this.unknownData = v;
|
||||
}
|
||||
|
||||
public int getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void setCategory(int c) {
|
||||
this.category = c;
|
||||
}
|
||||
|
||||
public boolean hasRatings() {
|
||||
return positiveRatingsCount + negativeRatingsCount + negativeRatingsCount > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommunityDatabaseItem{" +
|
||||
"number=" + number +
|
||||
", positiveRatingsCount=" + positiveRatingsCount +
|
||||
", negativeRatingsCount=" + negativeRatingsCount +
|
||||
", neutralRatingsCount=" + neutralRatingsCount +
|
||||
", unknownData=" + unknownData +
|
||||
", category=" + category +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
class DatabaseDataSliceNode {
|
||||
|
||||
private DatabaseDataSliceNode[] sliceTree;
|
||||
|
||||
public int init(String data, int offset) {
|
||||
this.sliceTree = new DatabaseDataSliceNode[10];
|
||||
|
||||
for (int i = 0; i <= 9; i++) {
|
||||
if (data.charAt(offset) == '+') {
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
|
||||
DatabaseDataSliceNode node = new DatabaseDataSliceNode();
|
||||
offset = node.init(data, offset + 1);
|
||||
sliceTree[i] = node;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
public int getSliceId(int currentNumber, String number) {
|
||||
int currentDigit = Integer.parseInt(number.substring(0, 1));
|
||||
|
||||
number = number.substring(1);
|
||||
|
||||
currentNumber = currentNumber * 10 + currentDigit;
|
||||
|
||||
if (sliceTree[currentDigit] == null) {
|
||||
return currentNumber;
|
||||
}
|
||||
|
||||
if (number.length() > 0) {
|
||||
DatabaseDataSliceNode sliceNode = sliceTree[currentDigit];
|
||||
return sliceNode.getSliceId(currentNumber, number);
|
||||
}
|
||||
|
||||
// the number is shorter
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
public class FeaturedDatabase extends AbstractDatabase<FeaturedDatabaseDataSlice, FeaturedDatabaseItem> {
|
||||
|
||||
@Override
|
||||
protected String getAssetNamePrefix() {
|
||||
return "featured_slice_";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FeaturedDatabaseItem getDbItemByNumberInternal(long number) {
|
||||
FeaturedDatabaseDataSlice slice = getDataSlice(number);
|
||||
return slice != null ? slice.getDbItemByNumber(number) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FeaturedDatabaseDataSlice createDbDataSlice() {
|
||||
return new FeaturedDatabaseDataSlice();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.utils.LittleEndianDataInputStream;
|
||||
|
||||
public class FeaturedDatabaseDataSlice extends AbstractDatabaseDataSlice<FeaturedDatabaseItem> {
|
||||
|
||||
private String[] names;
|
||||
|
||||
@Override
|
||||
protected FeaturedDatabaseItem getDbItemByNumberInternal(long number, int index) {
|
||||
return new FeaturedDatabaseItem(number, names[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamCheckHeader(String header) {
|
||||
if (!"MTZX".equalsIgnoreCase(header)) {
|
||||
throw new IllegalStateException("Invalid header. Actual value: " + header);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamInitFields() {
|
||||
names = new String[numberOfItems];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFromStreamLoadFields(int index, LittleEndianDataInputStream stream) throws IOException {
|
||||
int nameLength = stream.readInt();
|
||||
names[index] = stream.readUtf8StringChars(nameLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAssetNamePrefix() {
|
||||
return "featured_slice_";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package dummydomain.yetanothercallblocker.sia.model.database;
|
||||
|
||||
public class FeaturedDatabaseItem {
|
||||
|
||||
private long number;
|
||||
|
||||
private String name;
|
||||
|
||||
public FeaturedDatabaseItem(long number, String name) {
|
||||
this.number = number;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FeaturedDatabaseItem{" +
|
||||
"number=" + number +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
package dummydomain.yetanothercallblocker.sia.network;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import dummydomain.yetanothercallblocker.sia.utils.Utils;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class WebService {
|
||||
|
||||
public static class WSResponse {
|
||||
private boolean successful;
|
||||
private int responseCode;
|
||||
private String responseMessage;
|
||||
private JSONObject jsonObject;
|
||||
|
||||
public void setSuccessful(boolean successful) {
|
||||
this.successful = successful;
|
||||
}
|
||||
|
||||
public boolean getSuccessful() {
|
||||
return this.successful;
|
||||
}
|
||||
|
||||
public void setResponseCode(int i) {
|
||||
this.responseCode = i;
|
||||
}
|
||||
|
||||
public void setResponseMessage(String str) {
|
||||
this.responseMessage = str;
|
||||
}
|
||||
|
||||
public String getResponseMessage() {
|
||||
return this.responseMessage;
|
||||
}
|
||||
|
||||
public void setJsonObject(JSONObject jSONObject) {
|
||||
this.jsonObject = jSONObject;
|
||||
}
|
||||
|
||||
public final JSONObject getJsonObject() {
|
||||
return this.jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WebService.class);
|
||||
|
||||
private static final String GET_DATABASE_URL_PART = "/get-database";
|
||||
private static final String GET_REVIEWS_URL_PART = "/get-reviews";
|
||||
|
||||
public static String getGetDatabaseUrlPart() {
|
||||
return GET_DATABASE_URL_PART;
|
||||
}
|
||||
|
||||
public static String getGetReviewsUrlPart() {
|
||||
return GET_REVIEWS_URL_PART;
|
||||
}
|
||||
|
||||
public static Response call(String path, Map<String, String> params) {
|
||||
LOG.debug("call() started; path={}", path);
|
||||
|
||||
// TODO: retries
|
||||
|
||||
Request request = new Request.Builder().url(addHostname(path)).post(createRequestBody(params)).build();
|
||||
try {
|
||||
return new OkHttpClient().newCall(request).execute();
|
||||
} catch (IOException e) {
|
||||
LOG.warn("call()", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static WSResponse callForJson(String path, Map<String, String> params) {
|
||||
LOG.debug("callForJson() started; path={}", path);
|
||||
|
||||
try {
|
||||
Response response = call(path, params);
|
||||
if (response != null) {
|
||||
WSResponse wsResponse = new WSResponse();
|
||||
if (response.isSuccessful()) {
|
||||
ResponseBody body = response.body();
|
||||
if (body != null) {
|
||||
String bodyString = body.string();
|
||||
LOG.trace("callForJson() response body: {}", bodyString);
|
||||
try {
|
||||
wsResponse.setJsonObject(new JSONObject(bodyString));
|
||||
JSONObject c = wsResponse.getJsonObject();
|
||||
wsResponse.setSuccessful(c.getBoolean("success"));
|
||||
} catch (Exception e) {
|
||||
LOG.error("callForJson()", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG.trace("callForJson() response is not successful");
|
||||
wsResponse.setResponseCode(response.code());
|
||||
wsResponse.setResponseMessage(response.message());
|
||||
response.close();
|
||||
}
|
||||
return wsResponse;
|
||||
} else {
|
||||
LOG.warn("callForJson() response is null");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warn("callForJson()", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String addHostname(String path) {
|
||||
return "https://aapi.shouldianswer.net/srvapp" + path;
|
||||
}
|
||||
|
||||
private static RequestBody createRequestBody(Map<String, String> params) {
|
||||
if (params == null) params = new HashMap<>();
|
||||
|
||||
params.put("_appId", Utils.getAppId());
|
||||
|
||||
params.put("_device", "dreamlte");
|
||||
params.put("_model", "SM-G950F");
|
||||
params.put("_manufacturer", "Samsung");
|
||||
params.put("_api", String.valueOf(Build.VERSION_CODES.O));
|
||||
|
||||
params.put("_appFamily", "SIA-NEXT");
|
||||
params.put("_appVer", String.valueOf(Utils.getAppVersion()));
|
||||
params.put("_dbVer", String.valueOf(Utils.getEffectiveDbVersion()));
|
||||
params.put("_country", "US"); // TODO: remove hardcode
|
||||
|
||||
MultipartBody.Builder bodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
|
||||
|
||||
StringBuilder paramsSb = new StringBuilder();
|
||||
for (String key : params.keySet()) {
|
||||
String val = params.get(key);
|
||||
if (val != null) {
|
||||
paramsSb.append(val);
|
||||
bodyBuilder.addFormDataPart(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
bodyBuilder.addFormDataPart("_checksum", Utils.md5String(paramsSb.toString() + "saltandmira2"));
|
||||
|
||||
return bodyBuilder.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package dummydomain.yetanothercallblocker.sia.utils;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class LittleEndianDataInputStream {
|
||||
|
||||
private InputStream in;
|
||||
|
||||
private byte[] buffer;
|
||||
|
||||
public LittleEndianDataInputStream(InputStream in) {
|
||||
this(in, 200);
|
||||
}
|
||||
|
||||
public LittleEndianDataInputStream(InputStream in, int bufferSize) {
|
||||
this.in = in;
|
||||
buffer = new byte[bufferSize];
|
||||
}
|
||||
|
||||
public byte readByte() throws IOException {
|
||||
int ch = in.read();
|
||||
if (ch < 0) throw new EOFException();
|
||||
return (byte)(ch);
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
if (in.read(buffer, 0, 4) == 4) {
|
||||
return (((buffer[0] & 0xff) | ((buffer[1] & 0xff) << 8))
|
||||
| ((buffer[2] & 0xff) << 16)) | ((buffer[3] & 0xff) << 24);
|
||||
}
|
||||
throw new EOFException();
|
||||
}
|
||||
|
||||
public long readLong() throws IOException {
|
||||
if (in.read(buffer, 0, 8) == 8) {
|
||||
return (((((((((((((((long) (buffer[7] & 0xff)) << 8)
|
||||
| ((long) (buffer[6] & 0xff))) << 8)
|
||||
| ((long) (buffer[5] & 0xff))) << 8)
|
||||
| ((long) (buffer[4] & 0xff))) << 8)
|
||||
| ((long) (buffer[3] & 0xff))) << 8)
|
||||
| ((long) (buffer[2] & 0xff))) << 8)
|
||||
| ((long) (buffer[1] & 0xff))) << 8)
|
||||
| ((long) (buffer[0] & 0xff));
|
||||
}
|
||||
throw new EOFException();
|
||||
}
|
||||
|
||||
public String readUtf8StringChars(int length) throws IOException {
|
||||
if (buffer.length < length) buffer = new byte[length];
|
||||
|
||||
if (in.read(buffer, 0, length) == length) {
|
||||
return new String(buffer, 0, length, Charset.forName("UTF-8"));
|
||||
}
|
||||
throw new EOFException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package dummydomain.yetanothercallblocker.sia.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class LittleEndianDataOutputStream {
|
||||
|
||||
private OutputStream out;
|
||||
|
||||
private byte[] buffer;
|
||||
|
||||
public LittleEndianDataOutputStream(OutputStream out) {
|
||||
this(out, 8);
|
||||
}
|
||||
|
||||
public LittleEndianDataOutputStream(OutputStream out, int bufferSize) {
|
||||
this.out = out;
|
||||
buffer = new byte[bufferSize];
|
||||
}
|
||||
|
||||
public void writeByte(byte b) throws IOException {
|
||||
out.write(b);
|
||||
}
|
||||
|
||||
public void writeInt(int i) throws IOException {
|
||||
buffer[0] = (byte) (i & 0xff);
|
||||
buffer[1] = (byte) ((i >>> 8) & 0xff);
|
||||
buffer[2] = (byte) ((i >>> 16) & 0xff);
|
||||
buffer[3] = (byte) ((i >>> 24) & 0xff);
|
||||
out.write(buffer, 0, 4);
|
||||
}
|
||||
|
||||
public void writeLong(long l) throws IOException {
|
||||
buffer[0] = (byte) (l & 0xff);
|
||||
buffer[1] = (byte) ((l >>> 8) & 0xff);
|
||||
buffer[2] = (byte) ((l >>> 16) & 0xff);
|
||||
buffer[3] = (byte) ((l >>> 24) & 0xff);
|
||||
buffer[4] = (byte) ((l >>> 32) & 0xff);
|
||||
buffer[5] = (byte) ((l >>> 40) & 0xff);
|
||||
buffer[6] = (byte) ((l >>> 48) & 0xff);
|
||||
buffer[7] = (byte) ((l >>> 56) & 0xff);
|
||||
out.write(buffer, 0, 8);
|
||||
}
|
||||
|
||||
public void writeUtf8StringChars(String str) throws IOException {
|
||||
byte[] bytes = str.getBytes(Charset.forName("UTF-8"));
|
||||
out.write(bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package dummydomain.yetanothercallblocker.sia.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Base64;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
|
||||
import dummydomain.yetanothercallblocker.App;
|
||||
import dummydomain.yetanothercallblocker.sia.DatabaseSingleton;
|
||||
import dummydomain.yetanothercallblocker.sia.SiaSettings;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static Context getContext() {
|
||||
return App.getInstance();
|
||||
}
|
||||
|
||||
public static SiaSettings getSettings() {
|
||||
return new SiaSettings(getContext());
|
||||
}
|
||||
|
||||
public static String md5String(String str) {
|
||||
return new String(Hex.encodeHex(DigestUtils.md5(str)));
|
||||
}
|
||||
|
||||
public static int getAppVersion() {
|
||||
return DatabaseSingleton.getCommunityDatabase().getSiaAppVersion();
|
||||
}
|
||||
|
||||
public static int getEffectiveDbVersion() {
|
||||
return DatabaseSingleton.getCommunityDatabase().getEffectiveDbVersion();
|
||||
}
|
||||
|
||||
public static String getAppId() {
|
||||
return "qQq0O9nCRNy_aVdPgU9WOA";
|
||||
}
|
||||
|
||||
public static String generateAppId() {
|
||||
UUID randomUUID = UUID.randomUUID();
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.allocate(16);
|
||||
buffer.putLong(randomUUID.getMostSignificantBits());
|
||||
buffer.putLong(randomUUID.getLeastSignificantBits());
|
||||
|
||||
return Base64.encodeToString(buffer.array(), Base64.NO_PADDING)
|
||||
.replace('/', '_')
|
||||
.replace('\\', '-')
|
||||
.replaceAll("\n", "");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M15,3L6,3c-0.83,0 -1.54,0.5 -1.84,1.22l-3.02,7.05c-0.09,0.23 -0.14,0.47 -0.14,0.73v1.91l0.01,0.01L1,14c0,1.1 0.9,2 2,2h6.31l-0.95,4.57 -0.03,0.32c0,0.41 0.17,0.79 0.44,1.06L9.83,23l6.59,-6.59c0.36,-0.36 0.58,-0.86 0.58,-1.41L17,5c0,-1.1 -0.9,-2 -2,-2zM19,3v12h4L23,3h-4z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-1.91l-0.01,-0.01L23,10z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,6c0,-0.55 -0.45,-1 -1,-1L5.82,5l0.66,-3.18 0.02,-0.23c0,-0.31 -0.13,-0.59 -0.33,-0.8L5.38,0 0.44,4.94C0.17,5.21 0,5.59 0,6v6.5c0,0.83 0.67,1.5 1.5,1.5h6.75c0.62,0 1.15,-0.38 1.38,-0.91l2.26,-5.29c0.07,-0.17 0.11,-0.36 0.11,-0.55L12,6zM22.5,10h-6.75c-0.62,0 -1.15,0.38 -1.38,0.91l-2.26,5.29c-0.07,0.17 -0.11,0.36 -0.11,0.55L12,18c0,0.55 0.45,1 1,1h5.18l-0.66,3.18 -0.02,0.24c0,0.31 0.13,0.59 0.33,0.8l0.79,0.78 4.94,-4.94c0.27,-0.27 0.44,-0.65 0.44,-1.06v-6.5c0,-0.83 -0.67,-1.5 -1.5,-1.5z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".DummyActivity">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".ReviewsActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/app_bar_height"
|
||||
android:fitsSystemWindows="true"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:toolbarId="@+id/toolbar">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_reviews" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".ReviewsActivity"
|
||||
tools:showIn="@layout/activity_reviews">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/text_margin"
|
||||
android:text="" />
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:title="Test DB query"
|
||||
android:onClick="onQueryDb"/>
|
||||
|
||||
<item
|
||||
android:title="Test featured DB query "
|
||||
android:onClick="onQueryFeaturedDb"/>
|
||||
|
||||
<item
|
||||
android:title="Update DB"
|
||||
android:onClick="onUpdateDb"/>
|
||||
|
||||
<item
|
||||
android:title="Test reviews loading"
|
||||
android:onClick="onTestLoadReviews"/>
|
||||
|
||||
</menu>
|
|
@ -0,0 +1,4 @@
|
|||
<resources>
|
||||
<dimen name="app_bar_height">180dp</dimen>
|
||||
<dimen name="text_margin">16dp</dimen>
|
||||
</resources>
|
|
@ -1,3 +1,44 @@
|
|||
<resources>
|
||||
<string name="app_name">Yet Another Call Blocker</string>
|
||||
|
||||
<string name="notification_channel_group_name_incoming_calls">Incoming calls</string>
|
||||
|
||||
<string name="notification_channel_name_positive_known">Known positive calls</string>
|
||||
<string name="notification_channel_name_positive">Positive calls</string>
|
||||
<string name="notification_channel_name_neutral">Neutral calls</string>
|
||||
<string name="notification_channel_name_unknown">Unknown calls</string>
|
||||
<string name="notification_channel_name_negative">Negative calls</string>
|
||||
|
||||
<string name="notification_incoming_call_positive">Positive call</string>
|
||||
<string name="notification_incoming_call_neutral">Neutral call</string>
|
||||
<string name="notification_incoming_call_unknown">Unknown call</string>
|
||||
<string name="notification_incoming_call_negative">Negative call</string>
|
||||
|
||||
<string name="notification_incoming_call_text_description">Negative: %d, positive: %d, neutral: %d</string>
|
||||
|
||||
<string name="sia_category_none">None</string>
|
||||
<string name="sia_category_telemarketer">Telemarketer</string>
|
||||
<string name="sia_category_dept_collector">Debt collector</string>
|
||||
<string name="sia_category_silent">Silent</string>
|
||||
<string name="sia_category_nuisance">Nuisance</string>
|
||||
<string name="sia_category_unsolicited">Unsolicited</string>
|
||||
<string name="sia_category_call_center">Call center</string>
|
||||
<string name="sia_category_fax">FAX</string>
|
||||
<string name="sia_category_nonprofit">Nonprofit org.</string>
|
||||
<string name="sia_category_political">Political</string>
|
||||
<string name="sia_category_scam">Scam</string>
|
||||
<string name="sia_category_prank">Prank</string>
|
||||
<string name="sia_category_sms">SMS</string>
|
||||
<string name="sia_category_survey">Survey</string>
|
||||
<string name="sia_category_other">Other</string>
|
||||
<string name="sia_category_financial_service">Financial service</string>
|
||||
<string name="sia_category_company">Company</string>
|
||||
<string name="sia_category_service">Service</string>
|
||||
<string name="sia_category_robocall">Robocall</string>
|
||||
<string name="sia_category_safe_personal">Safe personal</string>
|
||||
<string name="sia_category_safe_company">Safe company</string>
|
||||
<string name="sia_category_safe_nonprofit">Safe nonprofit</string>
|
||||
|
||||
<string name="title_activity_reviews">Reviews</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -8,4 +8,13 @@
|
|||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue