mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-16 23:12:12 +00:00
Merge branch 'cmp-rewrite' into desktop
This commit is contained in:
commit
f1871fd8b3
44 changed files with 2386 additions and 100 deletions
674
LICENSE
Normal file
674
LICENSE
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
120
README.md
120
README.md
|
|
@ -1,35 +1,101 @@
|
|||
This is a Kotlin Multiplatform project targeting Android, iOS.
|
||||
<div align="center">
|
||||
|
||||
* [/composeApp](./composeApp/src) is for code that will be shared across your Compose Multiplatform applications.
|
||||
It contains several subfolders:
|
||||
- [commonMain](./composeApp/src/commonMain/kotlin) is for code that’s common for all targets.
|
||||
- Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name.
|
||||
For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app,
|
||||
the [iosMain](./composeApp/src/iosMain/kotlin) folder would be the right place for such calls.
|
||||
Similarly, if you want to edit the Desktop (JVM) specific part, the [jvmMain](./composeApp/src/jvmMain/kotlin)
|
||||
folder is the appropriate location.
|
||||
<img src="https://github.com/tapframe/NuvioTV/blob/main/assets/brand/app_logo_wordmark.png" alt="Nuvio" width="300" />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
* [/iosApp](./iosApp/iosApp) contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform,
|
||||
you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project.
|
||||
[![Contributors][contributors-shield]][contributors-url]
|
||||
[![Forks][forks-shield]][forks-url]
|
||||
[![Stargazers][stars-shield]][stars-url]
|
||||
[![Issues][issues-shield]][issues-url]
|
||||
[![License][license-shield]][license-url]
|
||||
|
||||
### Build and Run Android Application
|
||||
<p>
|
||||
A modern media hub for Android and iOS built with Kotlin Multiplatform and Compose Multiplatform.
|
||||
<br />
|
||||
Stremio addon ecosystem • Cross-platform
|
||||
</p>
|
||||
|
||||
To build and run the development version of the Android app, use the run configuration from the run widget
|
||||
in your IDE’s toolbar or build it directly from the terminal:
|
||||
- on macOS/Linux
|
||||
```shell
|
||||
./gradlew :composeApp:assembleDebug
|
||||
```
|
||||
- on Windows
|
||||
```shell
|
||||
.\gradlew.bat :composeApp:assembleDebug
|
||||
```
|
||||
</div>
|
||||
|
||||
### Build and Run iOS Application
|
||||
## About
|
||||
|
||||
To build and run the development version of the iOS app, use the run configuration from the run widget
|
||||
in your IDE’s toolbar or open the [/iosApp](./iosApp) directory in Xcode and run it from there.
|
||||
Nuvio is the current Kotlin Multiplatform rewrite of the original React Native app. It delivers a shared Compose UI for Android and iOS while keeping the playback-focused experience, collection tools, watch progress flows, downloads, and Stremio addon ecosystem integration that shaped the earlier app.
|
||||
|
||||
---
|
||||
The mobile app is built from a single shared codebase in [composeApp](./composeApp), with native platform entry points for Android and iOS.
|
||||
|
||||
Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)…
|
||||
## Installation
|
||||
|
||||
### Android
|
||||
|
||||
Download the latest Android build from [GitHub Releases](https://github.com/NuvioMedia/NuvioMobile/releases/latest).
|
||||
|
||||
### iOS
|
||||
|
||||
- [TestFlight](https://testflight.apple.com/join/u4y7MHK9)
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
git clone https://github.com/NuvioMedia/NuvioMobile.git
|
||||
cd NuvioMobile
|
||||
./scripts/run-mobile.sh android
|
||||
# or
|
||||
./scripts/run-mobile.sh ios
|
||||
```
|
||||
|
||||
### Project Structure
|
||||
|
||||
- `composeApp/` contains the shared Kotlin Multiplatform and Compose Multiplatform app code.
|
||||
- `composeApp/src/commonMain/` contains shared UI, features, repositories, and platform-agnostic logic.
|
||||
- `composeApp/src/androidMain/` contains Android-specific integrations.
|
||||
- `composeApp/src/iosMain/` contains iOS-specific integrations.
|
||||
- `iosApp/` contains the native Xcode project and iOS entry point.
|
||||
|
||||
Useful commands:
|
||||
|
||||
```bash
|
||||
./gradlew :composeApp:assembleDebug
|
||||
./gradlew :composeApp:compileKotlinIosSimulatorArm64
|
||||
./scripts/build-distribution.sh
|
||||
```
|
||||
|
||||
Versioning is driven from `iosApp/Configuration/Version.xcconfig`, which is used as the shared source of truth for both iOS and Android builds.
|
||||
|
||||
## Legal & DMCA
|
||||
|
||||
Nuvio functions solely as a client-side interface for browsing metadata and playing media provided by user-installed extensions and/or user-provided sources. It is intended for content the user owns or is otherwise authorized to access.
|
||||
|
||||
Nuvio is not affiliated with any third-party extensions, catalogs, sources, or content providers. It does not host, store, or distribute any media content.
|
||||
|
||||
For comprehensive legal information, including our full disclaimer, third-party extension policy, and DMCA/Copyright information, please visit our [Legal & Disclaimer Page](https://nuvioapp.space/legal).
|
||||
|
||||
## Built With
|
||||
|
||||
- Kotlin Multiplatform
|
||||
- Compose Multiplatform
|
||||
- Kotlin
|
||||
- AndroidX Media3
|
||||
- AVFoundation and native iOS integrations
|
||||
|
||||
## Star History
|
||||
|
||||
<a href="https://www.star-history.com/#NuvioMedia/NuvioMobile&type=date&legend=top-left">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=NuvioMedia/NuvioMobile&type=date&theme=dark&legend=top-left" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=NuvioMedia/NuvioMobile&type=date&legend=top-left" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=NuvioMedia/NuvioMobile&type=date&legend=top-left" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
<!-- MARKDOWN LINKS & IMAGES -->
|
||||
[contributors-shield]: https://img.shields.io/github/contributors/NuvioMedia/NuvioMobile.svg?style=for-the-badge
|
||||
[contributors-url]: https://github.com/NuvioMedia/NuvioMobile/graphs/contributors
|
||||
[forks-shield]: https://img.shields.io/github/forks/NuvioMedia/NuvioMobile.svg?style=for-the-badge
|
||||
[forks-url]: https://github.com/NuvioMedia/NuvioMobile/network/members
|
||||
[stars-shield]: https://img.shields.io/github/stars/NuvioMedia/NuvioMobile.svg?style=for-the-badge
|
||||
[stars-url]: https://github.com/NuvioMedia/NuvioMobile/stargazers
|
||||
[issues-shield]: https://img.shields.io/github/issues/NuvioMedia/NuvioMobile.svg?style=for-the-badge
|
||||
[issues-url]: https://github.com/NuvioMedia/NuvioMobile/issues
|
||||
[license-shield]: https://img.shields.io/github/license/NuvioMedia/NuvioMobile.svg?style=for-the-badge
|
||||
[license-url]: https://github.com/NuvioMedia/NuvioMobile/blob/main/LICENSE
|
||||
|
|
@ -88,6 +88,20 @@ abstract class GenerateRuntimeConfigsTask : DefaultTask() {
|
|||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
|
||||
outDir.resolve("com/nuvio/app/features/settings").apply {
|
||||
mkdirs()
|
||||
resolve("CommunityConfig.kt").writeText(
|
||||
"""
|
||||
|package com.nuvio.app.features.settings
|
||||
|
|
||||
|object CommunityConfig {
|
||||
| const val DONATIONS_BASE_URL = "${props.getProperty("DONATIONS_BASE_URL", "")}"
|
||||
| const val DONATIONS_DONATE_URL = "${props.getProperty("DONATIONS_DONATE_URL", "")}"
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import com.nuvio.app.features.notifications.EpisodeReleaseNotificationsStorage
|
|||
import com.nuvio.app.features.player.PlayerSettingsStorage
|
||||
import com.nuvio.app.features.player.PlayerPictureInPictureManager
|
||||
import com.nuvio.app.features.plugins.PluginStorage
|
||||
import com.nuvio.app.features.profiles.AvatarStorage
|
||||
import com.nuvio.app.features.profiles.ProfilePinCacheStorage
|
||||
import com.nuvio.app.features.profiles.ProfileStorage
|
||||
import com.nuvio.app.features.details.SeasonViewModeStorage
|
||||
import com.nuvio.app.features.search.SearchHistoryStorage
|
||||
|
|
@ -59,6 +61,8 @@ class MainActivity : ComponentActivity() {
|
|||
HomeCatalogSettingsStorage.initialize(applicationContext)
|
||||
PlayerSettingsStorage.initialize(applicationContext)
|
||||
ProfileStorage.initialize(applicationContext)
|
||||
AvatarStorage.initialize(applicationContext)
|
||||
ProfilePinCacheStorage.initialize(applicationContext)
|
||||
SearchHistoryStorage.initialize(applicationContext)
|
||||
SeasonViewModeStorage.initialize(applicationContext)
|
||||
ThemeSettingsStorage.initialize(applicationContext)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ internal actual object PlatformLocalAccountDataCleaner {
|
|||
"nuvio_home_catalog_settings",
|
||||
"nuvio_player_settings",
|
||||
"nuvio_profile_cache",
|
||||
"nuvio_avatar_cache",
|
||||
"nuvio_profile_pin_cache",
|
||||
"nuvio_theme_settings",
|
||||
"nuvio_poster_card_style",
|
||||
"nuvio_mdblist_settings",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
actual object AvatarStorage {
|
||||
private const val preferencesName = "nuvio_avatar_cache"
|
||||
private const val payloadKey = "avatar_catalog_payload"
|
||||
|
||||
private var preferences: SharedPreferences? = null
|
||||
|
||||
fun initialize(context: Context) {
|
||||
preferences = context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
actual fun loadPayload(): String? =
|
||||
preferences?.getString(payloadKey, null)
|
||||
|
||||
actual fun savePayload(payload: String) {
|
||||
preferences
|
||||
?.edit()
|
||||
?.putString(payloadKey, payload)
|
||||
?.apply()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
actual object ProfilePinCacheStorage {
|
||||
private const val preferencesName = "nuvio_profile_pin_cache"
|
||||
|
||||
private var preferences: SharedPreferences? = null
|
||||
|
||||
fun initialize(context: Context) {
|
||||
preferences = context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
actual fun loadPayload(profileIndex: Int): String? =
|
||||
preferences?.getString(payloadKey(profileIndex), null)
|
||||
|
||||
actual fun savePayload(profileIndex: Int, payload: String) {
|
||||
preferences
|
||||
?.edit()
|
||||
?.putString(payloadKey(profileIndex), payload)
|
||||
?.apply()
|
||||
}
|
||||
|
||||
actual fun removePayload(profileIndex: Int) {
|
||||
preferences
|
||||
?.edit()
|
||||
?.remove(payloadKey(profileIndex))
|
||||
?.apply()
|
||||
}
|
||||
|
||||
private fun payloadKey(profileIndex: Int): String = "profile_pin_cache_$profileIndex"
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
import java.security.MessageDigest
|
||||
|
||||
actual object ProfilePinCrypto {
|
||||
actual fun sha256Hex(value: String): String {
|
||||
val digest = MessageDigest.getInstance("SHA-256").digest(value.encodeToByteArray())
|
||||
return digest.joinToString(separator = "") { byte ->
|
||||
byte.toUByte().toString(16).padStart(2, '0')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -134,6 +134,7 @@ import com.nuvio.app.features.settings.ContinueWatchingSettingsScreen
|
|||
import com.nuvio.app.features.settings.AddonsSettingsScreen
|
||||
import com.nuvio.app.features.settings.PluginsSettingsScreen
|
||||
import com.nuvio.app.features.settings.AccountSettingsScreen
|
||||
import com.nuvio.app.features.settings.SupportersContributorsSettingsScreen
|
||||
import com.nuvio.app.features.settings.ThemeSettingsRepository
|
||||
import com.nuvio.app.features.collection.CollectionManagementScreen
|
||||
import com.nuvio.app.features.collection.CollectionEditorScreen
|
||||
|
|
@ -215,6 +216,9 @@ object PluginsSettingsRoute
|
|||
@Serializable
|
||||
object AccountSettingsRoute
|
||||
|
||||
@Serializable
|
||||
object SupportersContributorsSettingsRoute
|
||||
|
||||
@Serializable
|
||||
object CollectionsRoute
|
||||
|
||||
|
|
@ -278,40 +282,81 @@ fun App() {
|
|||
AuthRepository.initialize()
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
NetworkStatusRepository.ensureStarted()
|
||||
ProfileRepository.loadCachedProfiles()
|
||||
}
|
||||
|
||||
val authState by AuthRepository.state.collectAsStateWithLifecycle()
|
||||
val profileState by ProfileRepository.state.collectAsStateWithLifecycle()
|
||||
val networkStatusUiState by remember {
|
||||
NetworkStatusRepository.uiState
|
||||
}.collectAsStateWithLifecycle()
|
||||
var gateScreen by rememberSaveable { mutableStateOf(AppGateScreen.Loading.name) }
|
||||
var editingProfile by remember { mutableStateOf<NuvioProfile?>(null) }
|
||||
var isNewProfile by remember { mutableStateOf(false) }
|
||||
var autoSkipProfileSelection by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(authState) {
|
||||
fun enterProfileGate(profiles: List<NuvioProfile>, syncOnEnter: Boolean) {
|
||||
if (profiles.isEmpty()) {
|
||||
autoSkipProfileSelection = true
|
||||
gateScreen = AppGateScreen.ProfileSelection.name
|
||||
return
|
||||
}
|
||||
|
||||
autoSkipProfileSelection = true
|
||||
if (profiles.size == 1) {
|
||||
val onlyProfile = profiles.first()
|
||||
ProfileRepository.selectProfile(onlyProfile.profileIndex)
|
||||
if (syncOnEnter) {
|
||||
SyncManager.pullAllForProfile(onlyProfile.profileIndex)
|
||||
}
|
||||
gateScreen = AppGateScreen.Main.name
|
||||
autoSkipProfileSelection = false
|
||||
} else {
|
||||
gateScreen = AppGateScreen.ProfileSelection.name
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(authState, networkStatusUiState.condition, profileState.profiles) {
|
||||
val cachedProfiles = profileState.profiles
|
||||
val allowOfflineProfileAccess =
|
||||
cachedProfiles.isNotEmpty() &&
|
||||
authState !is AuthState.Authenticated &&
|
||||
networkStatusUiState.condition != NetworkCondition.Online
|
||||
|
||||
when (authState) {
|
||||
is AuthState.Loading -> gateScreen = AppGateScreen.Loading.name
|
||||
is AuthState.Loading -> {
|
||||
if (allowOfflineProfileAccess) {
|
||||
enterProfileGate(cachedProfiles, syncOnEnter = false)
|
||||
} else {
|
||||
gateScreen = AppGateScreen.Loading.name
|
||||
}
|
||||
}
|
||||
is AuthState.Unauthenticated -> {
|
||||
ProfileRepository.clearInMemory()
|
||||
gateScreen = AppGateScreen.Auth.name
|
||||
if (allowOfflineProfileAccess) {
|
||||
enterProfileGate(cachedProfiles, syncOnEnter = false)
|
||||
} else {
|
||||
ProfileRepository.clearInMemory()
|
||||
gateScreen = AppGateScreen.Auth.name
|
||||
}
|
||||
}
|
||||
is AuthState.Authenticated -> {
|
||||
val authenticatedState = authState as AuthState.Authenticated
|
||||
ProfileRepository.ensureLoaded(authenticatedState.userId)
|
||||
if (gateScreen == AppGateScreen.Loading.name || gateScreen == AppGateScreen.Auth.name) {
|
||||
autoSkipProfileSelection = true
|
||||
val cachedProfiles = ProfileRepository.state.value.profiles
|
||||
if (cachedProfiles.size == 1) {
|
||||
val onlyProfile = cachedProfiles.first()
|
||||
ProfileRepository.selectProfile(onlyProfile.profileIndex)
|
||||
SyncManager.pullAllForProfile(onlyProfile.profileIndex)
|
||||
gateScreen = AppGateScreen.Main.name
|
||||
autoSkipProfileSelection = false
|
||||
} else {
|
||||
gateScreen = AppGateScreen.ProfileSelection.name
|
||||
}
|
||||
enterProfileGate(ProfileRepository.state.value.profiles, syncOnEnter = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect((authState as? AuthState.Authenticated)?.userId) {
|
||||
val authenticatedState = authState as? AuthState.Authenticated ?: return@LaunchedEffect
|
||||
ProfileRepository.ensureLoaded(authenticatedState.userId)
|
||||
ProfileRepository.pullProfiles()
|
||||
}
|
||||
|
||||
LaunchedEffect(gateScreen, autoSkipProfileSelection, profileState.profiles) {
|
||||
if (
|
||||
autoSkipProfileSelection &&
|
||||
|
|
@ -352,7 +397,9 @@ fun App() {
|
|||
ProfileSelectionScreen(
|
||||
onProfileSelected = { profile ->
|
||||
ProfileRepository.selectProfile(profile.profileIndex)
|
||||
SyncManager.pullAllForProfile(profile.profileIndex)
|
||||
if (authState is AuthState.Authenticated) {
|
||||
SyncManager.pullAllForProfile(profile.profileIndex)
|
||||
}
|
||||
gateScreen = AppGateScreen.Main.name
|
||||
},
|
||||
onEditProfile = { profile ->
|
||||
|
|
@ -910,6 +957,9 @@ private fun MainAppContent(
|
|||
}
|
||||
},
|
||||
onAccountSettingsClick = { navController.navigate(AccountSettingsRoute) },
|
||||
onSupportersContributorsSettingsClick = {
|
||||
navController.navigate(SupportersContributorsSettingsRoute)
|
||||
},
|
||||
onCollectionsSettingsClick = { navController.navigate(CollectionsRoute) },
|
||||
onFolderClick = { collectionId, folderId ->
|
||||
navController.navigate(FolderDetailRoute(collectionId = collectionId, folderId = folderId))
|
||||
|
|
@ -1515,6 +1565,15 @@ private fun MainAppContent(
|
|||
onBack = onBack,
|
||||
)
|
||||
}
|
||||
composable<SupportersContributorsSettingsRoute> { backStackEntry ->
|
||||
val onBack = rememberGuardedPopBackStack(
|
||||
navController = navController,
|
||||
backStackEntry = backStackEntry,
|
||||
)
|
||||
SupportersContributorsSettingsScreen(
|
||||
onBack = onBack,
|
||||
)
|
||||
}
|
||||
composable<CollectionsRoute> { backStackEntry ->
|
||||
val onBack = rememberGuardedPopBackStack(
|
||||
navController = navController,
|
||||
|
|
@ -1780,6 +1839,7 @@ private fun AppTabHost(
|
|||
onAddonsSettingsClick: () -> Unit = {},
|
||||
onPluginsSettingsClick: () -> Unit = {},
|
||||
onAccountSettingsClick: () -> Unit = {},
|
||||
onSupportersContributorsSettingsClick: () -> Unit = {},
|
||||
onCollectionsSettingsClick: () -> Unit = {},
|
||||
onFolderClick: ((collectionId: String, folderId: String) -> Unit)? = null,
|
||||
onInitialHomeContentRendered: () -> Unit = {},
|
||||
|
|
@ -1829,6 +1889,7 @@ private fun AppTabHost(
|
|||
onAddonsClick = onAddonsSettingsClick,
|
||||
onPluginsClick = onPluginsSettingsClick,
|
||||
onAccountClick = onAccountSettingsClick,
|
||||
onSupportersContributorsClick = onSupportersContributorsSettingsClick,
|
||||
onCollectionsClick = onCollectionsSettingsClick,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ fun NuvioScreen(
|
|||
start = horizontalPadding,
|
||||
top = topPadding ?: 10.dp + statusBarTop + nuvioPlatformExtraTopPadding,
|
||||
end = horizontalPadding,
|
||||
bottom = 18.dp + nuvioPlatformExtraBottomPadding,
|
||||
bottom = nuvioSafeBottomPadding(18.dp),
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
content = content,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ fun NuvioContinueWatchingActionSheet(
|
|||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 16.dp + nuvioPlatformExtraBottomPadding),
|
||||
.padding(bottom = nuvioSafeBottomPadding(16.dp)),
|
||||
) {
|
||||
ContinueWatchingSheetHeader(item = item)
|
||||
NuvioBottomSheetDivider()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
package com.nuvio.app.core.ui
|
||||
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
internal expect val nuvioPlatformExtraTopPadding: Dp
|
||||
internal expect val nuvioPlatformExtraBottomPadding: Dp
|
||||
internal expect val nuvioBottomNavigationExtraVerticalPadding: Dp
|
||||
@Composable
|
||||
internal expect fun nuvioBottomNavigationBarInsets(): WindowInsets
|
||||
|
||||
@Composable
|
||||
internal fun nuvioSafeBottomPadding(extra: Dp = 0.dp): Dp {
|
||||
val navigationBarBottom = nuvioBottomNavigationBarInsets()
|
||||
.asPaddingValues()
|
||||
.calculateBottomPadding()
|
||||
return navigationBarBottom.coerceAtLeast(nuvioPlatformExtraBottomPadding) + extra
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ fun NuvioPosterActionSheet(
|
|||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 16.dp + nuvioPlatformExtraBottomPadding),
|
||||
.padding(bottom = nuvioSafeBottomPadding(16.dp)),
|
||||
) {
|
||||
PosterSheetHeader(item = item)
|
||||
NuvioBottomSheetDivider()
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import com.nuvio.app.core.format.formatReleaseDateForDisplay
|
|||
import com.nuvio.app.core.ui.NuvioBackButton
|
||||
import com.nuvio.app.core.ui.rememberPosterCardStyleUiState
|
||||
import com.nuvio.app.core.ui.posterCardClickable
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.features.home.MetaPreview
|
||||
import com.nuvio.app.features.home.PosterShape
|
||||
import com.nuvio.app.features.home.stableKey
|
||||
|
|
@ -144,7 +144,7 @@ fun CatalogScreen(
|
|||
start = 16.dp,
|
||||
top = with(androidx.compose.ui.platform.LocalDensity.current) { headerHeightPx.toDp() } + 12.dp,
|
||||
end = 16.dp,
|
||||
bottom = nuvioPlatformExtraBottomPadding + 28.dp,
|
||||
bottom = nuvioSafeBottomPadding(28.dp),
|
||||
),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(18.dp),
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ import com.nuvio.app.core.ui.NuvioScreen
|
|||
import com.nuvio.app.core.ui.NuvioScreenHeader
|
||||
import com.nuvio.app.core.ui.NuvioSectionLabel
|
||||
import com.nuvio.app.core.ui.NuvioSurfaceCard
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.core.ui.PlatformBackHandler
|
||||
import com.nuvio.app.features.home.PosterShape
|
||||
import sh.calvin.reorderable.ReorderableCollectionItemScope
|
||||
|
|
@ -75,7 +75,7 @@ fun CollectionEditorScreen(
|
|||
onBack: () -> Unit,
|
||||
) {
|
||||
val state by CollectionEditorRepository.uiState.collectAsState()
|
||||
val bottomInset = nuvioPlatformExtraBottomPadding
|
||||
val bottomInset = nuvioSafeBottomPadding()
|
||||
|
||||
LaunchedEffect(collectionId) {
|
||||
CollectionEditorRepository.initialize(collectionId)
|
||||
|
|
@ -504,7 +504,7 @@ private fun FolderEditorPage(
|
|||
onBack: () -> Unit,
|
||||
) {
|
||||
val folder = state.editingFolder ?: return
|
||||
val bottomInset = nuvioPlatformExtraBottomPadding
|
||||
val bottomInset = nuvioSafeBottomPadding()
|
||||
|
||||
PlatformBackHandler(enabled = true) {
|
||||
onBack()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ import coil3.compose.AsyncImage
|
|||
import com.nuvio.app.core.ui.NuvioPosterCard
|
||||
import com.nuvio.app.core.ui.NuvioPosterShape
|
||||
import com.nuvio.app.core.ui.NuvioScreenHeader
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.features.home.HomeCatalogSection
|
||||
import com.nuvio.app.features.home.MetaPreview
|
||||
import com.nuvio.app.features.home.PosterShape
|
||||
|
|
@ -260,7 +260,7 @@ private fun TabbedGridContent(
|
|||
contentPadding = PaddingValues(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
bottom = 18.dp + nuvioPlatformExtraBottomPadding,
|
||||
bottom = nuvioSafeBottomPadding(18.dp),
|
||||
),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(14.dp),
|
||||
|
|
@ -312,7 +312,7 @@ private fun RowsContent(
|
|||
LazyColumn(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
contentPadding = PaddingValues(
|
||||
bottom = 18.dp + nuvioPlatformExtraBottomPadding,
|
||||
bottom = nuvioSafeBottomPadding(18.dp),
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ import com.nuvio.app.core.network.NetworkCondition
|
|||
import com.nuvio.app.core.network.NetworkStatusRepository
|
||||
import com.nuvio.app.core.ui.NuvioBackButton
|
||||
import com.nuvio.app.core.ui.TraktListPickerDialog
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.features.details.components.DetailActionButtons
|
||||
import com.nuvio.app.features.details.components.CommentDetailSheet
|
||||
import com.nuvio.app.features.details.components.DetailAdditionalInfoSection
|
||||
|
|
@ -694,7 +694,7 @@ fun MetaDetailsScreen(
|
|||
animatedVisibilityScope = animatedVisibilityScope,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(32.dp + nuvioPlatformExtraBottomPadding))
|
||||
Spacer(modifier = Modifier.height(nuvioSafeBottomPadding(32.dp)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,26 @@ internal fun MetaDetails.sortedPlayableEpisodes(): List<MetaVideo> =
|
|||
.filter { it.season != null || it.episode != null }
|
||||
.sortedWith(metaVideoSeasonEpisodeComparator)
|
||||
|
||||
internal fun List<MetaVideo>.filterUnavailableFutureSeasons(
|
||||
todayIsoDate: String,
|
||||
): List<MetaVideo> {
|
||||
val unavailableSeasons = groupBy { episode -> normalizeSeasonNumber(episode.season) }
|
||||
.filter { (seasonNumber, episodes) ->
|
||||
if (seasonNumber <= 0) return@filter false
|
||||
val firstEpisode = episodes.minWithOrNull(
|
||||
compareBy<MetaVideo>({ it.episode ?: Int.MAX_VALUE }, { it.released.orEmpty() }),
|
||||
) ?: return@filter false
|
||||
!isReleasedBy(todayIsoDate = todayIsoDate, releasedDate = firstEpisode.released)
|
||||
}
|
||||
.keys
|
||||
|
||||
return if (unavailableSeasons.isEmpty()) {
|
||||
this
|
||||
} else {
|
||||
filter { episode -> normalizeSeasonNumber(episode.season) !in unavailableSeasons }
|
||||
}
|
||||
}
|
||||
|
||||
internal fun MetaDetails.firstPlayableEpisode(): MetaVideo? =
|
||||
sortedPlayableEpisodes().firstOrNull()
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import com.nuvio.app.core.ui.NuvioBottomSheetActionRow
|
|||
import com.nuvio.app.core.ui.NuvioBottomSheetDivider
|
||||
import com.nuvio.app.core.ui.NuvioModalBottomSheet
|
||||
import com.nuvio.app.core.ui.dismissNuvioBottomSheet
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.features.details.MetaVideo
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
|
|
@ -62,7 +62,7 @@ fun EpisodeWatchedActionSheet(
|
|||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 16.dp + nuvioPlatformExtraBottomPadding),
|
||||
.padding(bottom = nuvioSafeBottomPadding(16.dp)),
|
||||
) {
|
||||
EpisodeActionSheetHeader(
|
||||
episode = episode,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import androidx.compose.ui.draw.clip
|
|||
import com.nuvio.app.core.ui.NuvioBottomSheetDivider
|
||||
import com.nuvio.app.core.ui.NuvioModalBottomSheet
|
||||
import com.nuvio.app.core.ui.dismissNuvioBottomSheet
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.features.player.PlatformPlayerSurface
|
||||
import com.nuvio.app.features.player.PlayerResizeMode
|
||||
import com.nuvio.app.features.trailer.TrailerPlaybackSource
|
||||
|
|
@ -87,7 +87,7 @@ fun TrailerPlayerPopup(
|
|||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp)
|
||||
.padding(bottom = 14.dp + nuvioPlatformExtraBottomPadding),
|
||||
.padding(bottom = nuvioSafeBottomPadding(14.dp)),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Row(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.nuvio.app.core.ui.NuvioScreen
|
|||
import com.nuvio.app.core.ui.NuvioNetworkOfflineCard
|
||||
import com.nuvio.app.features.addons.AddonRepository
|
||||
import com.nuvio.app.features.details.MetaDetailsRepository
|
||||
import com.nuvio.app.features.details.filterUnavailableFutureSeasons
|
||||
import com.nuvio.app.features.details.sortedPlayableEpisodes
|
||||
import com.nuvio.app.features.home.components.HomeCatalogRowSection
|
||||
import com.nuvio.app.features.home.components.HomeContinueWatchingSection
|
||||
|
|
@ -568,6 +569,7 @@ internal fun buildHomeContinueWatchingItems(
|
|||
compareByDescending<HomeContinueWatchingCandidate> { it.lastUpdatedEpochMs }
|
||||
.thenByDescending { it.isProgressEntry },
|
||||
)
|
||||
.filter { candidate -> candidate.item.shouldDisplayInContinueWatching() }
|
||||
.distinctBy { it.item.videoId }
|
||||
.map(HomeContinueWatchingCandidate::item)
|
||||
}
|
||||
|
|
@ -627,6 +629,7 @@ private fun com.nuvio.app.features.details.MetaDetails.nextReleasedEpisodeAfter(
|
|||
}
|
||||
.drop(1)
|
||||
.filter { episode -> (episode.season ?: 0) > 0 }
|
||||
.filterUnavailableFutureSeasons(todayIsoDate = todayIsoDate)
|
||||
|
||||
if (showUnairedNextUp) {
|
||||
return ordered.firstOrNull()
|
||||
|
|
@ -637,6 +640,9 @@ private fun com.nuvio.app.features.details.MetaDetails.nextReleasedEpisodeAfter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun ContinueWatchingItem.shouldDisplayInContinueWatching(): Boolean =
|
||||
isNextUp || progressFraction < 0.995f
|
||||
|
||||
private fun CachedNextUpItem.toContinueWatchingItem(): ContinueWatchingItem? {
|
||||
val subtitle = buildString {
|
||||
append("Up Next")
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ import com.nuvio.app.features.watchprogress.ContinueWatchingItem
|
|||
import com.nuvio.app.features.watchprogress.ContinueWatchingSectionStyle
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
private fun continueWatchingProgressPercent(progressFraction: Float): Int =
|
||||
(progressFraction * 100f).roundToInt().coerceIn(1, 99)
|
||||
|
||||
@Composable
|
||||
internal fun HomeContinueWatchingSection(
|
||||
items: List<ContinueWatchingItem>,
|
||||
|
|
@ -361,7 +364,7 @@ private fun ContinueWatchingWideCard(
|
|||
trackColor = Color.White.copy(alpha = 0.10f),
|
||||
)
|
||||
Text(
|
||||
text = "${(item.progressFraction * 100).roundToInt()}% watched",
|
||||
text = "${continueWatchingProgressPercent(item.progressFraction)}% watched",
|
||||
style = MaterialTheme.typography.labelSmall.copy(
|
||||
fontSize = layout.progressLabelSize,
|
||||
fontWeight = FontWeight.Medium,
|
||||
|
|
|
|||
|
|
@ -7,34 +7,78 @@ import io.github.jan.supabase.postgrest.rpc
|
|||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
@Serializable
|
||||
private data class StoredAvatarCatalogPayload(
|
||||
val items: List<AvatarCatalogItem> = emptyList(),
|
||||
)
|
||||
|
||||
object AvatarRepository {
|
||||
private val log = Logger.withTag("AvatarRepository")
|
||||
private val json = Json { ignoreUnknownKeys = true; encodeDefaults = true }
|
||||
|
||||
private val _avatars = MutableStateFlow<List<AvatarCatalogItem>>(emptyList())
|
||||
val avatars: StateFlow<List<AvatarCatalogItem>> = _avatars.asStateFlow()
|
||||
|
||||
private var loaded = false
|
||||
private var cacheHydrated = false
|
||||
private var fetchInFlight = false
|
||||
|
||||
suspend fun fetchAvatars() {
|
||||
hydrateFromCacheIfNeeded()
|
||||
if (loaded && _avatars.value.isNotEmpty()) return
|
||||
doFetch()
|
||||
}
|
||||
|
||||
suspend fun refreshAvatars() {
|
||||
hydrateFromCacheIfNeeded()
|
||||
doFetch()
|
||||
}
|
||||
|
||||
private fun hydrateFromCacheIfNeeded() {
|
||||
if (cacheHydrated) return
|
||||
cacheHydrated = true
|
||||
|
||||
val payload = AvatarStorage.loadPayload().orEmpty().trim()
|
||||
if (payload.isEmpty()) return
|
||||
|
||||
val stored = runCatching {
|
||||
json.decodeFromString<StoredAvatarCatalogPayload>(payload)
|
||||
}.getOrNull() ?: return
|
||||
|
||||
val items = stored.items
|
||||
.filter { it.isActive }
|
||||
.sortedWith(compareBy({ it.category }, { it.sortOrder }))
|
||||
if (items.isEmpty()) return
|
||||
|
||||
_avatars.value = items
|
||||
loaded = true
|
||||
}
|
||||
|
||||
private suspend fun doFetch() {
|
||||
if (fetchInFlight) return
|
||||
fetchInFlight = true
|
||||
runCatching {
|
||||
val result = SupabaseProvider.client.postgrest.rpc("get_avatar_catalog")
|
||||
val items = result.decodeList<AvatarCatalogItem>()
|
||||
_avatars.value = items.filter { it.isActive }.sortedWith(
|
||||
val activeItems = items.filter { it.isActive }.sortedWith(
|
||||
compareBy({ it.category }, { it.sortOrder }),
|
||||
)
|
||||
_avatars.value = activeItems
|
||||
loaded = true
|
||||
AvatarStorage.savePayload(
|
||||
json.encodeToString(
|
||||
StoredAvatarCatalogPayload(items = activeItems),
|
||||
),
|
||||
)
|
||||
}.onFailure { e ->
|
||||
log.e(e) { "Failed to fetch avatar catalog" }
|
||||
}.also {
|
||||
fetchInFlight = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
internal expect object AvatarStorage {
|
||||
fun loadPayload(): String?
|
||||
fun savePayload(payload: String)
|
||||
}
|
||||
|
|
@ -46,6 +46,8 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import coil3.compose.AsyncImage
|
||||
import com.nuvio.app.core.auth.AuthRepository
|
||||
import com.nuvio.app.core.auth.AuthState
|
||||
import com.nuvio.app.core.ui.NuvioInputField
|
||||
import com.nuvio.app.core.ui.NuvioPrimaryButton
|
||||
import com.nuvio.app.core.ui.NuvioScreen
|
||||
|
|
@ -79,9 +81,13 @@ fun ProfileEditScreen(
|
|||
var showDeleteConfirm by remember { mutableStateOf(false) }
|
||||
var showPinSetup by remember { mutableStateOf(false) }
|
||||
var showPinClear by remember { mutableStateOf(false) }
|
||||
val authState by AuthRepository.state.collectAsStateWithLifecycle()
|
||||
|
||||
val avatars by AvatarRepository.avatars.collectAsStateWithLifecycle()
|
||||
LaunchedEffect(Unit) { AvatarRepository.fetchAvatars() }
|
||||
LaunchedEffect(Unit) {
|
||||
AvatarRepository.fetchAvatars()
|
||||
AvatarRepository.refreshAvatars()
|
||||
}
|
||||
LaunchedEffect(isNew, avatars, selectedAvatarId) {
|
||||
if (isNew && selectedAvatarId == null && avatars.isNotEmpty()) {
|
||||
selectedAvatarId = avatars.first().id
|
||||
|
|
@ -272,7 +278,11 @@ fun ProfileEditScreen(
|
|||
hasExistingPin = currentProfile.pinEnabled,
|
||||
onDone = {
|
||||
showPinSetup = false
|
||||
scope.launch { ProfileRepository.pullProfiles() }
|
||||
scope.launch {
|
||||
if (authState is AuthState.Authenticated) {
|
||||
ProfileRepository.pullProfiles()
|
||||
}
|
||||
}
|
||||
},
|
||||
onDismiss = { showPinSetup = false },
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
import kotlin.random.Random
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
internal data class CachedProfilePinPayload(
|
||||
val salt: String,
|
||||
val digest: String,
|
||||
val profileUpdatedAt: String = "",
|
||||
)
|
||||
|
||||
internal fun generateProfilePinSalt(): String {
|
||||
val first = Random.nextLong().toULong().toString(16)
|
||||
val second = Random.nextLong().toULong().toString(16)
|
||||
return "$first$second"
|
||||
}
|
||||
|
||||
internal fun hashProfilePin(profileIndex: Int, salt: String, pin: String): String =
|
||||
ProfilePinCrypto.sha256Hex("profile:$profileIndex:$salt:$pin")
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
internal expect object ProfilePinCacheStorage {
|
||||
fun loadPayload(profileIndex: Int): String?
|
||||
fun savePayload(profileIndex: Int, payload: String)
|
||||
fun removePayload(profileIndex: Int)
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
internal expect object ProfilePinCrypto {
|
||||
fun sha256Hex(value: String): String
|
||||
}
|
||||
|
|
@ -60,35 +60,31 @@ object ProfileRepository {
|
|||
|
||||
val activeProfileId: Int get() = activeProfileIndex
|
||||
|
||||
fun loadCachedProfiles(): Boolean {
|
||||
val stored = decodeStoredPayload() ?: return false
|
||||
loadedCacheForUserId = stored.userId
|
||||
applyStoredPayload(stored)
|
||||
return _state.value.profiles.isNotEmpty()
|
||||
}
|
||||
|
||||
fun ensureLoaded(userId: String) {
|
||||
if (loadedCacheForUserId == userId && _state.value.isLoaded) return
|
||||
|
||||
val stored = decodeStoredPayload()
|
||||
loadedCacheForUserId = userId
|
||||
val payload = ProfileStorage.loadPayload().orEmpty().trim()
|
||||
if (payload.isEmpty()) {
|
||||
if (stored == null) {
|
||||
_state.value = ProfileState()
|
||||
activeProfileIndex = 1
|
||||
return
|
||||
}
|
||||
|
||||
val stored = runCatching {
|
||||
json.decodeFromString<StoredProfilePayload>(payload)
|
||||
}.getOrNull() ?: return
|
||||
|
||||
if (stored.userId != userId) {
|
||||
_state.value = ProfileState()
|
||||
activeProfileIndex = 1
|
||||
return
|
||||
}
|
||||
|
||||
val profiles = stored.profiles.sortedBy { it.profileIndex }
|
||||
activeProfileIndex = stored.activeProfileIndex
|
||||
_state.value = ProfileState(
|
||||
profiles = profiles,
|
||||
activeProfile = profiles.find { it.profileIndex == activeProfileIndex } ?: profiles.firstOrNull(),
|
||||
isLoaded = profiles.isNotEmpty(),
|
||||
)
|
||||
_state.value.activeProfile?.let { activeProfileIndex = it.profileIndex }
|
||||
applyStoredPayload(stored)
|
||||
}
|
||||
|
||||
fun clearInMemory() {
|
||||
|
|
@ -232,6 +228,7 @@ object ProfileRepository {
|
|||
suspend fun deleteProfile(profileIndex: Int) {
|
||||
if (AuthRepository.state.value.isAnonymous) {
|
||||
val remaining = _state.value.profiles.filter { it.profileIndex != profileIndex }
|
||||
ProfilePinCacheStorage.removePayload(profileIndex)
|
||||
_state.value = _state.value.copy(
|
||||
profiles = remaining,
|
||||
activeProfile = if (_state.value.activeProfile?.profileIndex == profileIndex) remaining.firstOrNull() else _state.value.activeProfile,
|
||||
|
|
@ -252,20 +249,32 @@ object ProfileRepository {
|
|||
}
|
||||
|
||||
suspend fun verifyPin(profileIndex: Int, pin: String): PinVerifyResult {
|
||||
if (AuthRepository.state.value !is AuthState.Authenticated) {
|
||||
return verifyPinLocally(profileIndex, pin)
|
||||
}
|
||||
|
||||
return runCatching {
|
||||
val params = buildJsonObject {
|
||||
put("p_profile_id", profileIndex)
|
||||
put("p_pin", pin)
|
||||
}
|
||||
val result = SupabaseProvider.client.postgrest.rpc("verify_profile_pin", params)
|
||||
result.decodeSingle<PinVerifyResult>()
|
||||
result.decodeSingle<PinVerifyResult>().also { verifyResult ->
|
||||
if (verifyResult.unlocked) {
|
||||
rememberVerifiedPin(profileIndex = profileIndex, pin = pin)
|
||||
}
|
||||
}
|
||||
}.getOrElse { e ->
|
||||
log.e(e) { "Failed to verify pin" }
|
||||
PinVerifyResult(unlocked = false, retryAfterSeconds = 0, message = "Couldn't verify PIN. Try again.")
|
||||
verifyPinLocally(profileIndex, pin)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun setPin(profileIndex: Int, pin: String, currentPin: String? = null): PinVerifyResult {
|
||||
if (AuthRepository.state.value !is AuthState.Authenticated) {
|
||||
return PinVerifyResult(unlocked = false, message = "Connect to the internet to set a PIN.")
|
||||
}
|
||||
|
||||
return runCatching {
|
||||
val params = buildJsonObject {
|
||||
put("p_profile_id", profileIndex)
|
||||
|
|
@ -274,6 +283,7 @@ object ProfileRepository {
|
|||
}
|
||||
SupabaseProvider.client.postgrest.rpc("set_profile_pin", params)
|
||||
pullProfiles()
|
||||
rememberVerifiedPin(profileIndex = profileIndex, pin = pin)
|
||||
PinVerifyResult(unlocked = true)
|
||||
}.onFailure { e ->
|
||||
log.e(e) { "Failed to set pin" }
|
||||
|
|
@ -283,6 +293,10 @@ object ProfileRepository {
|
|||
}
|
||||
|
||||
suspend fun clearPin(profileIndex: Int, currentPin: String? = null): PinVerifyResult {
|
||||
if (AuthRepository.state.value !is AuthState.Authenticated) {
|
||||
return PinVerifyResult(unlocked = false, message = "Connect to the internet to remove the PIN lock.")
|
||||
}
|
||||
|
||||
return runCatching {
|
||||
val params = buildJsonObject {
|
||||
put("p_profile_id", profileIndex)
|
||||
|
|
@ -290,6 +304,7 @@ object ProfileRepository {
|
|||
}
|
||||
SupabaseProvider.client.postgrest.rpc("clear_profile_pin", params)
|
||||
pullProfiles()
|
||||
ProfilePinCacheStorage.removePayload(profileIndex)
|
||||
PinVerifyResult(unlocked = true)
|
||||
}.onFailure { e ->
|
||||
log.e(e) { "Failed to clear pin" }
|
||||
|
|
@ -306,6 +321,7 @@ object ProfileRepository {
|
|||
}
|
||||
SupabaseProvider.client.postgrest.rpc("clear_profile_pin_with_account_password", params)
|
||||
pullProfiles()
|
||||
ProfilePinCacheStorage.removePayload(profileIndex)
|
||||
}.onFailure { e ->
|
||||
log.e(e) { "Failed to clear pin with password" }
|
||||
}
|
||||
|
|
@ -343,9 +359,112 @@ object ProfileRepository {
|
|||
if (_state.value.activeProfile != null) {
|
||||
activeProfileIndex = _state.value.activeProfile!!.profileIndex
|
||||
}
|
||||
syncPinCache(profiles)
|
||||
persist()
|
||||
}
|
||||
|
||||
private fun decodeStoredPayload(): StoredProfilePayload? {
|
||||
val payload = ProfileStorage.loadPayload().orEmpty().trim()
|
||||
if (payload.isEmpty()) return null
|
||||
|
||||
return runCatching {
|
||||
json.decodeFromString<StoredProfilePayload>(payload)
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
private fun applyStoredPayload(stored: StoredProfilePayload) {
|
||||
val profiles = stored.profiles.sortedBy { it.profileIndex }
|
||||
activeProfileIndex = stored.activeProfileIndex
|
||||
_state.value = ProfileState(
|
||||
profiles = profiles,
|
||||
activeProfile = profiles.find { it.profileIndex == activeProfileIndex } ?: profiles.firstOrNull(),
|
||||
isLoaded = profiles.isNotEmpty(),
|
||||
)
|
||||
_state.value.activeProfile?.let { activeProfileIndex = it.profileIndex }
|
||||
syncPinCache(profiles)
|
||||
}
|
||||
|
||||
private fun rememberVerifiedPin(profileIndex: Int, pin: String) {
|
||||
val profile = _state.value.profiles.find { it.profileIndex == profileIndex }
|
||||
val salt = generateProfilePinSalt()
|
||||
val payload = CachedProfilePinPayload(
|
||||
salt = salt,
|
||||
digest = hashProfilePin(profileIndex = profileIndex, salt = salt, pin = pin),
|
||||
profileUpdatedAt = profile?.updatedAt.orEmpty(),
|
||||
)
|
||||
ProfilePinCacheStorage.savePayload(profileIndex, json.encodeToString(payload))
|
||||
}
|
||||
|
||||
private fun verifyPinLocally(profileIndex: Int, pin: String): PinVerifyResult {
|
||||
val profile = _state.value.profiles.find { it.profileIndex == profileIndex }
|
||||
if (profile?.pinEnabled != true) {
|
||||
return PinVerifyResult(unlocked = true)
|
||||
}
|
||||
|
||||
val payload = ProfilePinCacheStorage.loadPayload(profileIndex).orEmpty().trim()
|
||||
if (payload.isEmpty()) {
|
||||
return PinVerifyResult(
|
||||
unlocked = false,
|
||||
message = "This PIN can't be verified offline on this device yet. Connect once and unlock it online first.",
|
||||
)
|
||||
}
|
||||
|
||||
val cached = runCatching {
|
||||
json.decodeFromString<CachedProfilePinPayload>(payload)
|
||||
}.getOrNull() ?: return PinVerifyResult(
|
||||
unlocked = false,
|
||||
message = "This PIN can't be verified offline on this device yet. Connect once and unlock it online first.",
|
||||
)
|
||||
|
||||
if (
|
||||
cached.profileUpdatedAt.isNotBlank() &&
|
||||
profile.updatedAt.isNotBlank() &&
|
||||
cached.profileUpdatedAt != profile.updatedAt
|
||||
) {
|
||||
ProfilePinCacheStorage.removePayload(profileIndex)
|
||||
return PinVerifyResult(
|
||||
unlocked = false,
|
||||
message = "This profile PIN changed. Connect once to refresh the lock on this device.",
|
||||
)
|
||||
}
|
||||
|
||||
val digest = hashProfilePin(profileIndex = profileIndex, salt = cached.salt, pin = pin)
|
||||
return if (digest == cached.digest) {
|
||||
PinVerifyResult(unlocked = true)
|
||||
} else {
|
||||
PinVerifyResult(unlocked = false, message = "Incorrect PIN")
|
||||
}
|
||||
}
|
||||
|
||||
private fun syncPinCache(profiles: List<NuvioProfile>) {
|
||||
val profilesByIndex = profiles.associateBy { it.profileIndex }
|
||||
for (profileIndex in 1..4) {
|
||||
val profile = profilesByIndex[profileIndex]
|
||||
if (profile == null || !profile.pinEnabled) {
|
||||
ProfilePinCacheStorage.removePayload(profileIndex)
|
||||
continue
|
||||
}
|
||||
|
||||
val raw = ProfilePinCacheStorage.loadPayload(profileIndex).orEmpty().trim()
|
||||
if (raw.isEmpty()) continue
|
||||
|
||||
val cached = runCatching {
|
||||
json.decodeFromString<CachedProfilePinPayload>(raw)
|
||||
}.getOrNull() ?: run {
|
||||
ProfilePinCacheStorage.removePayload(profileIndex)
|
||||
continue
|
||||
}
|
||||
|
||||
if (
|
||||
cached.profileUpdatedAt.isNotBlank() &&
|
||||
profile.updatedAt.isNotBlank() &&
|
||||
cached.profileUpdatedAt != profile.updatedAt
|
||||
) {
|
||||
ProfilePinCacheStorage.removePayload(profileIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun persist() {
|
||||
val authState = AuthRepository.state.value as? AuthState.Authenticated ?: return
|
||||
ProfileStorage.savePayload(
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import coil3.compose.AsyncImage
|
||||
import com.nuvio.app.core.auth.AuthRepository
|
||||
import com.nuvio.app.core.auth.AuthState
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
|
@ -67,6 +69,7 @@ fun ProfileSelectionScreen(
|
|||
onAddProfile: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val authState by AuthRepository.state.collectAsStateWithLifecycle()
|
||||
val profileState by ProfileRepository.state.collectAsStateWithLifecycle()
|
||||
val scope = rememberCoroutineScope()
|
||||
var pinDialogProfile by remember { mutableStateOf<NuvioProfile?>(null) }
|
||||
|
|
@ -77,11 +80,16 @@ fun ProfileSelectionScreen(
|
|||
val manageAlpha = remember { Animatable(0f) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
ProfileRepository.pullProfiles()
|
||||
AvatarRepository.fetchAvatars()
|
||||
AvatarRepository.refreshAvatars()
|
||||
}
|
||||
|
||||
LaunchedEffect(authState) {
|
||||
if (authState is AuthState.Authenticated) {
|
||||
ProfileRepository.pullProfiles()
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
launch { titleAlpha.animateTo(1f, tween(600, easing = FastOutSlowInEasing)) }
|
||||
launch { titleOffset.animateTo(0f, tween(600, easing = FastOutSlowInEasing)) }
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ fun ProfileSwitcherTab(
|
|||
|
||||
LaunchedEffect(Unit) {
|
||||
AvatarRepository.fetchAvatars()
|
||||
AvatarRepository.refreshAvatars()
|
||||
}
|
||||
|
||||
val haptic = LocalHapticFeedback.current
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ import com.nuvio.app.core.ui.NuvioBottomSheetActionRow
|
|||
import com.nuvio.app.core.ui.NuvioBottomSheetDivider
|
||||
import com.nuvio.app.core.ui.NuvioModalBottomSheet
|
||||
import com.nuvio.app.core.ui.dismissNuvioBottomSheet
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.core.ui.rememberPosterCardStyleUiState
|
||||
import com.nuvio.app.core.ui.posterCardClickable
|
||||
import com.nuvio.app.features.home.MetaPreview
|
||||
|
|
@ -292,7 +292,7 @@ private fun DiscoverOptionsSheet(
|
|||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 16.dp + nuvioPlatformExtraBottomPadding),
|
||||
.padding(bottom = nuvioSafeBottomPadding(16.dp)),
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ internal fun LazyListScope.accountSettingsContent(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun AccountSettingsBody(isTablet: Boolean) {
|
||||
private fun AccountSettingsBody(
|
||||
isTablet: Boolean,
|
||||
) {
|
||||
val authState by AuthRepository.state.collectAsStateWithLifecycle()
|
||||
val scope = rememberCoroutineScope()
|
||||
var showDeleteConfirm by remember { mutableStateOf(false) }
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nuvio.app.features.settings
|
|||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.AccountCircle
|
||||
import androidx.compose.material.icons.rounded.Info
|
||||
import androidx.compose.material.icons.rounded.Notifications
|
||||
import androidx.compose.material.icons.rounded.Settings
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
|
@ -12,6 +13,7 @@ internal enum class SettingsCategory(
|
|||
) {
|
||||
Account("Account", Icons.Rounded.AccountCircle),
|
||||
General("General", Icons.Rounded.Settings),
|
||||
About("About", Icons.Rounded.Info),
|
||||
}
|
||||
|
||||
internal enum class SettingsPage(
|
||||
|
|
@ -29,6 +31,11 @@ internal enum class SettingsPage(
|
|||
category = SettingsCategory.Account,
|
||||
parentPage = Root,
|
||||
),
|
||||
SupportersContributors(
|
||||
title = "Supporters & Contributors",
|
||||
category = SettingsCategory.About,
|
||||
parentPage = Root,
|
||||
),
|
||||
Playback(
|
||||
title = "Playback",
|
||||
category = SettingsCategory.General,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.rounded.AccountCircle
|
||||
import androidx.compose.material.icons.rounded.CloudDownload
|
||||
import androidx.compose.material.icons.rounded.Extension
|
||||
import androidx.compose.material.icons.rounded.Favorite
|
||||
import androidx.compose.material.icons.rounded.Info
|
||||
import androidx.compose.material.icons.rounded.Link
|
||||
import androidx.compose.material.icons.rounded.Notifications
|
||||
import androidx.compose.material.icons.rounded.Palette
|
||||
|
|
@ -27,11 +29,13 @@ internal fun LazyListScope.settingsRootContent(
|
|||
onContentDiscoveryClick: () -> Unit,
|
||||
onIntegrationsClick: () -> Unit,
|
||||
onTraktClick: () -> Unit,
|
||||
onSupportersContributorsClick: () -> Unit,
|
||||
onDownloadsClick: () -> Unit,
|
||||
onAccountClick: () -> Unit,
|
||||
onSwitchProfileClick: (() -> Unit)? = null,
|
||||
showAccountSection: Boolean = true,
|
||||
showGeneralSection: Boolean = true,
|
||||
showAboutSection: Boolean = true,
|
||||
) {
|
||||
if (showAccountSection) {
|
||||
item {
|
||||
|
|
@ -127,15 +131,44 @@ internal fun LazyListScope.settingsRootContent(
|
|||
}
|
||||
}
|
||||
}
|
||||
if (showAboutSection) {
|
||||
item {
|
||||
SettingsSection(
|
||||
title = "ABOUT",
|
||||
isTablet = isTablet,
|
||||
) {
|
||||
SettingsGroup(isTablet = isTablet) {
|
||||
SettingsNavigationRow(
|
||||
title = "Supporters & Contributors",
|
||||
description = "See cross-app contributors and the supporters backing Nuvio.",
|
||||
icon = Icons.Rounded.Favorite,
|
||||
isTablet = isTablet,
|
||||
onClick = onSupportersContributorsClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
item {
|
||||
Text(
|
||||
text = "Version ${AppVersionConfig.VERSION_NAME} (${AppVersionConfig.VERSION_CODE})",
|
||||
androidx.compose.foundation.layout.Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp, vertical = if (isTablet) 20.dp else 16.dp),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Made with ❤️ by Tapframe and friends",
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
Text(
|
||||
text = "Version ${AppVersionConfig.VERSION_NAME} (${AppVersionConfig.VERSION_CODE})",
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ fun SettingsScreen(
|
|||
onPluginsClick: () -> Unit = {},
|
||||
onDownloadsClick: () -> Unit = {},
|
||||
onAccountClick: () -> Unit = {},
|
||||
onSupportersContributorsClick: () -> Unit = {},
|
||||
onCollectionsClick: () -> Unit = {},
|
||||
) {
|
||||
BoxWithConstraints(
|
||||
|
|
@ -188,6 +189,7 @@ fun SettingsScreen(
|
|||
posterCardStyleUiState = posterCardStyleUiState,
|
||||
onSwitchProfile = onSwitchProfile,
|
||||
onDownloadsClick = onDownloadsClick,
|
||||
onSupportersContributorsClick = onSupportersContributorsClick,
|
||||
onCollectionsClick = onCollectionsClick,
|
||||
)
|
||||
} else {
|
||||
|
|
@ -230,6 +232,7 @@ fun SettingsScreen(
|
|||
onPluginsClick = onPluginsClick,
|
||||
onDownloadsClick = onDownloadsClick,
|
||||
onAccountClick = onAccountClick,
|
||||
onSupportersContributorsClick = onSupportersContributorsClick,
|
||||
onCollectionsClick = onCollectionsClick,
|
||||
)
|
||||
}
|
||||
|
|
@ -276,6 +279,7 @@ private fun MobileSettingsScreen(
|
|||
onPluginsClick: () -> Unit = {},
|
||||
onDownloadsClick: () -> Unit = {},
|
||||
onAccountClick: () -> Unit = {},
|
||||
onSupportersContributorsClick: () -> Unit = {},
|
||||
onCollectionsClick: () -> Unit = {},
|
||||
) {
|
||||
NuvioScreen {
|
||||
|
|
@ -296,6 +300,7 @@ private fun MobileSettingsScreen(
|
|||
onContentDiscoveryClick = { onPageChange(SettingsPage.ContentDiscovery) },
|
||||
onIntegrationsClick = { onPageChange(SettingsPage.Integrations) },
|
||||
onTraktClick = { onPageChange(SettingsPage.TraktAuthentication) },
|
||||
onSupportersContributorsClick = onSupportersContributorsClick,
|
||||
onDownloadsClick = onDownloadsClick,
|
||||
onAccountClick = onAccountClick,
|
||||
onSwitchProfileClick = onSwitchProfile,
|
||||
|
|
@ -303,6 +308,9 @@ private fun MobileSettingsScreen(
|
|||
SettingsPage.Account -> accountSettingsContent(
|
||||
isTablet = false,
|
||||
)
|
||||
SettingsPage.SupportersContributors -> supportersContributorsContent(
|
||||
isTablet = false,
|
||||
)
|
||||
SettingsPage.Playback -> playbackSettingsContent(
|
||||
isTablet = false,
|
||||
showLoadingOverlay = showLoadingOverlay,
|
||||
|
|
@ -421,6 +429,7 @@ private fun TabletSettingsScreen(
|
|||
posterCardStyleUiState: PosterCardStyleUiState,
|
||||
onSwitchProfile: (() -> Unit)? = null,
|
||||
onDownloadsClick: () -> Unit = {},
|
||||
onSupportersContributorsClick: () -> Unit = {},
|
||||
onCollectionsClick: () -> Unit = {},
|
||||
) {
|
||||
var selectedCategory by rememberSaveable { mutableStateOf(SettingsCategory.General.name) }
|
||||
|
|
@ -508,15 +517,20 @@ private fun TabletSettingsScreen(
|
|||
onContentDiscoveryClick = { openInlinePage(SettingsPage.ContentDiscovery) },
|
||||
onIntegrationsClick = { openInlinePage(SettingsPage.Integrations) },
|
||||
onTraktClick = { openInlinePage(SettingsPage.TraktAuthentication) },
|
||||
onSupportersContributorsClick = { openInlinePage(SettingsPage.SupportersContributors) },
|
||||
onDownloadsClick = onDownloadsClick,
|
||||
onAccountClick = { openInlinePage(SettingsPage.Account) },
|
||||
onSwitchProfileClick = onSwitchProfile,
|
||||
showAccountSection = activeCategory == SettingsCategory.Account,
|
||||
showGeneralSection = activeCategory == SettingsCategory.General,
|
||||
showAboutSection = activeCategory == SettingsCategory.About,
|
||||
)
|
||||
SettingsPage.Account -> accountSettingsContent(
|
||||
isTablet = true,
|
||||
)
|
||||
SettingsPage.SupportersContributors -> supportersContributorsContent(
|
||||
isTablet = true,
|
||||
)
|
||||
SettingsPage.Playback -> playbackSettingsContent(
|
||||
isTablet = true,
|
||||
showLoadingOverlay = showLoadingOverlay,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,994 @@
|
|||
package com.nuvio.app.features.settings
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.rounded.OpenInNew
|
||||
import androidx.compose.material.icons.rounded.Favorite
|
||||
import androidx.compose.material3.BasicAlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil3.compose.AsyncImage
|
||||
import com.nuvio.app.core.ui.NuvioScreen
|
||||
import com.nuvio.app.core.ui.NuvioScreenHeader
|
||||
import com.nuvio.app.core.ui.NuvioSurfaceCard
|
||||
import com.nuvio.app.features.addons.httpRequestRaw
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
private enum class CommunityTab {
|
||||
Contributors,
|
||||
Supporters,
|
||||
}
|
||||
|
||||
private data class CommunityUiState(
|
||||
val selectedTab: CommunityTab = CommunityTab.Contributors,
|
||||
val isContributorsLoading: Boolean = false,
|
||||
val hasLoadedContributors: Boolean = false,
|
||||
val contributors: List<CommunityContributor> = emptyList(),
|
||||
val contributorsErrorMessage: String? = null,
|
||||
val isSupportersLoading: Boolean = false,
|
||||
val hasLoadedSupporters: Boolean = false,
|
||||
val supporters: List<SupporterDonation> = emptyList(),
|
||||
val supportersErrorMessage: String? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
private data class GitHubContributorDto(
|
||||
val login: String? = null,
|
||||
@SerialName("avatar_url") val avatarUrl: String? = null,
|
||||
@SerialName("html_url") val htmlUrl: String? = null,
|
||||
val contributions: Int? = null,
|
||||
val type: String? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
private data class DonationsResponseDto(
|
||||
val donations: List<DonationDto> = emptyList(),
|
||||
)
|
||||
|
||||
@Serializable
|
||||
private data class DonationDto(
|
||||
val name: String? = null,
|
||||
val date: String? = null,
|
||||
val message: String? = null,
|
||||
)
|
||||
|
||||
internal data class CommunityContributor(
|
||||
val login: String,
|
||||
val avatarUrl: String?,
|
||||
val profileUrl: String?,
|
||||
val totalContributions: Int,
|
||||
val mobileContributions: Int,
|
||||
val tvContributions: Int,
|
||||
val webContributions: Int,
|
||||
)
|
||||
|
||||
internal data class SupporterDonation(
|
||||
val key: String,
|
||||
val name: String,
|
||||
val date: String,
|
||||
val message: String?,
|
||||
val sortTimestamp: Long,
|
||||
)
|
||||
|
||||
private object SupportersContributorsRepository {
|
||||
private const val gitHubOwner = "nuviomedia"
|
||||
private const val mobileRepository = "nuviomobile"
|
||||
private const val tvRepository = "nuviotv"
|
||||
private const val webRepository = "nuvioweb"
|
||||
private const val gitHubApiBase = "https://api.github.com"
|
||||
|
||||
private val json = Json { ignoreUnknownKeys = true; isLenient = true }
|
||||
|
||||
suspend fun getContributors(): Result<List<CommunityContributor>> = runCatching {
|
||||
coroutineScope {
|
||||
val mobileDeferred = async { fetchRepoContributors(mobileRepository) }
|
||||
val tvDeferred = async { fetchRepoContributors(tvRepository) }
|
||||
val webDeferred = async { fetchRepoContributors(webRepository) }
|
||||
|
||||
val mobileResult = mobileDeferred.await()
|
||||
val tvResult = tvDeferred.await()
|
||||
val webResult = webDeferred.await()
|
||||
|
||||
if (mobileResult.isFailure && tvResult.isFailure && webResult.isFailure) {
|
||||
throw (
|
||||
mobileResult.exceptionOrNull()
|
||||
?: tvResult.exceptionOrNull()
|
||||
?: webResult.exceptionOrNull()
|
||||
?: IllegalStateException("Unable to load contributors")
|
||||
)
|
||||
}
|
||||
|
||||
mergeContributors(
|
||||
mobileContributors = mobileResult.getOrDefault(emptyList()),
|
||||
tvContributors = tvResult.getOrDefault(emptyList()),
|
||||
webContributors = webResult.getOrDefault(emptyList()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSupporters(limit: Int = 200): Result<List<SupporterDonation>> = runCatching {
|
||||
val baseUrl = CommunityConfig.DONATIONS_BASE_URL.trim().removeSuffix("/")
|
||||
check(baseUrl.isNotBlank()) {
|
||||
"Supporters endpoint is not configured. Add DONATIONS_BASE_URL to local.properties."
|
||||
}
|
||||
|
||||
val response = httpRequestRaw(
|
||||
method = "GET",
|
||||
url = "$baseUrl/api/donations?limit=$limit",
|
||||
headers = emptyMap(),
|
||||
body = "",
|
||||
)
|
||||
if (response.status !in 200..299) {
|
||||
error("Donations API error: ${response.status}")
|
||||
}
|
||||
|
||||
json.decodeFromString<DonationsResponseDto>(response.body)
|
||||
.donations
|
||||
.mapNotNull { donation ->
|
||||
val name = donation.name?.trim().orEmpty()
|
||||
val date = donation.date?.trim().orEmpty()
|
||||
if (name.isBlank() || date.isBlank()) return@mapNotNull null
|
||||
|
||||
SupporterDonation(
|
||||
key = "${name.lowercase()}-$date",
|
||||
name = name,
|
||||
date = date,
|
||||
message = donation.message?.trim()?.takeIf { it.isNotBlank() },
|
||||
sortTimestamp = supporterSortTimestamp(date),
|
||||
)
|
||||
}
|
||||
.sortedByDescending { it.sortTimestamp }
|
||||
.mapIndexed { index, donation ->
|
||||
donation.copy(key = "${donation.key}#$index")
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun fetchRepoContributors(repo: String): Result<List<GitHubContributorDto>> = runCatching {
|
||||
val contributors = mutableListOf<GitHubContributorDto>()
|
||||
var nextUrl: String? = "$gitHubApiBase/repos/$gitHubOwner/$repo/contributors?per_page=100"
|
||||
|
||||
while (nextUrl != null) {
|
||||
val response = httpRequestRaw(
|
||||
method = "GET",
|
||||
url = nextUrl,
|
||||
headers = mapOf(
|
||||
"Accept" to "application/vnd.github+json",
|
||||
"User-Agent" to "NuvioMobile",
|
||||
),
|
||||
body = "",
|
||||
)
|
||||
if (response.status !in 200..299) {
|
||||
error("GitHub contributors API error for $repo: ${response.status}")
|
||||
}
|
||||
|
||||
contributors += json.decodeFromString<List<GitHubContributorDto>>(response.body)
|
||||
nextUrl = response.headers.entries
|
||||
.firstOrNull { it.key.equals("link", ignoreCase = true) }
|
||||
?.value
|
||||
?.let(::parseNextLink)
|
||||
}
|
||||
|
||||
contributors
|
||||
}
|
||||
|
||||
private fun mergeContributors(
|
||||
mobileContributors: List<GitHubContributorDto>,
|
||||
tvContributors: List<GitHubContributorDto>,
|
||||
webContributors: List<GitHubContributorDto>,
|
||||
): List<CommunityContributor> {
|
||||
val contributorsByLogin = linkedMapOf<String, MutableCommunityContributor>()
|
||||
|
||||
mobileContributors.forEach { dto ->
|
||||
normalizeContributor(dto)?.let { contributor ->
|
||||
val entry = contributorsByLogin.getOrPut(contributor.login.lowercase()) {
|
||||
MutableCommunityContributor(
|
||||
login = contributor.login,
|
||||
avatarUrl = contributor.avatarUrl,
|
||||
profileUrl = contributor.htmlUrl,
|
||||
)
|
||||
}
|
||||
entry.avatarUrl = entry.avatarUrl ?: contributor.avatarUrl
|
||||
entry.profileUrl = entry.profileUrl ?: contributor.htmlUrl
|
||||
entry.mobileContributions += contributor.contributions
|
||||
}
|
||||
}
|
||||
|
||||
tvContributors.forEach { dto ->
|
||||
normalizeContributor(dto)?.let { contributor ->
|
||||
val entry = contributorsByLogin.getOrPut(contributor.login.lowercase()) {
|
||||
MutableCommunityContributor(
|
||||
login = contributor.login,
|
||||
avatarUrl = contributor.avatarUrl,
|
||||
profileUrl = contributor.htmlUrl,
|
||||
)
|
||||
}
|
||||
entry.avatarUrl = entry.avatarUrl ?: contributor.avatarUrl
|
||||
entry.profileUrl = entry.profileUrl ?: contributor.htmlUrl
|
||||
entry.tvContributions += contributor.contributions
|
||||
}
|
||||
}
|
||||
|
||||
webContributors.forEach { dto ->
|
||||
normalizeContributor(dto)?.let { contributor ->
|
||||
val entry = contributorsByLogin.getOrPut(contributor.login.lowercase()) {
|
||||
MutableCommunityContributor(
|
||||
login = contributor.login,
|
||||
avatarUrl = contributor.avatarUrl,
|
||||
profileUrl = contributor.htmlUrl,
|
||||
)
|
||||
}
|
||||
entry.avatarUrl = entry.avatarUrl ?: contributor.avatarUrl
|
||||
entry.profileUrl = entry.profileUrl ?: contributor.htmlUrl
|
||||
entry.webContributions += contributor.contributions
|
||||
}
|
||||
}
|
||||
|
||||
return contributorsByLogin.values
|
||||
.map { contributor ->
|
||||
CommunityContributor(
|
||||
login = contributor.login,
|
||||
avatarUrl = contributor.avatarUrl,
|
||||
profileUrl = contributor.profileUrl,
|
||||
totalContributions = contributor.mobileContributions + contributor.tvContributions + contributor.webContributions,
|
||||
mobileContributions = contributor.mobileContributions,
|
||||
tvContributions = contributor.tvContributions,
|
||||
webContributions = contributor.webContributions,
|
||||
)
|
||||
}
|
||||
.sortedWith(
|
||||
compareByDescending<CommunityContributor> { it.totalContributions }
|
||||
.thenBy { it.login.lowercase() },
|
||||
)
|
||||
}
|
||||
|
||||
private fun normalizeContributor(dto: GitHubContributorDto): NormalizedContributor? {
|
||||
val login = dto.login?.trim().orEmpty()
|
||||
val contributions = dto.contributions ?: 0
|
||||
val type = dto.type?.trim()
|
||||
if (login.isBlank() || contributions <= 0) return null
|
||||
if (type != null && !type.equals("User", ignoreCase = true)) return null
|
||||
|
||||
return NormalizedContributor(
|
||||
login = login,
|
||||
avatarUrl = dto.avatarUrl?.trim()?.takeIf { it.isNotBlank() },
|
||||
htmlUrl = dto.htmlUrl?.trim()?.takeIf { it.isNotBlank() },
|
||||
contributions = contributions,
|
||||
)
|
||||
}
|
||||
|
||||
private fun parseNextLink(linkHeader: String): String? =
|
||||
linkHeader.split(',')
|
||||
.map(String::trim)
|
||||
.firstOrNull { it.contains("rel=\"next\"") }
|
||||
?.substringAfter('<')
|
||||
?.substringBefore('>')
|
||||
?.takeIf { it.isNotBlank() }
|
||||
|
||||
private fun supporterSortTimestamp(rawDate: String): Long {
|
||||
val datePart = rawDate.substringBefore('T')
|
||||
val parts = datePart.split('-')
|
||||
if (parts.size != 3) return Long.MIN_VALUE
|
||||
val year = parts[0].toLongOrNull() ?: return Long.MIN_VALUE
|
||||
val month = parts[1].toLongOrNull() ?: return Long.MIN_VALUE
|
||||
val day = parts[2].toLongOrNull() ?: return Long.MIN_VALUE
|
||||
return year * 10_000L + month * 100L + day
|
||||
}
|
||||
|
||||
private data class NormalizedContributor(
|
||||
val login: String,
|
||||
val avatarUrl: String?,
|
||||
val htmlUrl: String?,
|
||||
val contributions: Int,
|
||||
)
|
||||
|
||||
private data class MutableCommunityContributor(
|
||||
val login: String,
|
||||
var avatarUrl: String?,
|
||||
var profileUrl: String?,
|
||||
var mobileContributions: Int = 0,
|
||||
var tvContributions: Int = 0,
|
||||
var webContributions: Int = 0,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SupportersContributorsSettingsScreen(
|
||||
onBack: () -> Unit,
|
||||
) {
|
||||
NuvioScreen(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) {
|
||||
stickyHeader {
|
||||
NuvioScreenHeader(
|
||||
title = "Supporters & Contributors",
|
||||
onBack = onBack,
|
||||
)
|
||||
}
|
||||
supportersContributorsContent(isTablet = false)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun LazyListScope.supportersContributorsContent(
|
||||
isTablet: Boolean,
|
||||
) {
|
||||
item {
|
||||
SupportersContributorsBody(isTablet = isTablet)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SupportersContributorsBody(
|
||||
isTablet: Boolean,
|
||||
) {
|
||||
val uriHandler = LocalUriHandler.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val donateUrl = remember { CommunityConfig.DONATIONS_DONATE_URL.trim().removeSuffix("/") }
|
||||
val donationsConfigured = remember { CommunityConfig.DONATIONS_BASE_URL.trim().isNotBlank() }
|
||||
val donateConfigured = donateUrl.isNotBlank()
|
||||
|
||||
var uiState by remember { mutableStateOf(CommunityUiState()) }
|
||||
var selectedContributor by remember { mutableStateOf<CommunityContributor?>(null) }
|
||||
var selectedSupporter by remember { mutableStateOf<SupporterDonation?>(null) }
|
||||
|
||||
fun loadContributors(force: Boolean) {
|
||||
if (uiState.isContributorsLoading) return
|
||||
if (!force && uiState.hasLoadedContributors) return
|
||||
scope.launch {
|
||||
uiState = uiState.copy(
|
||||
isContributorsLoading = true,
|
||||
contributorsErrorMessage = null,
|
||||
)
|
||||
SupportersContributorsRepository.getContributors()
|
||||
.onSuccess { contributors ->
|
||||
uiState = uiState.copy(
|
||||
isContributorsLoading = false,
|
||||
hasLoadedContributors = true,
|
||||
contributors = contributors,
|
||||
contributorsErrorMessage = null,
|
||||
)
|
||||
}
|
||||
.onFailure { error ->
|
||||
uiState = uiState.copy(
|
||||
isContributorsLoading = false,
|
||||
hasLoadedContributors = false,
|
||||
contributors = emptyList(),
|
||||
contributorsErrorMessage = error.message ?: "Unable to load contributors.",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun loadSupporters(force: Boolean) {
|
||||
if (uiState.isSupportersLoading) return
|
||||
if (!force && uiState.hasLoadedSupporters) return
|
||||
scope.launch {
|
||||
uiState = uiState.copy(
|
||||
isSupportersLoading = true,
|
||||
supportersErrorMessage = null,
|
||||
)
|
||||
SupportersContributorsRepository.getSupporters()
|
||||
.onSuccess { supporters ->
|
||||
uiState = uiState.copy(
|
||||
isSupportersLoading = false,
|
||||
hasLoadedSupporters = true,
|
||||
supporters = supporters,
|
||||
supportersErrorMessage = null,
|
||||
)
|
||||
}
|
||||
.onFailure { error ->
|
||||
uiState = uiState.copy(
|
||||
isSupportersLoading = false,
|
||||
hasLoadedSupporters = false,
|
||||
supporters = emptyList(),
|
||||
supportersErrorMessage = error.message ?: "Unable to load supporters.",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
loadContributors(force = false)
|
||||
}
|
||||
|
||||
LaunchedEffect(uiState.selectedTab) {
|
||||
if (uiState.selectedTab == CommunityTab.Supporters) {
|
||||
loadSupporters(force = false)
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(if (isTablet) 18.dp else 14.dp),
|
||||
) {
|
||||
NuvioSurfaceCard {
|
||||
Text(
|
||||
text = "Community",
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
Text(
|
||||
text = "See the people building and supporting Nuvio across Mobile, TV, and Web.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Button(
|
||||
onClick = { if (donateConfigured) uriHandler.openUri(donateUrl) },
|
||||
enabled = donateConfigured,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Favorite,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(18.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.size(8.dp))
|
||||
Text("Donate")
|
||||
}
|
||||
if (!donationsConfigured) {
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
Text(
|
||||
text = "Supporters API is not configured. Add DONATIONS_BASE_URL to local.properties.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
NuvioSurfaceCard {
|
||||
CommunityTabRow(
|
||||
selectedTab = uiState.selectedTab,
|
||||
onSelectTab = { tab -> uiState = uiState.copy(selectedTab = tab) },
|
||||
)
|
||||
}
|
||||
|
||||
when (uiState.selectedTab) {
|
||||
CommunityTab.Contributors -> ContributorsCard(
|
||||
contributors = uiState.contributors,
|
||||
isLoading = uiState.isContributorsLoading,
|
||||
errorMessage = uiState.contributorsErrorMessage,
|
||||
onRetry = { loadContributors(force = true) },
|
||||
onContributorClick = { selectedContributor = it },
|
||||
)
|
||||
|
||||
CommunityTab.Supporters -> SupportersCard(
|
||||
supporters = uiState.supporters,
|
||||
isLoading = uiState.isSupportersLoading,
|
||||
errorMessage = uiState.supportersErrorMessage,
|
||||
onRetry = { loadSupporters(force = true) },
|
||||
onSupporterClick = { selectedSupporter = it },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
selectedContributor?.let { contributor ->
|
||||
val supportUrl = contributorSupportLink(contributor.login)
|
||||
CommunityDetailsDialog(
|
||||
title = contributor.login,
|
||||
subtitle = contributorContributionSummary(contributor),
|
||||
onDismiss = { selectedContributor = null },
|
||||
primaryActionLabel = if (contributor.profileUrl != null) "Open GitHub" else null,
|
||||
onPrimaryAction = contributor.profileUrl?.let { url -> { uriHandler.openUri(url) } },
|
||||
secondaryActionLabel = if (supportUrl != null) "Donate" else null,
|
||||
onSecondaryAction = supportUrl?.let { url -> { uriHandler.openUri(url) } },
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
CommunityAvatar(
|
||||
label = contributor.login,
|
||||
imageUrl = contributor.avatarUrl,
|
||||
modifier = Modifier.size(72.dp),
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
Text(
|
||||
text = contributorContributionSummary(contributor),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
Text(
|
||||
text = contributor.profileUrl ?: "GitHub profile unavailable",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectedSupporter?.let { supporter ->
|
||||
CommunityDetailsDialog(
|
||||
title = supporter.name,
|
||||
subtitle = formatDonationDate(supporter.date),
|
||||
onDismiss = { selectedSupporter = null },
|
||||
primaryActionLabel = null,
|
||||
onPrimaryAction = null,
|
||||
secondaryActionLabel = null,
|
||||
onSecondaryAction = null,
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
NameAvatar(
|
||||
label = supporter.name,
|
||||
modifier = Modifier.size(72.dp),
|
||||
)
|
||||
Text(
|
||||
text = supporter.message ?: "No message attached.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CommunityTabRow(
|
||||
selectedTab: CommunityTab,
|
||||
onSelectTab: (CommunityTab) -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
CommunityTab.entries.forEach { tab ->
|
||||
val isSelected = tab == selectedTab
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.clip(RoundedCornerShape(999.dp))
|
||||
.clickable { onSelectTab(tab) },
|
||||
color = if (isSelected) {
|
||||
MaterialTheme.colorScheme.primary.copy(alpha = 0.14f)
|
||||
} else {
|
||||
MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.55f)
|
||||
},
|
||||
shape = RoundedCornerShape(999.dp),
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
text = if (tab == CommunityTab.Contributors) "Contributors" else "Supporters",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = if (isSelected) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Medium,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ContributorsCard(
|
||||
contributors: List<CommunityContributor>,
|
||||
isLoading: Boolean,
|
||||
errorMessage: String?,
|
||||
onRetry: () -> Unit,
|
||||
onContributorClick: (CommunityContributor) -> Unit,
|
||||
) {
|
||||
NuvioSurfaceCard {
|
||||
when {
|
||||
isLoading -> LoadingState(label = "Loading contributors...")
|
||||
errorMessage != null -> ErrorState(
|
||||
title = "Couldn't load contributors",
|
||||
message = errorMessage,
|
||||
onRetry = onRetry,
|
||||
)
|
||||
contributors.isEmpty() -> EmptyState(label = "No contributors found.")
|
||||
else -> LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = 480.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
contentPadding = PaddingValues(vertical = 2.dp),
|
||||
) {
|
||||
items(
|
||||
items = contributors,
|
||||
key = { contributor -> contributor.login.lowercase() },
|
||||
) { contributor ->
|
||||
ContributorRow(
|
||||
contributor = contributor,
|
||||
onClick = { onContributorClick(contributor) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SupportersCard(
|
||||
supporters: List<SupporterDonation>,
|
||||
isLoading: Boolean,
|
||||
errorMessage: String?,
|
||||
onRetry: () -> Unit,
|
||||
onSupporterClick: (SupporterDonation) -> Unit,
|
||||
) {
|
||||
NuvioSurfaceCard {
|
||||
when {
|
||||
isLoading -> LoadingState(label = "Loading supporters...")
|
||||
errorMessage != null -> ErrorState(
|
||||
title = "Couldn't load supporters",
|
||||
message = errorMessage,
|
||||
onRetry = onRetry,
|
||||
)
|
||||
supporters.isEmpty() -> EmptyState(label = "No supporters found.")
|
||||
else -> LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = 480.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
contentPadding = PaddingValues(vertical = 2.dp),
|
||||
) {
|
||||
items(
|
||||
items = supporters,
|
||||
key = { supporter -> supporter.key },
|
||||
) { supporter ->
|
||||
SupporterRow(
|
||||
supporter = supporter,
|
||||
onClick = { onSupporterClick(supporter) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ContributorRow(
|
||||
contributor: CommunityContributor,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(18.dp))
|
||||
.clickable(onClick = onClick)
|
||||
.padding(vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
) {
|
||||
CommunityAvatar(
|
||||
label = contributor.login,
|
||||
imageUrl = contributor.avatarUrl,
|
||||
modifier = Modifier.size(54.dp),
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(
|
||||
text = contributor.login,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(
|
||||
text = contributorContributionSummary(contributor),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Rounded.OpenInNew,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SupporterRow(
|
||||
supporter: SupporterDonation,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(18.dp))
|
||||
.clickable(onClick = onClick)
|
||||
.padding(vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
) {
|
||||
NameAvatar(
|
||||
label = supporter.name,
|
||||
modifier = Modifier.size(54.dp),
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(
|
||||
text = supporter.name,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(
|
||||
text = formatDonationDate(supporter.date),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
supporter.message?.let { message ->
|
||||
Text(
|
||||
text = message,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Rounded.OpenInNew,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CommunityAvatar(
|
||||
label: String,
|
||||
imageUrl: String?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.clip(CircleShape)
|
||||
.background(MaterialTheme.colorScheme.surfaceVariant),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
if (imageUrl.isNullOrBlank()) {
|
||||
Text(
|
||||
text = label.take(1).uppercase(),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
} else {
|
||||
AsyncImage(
|
||||
model = imageUrl,
|
||||
contentDescription = label,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun NameAvatar(
|
||||
label: String,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.clip(CircleShape)
|
||||
.background(MaterialTheme.colorScheme.primary.copy(alpha = 0.12f)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
text = label.trim().firstOrNull()?.uppercaseChar()?.toString() ?: "?",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LoadingState(
|
||||
label: String,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
CircularProgressIndicator(strokeWidth = 2.dp)
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EmptyState(
|
||||
label: String,
|
||||
) {
|
||||
Text(
|
||||
text = label,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 24.dp),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ErrorState(
|
||||
title: String,
|
||||
message: String,
|
||||
onRetry: () -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 12.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
Text(
|
||||
text = message,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
Button(onClick = onRetry) {
|
||||
Text("Retry")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
|
||||
private fun CommunityDetailsDialog(
|
||||
title: String,
|
||||
subtitle: String,
|
||||
onDismiss: () -> Unit,
|
||||
primaryActionLabel: String?,
|
||||
onPrimaryAction: (() -> Unit)?,
|
||||
secondaryActionLabel: String?,
|
||||
onSecondaryAction: (() -> Unit)?,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
BasicAlertDialog(onDismissRequest = onDismiss) {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
color = MaterialTheme.colorScheme.surface,
|
||||
shape = RoundedCornerShape(24.dp),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(24.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
Text(
|
||||
text = subtitle,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
content()
|
||||
|
||||
FlowRow(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
if (primaryActionLabel != null && onPrimaryAction != null) {
|
||||
Button(onClick = onPrimaryAction) {
|
||||
Text(primaryActionLabel)
|
||||
}
|
||||
}
|
||||
if (secondaryActionLabel != null && onSecondaryAction != null) {
|
||||
Button(onClick = onSecondaryAction) {
|
||||
Text(secondaryActionLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun contributorContributionSummary(contributor: CommunityContributor): String =
|
||||
"${contributor.totalContributions} total commits"
|
||||
|
||||
private fun contributorSupportLink(login: String): String? = when (login.lowercase()) {
|
||||
"skoruppa" -> "https://ko-fi.com/skoruppa"
|
||||
"crisszollo", "xrissozollo" -> "https://ko-fi.com/crisszollo"
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun formatDonationDate(rawDate: String): String {
|
||||
val datePart = rawDate.substringBefore('T')
|
||||
val parts = datePart.split('-')
|
||||
if (parts.size != 3) return rawDate
|
||||
val year = parts[0]
|
||||
val month = parts[1].toIntOrNull()?.let { monthIndex ->
|
||||
listOf(
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
).getOrNull(monthIndex - 1)
|
||||
} ?: return rawDate
|
||||
val day = parts[2].toIntOrNull()?.toString() ?: return rawDate
|
||||
return "$month $day, $year"
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import coil3.compose.AsyncImage
|
||||
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
|
||||
import com.nuvio.app.core.ui.nuvioSafeBottomPadding
|
||||
import com.nuvio.app.features.watchprogress.WatchProgressRepository
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.round
|
||||
|
|
@ -745,8 +745,9 @@ internal fun StreamList(
|
|||
}
|
||||
|
||||
else -> {
|
||||
filteredGroups.forEach { group ->
|
||||
filteredGroups.forEachIndexed { groupIndex, group ->
|
||||
streamSection(
|
||||
sectionKey = streamSectionRenderKey(groupIndex = groupIndex, group = group),
|
||||
group = group,
|
||||
showHeader = uiState.selectedFilter == null,
|
||||
onStreamSelected = onStreamSelected,
|
||||
|
|
@ -761,7 +762,7 @@ internal fun StreamList(
|
|||
}
|
||||
}
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(nuvioPlatformExtraBottomPadding + 80.dp))
|
||||
Spacer(modifier = Modifier.height(nuvioSafeBottomPadding(80.dp)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -769,6 +770,7 @@ internal fun StreamList(
|
|||
}
|
||||
|
||||
private fun LazyListScope.streamSection(
|
||||
sectionKey: String,
|
||||
group: AddonStreamGroup,
|
||||
showHeader: Boolean,
|
||||
onStreamSelected: (stream: StreamItem, resumePositionMs: Long?, resumeProgressFraction: Float?) -> Unit,
|
||||
|
|
@ -779,7 +781,7 @@ private fun LazyListScope.streamSection(
|
|||
if (group.streams.isEmpty() && !group.isLoading) return
|
||||
|
||||
if (showHeader) {
|
||||
item(key = "header_${group.addonId}") {
|
||||
item(key = "header_$sectionKey") {
|
||||
StreamSectionHeader(
|
||||
addonName = group.addonName,
|
||||
isLoading = group.isLoading,
|
||||
|
|
@ -793,10 +795,10 @@ private fun LazyListScope.streamSection(
|
|||
val sortedSources = streamsBySource.keys.sortedBy { it.lowercase() }
|
||||
val showSourceHeaders = sortedSources.size > 1
|
||||
|
||||
sortedSources.forEach { sourceName ->
|
||||
sortedSources.forEachIndexed { sourceIndex, sourceName ->
|
||||
val sourceStreams = streamsBySource[sourceName].orEmpty()
|
||||
if (showSourceHeaders) {
|
||||
item(key = "source_${group.addonId}_${sourceName}") {
|
||||
item(key = "source_${sectionKey}_$sourceIndex") {
|
||||
StreamSourceHeader(sourceName = sourceName)
|
||||
}
|
||||
}
|
||||
|
|
@ -804,7 +806,12 @@ private fun LazyListScope.streamSection(
|
|||
itemsIndexed(
|
||||
items = sourceStreams,
|
||||
key = { index, stream ->
|
||||
"${group.addonId}_${sourceName}_${index}_${stream.url ?: stream.infoHash ?: stream.streamLabel}"
|
||||
streamCardRenderKey(
|
||||
sectionKey = sectionKey,
|
||||
sourceIndex = sourceIndex,
|
||||
itemIndex = index,
|
||||
stream = stream,
|
||||
)
|
||||
},
|
||||
) { _, stream ->
|
||||
StreamCard(
|
||||
|
|
@ -825,6 +832,26 @@ private fun LazyListScope.streamSection(
|
|||
}
|
||||
}
|
||||
|
||||
internal fun streamSectionRenderKey(
|
||||
groupIndex: Int,
|
||||
group: AddonStreamGroup,
|
||||
): String = "$groupIndex:${group.addonId}"
|
||||
|
||||
internal fun streamCardRenderKey(
|
||||
sectionKey: String,
|
||||
sourceIndex: Int,
|
||||
itemIndex: Int,
|
||||
stream: StreamItem,
|
||||
): String = buildString {
|
||||
append(sectionKey)
|
||||
append(':')
|
||||
append(sourceIndex)
|
||||
append(':')
|
||||
append(itemIndex)
|
||||
append(':')
|
||||
append(stream.url ?: stream.infoHash ?: stream.streamLabel)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Stream Section Header
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -975,7 +1002,7 @@ private fun StreamActionsSheet(
|
|||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 16.dp + nuvioPlatformExtraBottomPadding),
|
||||
.padding(bottom = nuvioSafeBottomPadding(16.dp)),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ package com.nuvio.app.core.storage
|
|||
import platform.Foundation.NSUserDefaults
|
||||
|
||||
internal actual object PlatformLocalAccountDataCleaner {
|
||||
private val plainKeys = listOf("profile_payload")
|
||||
private val plainKeys = listOf(
|
||||
"profile_payload",
|
||||
"avatar_catalog_payload",
|
||||
)
|
||||
private val profilePinCachePrefixes = listOf("profile_pin_cache_")
|
||||
private val profileIndexedPrefixes = listOf(
|
||||
"installed_manifest_urls_",
|
||||
"plugins_state_",
|
||||
|
|
@ -52,6 +56,9 @@ internal actual object PlatformLocalAccountDataCleaner {
|
|||
profileIndexedPrefixes.forEach { prefix ->
|
||||
defaults.removeObjectForKey("$prefix$profileId")
|
||||
}
|
||||
profilePinCachePrefixes.forEach { prefix ->
|
||||
defaults.removeObjectForKey("$prefix$profileId")
|
||||
}
|
||||
profileScopedBaseKeys.forEach { baseKey ->
|
||||
defaults.removeObjectForKey("${baseKey}_$profileId")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
import platform.Foundation.NSUserDefaults
|
||||
|
||||
actual object AvatarStorage {
|
||||
private const val payloadKey = "avatar_catalog_payload"
|
||||
|
||||
actual fun loadPayload(): String? =
|
||||
NSUserDefaults.standardUserDefaults.stringForKey(payloadKey)
|
||||
|
||||
actual fun savePayload(payload: String) {
|
||||
NSUserDefaults.standardUserDefaults.setObject(payload, forKey = payloadKey)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
import platform.Foundation.NSUserDefaults
|
||||
|
||||
actual object ProfilePinCacheStorage {
|
||||
actual fun loadPayload(profileIndex: Int): String? =
|
||||
NSUserDefaults.standardUserDefaults.stringForKey(payloadKey(profileIndex))
|
||||
|
||||
actual fun savePayload(profileIndex: Int, payload: String) {
|
||||
NSUserDefaults.standardUserDefaults.setObject(payload, forKey = payloadKey(profileIndex))
|
||||
}
|
||||
|
||||
actual fun removePayload(profileIndex: Int) {
|
||||
NSUserDefaults.standardUserDefaults.removeObjectForKey(payloadKey(profileIndex))
|
||||
}
|
||||
|
||||
private fun payloadKey(profileIndex: Int): String = "profile_pin_cache_$profileIndex"
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nuvio.app.features.profiles
|
||||
|
||||
import com.nuvio.app.features.plugins.cryptointerop.CC_SHA256
|
||||
import com.nuvio.app.features.plugins.cryptointerop.CC_SHA256_DIGEST_LENGTH
|
||||
import kotlinx.cinterop.ExperimentalForeignApi
|
||||
import kotlinx.cinterop.refTo
|
||||
|
||||
actual object ProfilePinCrypto {
|
||||
@OptIn(ExperimentalForeignApi::class)
|
||||
actual fun sha256Hex(value: String): String {
|
||||
val input = value.encodeToByteArray()
|
||||
val output = UByteArray(CC_SHA256_DIGEST_LENGTH.toInt())
|
||||
CC_SHA256(input.refTo(0), input.size.toUInt(), output.refTo(0))
|
||||
return output.joinToString(separator = "") { byte ->
|
||||
byte.toString(16).padStart(2, '0')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
CURRENT_PROJECT_VERSION=27
|
||||
|
||||
CURRENT_PROJECT_VERSION=29
|
||||
MARKETING_VERSION=0.1.0
|
||||
|
||||
|
|
|
|||
1
mediamp
Submodule
1
mediamp
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit df33966d7fbc6eb14e43fb1892e062417d76e7f5
|
||||
Loading…
Reference in a new issue