Merge remote-tracking branch 'remotes/tom-repo/develop' into PhotonQyv-Baseline
This commit is contained in:
commit
feecab8dec
|
@ -1,8 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" />
|
||||
<option name="OPTION_SCOPE" value="protected" />
|
||||
|
@ -45,17 +42,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Mastodon.iml" filepath="$PROJECT_DIR$/Mastodon.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/mastalab.iml" filepath="$PROJECT_DIR$/mastalab.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://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.
|
||||
|
||||
Mastalab is a Mastodon client for Android devices
|
||||
Copyright (C) 2017 Thomas Schneider
|
||||
|
||||
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 <http://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:
|
||||
|
||||
Mastalab Copyright (C) 2017 Thomas Schneider
|
||||
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
|
||||
<http://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
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -10,6 +10,7 @@ android {
|
|||
versionCode 64
|
||||
versionName "1.5.4"
|
||||
}
|
||||
flavorDimensions "default"
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
|
@ -31,10 +32,11 @@ allprojects {
|
|||
}
|
||||
}
|
||||
dependencies {
|
||||
compile 'com.android.support:appcompat-v7:26.0.2'
|
||||
compile 'com.android.support:design:26.0.2'
|
||||
compile 'com.android.support:support-v4:26.0.2'
|
||||
compile 'com.android.support:cardview-v7:26.0.2'
|
||||
compile 'com.android.support:appcompat-v7:26.1.0'
|
||||
compile 'com.android.support:design:26.1.0'
|
||||
compile 'com.android.support:support-v4:26.1.0'
|
||||
compile 'com.android.support:cardview-v7:26.1.0'
|
||||
compile 'com.android.support:recyclerview-v7:26.1.0'
|
||||
compile 'com.loopj.android:android-async-http:1.4.9'
|
||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||
compile 'com.evernote:android-job:1.2.0'
|
||||
|
@ -42,6 +44,6 @@ dependencies {
|
|||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
compile 'org.jsoup:jsoup:1.10.3'
|
||||
compile 'de.hdodenhof:circleimageview:2.2.0'
|
||||
safetynetCompile 'com.google.android.gms:play-services-safetynet:11.0.4'
|
||||
safetynetCompile 'com.google.android.gms:play-services-safetynet:11.4.2'
|
||||
safetynetCompile 'io.github.kobakei:ratethisapp:1.2.0'
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
@ -33,10 +32,8 @@ import android.widget.Toast;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveDeveloperAccountsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteAccountsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
||||
|
@ -46,7 +43,6 @@ import fr.gouv.etalab.mastodon.helper.ExpandableHeightListView;
|
|||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchDevelopersAccountshInterface;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
|
||||
|
@ -78,20 +74,20 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
|
|||
if( getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.activity_about);
|
||||
TextView about_version = (TextView) findViewById(R.id.about_version);
|
||||
TextView about_version = findViewById(R.id.about_version);
|
||||
try {
|
||||
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
String version = pInfo.versionName;
|
||||
about_version.setText(getResources().getString(R.string.about_vesrion, version));
|
||||
} catch (PackageManager.NameNotFoundException ignored) {}
|
||||
|
||||
ExpandableHeightListView lv_developers = (ExpandableHeightListView) findViewById(R.id.lv_developers);
|
||||
ExpandableHeightListView lv_designers = (ExpandableHeightListView) findViewById(R.id.lv_designers);
|
||||
ExpandableHeightListView lv_contributors = (ExpandableHeightListView) findViewById(R.id.lv_contributors);
|
||||
ExpandableHeightListView lv_developers = findViewById(R.id.lv_developers);
|
||||
ExpandableHeightListView lv_designers = findViewById(R.id.lv_designers);
|
||||
ExpandableHeightListView lv_contributors = findViewById(R.id.lv_contributors);
|
||||
|
||||
Button about_code = (Button) findViewById(R.id.about_code);
|
||||
Button about_license = (Button) findViewById(R.id.about_license);
|
||||
Button about_thekinrar = (Button) findViewById(R.id.about_thekinrar);
|
||||
Button about_code = findViewById(R.id.about_code);
|
||||
Button about_license = findViewById(R.id.about_license);
|
||||
Button about_thekinrar = findViewById(R.id.about_thekinrar);
|
||||
|
||||
about_code.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -116,7 +112,7 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
|
|||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
Button about_translation = (Button) findViewById(R.id.about_translation);
|
||||
Button about_translation = findViewById(R.id.about_translation);
|
||||
about_translation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -133,7 +129,7 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
|
|||
about_license.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
|
||||
}
|
||||
|
||||
TextView about_website = (TextView) findViewById(R.id.about_website);
|
||||
TextView about_website = findViewById(R.id.about_website);
|
||||
about_website.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -24,7 +24,6 @@ import android.support.v4.content.ContextCompat;
|
|||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
|
|
@ -438,10 +438,19 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
displayStatusFragment.scrollToTop();
|
||||
break;
|
||||
case 2:
|
||||
if( display_local)
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.LOCAL,0);
|
||||
else if( display_global)
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC,0);
|
||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
if( displayStatusFragment != null )
|
||||
displayStatusFragment.scrollToTop();
|
||||
break;
|
||||
case 3:
|
||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
if( displayStatusFragment != null )
|
||||
displayStatusFragment.scrollToTop();
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC,0);
|
||||
break;
|
||||
case 1:
|
||||
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
||||
|
@ -507,6 +516,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
public boolean onQueryTextSubmit(String query) {
|
||||
//Hide keyboard
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
assert imm != null;
|
||||
imm.hideSoftInputFromWindow(toolbar_search.getWindowToken(), 0);
|
||||
Intent intent = new Intent(BaseMainActivity.this, SearchResultActivity.class);
|
||||
intent.putExtra("search", query);
|
||||
|
@ -841,15 +851,14 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
* Manages new intents
|
||||
* @param intent Intent - intent related to a notification in top bar
|
||||
*/
|
||||
private boolean mamageNewIntent(Intent intent){
|
||||
private void mamageNewIntent(Intent intent){
|
||||
if( intent == null || intent.getExtras() == null )
|
||||
return false;
|
||||
return;
|
||||
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
Bundle extras = intent.getExtras();
|
||||
String userIdIntent;
|
||||
boolean matchingIntent = false;
|
||||
if( extras.containsKey(INTENT_ACTION) ){
|
||||
final NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
|
||||
|
@ -859,7 +868,6 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
if( tabLayout.getTabAt(1) != null)
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(1).select();
|
||||
matchingIntent = true;
|
||||
}else if( extras.getInt(INTENT_ACTION) == HOME_TIMELINE_INTENT){
|
||||
changeUser(BaseMainActivity.this, userIdIntent, true); //Connects the account which is related to the notification
|
||||
}else if( extras.getInt(INTENT_ACTION) == CHANGE_THEME_INTENT){
|
||||
|
@ -867,7 +875,6 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
navigationView.setCheckedItem(R.id.nav_settings);
|
||||
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
||||
toolbarTitle.setText(R.string.settings);
|
||||
matchingIntent = true;
|
||||
}else if( extras.getInt(INTENT_ACTION) == CHANGE_USER_INTENT){
|
||||
unCheckAllMenuItems(navigationView);
|
||||
if( tabLayout.getTabAt(0) != null)
|
||||
|
@ -876,7 +883,6 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
if( !toolbar_search.isIconified() ) {
|
||||
toolbar_search.setIconified(true);
|
||||
}
|
||||
matchingIntent = true;
|
||||
}
|
||||
}else if( Intent.ACTION_SEND.equals(action) && type != null ) {
|
||||
if ("text/plain".equals(type)) {
|
||||
|
@ -941,7 +947,6 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
intent.setAction("");
|
||||
intent.setData(null);
|
||||
intent.setFlags(0);
|
||||
return matchingIntent;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1036,6 +1041,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle b = intent.getExtras();
|
||||
assert b != null;
|
||||
userIdService = b.getString("userIdService", null);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if( userIdService != null && userIdService.equals(userId)) {
|
||||
|
@ -1050,6 +1056,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle b = intent.getExtras();
|
||||
assert b != null;
|
||||
userIdService = b.getString("userIdService", null);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if( userIdService != null && userIdService.equals(userId)) {
|
||||
|
@ -1065,6 +1072,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle b = intent.getExtras();
|
||||
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
||||
assert b != null;
|
||||
userIdService = b.getString("userIdService", null);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if( userIdService != null && userIdService.equals(userId)) {
|
||||
|
@ -1284,6 +1292,10 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
return;
|
||||
Version currentVersion = new Version(apiResponse.getInstance().getVersion());
|
||||
Version minVersion = new Version("1.6");
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.INSTANCE_VERSION, apiResponse.getInstance().getVersion());
|
||||
editor.apply();
|
||||
Helper.canPin = (currentVersion.compareTo(minVersion) == 1 || currentVersion.equals(minVersion));
|
||||
}
|
||||
|
||||
|
@ -1386,6 +1398,45 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void updateTimeLine(RetrieveFeedsAsyncTask.Type type, int value){
|
||||
if( type == RetrieveFeedsAsyncTask.Type.LOCAL){
|
||||
if( tabLayout.getTabAt(2) != null && display_local){
|
||||
View tabLocal = tabLayout.getTabAt(2).getCustomView();
|
||||
assert tabLocal != null;
|
||||
TextView tabCounterLocal = tabLocal.findViewById(R.id.tab_counter);
|
||||
tabCounterLocal.setText(String.valueOf(value));
|
||||
if( value > 0){
|
||||
tabCounterLocal.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
tabCounterLocal.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}else if( type == RetrieveFeedsAsyncTask.Type.PUBLIC){
|
||||
if( tabLayout.getTabAt(3) != null && display_local){
|
||||
View tabPublic = tabLayout.getTabAt(3).getCustomView();
|
||||
assert tabPublic != null;
|
||||
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
||||
tabCounterPublic.setText(String.valueOf(value));
|
||||
if( value > 0){
|
||||
tabCounterPublic.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
tabCounterPublic.setVisibility(View.GONE);
|
||||
}
|
||||
}else if( tabLayout.getTabAt(2) != null && !display_local && display_global){
|
||||
View tabPublic = tabLayout.getTabAt(2).getCustomView();
|
||||
assert tabPublic != null;
|
||||
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
||||
tabCounterPublic.setText(String.valueOf(value));
|
||||
if( value > 0){
|
||||
tabCounterPublic.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
tabCounterPublic.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNotifCounter(){
|
||||
if(tabLayout.getTabAt(1) == null)
|
||||
return;
|
||||
|
|
|
@ -36,7 +36,6 @@ import android.text.Html;
|
|||
import android.text.TextWatcher;
|
||||
import android.util.Base64;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -93,7 +92,6 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
|
|||
private static final int PICK_IMAGE_PROFILE = 6545;
|
||||
private String profile_picture, header_picture, profile_username, profile_note;
|
||||
private Bitmap profile_picture_bmp, profile_header_bmp;
|
||||
private TextView title;
|
||||
private ImageView pp_actionBar;
|
||||
|
||||
@Override
|
||||
|
@ -112,13 +110,14 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
|
|||
ActionBar actionBar = getSupportActionBar();
|
||||
if( actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.conversation_action_bar, null);
|
||||
assert inflater != null;
|
||||
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.conversation_action_bar, null);
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
TextView title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
pp_actionBar = actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
title.setText(R.string.settings_title_profile);
|
||||
ImageView close_conversation = (ImageView) actionBar.getCustomView().findViewById(R.id.close_conversation);
|
||||
ImageView close_conversation = actionBar.getCustomView().findViewById(R.id.close_conversation);
|
||||
if( close_conversation != null){
|
||||
close_conversation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -172,14 +171,14 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
|
|||
|
||||
}});
|
||||
|
||||
set_profile_name = (EditText) findViewById(R.id.set_profile_name);
|
||||
set_profile_description = (EditText) findViewById(R.id.set_profile_description);
|
||||
set_profile_picture = (ImageView) findViewById(R.id.set_profile_picture);
|
||||
set_header_picture = (ImageView) findViewById(R.id.set_header_picture);
|
||||
set_change_profile_picture = (Button) findViewById(R.id.set_change_profile_picture);
|
||||
set_change_header_picture = (Button) findViewById(R.id.set_change_header_picture);
|
||||
set_profile_save = (Button) findViewById(R.id.set_profile_save);
|
||||
set_header_picture_overlay = (TextView) findViewById(R.id.set_header_picture_overlay);
|
||||
set_profile_name = findViewById(R.id.set_profile_name);
|
||||
set_profile_description = findViewById(R.id.set_profile_description);
|
||||
set_profile_picture = findViewById(R.id.set_profile_picture);
|
||||
set_header_picture = findViewById(R.id.set_header_picture);
|
||||
set_change_profile_picture = findViewById(R.id.set_change_profile_picture);
|
||||
set_change_header_picture = findViewById(R.id.set_change_header_picture);
|
||||
set_profile_save = findViewById(R.id.set_profile_save);
|
||||
set_header_picture_overlay = findViewById(R.id.set_header_picture_overlay);
|
||||
|
||||
set_profile_save.setEnabled(false);
|
||||
set_change_header_picture.setEnabled(false);
|
||||
|
@ -315,10 +314,10 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
|
|||
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.dialog_profile, null);
|
||||
dialogBuilder.setView(dialogView);
|
||||
|
||||
ImageView back_ground_image = (ImageView) dialogView.findViewById(R.id.back_ground_image);
|
||||
ImageView dialog_profile_picture = (ImageView) dialogView.findViewById(R.id.dialog_profile_picture);
|
||||
TextView dialog_profile_name = (TextView) dialogView.findViewById(R.id.dialog_profile_name);
|
||||
TextView dialog_profile_description = (TextView) dialogView.findViewById(R.id.dialog_profile_description);
|
||||
ImageView back_ground_image = dialogView.findViewById(R.id.back_ground_image);
|
||||
ImageView dialog_profile_picture = dialogView.findViewById(R.id.dialog_profile_picture);
|
||||
TextView dialog_profile_name = dialogView.findViewById(R.id.dialog_profile_name);
|
||||
TextView dialog_profile_description = dialogView.findViewById(R.id.dialog_profile_description);
|
||||
|
||||
if( profile_username != null)
|
||||
dialog_profile_name.setText(profile_username);
|
||||
|
@ -386,6 +385,7 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
|
|||
return;
|
||||
}
|
||||
try {
|
||||
//noinspection ConstantConditions
|
||||
InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(data.getData());
|
||||
BufferedInputStream bufferedInputStream;
|
||||
if (inputStream != null) {
|
||||
|
@ -412,7 +412,7 @@ public class EditProfileActivity extends AppCompatActivity implements OnRetrieve
|
|||
return;
|
||||
}
|
||||
try {
|
||||
InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(data.getData());
|
||||
@SuppressWarnings("ConstantConditions") InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(data.getData());
|
||||
BufferedInputStream bufferedInputStream;
|
||||
if (inputStream != null) {
|
||||
bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
|
|
|
@ -21,10 +21,10 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -87,17 +87,17 @@ public class HashTagActivity extends AppCompatActivity implements OnRetrieveFeed
|
|||
flag_loading = true;
|
||||
firstLoad = true;
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
|
||||
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||
|
||||
|
||||
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||
|
||||
|
||||
final ListView lv_status = (ListView) findViewById(R.id.lv_status);
|
||||
final RecyclerView lv_status = findViewById(R.id.lv_status);
|
||||
tootsPerPage = sharedpreferences.getInt(Helper.SET_TOOTS_PER_PAGE, 40);
|
||||
mainLoader = (RelativeLayout) findViewById(R.id.loader);
|
||||
nextElementLoader = (RelativeLayout) findViewById(R.id.loading_next_status);
|
||||
textviewNoAction = (RelativeLayout) findViewById(R.id.no_action);
|
||||
mainLoader = findViewById(R.id.loader);
|
||||
nextElementLoader = findViewById(R.id.loading_next_status);
|
||||
textviewNoAction = findViewById(R.id.no_action);
|
||||
mainLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
int positionSpinnerTrans = (sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX));
|
||||
|
@ -123,23 +123,28 @@ public class HashTagActivity extends AppCompatActivity implements OnRetrieveFeed
|
|||
R.color.colorPrimaryD,
|
||||
R.color.colorPrimaryDarkD);
|
||||
}
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
|
||||
{
|
||||
if(dy > 0){
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if(firstVisibleItem + visibleItemCount == totalItemCount ) {
|
||||
if(!flag_loading ) {
|
||||
flag_loading = true;
|
||||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.TAG, tag,null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
lv_status.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
||||
}
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
if(firstVisibleItem + visibleItemCount == totalItemCount ) {
|
||||
if(!flag_loading ) {
|
||||
flag_loading = true;
|
||||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.TAG, tag,null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.TAG, tag,null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -179,9 +184,7 @@ public class HashTagActivity extends AppCompatActivity implements OnRetrieveFeed
|
|||
else
|
||||
max_id = null;
|
||||
if( statuses != null) {
|
||||
for(Status tmpStatus: statuses){
|
||||
this.statuses.add(tmpStatus);
|
||||
}
|
||||
this.statuses.addAll(statuses);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
|
|
|
@ -64,8 +64,8 @@ public class InstanceActivity extends AppCompatActivity implements OnRetrieveIns
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.activity_instance);
|
||||
|
||||
instance_container = (LinearLayout) findViewById(R.id.instance_container);
|
||||
loader = (RelativeLayout) findViewById(R.id.loader);
|
||||
instance_container = findViewById(R.id.instance_container);
|
||||
loader = findViewById(R.id.loader);
|
||||
instance_container.setVisibility(View.GONE);
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
setTitle(getString(R.string.action_about_instance));
|
||||
|
@ -94,11 +94,11 @@ public class InstanceActivity extends AppCompatActivity implements OnRetrieveIns
|
|||
return;
|
||||
}
|
||||
final Instance instance = apiResponse.getInstance();
|
||||
TextView instance_title = (TextView) findViewById(R.id.instance_title);
|
||||
TextView instance_description = (TextView) findViewById(R.id.instance_description);
|
||||
TextView instance_version = (TextView) findViewById(R.id.instance_version);
|
||||
TextView instance_uri = (TextView) findViewById(R.id.instance_uri);
|
||||
FloatingActionButton instance_contact = (FloatingActionButton) findViewById(R.id.instance_contact);
|
||||
TextView instance_title = findViewById(R.id.instance_title);
|
||||
TextView instance_description = findViewById(R.id.instance_description);
|
||||
TextView instance_version = findViewById(R.id.instance_version);
|
||||
TextView instance_uri = findViewById(R.id.instance_uri);
|
||||
FloatingActionButton instance_contact = findViewById(R.id.instance_contact);
|
||||
|
||||
instance_title.setText(instance.getTitle());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
|
|
|
@ -119,13 +119,14 @@ public class MediaActivity extends AppCompatActivity {
|
|||
}
|
||||
setContentView(R.layout.activity_media);
|
||||
attachments = getIntent().getParcelableArrayListExtra("mediaArray");
|
||||
mediaPosition = getIntent().getExtras().getInt("position", 1);
|
||||
if( getIntent().getExtras() != null)
|
||||
mediaPosition = getIntent().getExtras().getInt("position", 1);
|
||||
if( attachments == null || attachments.size() == 0)
|
||||
finish();
|
||||
if( getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
RelativeLayout main_container_media = (RelativeLayout) findViewById(R.id.main_container_media);
|
||||
RelativeLayout main_container_media = findViewById(R.id.main_container_media);
|
||||
if( theme == Helper.THEME_LIGHT){
|
||||
main_container_media.setBackgroundResource(R.color.mastodonC2);
|
||||
}else {
|
||||
|
@ -135,11 +136,11 @@ public class MediaActivity extends AppCompatActivity {
|
|||
changeDrawableColor(getApplicationContext(), R.drawable.ic_prev_pic,R.color.mastodonC4);
|
||||
|
||||
canSwipe = true;
|
||||
loader = (RelativeLayout) findViewById(R.id.loader);
|
||||
imageView = (PhotoView) findViewById(R.id.media_picture);
|
||||
videoView = (VideoView) findViewById(R.id.media_video);
|
||||
prev = (ImageView) findViewById(R.id.media_prev);
|
||||
next = (ImageView) findViewById(R.id.media_next);
|
||||
loader = findViewById(R.id.loader);
|
||||
imageView = findViewById(R.id.media_picture);
|
||||
videoView = findViewById(R.id.media_video);
|
||||
prev = findViewById(R.id.media_prev);
|
||||
next = findViewById(R.id.media_next);
|
||||
prev.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -161,7 +162,7 @@ public class MediaActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
progress = (TextView) findViewById(R.id.loader_progress);
|
||||
progress = findViewById(R.id.loader_progress);
|
||||
setTitle("");
|
||||
|
||||
isHiding = false;
|
||||
|
@ -399,7 +400,7 @@ public class MediaActivity extends AppCompatActivity {
|
|||
ActionBar actionBar = getSupportActionBar();
|
||||
if( actionBar != null){
|
||||
@SuppressLint("InflateParams") View picture_actionbar = mInflater.inflate(R.layout.picture_actionbar, null);
|
||||
TextView picture_actionbar_title = (TextView) picture_actionbar.findViewById(R.id.picture_actionbar);
|
||||
TextView picture_actionbar_title = picture_actionbar.findViewById(R.id.picture_actionbar);
|
||||
picture_actionbar_title.setText(filename);
|
||||
actionBar.setCustomView(picture_actionbar);
|
||||
actionBar.setDisplayShowCustomEnabled(true);
|
||||
|
|
|
@ -40,7 +40,6 @@ import android.widget.AutoCompleteTextView;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -65,7 +64,6 @@ import java.util.List;
|
|||
|
||||
import cz.msebera.android.httpclient.Header;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteAccountsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
|
@ -75,7 +73,8 @@ import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
|||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.KinrarClient;
|
||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||
import fr.gouv.etalab.mastodon.drawers.AccountsListAdapter;
|
||||
import fr.gouv.etalab.mastodon.drawers.AccountSearchDevAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.ExpandableHeightListView;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||
|
@ -98,7 +97,7 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
|
|||
private EditText rf_username;
|
||||
private TextView rf_no_result;
|
||||
private Button rf_search;
|
||||
private ListView lv_account;
|
||||
private ExpandableHeightListView lv_account;
|
||||
private RelativeLayout loader;
|
||||
private boolean isLoadingInstance;
|
||||
private String instance_name, screen_name;
|
||||
|
@ -115,12 +114,12 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
|
|||
}
|
||||
setContentView(R.layout.activity_remote_follow);
|
||||
|
||||
rf_instance = (AutoCompleteTextView) findViewById(R.id.rf_instance);
|
||||
rf_username = (EditText) findViewById(R.id.rf_username);
|
||||
rf_search = (Button) findViewById(R.id.rf_search);
|
||||
loader = (RelativeLayout) findViewById(R.id.loader);
|
||||
lv_account = (ListView) findViewById(R.id.lv_account);
|
||||
rf_no_result = (TextView) findViewById(R.id.rf_no_result);
|
||||
rf_instance = findViewById(R.id.rf_instance);
|
||||
rf_username = findViewById(R.id.rf_username);
|
||||
rf_search = findViewById(R.id.rf_search);
|
||||
loader = findViewById(R.id.loader);
|
||||
lv_account = findViewById(R.id.lv_account);
|
||||
rf_no_result = findViewById(R.id.rf_no_result);
|
||||
if( theme == Helper.THEME_LIGHT) {
|
||||
rf_search.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
|
||||
}
|
||||
|
@ -128,13 +127,14 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
|
|||
ActionBar actionBar = getSupportActionBar();
|
||||
if( actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
|
||||
assert inflater != null;
|
||||
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.conversation_action_bar, null);
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
TextView title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
pp_actionBar = actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
title.setText(R.string.remote_follow_menu);
|
||||
ImageView close_conversation = (ImageView) actionBar.getCustomView().findViewById(R.id.close_conversation);
|
||||
ImageView close_conversation = actionBar.getCustomView().findViewById(R.id.close_conversation);
|
||||
if( close_conversation != null){
|
||||
close_conversation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -253,6 +253,7 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
|
|||
screen_name = screen_name.substring(1);
|
||||
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), screen_name, instance_name, RemoteFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
assert imm != null;
|
||||
imm.hideSoftInputFromWindow(rf_search.getWindowToken(), 0);
|
||||
}
|
||||
});
|
||||
|
@ -287,8 +288,7 @@ public class RemoteFollowActivity extends AppCompatActivity implements OnRetriev
|
|||
if( accounts != null && accounts.size() > 0){
|
||||
account = accounts.get(0);
|
||||
selectedAccount.add(account);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
AccountsListAdapter accountSearchWebAdapter = new AccountsListAdapter(RemoteFollowActivity.this, RetrieveAccountsAsyncTask.Type.FOLLOWERS, userId, selectedAccount);
|
||||
AccountSearchDevAdapter accountSearchWebAdapter = new AccountSearchDevAdapter(RemoteFollowActivity.this, selectedAccount);
|
||||
lv_account.setAdapter(accountSearchWebAdapter);
|
||||
lv_account.setVisibility(View.VISIBLE);
|
||||
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),RemoteFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
|
|
@ -61,8 +61,8 @@ public class SearchResultActivity extends AppCompatActivity implements OnRetriev
|
|||
}
|
||||
setContentView(R.layout.activity_search_result);
|
||||
|
||||
loader = (RelativeLayout) findViewById(R.id.loader);
|
||||
lv_search = (ListView) findViewById(R.id.lv_search);
|
||||
loader = findViewById(R.id.loader);
|
||||
lv_search = findViewById(R.id.lv_search);
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
if(b != null){
|
||||
|
@ -107,7 +107,7 @@ public class SearchResultActivity extends AppCompatActivity implements OnRetriev
|
|||
return;
|
||||
}
|
||||
if( results == null || (results.getAccounts().size() == 0 && results.getStatuses().size() == 0 && results.getHashtags().size() == 0)){
|
||||
RelativeLayout no_result = (RelativeLayout) findViewById(R.id.no_result);
|
||||
RelativeLayout no_result = findViewById(R.id.no_result);
|
||||
no_result.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -363,42 +363,40 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
}else {
|
||||
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_lock_closed,R.color.mastodonC4);
|
||||
}
|
||||
if( account!= null) {
|
||||
String urlHeader = account.getHeader();
|
||||
if (urlHeader.startsWith("/")) {
|
||||
urlHeader = "https://" + Helper.getLiveInstance(ShowAccountActivity.this) + account.getHeader();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && !urlHeader.contains("missing.png")) {
|
||||
String urlHeader = account.getHeader();
|
||||
if (urlHeader.startsWith("/")) {
|
||||
urlHeader = "https://" + Helper.getLiveInstance(ShowAccountActivity.this) + account.getHeader();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && !urlHeader.contains("missing.png")) {
|
||||
|
||||
DisplayImageOptions optionNew = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
imageLoader.loadImage(urlHeader, optionNew, new SimpleImageLoadingListener() {
|
||||
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||
ImageView banner_pp = findViewById(R.id.banner_pp);
|
||||
Bitmap workingBitmap = Bitmap.createBitmap(loadedImage);
|
||||
Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
Canvas canvas = new Canvas(mutableBitmap);
|
||||
Paint p = new Paint(Color.BLACK);
|
||||
ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);
|
||||
p.setColorFilter(filter);
|
||||
canvas.drawBitmap(mutableBitmap, new Matrix(), p);
|
||||
BitmapDrawable background = new BitmapDrawable(getResources(), mutableBitmap);
|
||||
banner_pp.setImageDrawable(background);
|
||||
}
|
||||
DisplayImageOptions optionNew = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
imageLoader.loadImage(urlHeader, optionNew, new SimpleImageLoadingListener() {
|
||||
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||
ImageView banner_pp = findViewById(R.id.banner_pp);
|
||||
Bitmap workingBitmap = Bitmap.createBitmap(loadedImage);
|
||||
Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
Canvas canvas = new Canvas(mutableBitmap);
|
||||
Paint p = new Paint(Color.BLACK);
|
||||
ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);
|
||||
p.setColorFilter(filter);
|
||||
canvas.drawBitmap(mutableBitmap, new Matrix(), p);
|
||||
BitmapDrawable background = new BitmapDrawable(getResources(), mutableBitmap);
|
||||
banner_pp.setImageDrawable(background);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason) {
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//Redraws icon for locked accounts
|
||||
final float scale = getResources().getDisplayMetrics().density;
|
||||
if( account != null && account.isLocked()){
|
||||
if(account.isLocked()){
|
||||
Drawable img = ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_action_lock_closed);
|
||||
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
|
||||
account_dn.setCompoundDrawables( img, null, null, null);
|
||||
|
@ -407,170 +405,160 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
}
|
||||
|
||||
|
||||
if( account != null){
|
||||
TextView actionbar_title = findViewById(R.id.show_account_title);
|
||||
if( account.getAcct() != null)
|
||||
actionbar_title.setText(account.getAcct());
|
||||
pp_actionBar = findViewById(R.id.pp_actionBar);
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
url = "https://" + Helper.getLiveInstance(getApplicationContext()) + account.getAvatar();
|
||||
TextView actionbar_title = findViewById(R.id.show_account_title);
|
||||
if( account.getAcct() != null)
|
||||
actionbar_title.setText(account.getAcct());
|
||||
pp_actionBar = findViewById(R.id.pp_actionBar);
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
url = "https://" + Helper.getLiveInstance(getApplicationContext()) + account.getAvatar();
|
||||
}
|
||||
DisplayImageOptions optionsPP = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
imageLoader.loadImage(url, optionsPP, new SimpleImageLoadingListener(){
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||
BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(loadedImage, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true));
|
||||
if( pp_actionBar != null){
|
||||
pp_actionBar.setImageDrawable(ppDrawable);
|
||||
}
|
||||
}
|
||||
DisplayImageOptions optionsPP = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
imageLoader.loadImage(url, optionsPP, new SimpleImageLoadingListener(){
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||
BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(loadedImage, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true));
|
||||
if( pp_actionBar != null){
|
||||
pp_actionBar.setImageDrawable(ppDrawable);
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason){
|
||||
|
||||
}});
|
||||
final AppBarLayout appBar = findViewById(R.id.appBar);
|
||||
maxScrollSize = appBar.getTotalScrollRange();
|
||||
|
||||
|
||||
appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
LinearLayout toolbarContent = findViewById(R.id.toolbar_content);
|
||||
if( toolbarContent != null) {
|
||||
if (Math.abs(verticalOffset) - appBar.getTotalScrollRange() == 0) {
|
||||
if (toolbarContent.getVisibility() == View.GONE)
|
||||
toolbarContent.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (toolbarContent.getVisibility() == View.VISIBLE)
|
||||
toolbarContent.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
if (maxScrollSize == 0)
|
||||
maxScrollSize = appBarLayout.getTotalScrollRange();
|
||||
|
||||
int percentage = (Math.abs(verticalOffset)) * 100 / maxScrollSize;
|
||||
|
||||
if (percentage >= 40 && avatarShown) {
|
||||
avatarShown = false;
|
||||
|
||||
account_pp.animate()
|
||||
.scaleY(0).scaleX(0)
|
||||
.setDuration(400)
|
||||
.start();
|
||||
}
|
||||
if (percentage <= 40 && !avatarShown) {
|
||||
avatarShown = true;
|
||||
account_pp.animate()
|
||||
.scaleY(1).scaleX(1)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
});
|
||||
account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||
account_un.setText(String.format("@%s", account.getAcct()));
|
||||
SpannableString spannableString = Helper.clickableElementsDescription(ShowAccountActivity.this, account.getNote());
|
||||
account_note.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
account_note.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
if (tabLayout.getTabAt(0) != null && tabLayout.getTabAt(1) != null && tabLayout.getTabAt(2) != null) {
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, account.getStatuses_count()));
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, account.getFollowing_count()));
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(2).setText(getString(R.string.followers_cnt, account.getFollowers_count()));
|
||||
|
||||
//Allows to filter by long click
|
||||
final LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
||||
tabStrip.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason){
|
||||
public boolean onLongClick(View v) {
|
||||
PopupMenu popup = new PopupMenu(ShowAccountActivity.this, tabStrip.getChildAt(0));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_toots_account, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
|
||||
}});
|
||||
final AppBarLayout appBar = findViewById(R.id.appBar);
|
||||
maxScrollSize = appBar.getTotalScrollRange();
|
||||
if( !Helper.canPin || !accountId.equals(userId)) {
|
||||
popup.getMenu().findItem(R.id.action_show_pinned).setVisible(false);
|
||||
}
|
||||
final MenuItem itemShowPined = menu.findItem(R.id.action_show_pinned);
|
||||
final MenuItem itemShowMedia = menu.findItem(R.id.action_show_media);
|
||||
|
||||
|
||||
appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
LinearLayout toolbarContent = findViewById(R.id.toolbar_content);
|
||||
if( toolbarContent != null) {
|
||||
if (Math.abs(verticalOffset) - appBar.getTotalScrollRange() == 0) {
|
||||
if (toolbarContent.getVisibility() == View.GONE)
|
||||
toolbarContent.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (toolbarContent.getVisibility() == View.VISIBLE)
|
||||
toolbarContent.setVisibility(View.GONE);
|
||||
itemShowMedia.setChecked(showMediaOnly);
|
||||
itemShowPined.setChecked(showPinned);
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
if( displayStatusFragment != null)
|
||||
displayStatusFragment.refreshFilter();
|
||||
}
|
||||
}
|
||||
if (maxScrollSize == 0)
|
||||
maxScrollSize = appBarLayout.getTotalScrollRange();
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int percentage = (Math.abs(verticalOffset)) * 100 / maxScrollSize;
|
||||
|
||||
if (percentage >= 40 && avatarShown) {
|
||||
avatarShown = false;
|
||||
|
||||
account_pp.animate()
|
||||
.scaleY(0).scaleX(0)
|
||||
.setDuration(400)
|
||||
.start();
|
||||
}
|
||||
if (percentage <= 40 && !avatarShown) {
|
||||
avatarShown = true;
|
||||
account_pp.animate()
|
||||
.scaleY(1).scaleX(1)
|
||||
.start();
|
||||
}
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_pinned:
|
||||
showPinned = !showPinned;
|
||||
if( tabLayout.getTabAt(0) != null)
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(0).select();
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
mPager.setAdapter(mPagerAdapter);
|
||||
break;
|
||||
case R.id.action_show_media:
|
||||
showMediaOnly = !showMediaOnly;
|
||||
if( tabLayout.getTabAt(0) != null)
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(0).select();
|
||||
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
mPager.setAdapter(mPagerAdapter);
|
||||
break;
|
||||
}
|
||||
itemShowMedia.setChecked(showMediaOnly);
|
||||
itemShowPined.setChecked(showPinned);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}else {
|
||||
if( account != null && account.getAcct() != null)
|
||||
setTitle(account.getAcct());
|
||||
}
|
||||
if( account != null){
|
||||
account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||
account_un.setText(String.format("@%s", account.getAcct()));
|
||||
SpannableString spannableString = Helper.clickableElementsDescription(ShowAccountActivity.this, account.getNote());
|
||||
account_note.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
account_note.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
if (tabLayout.getTabAt(0) != null && tabLayout.getTabAt(1) != null && tabLayout.getTabAt(2) != null) {
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, account.getStatuses_count()));
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, account.getFollowing_count()));
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(2).setText(getString(R.string.followers_cnt, account.getFollowers_count()));
|
||||
|
||||
//Allows to filter by long click
|
||||
final LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
||||
tabStrip.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
PopupMenu popup = new PopupMenu(ShowAccountActivity.this, tabStrip.getChildAt(0));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_toots_account, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
|
||||
if( !Helper.canPin || !accountId.equals(userId)) {
|
||||
popup.getMenu().findItem(R.id.action_show_pinned).setVisible(false);
|
||||
}
|
||||
final MenuItem itemShowPined = menu.findItem(R.id.action_show_pinned);
|
||||
final MenuItem itemShowMedia = menu.findItem(R.id.action_show_media);
|
||||
|
||||
itemShowMedia.setChecked(showMediaOnly);
|
||||
itemShowPined.setChecked(showPinned);
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
if( displayStatusFragment != null)
|
||||
displayStatusFragment.refreshFilter();
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_pinned:
|
||||
showPinned = !showPinned;
|
||||
if( tabLayout.getTabAt(0) != null)
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(0).select();
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
mPager.setAdapter(mPagerAdapter);
|
||||
break;
|
||||
case R.id.action_show_media:
|
||||
showMediaOnly = !showMediaOnly;
|
||||
if( tabLayout.getTabAt(0) != null)
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(0).select();
|
||||
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
mPager.setAdapter(mPagerAdapter);
|
||||
break;
|
||||
}
|
||||
itemShowMedia.setChecked(showMediaOnly);
|
||||
itemShowPined.setChecked(showPinned);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
imageLoader.displayImage(account.getAvatar(), account_pp, options);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
imageLoader.displayImage(account.getAvatar(), account_pp, options);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveFeedsAccount(List<Status> statuses) {
|
||||
if( statuses != null) {
|
||||
for(Status tmpStatus: statuses){
|
||||
this.statuses.add(tmpStatus);
|
||||
}
|
||||
this.statuses.addAll(statuses);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
@ -588,10 +576,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
pins = apiResponse.getStatuses();
|
||||
if (pins != null && pins.size() > 0) {
|
||||
if( pins.get(0).isPinned()) {
|
||||
|
||||
for (Status pin : pins) {
|
||||
this.statuses.add(pin);
|
||||
}
|
||||
this.statuses.addAll(pins);
|
||||
//noinspection ConstantConditions
|
||||
tabLayout.getTabAt(3).setText(getString(R.string.pins_cnt, pins.size()));
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package fr.gouv.etalab.mastodon.activities;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -25,13 +26,14 @@ import android.os.Handler;
|
|||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -76,7 +78,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
|||
private String statusId;
|
||||
private Status initialStatus;
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
private ListView lv_status;
|
||||
private RecyclerView lv_status;
|
||||
private boolean isRefreshed;
|
||||
private ImageView pp_actionBar;
|
||||
|
||||
|
@ -96,7 +98,8 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
|||
ActionBar actionBar = getSupportActionBar();
|
||||
if( actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.conversation_action_bar, null);
|
||||
assert inflater != null;
|
||||
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.conversation_action_bar, null);
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
TextView title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
|
@ -172,12 +175,16 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
|||
}
|
||||
});
|
||||
lv_status = findViewById(R.id.lv_status);
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
lv_status.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
|
||||
|
||||
if (lv_status.getLastVisiblePosition() == lv_status.getAdapter().getCount() -1 && lv_status.getFirstVisiblePosition() > 0 &&
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if (firstVisibleItem + visibleItemCount == lv_status.getAdapter().getItemCount() -1 && firstVisibleItem > 0 &&
|
||||
lv_status.getChildAt(lv_status.getChildCount() - 1).getBottom() <= lv_status.getHeight()) {
|
||||
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
|
@ -273,7 +280,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
|
|||
lv_status.setVisibility(View.VISIBLE);
|
||||
if( isRefreshed){
|
||||
position = statuses.size()-1;
|
||||
lv_status.setSelection(position);
|
||||
lv_status.scrollToPosition(position);
|
||||
}else {
|
||||
lv_status.smoothScrollToPosition(position);
|
||||
}
|
||||
|
|
|
@ -39,14 +39,13 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.speech.RecognizerIntent;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -102,8 +101,10 @@ import java.util.regex.Pattern;
|
|||
|
||||
import cz.msebera.android.httpclient.Header;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.PostStatusAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsForReplyAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAccountsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateDescriptionAttachmentAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.UploadActionAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
|
@ -113,14 +114,15 @@ import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
|||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Tag;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Version;
|
||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||
import fr.gouv.etalab.mastodon.drawers.AccountsReplyAdapter;
|
||||
import fr.gouv.etalab.mastodon.drawers.AccountsSearchAdapter;
|
||||
import fr.gouv.etalab.mastodon.drawers.DraftsListAdapter;
|
||||
import fr.gouv.etalab.mastodon.drawers.TagsListAdapter;
|
||||
import fr.gouv.etalab.mastodon.drawers.TagsSearchAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsReplyInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearcAccountshInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
|
||||
|
@ -139,7 +141,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
|||
* Toot activity class
|
||||
*/
|
||||
|
||||
public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface {
|
||||
public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveAccountsReplyInterface {
|
||||
|
||||
|
||||
private String visibility;
|
||||
|
@ -191,22 +193,24 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
ActionBar actionBar = getSupportActionBar();
|
||||
if( actionBar != null ){
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
assert inflater != null;
|
||||
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.toot_action_bar, null);
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
||||
ImageView close_toot = (ImageView) actionBar.getCustomView().findViewById(R.id.close_toot);
|
||||
ImageView close_toot = actionBar.getCustomView().findViewById(R.id.close_toot);
|
||||
close_toot.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
assert inputMethodManager != null;
|
||||
inputMethodManager.hideSoftInputFromWindow(toot_content.getWindowToken(), 0);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
pp_progress = (ProgressBar) actionBar.getCustomView().findViewById(R.id.pp_progress);
|
||||
title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
pp_actionBar = actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
pp_progress = actionBar.getCustomView().findViewById(R.id.pp_progress);
|
||||
|
||||
}
|
||||
|
||||
|
@ -226,22 +230,22 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
|
||||
toot_it = (Button) findViewById(R.id.toot_it);
|
||||
Button toot_cw = (Button) findViewById(R.id.toot_cw);
|
||||
toot_space_left = (TextView) findViewById(R.id.toot_space_left);
|
||||
toot_visibility = (ImageButton) findViewById(R.id.toot_visibility);
|
||||
toot_picture = (ImageButton) findViewById(R.id.toot_picture);
|
||||
loading_picture = (ProgressBar) findViewById(R.id.loading_picture);
|
||||
toot_picture_container = (LinearLayout) findViewById(R.id.toot_picture_container);
|
||||
toot_content = (AutoCompleteTextView) findViewById(R.id.toot_content);
|
||||
toot_it = findViewById(R.id.toot_it);
|
||||
Button toot_cw = findViewById(R.id.toot_cw);
|
||||
toot_space_left = findViewById(R.id.toot_space_left);
|
||||
toot_visibility = findViewById(R.id.toot_visibility);
|
||||
toot_picture = findViewById(R.id.toot_picture);
|
||||
loading_picture = findViewById(R.id.loading_picture);
|
||||
toot_picture_container = findViewById(R.id.toot_picture_container);
|
||||
toot_content = findViewById(R.id.toot_content);
|
||||
int newInputType = toot_content.getInputType() & (toot_content.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
||||
toot_content.setInputType(newInputType);
|
||||
toot_cw_content = (EditText) findViewById(R.id.toot_cw_content);
|
||||
picture_scrollview = (HorizontalScrollView) findViewById(R.id.picture_scrollview);
|
||||
toot_sensitive = (CheckBox) findViewById(R.id.toot_sensitive);
|
||||
//search_small_container = (LinearLayout) findViewById(R.id.search_small_container);
|
||||
toot_cw_content = findViewById(R.id.toot_cw_content);
|
||||
picture_scrollview = findViewById(R.id.picture_scrollview);
|
||||
toot_sensitive = findViewById(R.id.toot_sensitive);
|
||||
|
||||
drawer_layout = (LinearLayout) findViewById(R.id.drawer_layout);
|
||||
|
||||
drawer_layout = findViewById(R.id.drawer_layout);
|
||||
drawer_layout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
|
@ -548,6 +552,18 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
String patternTag = "^(.|\\s)*(\\#([\\w-]{2,}))$";
|
||||
final Pattern tPattern = Pattern.compile(patternTag);
|
||||
|
||||
toot_cw_content.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
int totalChar = toot_cw_content.length() + toot_content.length();
|
||||
toot_space_left.setText(String.valueOf(totalChar));
|
||||
}
|
||||
});
|
||||
|
||||
toot_content.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
@ -605,32 +621,8 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
toot_space_left.setText(String.valueOf(totalChar));
|
||||
}
|
||||
});
|
||||
//Allow scroll of the EditText though it's embedded in a scrollview
|
||||
toot_content.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (v.getId() == R.id.toot_content) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
switch (event.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_UP:
|
||||
v.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
toot_cw_content.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
int totalChar = toot_cw_content.length() + toot_content.length();
|
||||
toot_space_left.setText(String.valueOf(totalChar));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if( restored != -1 ){
|
||||
restoreToot(restored);
|
||||
}
|
||||
|
@ -718,6 +710,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
return;
|
||||
}
|
||||
try {
|
||||
//noinspection ConstantConditions
|
||||
InputStream inputStream = getContentResolver().openInputStream(data.getData());
|
||||
toot_picture_container.setVisibility(View.VISIBLE);
|
||||
loading_picture.setVisibility(View.VISIBLE);
|
||||
|
@ -766,6 +759,12 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
alert.setNegativeButton(R.string.accounts, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
new RetrieveAccountsForReplyAsyncTask(getApplicationContext(), tootReply.getReblog() != null?tootReply.getReblog():tootReply, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
alert.show();
|
||||
return true;
|
||||
case R.id.action_microphone:
|
||||
|
@ -857,13 +856,13 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
dialogBuilder.setView(dialogView);
|
||||
final AlertDialog alertDialog = dialogBuilder.create();
|
||||
|
||||
final DatePicker datePicker = (DatePicker) dialogView.findViewById(R.id.date_picker);
|
||||
final TimePicker timePicker = (TimePicker) dialogView.findViewById(R.id.time_picker);
|
||||
final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
|
||||
final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
|
||||
timePicker.setIs24HourView(true);
|
||||
Button date_time_cancel = (Button) dialogView.findViewById(R.id.date_time_cancel);
|
||||
final ImageButton date_time_previous = (ImageButton) dialogView.findViewById(R.id.date_time_previous);
|
||||
final ImageButton date_time_next = (ImageButton) dialogView.findViewById(R.id.date_time_next);
|
||||
final ImageButton date_time_set = (ImageButton) dialogView.findViewById(R.id.date_time_set);
|
||||
Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
|
||||
final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
|
||||
final ImageButton date_time_next = dialogView.findViewById(R.id.date_time_next);
|
||||
final ImageButton date_time_set = dialogView.findViewById(R.id.date_time_set);
|
||||
|
||||
//Buttons management
|
||||
date_time_cancel.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -992,43 +991,101 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
toot_picture.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
toot_picture_container.setVisibility(View.VISIBLE);
|
||||
if( attachment != null ){
|
||||
String url = attachment.getPreview_url();
|
||||
if( url == null || url.trim().equals(""))
|
||||
url = attachment.getUrl();
|
||||
|
||||
final ImageView imageView = new ImageView(getApplicationContext());
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
imageLoader.displayImage(url, imageView, options);
|
||||
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
imParams.setMargins(20, 5, 20, 5);
|
||||
imParams.height = (int) Helper.convertDpToPixel(100, getApplicationContext());
|
||||
imageView.setAdjustViewBounds(true);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean show_media_urls = sharedpreferences.getBoolean(Helper.SET_MEDIA_URLS, true);
|
||||
if( show_media_urls) {
|
||||
//Adds the shorter text_url of attachment at the end of the toot
|
||||
int selectionBefore = toot_content.getSelectionStart();
|
||||
toot_content.setText(toot_content.getText().toString() + "\n" + attachment.getText_url());
|
||||
toot_space_left.setText(String.valueOf(toot_content.length()));
|
||||
//Moves the cursor
|
||||
if (selectionBefore >= 0)
|
||||
toot_content.setSelection(selectionBefore);
|
||||
boolean alreadyAdded = false;
|
||||
int index = 0;
|
||||
for(Attachment attach_: this.attachments){
|
||||
if( attach_.getId().equals(attachment.getId())){
|
||||
alreadyAdded = true;
|
||||
break;
|
||||
}
|
||||
toot_picture_container.addView(imageView, attachments.size(), imParams);
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showRemove(imageView.getId());
|
||||
index++;
|
||||
}
|
||||
if( !alreadyAdded){
|
||||
toot_picture_container.setVisibility(View.VISIBLE);
|
||||
if( attachment != null ) {
|
||||
String url = attachment.getPreview_url();
|
||||
if (url == null || url.trim().equals(""))
|
||||
url = attachment.getUrl();
|
||||
|
||||
final ImageView imageView = new ImageView(getApplicationContext());
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
imageLoader.displayImage(url, imageView, options);
|
||||
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
imParams.setMargins(20, 5, 20, 5);
|
||||
imParams.height = (int) Helper.convertDpToPixel(100, getApplicationContext());
|
||||
imageView.setAdjustViewBounds(true);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean show_media_urls = sharedpreferences.getBoolean(Helper.SET_MEDIA_URLS, true);
|
||||
if (show_media_urls) {
|
||||
//Adds the shorter text_url of attachment at the end of the toot
|
||||
int selectionBefore = toot_content.getSelectionStart();
|
||||
toot_content.setText(toot_content.getText().toString() + "\n" + attachment.getText_url());
|
||||
toot_space_left.setText(String.valueOf(toot_content.length()));
|
||||
//Moves the cursor
|
||||
if (selectionBefore >= 0)
|
||||
toot_content.setSelection(selectionBefore);
|
||||
}
|
||||
});
|
||||
attachments.add(attachment);
|
||||
if( attachments.size() < 4)
|
||||
toot_picture.setEnabled(true);
|
||||
toot_sensitive.setVisibility(View.VISIBLE);
|
||||
picture_scrollview.setVisibility(View.VISIBLE);
|
||||
toot_picture_container.addView(imageView, attachments.size(), imParams);
|
||||
imageView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
showRemove(imageView.getId());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION, null);
|
||||
if (instanceVersion != null) {
|
||||
Version currentVersion = new Version(instanceVersion);
|
||||
Version minVersion = new Version("2.0");
|
||||
if (currentVersion.compareTo(minVersion) == 1 || currentVersion.equals(minVersion)) {
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this);
|
||||
builderInner.setTitle(R.string.upload_form_description);
|
||||
//Text for report
|
||||
EditText input = null;
|
||||
input = new EditText(TootActivity.this);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
input.setLayoutParams(lp);
|
||||
builderInner.setView(input);
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
final EditText finalInput = input;
|
||||
finalInput.setFilters(new InputFilter[]{new InputFilter.LengthFilter(420)});
|
||||
if( attachment.getDescription() != null && !attachment.getDescription().equals("null")) {
|
||||
finalInput.setText(attachment.getDescription());
|
||||
finalInput.setSelection(finalInput.getText().length());
|
||||
}
|
||||
builderInner.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new UpdateDescriptionAttachmentAsyncTask(getApplicationContext(), attachment.getId(), finalInput.getText().toString(), TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
attachments.add(attachment);
|
||||
if (attachments.size() < 4)
|
||||
toot_picture.setEnabled(true);
|
||||
toot_sensitive.setVisibility(View.VISIBLE);
|
||||
picture_scrollview.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}else {
|
||||
if( attachments.size() > index && attachment.getDescription() != null) {
|
||||
attachments.get(index).setDescription(attachment.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1315,7 +1372,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
if( childCount > 0 ){
|
||||
for(int i = 0 ; i < childCount ; i++){
|
||||
if( toot_picture_container.getChildAt(i) instanceof ImageView)
|
||||
toRemove.add((ImageView) toot_picture_container.getChildAt(i));
|
||||
toRemove.add((ImageView)toot_picture_container.getChildAt(i));
|
||||
}
|
||||
if( toRemove.size() > 0){
|
||||
for(ImageView imageView: toRemove)
|
||||
|
@ -1529,4 +1586,33 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRetrieveAccountsReply(ArrayList<Account> accounts) {
|
||||
final boolean[] checkedValues = new boolean[accounts.size()];
|
||||
int i = 0;
|
||||
for(Account account: accounts) {
|
||||
checkedValues[i] = toot_content.getText().toString().contains("@" + account.getAcct());
|
||||
i++;
|
||||
}
|
||||
final AlertDialog.Builder builderSingle = new AlertDialog.Builder(TootActivity.this);
|
||||
AccountsReplyAdapter accountsReplyAdapter = new AccountsReplyAdapter(TootActivity.this, accounts, checkedValues);
|
||||
builderSingle.setTitle(getString(R.string.select_accounts)).setAdapter(accountsReplyAdapter, null);
|
||||
builderSingle.setNegativeButton(R.string.validate, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
toot_content.setSelection(toot_content.getText().length());
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
}
|
||||
|
||||
public void changeAccountReply(boolean isChecked, String acct){
|
||||
if (isChecked) {
|
||||
if( !toot_content.getText().toString().contains(acct))
|
||||
toot_content.setText(acct + " " + toot_content.getText());
|
||||
} else {
|
||||
toot_content.setText(toot_content.getText().toString().replaceAll("\\s*" +acct, ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,8 +76,8 @@ public class WebviewActivity extends AppCompatActivity {
|
|||
webView = Helper.initializeWebview(WebviewActivity.this, R.id.webview);
|
||||
|
||||
setTitle("");
|
||||
FrameLayout webview_container = (FrameLayout) findViewById(R.id.webview_container);
|
||||
final ViewGroup videoLayout = (ViewGroup) findViewById(R.id.videoLayout); // Your own view, read class comments
|
||||
FrameLayout webview_container = findViewById(R.id.webview_container);
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout); // Your own view, read class comments
|
||||
|
||||
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(WebviewActivity.this, webView, webview_container, videoLayout);
|
||||
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
|
||||
|
|
|
@ -75,9 +75,9 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
|||
clientId = sharedpreferences.getString(Helper.CLIENT_ID, null);
|
||||
clientSecret = sharedpreferences.getString(Helper.CLIENT_SECRET, null);
|
||||
|
||||
webView = (WebView) findViewById(R.id.webviewConnect);
|
||||
webView = findViewById(R.id.webviewConnect);
|
||||
clearCookies(getApplicationContext());
|
||||
final ProgressBar pbar = (ProgressBar) findViewById(R.id.progress_bar);
|
||||
final ProgressBar pbar = findViewById(R.id.progress_bar);
|
||||
webView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int progress) {
|
||||
|
|
|
@ -17,12 +17,12 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||
|
||||
|
||||
|
@ -33,7 +33,6 @@ import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
|||
|
||||
public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private OnPostActionInterface listener;
|
||||
private int statusCode;
|
||||
private API.StatusAction apiAction;
|
||||
|
@ -43,17 +42,17 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
private API api;
|
||||
private Account account;
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Status remoteStatus;
|
||||
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public PostActionAsyncTask(Context context, API.StatusAction apiAction, String targetedId, OnPostActionInterface onPostActionInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onPostActionInterface;
|
||||
this.apiAction = apiAction;
|
||||
this.targetedId = targetedId;
|
||||
}
|
||||
|
||||
public PostActionAsyncTask(Context context, Account account, API.StatusAction apiAction, String targetedId, OnPostActionInterface onPostActionInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onPostActionInterface;
|
||||
this.apiAction = apiAction;
|
||||
this.targetedId = targetedId;
|
||||
|
@ -61,7 +60,7 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
|
||||
public PostActionAsyncTask(Context context, Account account, fr.gouv.etalab.mastodon.client.Entities.Status remoteStatus, API.StatusAction apiAction, OnPostActionInterface onPostActionInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onPostActionInterface;
|
||||
this.apiAction = apiAction;
|
||||
this.remoteStatus = remoteStatus;
|
||||
|
@ -69,7 +68,7 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
|
||||
public PostActionAsyncTask(Context context, API.StatusAction apiAction, String targetedId, fr.gouv.etalab.mastodon.client.Entities.Status status, String comment, OnPostActionInterface onPostActionInterface){
|
||||
this.context = context;
|
||||
contextReference = new WeakReference<>(context);
|
||||
this.listener = onPostActionInterface;
|
||||
this.apiAction = apiAction;
|
||||
this.targetedId = targetedId;
|
||||
|
@ -82,9 +81,9 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
//Remote action
|
||||
if( account !=null)
|
||||
api = new API(context, account.getInstance(), account.getToken());
|
||||
api = new API(contextReference.get(), account.getInstance(), account.getToken());
|
||||
else
|
||||
api = new API(context);
|
||||
api = new API(contextReference.get());
|
||||
if( remoteStatus != null){
|
||||
Results search = api.search(remoteStatus.getUri());
|
||||
if( search != null){
|
||||
|
|
|
@ -17,6 +17,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||
|
@ -30,13 +32,13 @@ import fr.gouv.etalab.mastodon.interfaces.OnPostNotificationsActionInterface;
|
|||
|
||||
public class PostNotificationsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private OnPostNotificationsActionInterface listener;
|
||||
private APIResponse apiResponse;
|
||||
private Notification notification;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public PostNotificationsAsyncTask(Context context, Notification notification, OnPostNotificationsActionInterface onPostNotificationsActionInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onPostNotificationsActionInterface;
|
||||
this.notification = notification;
|
||||
}
|
||||
|
@ -44,9 +46,9 @@ public class PostNotificationsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if( notification != null)
|
||||
apiResponse = new API(context).postNoticationAction(notification.getId());
|
||||
apiResponse = new API(this.contextReference.get()).postNoticationAction(notification.getId());
|
||||
else //Delete all notifications
|
||||
apiResponse = new API(context).postNoticationAction(null);
|
||||
apiResponse = new API(this.contextReference.get()).postNoticationAction(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,10 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface;
|
||||
|
||||
|
||||
|
@ -32,14 +30,15 @@ import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface;
|
|||
|
||||
public class PostStatusAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private OnPostStatusActionInterface listener;
|
||||
private APIResponse apiResponse;
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Status status;
|
||||
private Account account;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
|
||||
public PostStatusAsyncTask(Context context, Account account, fr.gouv.etalab.mastodon.client.Entities.Status status, OnPostStatusActionInterface onPostStatusActionInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onPostStatusActionInterface;
|
||||
this.status = status;
|
||||
this.account = account;
|
||||
|
@ -48,9 +47,9 @@ public class PostStatusAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if( account == null)
|
||||
apiResponse = new API(context).postStatusAction(status);
|
||||
apiResponse = new API(this.contextReference.get()).postStatusAction(status);
|
||||
else
|
||||
apiResponse = new API(context, account.getInstance(), account.getToken()).postStatusAction(status);
|
||||
apiResponse = new API(this.contextReference.get(), account.getInstance(), account.getToken()).postStatusAction(status);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.app.Activity;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||
|
@ -28,18 +31,18 @@ import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
|||
|
||||
public class RemoveAccountAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Activity activity;
|
||||
private WeakReference<Activity> activityReference;
|
||||
private Account account;
|
||||
|
||||
public RemoveAccountAsyncTask(Activity activity, Account account){
|
||||
this.activity = activity;
|
||||
activityReference = new WeakReference<>(activity);
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new AccountDAO(activity, db).removeUser(account);
|
||||
SQLiteDatabase db = Sqlite.getInstance(activityReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new AccountDAO(activityReference.get(), db).removeUser(account);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
|
@ -29,21 +31,22 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
|
|||
|
||||
public class RetrieveAccountAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private String targetedId;
|
||||
private Account account;
|
||||
private OnRetrieveAccountInterface listener;
|
||||
private API api;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveAccountAsyncTask(Context context, String targetedId, OnRetrieveAccountInterface onRetrieveAccountInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.targetedId = targetedId;
|
||||
this.listener = onRetrieveAccountInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
api = new API(context);
|
||||
api = new API(this.contextReference.get());
|
||||
account = api.getAccount(targetedId);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
|
||||
|
@ -27,19 +30,20 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
|
|||
|
||||
public class RetrieveAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private OnRetrieveAccountInterface listener;
|
||||
private Account account;
|
||||
private API api;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveAccountInfoAsyncTask(Context context, OnRetrieveAccountInterface onRetrieveAccountInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveAccountInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
api = new API(context);
|
||||
api = new API(this.contextReference.get());
|
||||
account = api.verifyCredentials();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
||||
|
@ -28,12 +31,12 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
|||
|
||||
public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private Type action;
|
||||
private APIResponse apiResponse;
|
||||
private String max_id;
|
||||
private OnRetrieveAccountsInterface listener;
|
||||
private String targetedId;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public enum Type{
|
||||
BLOCKED,
|
||||
|
@ -43,7 +46,7 @@ public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
|
||||
public RetrieveAccountsAsyncTask(Context context, Type action, String targetedId, String max_id, OnRetrieveAccountsInterface onRetrieveAccountsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.action = action;
|
||||
this.max_id = max_id;
|
||||
this.listener = onRetrieveAccountsInterface;
|
||||
|
@ -51,7 +54,7 @@ public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
|
||||
public RetrieveAccountsAsyncTask(Context context, Type action, String max_id, OnRetrieveAccountsInterface onRetrieveAccountsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.action = action;
|
||||
this.max_id = max_id;
|
||||
this.listener = onRetrieveAccountsInterface;
|
||||
|
@ -60,7 +63,7 @@ public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
switch (action){
|
||||
case BLOCKED:
|
||||
apiResponse = api.getBlocks(max_id);
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Mastalab 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 Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.AsyncTask;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsReplyInterface;
|
||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 25/10/2017.
|
||||
* Retrieves accounts which are involved in a conversation
|
||||
*/
|
||||
|
||||
public class RetrieveAccountsForReplyAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Status status;
|
||||
private OnRetrieveAccountsReplyInterface listener;
|
||||
private ArrayList<String> addedAccounts;
|
||||
private ArrayList<Account> accounts;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveAccountsForReplyAsyncTask(Context context, fr.gouv.etalab.mastodon.client.Entities.Status status, OnRetrieveAccountsReplyInterface onRetrieveAccountsReplyInterface){
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.status = status;
|
||||
this.listener = onRetrieveAccountsReplyInterface;
|
||||
this.accounts = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(this.contextReference.get());
|
||||
fr.gouv.etalab.mastodon.client.Entities.Context statusContext = api.getStatusContext(status.getId());
|
||||
ArrayList<Mention> mentions = new ArrayList<>();
|
||||
addedAccounts = new ArrayList<>();
|
||||
//Retrieves the first toot
|
||||
if( statusContext.getAncestors().size() > 0 ) {
|
||||
statusContext = api.getStatusContext(statusContext.getAncestors().get(0).getId());
|
||||
}
|
||||
if( status != null){
|
||||
for(Mention mention : status.getMentions()){
|
||||
if( canBeAdded(mention.getAcct())){
|
||||
mentions.add(mention);
|
||||
addedAccounts.add(mention.getAcct());
|
||||
}
|
||||
}
|
||||
}
|
||||
if( statusContext != null && statusContext.getDescendants().size() > 0){
|
||||
for(fr.gouv.etalab.mastodon.client.Entities.Status status : statusContext.getDescendants())
|
||||
for(Mention mention : status.getMentions()){
|
||||
if( canBeAdded(mention.getAcct())){
|
||||
mentions.add(mention);
|
||||
addedAccounts.add(mention.getAcct());
|
||||
}
|
||||
}
|
||||
}
|
||||
if( statusContext != null && statusContext.getAncestors().size() > 0){
|
||||
for(fr.gouv.etalab.mastodon.client.Entities.Status status : statusContext.getAncestors())
|
||||
for(Mention mention : status.getMentions()){
|
||||
if( canBeAdded(mention.getAcct())){
|
||||
mentions.add(mention);
|
||||
addedAccounts.add(mention.getAcct());
|
||||
}
|
||||
}
|
||||
}
|
||||
for( Mention mention: mentions){
|
||||
Results accountSearch = api.search(mention.getUrl());
|
||||
if( accountSearch != null && accountSearch.getAccounts() != null && accountSearch.getAccounts().size() == 1)
|
||||
accounts.add(accountSearch.getAccounts().get(0));
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean canBeAdded(String acct){
|
||||
final SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account currentAccount = new AccountDAO(this.contextReference.get(), db).getAccountByID(userId);
|
||||
return acct != null && !acct.equals(currentAccount.getAcct()) && !addedAccounts.contains(acct);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
listener.onRetrieveAccountsReply(accounts);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveContextInterface;
|
||||
|
||||
|
@ -28,22 +30,22 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveContextInterface;
|
|||
|
||||
public class RetrieveContextAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private String statusId;
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Status statusFirst;
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Context statusContext;
|
||||
private OnRetrieveContextInterface listener;
|
||||
private API api;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveContextAsyncTask(Context context, String statusId, OnRetrieveContextInterface onRetrieveContextInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.statusId = statusId;
|
||||
this.listener = onRetrieveContextInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
api = new API(context);
|
||||
api = new API(this.contextReference.get());
|
||||
statusContext = api.getStatusContext(statusId);
|
||||
//Retrieves the first toot
|
||||
if( statusContext.getAncestors().size() > 0 ) {
|
||||
|
|
|
@ -17,6 +17,7 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
|
@ -32,18 +33,19 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchDevelopersAccountshInt
|
|||
|
||||
public class RetrieveDeveloperAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private OnRetrieveSearchDevelopersAccountshInterface listener;
|
||||
private ArrayList<Account> accounts;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveDeveloperAccountsAsyncTask(Context context, OnRetrieveSearchDevelopersAccountshInterface onRetrieveSearchDevelopersAccountshInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveSearchDevelopersAccountshInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
accounts = new ArrayList<>();
|
||||
APIResponse apiResponse = api.searchAccounts("@tom79@mastodon.social", 1);
|
||||
if( apiResponse.getAccounts() != null && apiResponse.getAccounts().size() > 0)
|
||||
|
|
|
@ -16,6 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
||||
|
@ -28,7 +31,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
|||
|
||||
public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private Type action;
|
||||
private APIResponse apiResponse;
|
||||
private String max_id;
|
||||
|
@ -37,6 +40,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
private String tag;
|
||||
private boolean showMediaOnly = false;
|
||||
private boolean showPinned = false;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public enum Type{
|
||||
HOME,
|
||||
|
@ -51,14 +55,14 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
|
||||
public RetrieveFeedsAsyncTask(Context context, Type action, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.action = action;
|
||||
this.max_id = max_id;
|
||||
this.listener = onRetrieveFeedsInterface;
|
||||
}
|
||||
|
||||
public RetrieveFeedsAsyncTask(Context context, Type action, String targetedID, String max_id, boolean showMediaOnly, boolean showPinned, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.action = action;
|
||||
this.max_id = max_id;
|
||||
this.listener = onRetrieveFeedsInterface;
|
||||
|
@ -67,7 +71,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
this.showPinned = showPinned;
|
||||
}
|
||||
public RetrieveFeedsAsyncTask(Context context, Type action, String tag, String targetedID, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.action = action;
|
||||
this.max_id = max_id;
|
||||
this.listener = onRetrieveFeedsInterface;
|
||||
|
@ -78,7 +82,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
switch (action){
|
||||
case HOME:
|
||||
apiResponse = api.getHomeTimeline(max_id);
|
||||
|
|
|
@ -17,6 +17,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
||||
|
@ -29,14 +31,14 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
|||
|
||||
public class RetrieveFollowRequestSentAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private APIResponse apiResponse;
|
||||
private String max_id;
|
||||
private OnRetrieveAccountsInterface listener;
|
||||
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveFollowRequestSentAsyncTask(Context context, String max_id, OnRetrieveAccountsInterface onRetrieveAccountsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.max_id = max_id;
|
||||
this.listener = onRetrieveAccountsInterface;
|
||||
}
|
||||
|
@ -44,7 +46,7 @@ public class RetrieveFollowRequestSentAsyncTask extends AsyncTask<Void, Void, Vo
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
apiResponse = new API(context).getFollowRequest(max_id);
|
||||
apiResponse = new API(this.contextReference.get()).getFollowRequest(max_id);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveHomeTimelineServiceInterface;
|
||||
|
@ -27,16 +30,16 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveHomeTimelineServiceInterface
|
|||
|
||||
public class RetrieveHomeTimelineServiceAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private APIResponse apiResponse;
|
||||
private String since_id;
|
||||
private String acct, userId;
|
||||
private OnRetrieveHomeTimelineServiceInterface listener;
|
||||
private String instance;
|
||||
private String token;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveHomeTimelineServiceAsyncTask(Context context, String instance, String token, String since_id, String acct, String userId, OnRetrieveHomeTimelineServiceInterface onRetrieveHomeTimelineServiceInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.since_id = since_id;
|
||||
this.listener = onRetrieveHomeTimelineServiceInterface;
|
||||
this.acct = acct;
|
||||
|
@ -47,7 +50,7 @@ public class RetrieveHomeTimelineServiceAsyncTask extends AsyncTask<Void, Void,
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(context, instance, token);
|
||||
API api = new API(this.contextReference.get(), instance, token);
|
||||
apiResponse = api.getHomeTimelineSinceId(since_id);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
|
||||
|
@ -29,18 +31,18 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
|
|||
|
||||
public class RetrieveInstanceAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private OnRetrieveInstanceInterface listener;
|
||||
private APIResponse apiResponse;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveInstanceAsyncTask(Context context, OnRetrieveInstanceInterface onRetrieveInstanceInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveInstanceInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
apiResponse = new API(context).getInstance();
|
||||
apiResponse = new API(this.contextReference.get()).getInstance();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
|
@ -29,20 +31,21 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveManyRelationshipsInterface;
|
|||
|
||||
public class RetrieveManyRelationshipsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private List<Account> accounts;
|
||||
private OnRetrieveManyRelationshipsInterface listener;
|
||||
private APIResponse apiResponse;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveManyRelationshipsAsyncTask(Context context, List<Account> accounts, OnRetrieveManyRelationshipsInterface onRetrieveManyRelationshipsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveManyRelationshipsInterface;
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
apiResponse = new API(context).getRelationship(accounts);
|
||||
apiResponse = new API(this.contextReference.get()).getRelationship(accounts);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
|
@ -31,14 +33,14 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingFeedsInterface;
|
|||
|
||||
public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private String since_id;
|
||||
private OnRetrieveMissingFeedsInterface listener;
|
||||
private List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses = new ArrayList<>();
|
||||
private RetrieveFeedsAsyncTask.Type type;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveMissingFeedsAsyncTask(Context context, String since_id, RetrieveFeedsAsyncTask.Type type, OnRetrieveMissingFeedsInterface onRetrieveMissingFeedsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.since_id = since_id;
|
||||
this.listener = onRetrieveMissingFeedsInterface;
|
||||
this.type = type;
|
||||
|
@ -48,7 +50,7 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
int loopInc = 0;
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
List<fr.gouv.etalab.mastodon.client.Entities.Status> tempStatus;
|
||||
APIResponse apiResponse = null;
|
||||
while (loopInc < 10){
|
||||
|
|
|
@ -16,8 +16,7 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,7 +24,6 @@ import fr.gouv.etalab.mastodon.activities.MainActivity;
|
|||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingNotificationsInterface;
|
||||
|
||||
|
||||
|
@ -36,13 +34,14 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingNotificationsInterfac
|
|||
|
||||
public class RetrieveMissingNotificationsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private String since_id;
|
||||
private OnRetrieveMissingNotificationsInterface listener;
|
||||
private List<Notification> notifications = new ArrayList<>();
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveMissingNotificationsAsyncTask(Context context, String since_id, OnRetrieveMissingNotificationsInterface onRetrieveMissingNotifications){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.since_id = since_id;
|
||||
this.listener = onRetrieveMissingNotifications;
|
||||
}
|
||||
|
@ -51,7 +50,7 @@ public class RetrieveMissingNotificationsAsyncTask extends AsyncTask<Void, Void,
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
int loopInc = 0;
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
List<Notification> tempNotifications;
|
||||
while (loopInc < 10){
|
||||
APIResponse apiResponse = api.getNotificationsSince(since_id, 40);
|
||||
|
|
|
@ -16,6 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveNotificationsInterface;
|
||||
|
@ -28,7 +31,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveNotificationsInterface;
|
|||
|
||||
public class RetrieveNotificationsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private APIResponse apiResponse;
|
||||
private String max_id;
|
||||
private String acct, userId;
|
||||
|
@ -36,9 +39,10 @@ public class RetrieveNotificationsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
private String instance;
|
||||
private String token;
|
||||
private boolean refreshData;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveNotificationsAsyncTask(Context context, String instance, String token, String max_id, String acct, String userId, OnRetrieveNotificationsInterface onRetrieveNotificationsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.max_id = max_id;
|
||||
this.listener = onRetrieveNotificationsInterface;
|
||||
this.acct = acct;
|
||||
|
@ -52,7 +56,7 @@ public class RetrieveNotificationsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
API api = new API(context, instance, token);
|
||||
API api = new API(this.contextReference.get(), instance, token);
|
||||
if( acct == null)
|
||||
apiResponse = api.getNotifications(max_id);
|
||||
else
|
||||
|
|
|
@ -16,11 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||
|
||||
/**
|
||||
|
@ -30,21 +28,22 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
|||
|
||||
public class RetrieveRelationshipAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private String accountId;
|
||||
private Relationship relationship;
|
||||
private OnRetrieveRelationshipInterface listener;
|
||||
private API api;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveRelationshipAsyncTask(Context context, String accountId, OnRetrieveRelationshipInterface onRetrieveRelationshipInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveRelationshipInterface;
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
api = new API(context);
|
||||
api = new API(this.contextReference.get());
|
||||
relationship = api.getRelationship(accountId);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
||||
|
@ -30,20 +33,20 @@ public class RetrieveRemoteAccountsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
|
||||
private OnRetrieveRemoteAccountInterface listener;
|
||||
private String url;
|
||||
private Context context;
|
||||
private Results results;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveRemoteAccountsAsyncTask(Context context, String username, String instance, OnRetrieveRemoteAccountInterface onRetrieveRemoteAccountInterface){
|
||||
this.url = "https://" + instance + "/@" + username;
|
||||
this.listener = onRetrieveRemoteAccountInterface;
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
results = api.search(this.url);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.content.Context;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
|
@ -32,15 +33,13 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRepliesInterface;
|
|||
|
||||
public class RetrieveRepliesAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private APIResponse apiResponse;
|
||||
private OnRetrieveRepliesInterface listener;
|
||||
private List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses;
|
||||
|
||||
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveRepliesAsyncTask(Context context, List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses, OnRetrieveRepliesInterface onRetrieveRepliesInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.statuses = statuses;
|
||||
this.listener = onRetrieveRepliesInterface;
|
||||
}
|
||||
|
@ -48,7 +47,7 @@ public class RetrieveRepliesAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
for (fr.gouv.etalab.mastodon.client.Entities.Status status : statuses) {
|
||||
fr.gouv.etalab.mastodon.client.Entities.Context statusContext = api.getStatusContext((status.getReblog() != null) ? status.getReblog().getId() : status.getId());
|
||||
SystemClock.sleep(25);
|
||||
|
|
|
@ -18,14 +18,11 @@ import android.content.Context;
|
|||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.evernote.android.job.JobManager;
|
||||
import com.evernote.android.job.JobRequest;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveScheduledTootsInterface;
|
||||
|
@ -41,21 +38,22 @@ import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
|||
|
||||
public class RetrieveScheduledTootsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private OnRetrieveScheduledTootsInterface listener;
|
||||
private List<StoredStatus> storedStatuses;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveScheduledTootsAsyncTask(Context context, OnRetrieveScheduledTootsInterface onRetrieveScheduledTootsInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveScheduledTootsInterface;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Retrieves job asked by the user
|
||||
storedStatuses = new StatusStoredDAO(context, db).getAllScheduled();
|
||||
storedStatuses = new StatusStoredDAO(this.contextReference.get(), db).getAllScheduled();
|
||||
//Retrieves real jobs still waiting
|
||||
Set<JobRequest> jobRequests = JobManager.instance().getAllJobRequestsForTag(ScheduledTootsSyncJob.SCHEDULED_TOOT);
|
||||
int[] jobIds;
|
||||
|
@ -74,7 +72,7 @@ public class RetrieveScheduledTootsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
for(StoredStatus ss: storedStatuses){
|
||||
if (!Helper.isJobPresent(jobIds, ss.getJobId())){
|
||||
//JobId is fixed to -1 which means an error occured (it was never sent)
|
||||
new StatusStoredDAO(context, db).updateJobId(ss.getId(),-1);
|
||||
new StatusStoredDAO(this.contextReference.get(), db).updateJobId(ss.getId(),-1);
|
||||
}
|
||||
}
|
||||
//Lets time to update db before dispaying
|
||||
|
|
|
@ -16,6 +16,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearcAccountshInterface;
|
||||
|
@ -28,13 +31,13 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearcAccountshInterface;
|
|||
|
||||
public class RetrieveSearchAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private String query;
|
||||
private APIResponse apiResponse;
|
||||
private OnRetrieveSearcAccountshInterface listener;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveSearchAccountsAsyncTask(Context context, String query, OnRetrieveSearcAccountshInterface onRetrieveSearcAccountshInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.query = query;
|
||||
this.listener = onRetrieveSearcAccountshInterface;
|
||||
}
|
||||
|
@ -42,7 +45,7 @@ public class RetrieveSearchAccountsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(context);
|
||||
API api = new API(this.contextReference.get());
|
||||
apiResponse = api.searchAccounts(query, 20);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
|
||||
|
@ -29,14 +31,14 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
|
|||
|
||||
public class RetrieveSearchAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private String query;
|
||||
private Results results;
|
||||
private OnRetrieveSearchInterface listener;
|
||||
private API api;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveSearchAsyncTask(Context context, String query, OnRetrieveSearchInterface onRetrieveSearchInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.query = query;
|
||||
this.listener = onRetrieveSearchInterface;
|
||||
}
|
||||
|
@ -44,7 +46,7 @@ public class RetrieveSearchAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
api = new API(context);
|
||||
api = new API(this.contextReference.get());
|
||||
results = api.search(query);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
|
@ -34,36 +37,36 @@ import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
|||
|
||||
public class UpdateAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private String token;
|
||||
private String instance;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public UpdateAccountInfoAsyncTask(Context context, String token, String instance){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.token = token;
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
Account account = new API(context, instance, null).verifyCredentials();
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
Account account = new API(this.contextReference.get(), instance, null).verifyCredentials();
|
||||
SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( token == null) {
|
||||
token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||
}
|
||||
account.setToken(token);
|
||||
//TODO: remove this static value to allow other instances
|
||||
account.setInstance(instance);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(context, db).userExist(account);
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||
editor.apply();
|
||||
if( userExists)
|
||||
new AccountDAO(context, db).updateAccount(account);
|
||||
new AccountDAO(this.contextReference.get(), db).updateAccount(account);
|
||||
else {
|
||||
if( account.getUsername() != null && account.getCreated_at() != null)
|
||||
new AccountDAO(context, db).insertAccount(account);
|
||||
new AccountDAO(this.contextReference.get(), db).insertAccount(account);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -71,10 +74,10 @@ public class UpdateAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
|
||||
Intent mainActivity = new Intent(context, MainActivity.class);
|
||||
Intent mainActivity = new Intent(this.contextReference.get(), MainActivity.class);
|
||||
mainActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(mainActivity);
|
||||
((Activity) context).finish();
|
||||
this.contextReference.get().startActivity(mainActivity);
|
||||
((Activity) this.contextReference.get()).finish();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
|
@ -32,28 +35,29 @@ import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
|||
|
||||
public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private OnUpdateAccountInfoInterface listener;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public UpdateAccountInfoByIDAsyncTask(Context context, OnUpdateAccountInfoInterface onUpdateAccountInfoInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onUpdateAccountInfoInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new API(context).getAccount(userId);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(context, db).userExist(account);
|
||||
Account account = new API(this.contextReference.get()).getAccount(userId);
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
|
||||
if( userExists) {
|
||||
Account accountDb = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account accountDb = new AccountDAO(this.contextReference.get(), db).getAccountByID(userId);
|
||||
if( accountDb != null){
|
||||
account.setInstance(accountDb.getInstance());
|
||||
account.setToken(accountDb.getToken());
|
||||
new AccountDAO(context, db).updateAccount(account);
|
||||
new AccountDAO(this.contextReference.get(), db).updateAccount(account);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -17,6 +17,9 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
|
||||
|
@ -28,13 +31,13 @@ import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
|
|||
|
||||
public class UpdateCredentialAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private String display_name, note, avatar, header;
|
||||
private APIResponse apiResponse;
|
||||
private OnUpdateCredentialInterface listener;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public UpdateCredentialAsyncTask(Context context, String display_name, String note, String avatar, String header, OnUpdateCredentialInterface onUpdateCredentialInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.display_name = display_name;
|
||||
this.note = note;
|
||||
this.avatar = avatar;
|
||||
|
@ -44,7 +47,7 @@ public class UpdateCredentialAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
apiResponse = new API(context).updateCredential(display_name, note, avatar, header);
|
||||
apiResponse = new API(this.contextReference.get()).updateCredential(display_name, note, avatar, header);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Mastalab 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 Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 27/10/2017.
|
||||
* Updates media description
|
||||
*/
|
||||
|
||||
public class UpdateDescriptionAttachmentAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private OnRetrieveAttachmentInterface listener;
|
||||
private Attachment attachment;
|
||||
private String mediaId, description;
|
||||
private API api;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public UpdateDescriptionAttachmentAsyncTask(Context context, String mediaId, String description, OnRetrieveAttachmentInterface onRetrieveAttachmentInterface){
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveAttachmentInterface;
|
||||
this.description = description;
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
api = new API(this.contextReference.get());
|
||||
attachment = api.updateDescription(mediaId, description);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
listener.onRetrieveAttachment(attachment, api.getError());
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import android.content.Context;
|
|||
import android.os.AsyncTask;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
|
||||
|
@ -31,21 +32,21 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface;
|
|||
|
||||
public class UploadActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context context;
|
||||
private OnRetrieveAttachmentInterface listener;
|
||||
private Attachment attachment;
|
||||
private InputStream inputStream;
|
||||
private API api;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public UploadActionAsyncTask(Context context, InputStream inputStream, OnRetrieveAttachmentInterface onRetrieveAttachmentInterface){
|
||||
this.context = context;
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.listener = onRetrieveAttachmentInterface;
|
||||
this.inputStream = inputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
api = new API(context);
|
||||
api = new API(this.contextReference.get());
|
||||
attachment = api.uploadMedia(inputStream);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1299,6 +1299,42 @@ public class API {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes media description
|
||||
* @param mediaId String
|
||||
* @param description String
|
||||
* @return Attachment
|
||||
*/
|
||||
public Attachment updateDescription(String mediaId, String description){
|
||||
|
||||
RequestParams params = new RequestParams();
|
||||
params.put("description", description);
|
||||
put(String.format("/media/%s", mediaId), 240000, params, new JsonHttpResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
|
||||
attachment = parseAttachmentResponse(response);
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
|
||||
try {
|
||||
attachment = parseAttachmentResponse(response.getJSONObject(0));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers, Throwable error, JSONObject response){
|
||||
setError(statusCode, error);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers, String message, Throwable error){
|
||||
setError(statusCode, error);
|
||||
}
|
||||
});
|
||||
return attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Accounts and feeds when searching *synchronously*
|
||||
*
|
||||
|
@ -1694,6 +1730,9 @@ public class API {
|
|||
attachment.setId(resobj.get("id").toString());
|
||||
attachment.setType(resobj.get("type").toString());
|
||||
attachment.setUrl(resobj.get("url").toString());
|
||||
try {
|
||||
attachment.setDescription(resobj.get("description").toString());
|
||||
}catch (JSONException ignore){}
|
||||
try{
|
||||
attachment.setRemote_url(resobj.get("remote_url").toString());
|
||||
}catch (JSONException ignore){}
|
||||
|
@ -1803,6 +1842,21 @@ public class API {
|
|||
}
|
||||
}
|
||||
|
||||
private void put(String action, int timeout, RequestParams params, AsyncHttpResponseHandler responseHandler) {
|
||||
try {
|
||||
client.setConnectTimeout(timeout);
|
||||
client.setUserAgent(USER_AGENT);
|
||||
client.addHeader("Authorization", "Bearer "+prefKeyOauthTokenT);
|
||||
MastalabSSLSocketFactory mastalabSSLSocketFactory = new MastalabSSLSocketFactory(MastalabSSLSocketFactory.getKeystore());
|
||||
mastalabSSLSocketFactory.setHostnameVerifier(MastalabSSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
client.setSSLSocketFactory(mastalabSSLSocketFactory);
|
||||
client.put(getAbsoluteUrl(action), params, responseHandler);
|
||||
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException | UnrecoverableKeyException e) {
|
||||
Toast.makeText(context, R.string.toast_error,Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void delete(String action, RequestParams params, AsyncHttpResponseHandler responseHandler){
|
||||
try {
|
||||
client.setConnectTimeout(20000); //20s timeout
|
||||
|
|
|
@ -30,6 +30,7 @@ public class Attachment implements Parcelable {
|
|||
private String remote_url;
|
||||
private String preview_url;
|
||||
private String text_url;
|
||||
private String description;
|
||||
|
||||
public Attachment(Parcel in) {
|
||||
id = in.readString();
|
||||
|
@ -38,6 +39,7 @@ public class Attachment implements Parcelable {
|
|||
remote_url = in.readString();
|
||||
preview_url = in.readString();
|
||||
text_url = in.readString();
|
||||
description = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<Attachment> CREATOR = new Creator<Attachment>() {
|
||||
|
@ -117,5 +119,14 @@ public class Attachment implements Parcelable {
|
|||
dest.writeString(remote_url);
|
||||
dest.writeString(preview_url);
|
||||
dest.writeString(text_url);
|
||||
dest.writeString(description);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -55,7 +55,7 @@ import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
|||
* Created by Thomas on 27/04/2017.
|
||||
* Adapter for accounts
|
||||
*/
|
||||
public class AccountsListAdapter extends BaseAdapter implements OnPostActionInterface {
|
||||
public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostActionInterface {
|
||||
|
||||
private List<Account> accounts;
|
||||
private LayoutInflater layoutInflater;
|
||||
|
@ -73,35 +73,18 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
|||
this.targetedId = targetedId;
|
||||
}
|
||||
|
||||
public enum action{
|
||||
FOLLOW,
|
||||
UNFOLLOW,
|
||||
UNBLOCK,
|
||||
NOTHING,
|
||||
UNMUTE
|
||||
}
|
||||
|
||||
private API.StatusAction doAction;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return accounts.size();
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_account, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return accounts.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
|
||||
final AccountsListAdapter.ViewHolder holder = (AccountsListAdapter.ViewHolder) viewHolder;
|
||||
ImageLoader imageLoader = ImageLoader.getInstance();
|
||||
File cacheDir = new File(context.getCacheDir(), context.getString(R.string.app_name));
|
||||
ImageLoaderConfiguration configImg = new ImageLoaderConfiguration.Builder(context)
|
||||
|
@ -116,26 +99,7 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
|||
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
final Account account = accounts.get(position);
|
||||
final ViewHolder holder;
|
||||
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_account, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.account_pp = (ImageView) convertView.findViewById(R.id.account_pp);
|
||||
holder.account_dn = (TextView) convertView.findViewById(R.id.account_dn);
|
||||
holder.account_ac = (TextView) convertView.findViewById(R.id.account_ac);
|
||||
holder.account_un = (TextView) convertView.findViewById(R.id.account_un);
|
||||
holder.account_ds = (TextView) convertView.findViewById(R.id.account_ds);
|
||||
holder.account_sc = (TextView) convertView.findViewById(R.id.account_sc);
|
||||
holder.account_fgc = (TextView) convertView.findViewById(R.id.account_fgc);
|
||||
holder.account_frc = (TextView) convertView.findViewById(R.id.account_frc);
|
||||
holder.account_follow = (FloatingActionButton) convertView.findViewById(R.id.account_follow);
|
||||
holder.account_follow_request = (TextView) convertView.findViewById(R.id.account_follow_request);
|
||||
holder.account_container = (LinearLayout) convertView.findViewById(R.id.account_container);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
if( action == RetrieveAccountsAsyncTask.Type.BLOCKED)
|
||||
account.setFollowType(Account.followAction.BLOCK);
|
||||
|
@ -172,7 +136,7 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
|||
holder.account_follow_request.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
holder.account_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -232,9 +196,20 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
|||
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return accounts.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onPostAction(int statusCode, API.StatusAction statusAction, String targetedId, Error error) {
|
||||
if( error != null){
|
||||
|
@ -272,7 +247,7 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
|||
}
|
||||
|
||||
|
||||
private class ViewHolder {
|
||||
private class ViewHolder extends RecyclerView.ViewHolder{
|
||||
ImageView account_pp;
|
||||
TextView account_ac;
|
||||
TextView account_dn;
|
||||
|
@ -284,6 +259,21 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
|||
FloatingActionButton account_follow;
|
||||
TextView account_follow_request;
|
||||
LinearLayout account_container;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
account_pp = itemView.findViewById(R.id.account_pp);
|
||||
account_dn = itemView.findViewById(R.id.account_dn);
|
||||
account_ac = itemView.findViewById(R.id.account_ac);
|
||||
account_un = itemView.findViewById(R.id.account_un);
|
||||
account_ds = itemView.findViewById(R.id.account_ds);
|
||||
account_sc = itemView.findViewById(R.id.account_sc);
|
||||
account_fgc = itemView.findViewById(R.id.account_fgc);
|
||||
account_frc = itemView.findViewById(R.id.account_frc);
|
||||
account_follow = itemView.findViewById(R.id.account_follow);
|
||||
account_follow_request = itemView.findViewById(R.id.account_follow_request);
|
||||
account_container = itemView.findViewById(R.id.account_container);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package fr.gouv.etalab.mastodon.drawers;
|
||||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Mastalab 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 Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||
import java.util.List;
|
||||
import fr.gouv.etalab.mastodon.activities.TootActivity;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 25/10/2017.
|
||||
* Adapter for accounts when replying
|
||||
*/
|
||||
public class AccountsReplyAdapter extends BaseAdapter{
|
||||
|
||||
private List<Account> accounts;
|
||||
private LayoutInflater layoutInflater;
|
||||
private ImageLoader imageLoader;
|
||||
private DisplayImageOptions options;
|
||||
private boolean[] checked;
|
||||
private Context context;
|
||||
|
||||
public AccountsReplyAdapter(Context context, List<Account> accounts, boolean[] checked){
|
||||
this.accounts = accounts;
|
||||
this.context = context;
|
||||
layoutInflater = LayoutInflater.from(context);
|
||||
imageLoader = ImageLoader.getInstance();
|
||||
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return accounts.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account getItem(int position) {
|
||||
return accounts.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
|
||||
|
||||
final Account account = accounts.get(position);
|
||||
final ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_account_reply, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.account_pp = convertView.findViewById(R.id.account_pp);
|
||||
holder.account_dn = convertView.findViewById(R.id.account_dn);
|
||||
holder.checkbox = convertView.findViewById(R.id.checkbox);
|
||||
|
||||
holder.account_container = convertView.findViewById(R.id.account_container);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||
try {
|
||||
((TootActivity) context).changeAccountReply(isChecked, "@"+account.getAcct());
|
||||
checked[position] = isChecked;
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
});
|
||||
holder.checkbox.setChecked(checked[position]);
|
||||
holder.account_dn.setText(String.format("@%s", account.getAcct()));
|
||||
holder.account_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
holder.checkbox.performClick();
|
||||
}
|
||||
});
|
||||
//Profile picture
|
||||
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private class ViewHolder {
|
||||
ImageView account_pp;
|
||||
TextView account_dn;
|
||||
CheckBox checkbox;
|
||||
LinearLayout account_container;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -36,6 +36,7 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||
|
@ -67,7 +68,6 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
|
|||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
this.owner = false;
|
||||
}
|
||||
|
||||
public AccountsSearchAdapter(Context context, List<Account> accounts, boolean owner){
|
||||
super(context, android.R.layout.simple_list_item_1, accounts);
|
||||
this.accounts = accounts;
|
||||
|
@ -81,6 +81,7 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
|
|||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return accounts.size();
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
|
@ -39,7 +40,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
|
@ -85,7 +85,8 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
|||
* Created by Thomas on 24/04/2017.
|
||||
* Adapter for Status
|
||||
*/
|
||||
public class NotificationsListAdapter extends BaseAdapter implements OnPostActionInterface, OnPostNotificationsActionInterface, OnRetrieveEmojiInterface {
|
||||
|
||||
public class NotificationsListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnPostNotificationsActionInterface, OnRetrieveEmojiInterface {
|
||||
|
||||
private Context context;
|
||||
private List<Notification> notifications;
|
||||
|
@ -109,65 +110,18 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return notifications.size();
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_notification, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return notifications.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
|
||||
|
||||
final NotificationsListAdapter.ViewHolder holder = (NotificationsListAdapter.ViewHolder) viewHolder;
|
||||
final Notification notification = notifications.get(position);
|
||||
final ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_notification, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.card_status_container = (CardView) convertView.findViewById(R.id.card_status_container);
|
||||
holder.notification_status_container = (LinearLayout) convertView.findViewById(R.id.notification_status_container);
|
||||
holder.status_document_container = (LinearLayout) convertView.findViewById(R.id.status_document_container);
|
||||
holder.notification_status_content = (TextView) convertView.findViewById(R.id.notification_status_content);
|
||||
holder.notification_account_username = (TextView) convertView.findViewById(R.id.notification_account_username);
|
||||
holder.notification_type = (TextView) convertView.findViewById(R.id.notification_type);
|
||||
holder.notification_account_profile = (ImageView) convertView.findViewById(R.id.notification_account_profile);
|
||||
holder.status_favorite_count = (TextView) convertView.findViewById(R.id.status_favorite_count);
|
||||
holder.status_reblog_count = (TextView) convertView.findViewById(R.id.status_reblog_count);
|
||||
holder.status_date = (TextView) convertView.findViewById(R.id.status_date);
|
||||
holder.status_reply = (ImageView) convertView.findViewById(R.id.status_reply);
|
||||
holder.status_privacy = (ImageView) convertView.findViewById(R.id.status_privacy);
|
||||
holder.notification_delete = (ImageView) convertView.findViewById(R.id.notification_delete);
|
||||
|
||||
holder.status_show_more = (Button) convertView.findViewById(R.id.status_show_more);
|
||||
holder.status_prev1 = (ImageView) convertView.findViewById(R.id.status_prev1);
|
||||
holder.status_prev2 = (ImageView) convertView.findViewById(R.id.status_prev2);
|
||||
holder.status_prev3 = (ImageView) convertView.findViewById(R.id.status_prev3);
|
||||
holder.status_prev4 = (ImageView) convertView.findViewById(R.id.status_prev4);
|
||||
holder.status_prev1_play = (ImageView) convertView.findViewById(R.id.status_prev1_play);
|
||||
holder.status_prev2_play = (ImageView) convertView.findViewById(R.id.status_prev2_play);
|
||||
holder.status_prev3_play = (ImageView) convertView.findViewById(R.id.status_prev3_play);
|
||||
holder.status_prev4_play = (ImageView) convertView.findViewById(R.id.status_prev4_play);
|
||||
holder.status_container2 = (LinearLayout) convertView.findViewById(R.id.status_container2);
|
||||
holder.status_container3 = (LinearLayout) convertView.findViewById(R.id.status_container3);
|
||||
holder.status_prev4_container = (RelativeLayout) convertView.findViewById(R.id.status_prev4_container);
|
||||
holder.status_action_container = (LinearLayout) convertView.findViewById(R.id.status_action_container);
|
||||
holder.status_more = (ImageView) convertView.findViewById(R.id.status_more);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
||||
int iconSizePercent = sharedpreferences.getInt(Helper.SET_ICON_SIZE, 130);
|
||||
|
@ -296,7 +250,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
content = content.substring(0, content.length() - 10);
|
||||
}
|
||||
|
||||
SpannableString spannableString = Helper.clickableElements(context, status.getContent(),
|
||||
SpannableString spannableString = Helper.clickableElements(context, content,
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions(),
|
||||
status.getReblog() != null?status.getReblog().getEmojis():status.getEmojis(),
|
||||
position,
|
||||
|
@ -539,7 +493,6 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
});
|
||||
holder.notification_account_username.setVisibility(View.GONE);
|
||||
|
||||
final View finalConvertView = convertView;
|
||||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
final View attached = holder.status_more;
|
||||
holder.status_more.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -628,7 +581,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
Bitmap bitmap = Helper.convertTootIntoBitmap(context, finalConvertView);
|
||||
Bitmap bitmap = Helper.convertTootIntoBitmap(context, holder.getView());
|
||||
status.setTakingScreenShot(false);
|
||||
notificationsListAdapter.notifyDataSetChanged();
|
||||
Intent intent = new Intent(context, TootActivity.class);
|
||||
|
@ -709,7 +662,17 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
|
||||
//Profile picture
|
||||
imageLoader.displayImage(notification.getAccount().getAvatar(), holder.notification_account_profile, options);
|
||||
return convertView;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return notifications.size();
|
||||
}
|
||||
|
||||
|
||||
|
@ -923,7 +886,8 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
}
|
||||
|
||||
|
||||
private class ViewHolder {
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
CardView card_status_container;
|
||||
TextView notification_status_content;
|
||||
TextView notification_type;
|
||||
|
@ -951,6 +915,41 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
LinearLayout status_container3;
|
||||
LinearLayout notification_status_container;
|
||||
ImageView status_privacy;
|
||||
|
||||
public View getView(){
|
||||
return itemView;
|
||||
}
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
card_status_container = itemView.findViewById(R.id.card_status_container);
|
||||
notification_status_container = itemView.findViewById(R.id.notification_status_container);
|
||||
status_document_container = itemView.findViewById(R.id.status_document_container);
|
||||
notification_status_content = itemView.findViewById(R.id.notification_status_content);
|
||||
notification_account_username = itemView.findViewById(R.id.notification_account_username);
|
||||
notification_type = itemView.findViewById(R.id.notification_type);
|
||||
notification_account_profile = itemView.findViewById(R.id.notification_account_profile);
|
||||
status_favorite_count = itemView.findViewById(R.id.status_favorite_count);
|
||||
status_reblog_count = itemView.findViewById(R.id.status_reblog_count);
|
||||
status_date = itemView.findViewById(R.id.status_date);
|
||||
status_reply = itemView.findViewById(R.id.status_reply);
|
||||
status_privacy = itemView.findViewById(R.id.status_privacy);
|
||||
notification_delete = itemView.findViewById(R.id.notification_delete);
|
||||
status_show_more = itemView.findViewById(R.id.status_show_more);
|
||||
status_prev1 = itemView.findViewById(R.id.status_prev1);
|
||||
status_prev2 = itemView.findViewById(R.id.status_prev2);
|
||||
status_prev3 = itemView.findViewById(R.id.status_prev3);
|
||||
status_prev4 = itemView.findViewById(R.id.status_prev4);
|
||||
status_prev1_play = itemView.findViewById(R.id.status_prev1_play);
|
||||
status_prev2_play = itemView.findViewById(R.id.status_prev2_play);
|
||||
status_prev3_play = itemView.findViewById(R.id.status_prev3_play);
|
||||
status_prev4_play = itemView.findViewById(R.id.status_prev4_play);
|
||||
status_container2 = itemView.findViewById(R.id.status_container2);
|
||||
status_container3 = itemView.findViewById(R.id.status_container3);
|
||||
status_prev4_container = itemView.findViewById(R.id.status_prev4_container);
|
||||
status_action_container = itemView.findViewById(R.id.status_action_container);
|
||||
status_more = itemView.findViewById(R.id.status_more);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ package fr.gouv.etalab.mastodon.drawers;
|
|||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
|
@ -34,6 +35,7 @@ import android.os.CountDownTimer;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
|
@ -44,10 +46,8 @@ import android.util.Patterns;
|
|||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
|
@ -110,14 +110,12 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
|||
* Created by Thomas on 24/04/2017.
|
||||
* Adapter for Status
|
||||
*/
|
||||
public class StatusListAdapter extends BaseAdapter implements OnPostActionInterface, OnTranslatedInterface, OnRetrieveFeedsInterface, OnRetrieveEmojiInterface {
|
||||
public class StatusListAdapter extends RecyclerView.Adapter implements OnPostActionInterface, OnTranslatedInterface, OnRetrieveFeedsInterface, OnRetrieveEmojiInterface {
|
||||
|
||||
private Context context;
|
||||
private List<Status> statuses;
|
||||
private LayoutInflater layoutInflater;
|
||||
private ImageLoader imageLoader;
|
||||
private DisplayImageOptions optionsAttachment;
|
||||
private ViewHolder holder;
|
||||
private boolean isOnWifi;
|
||||
private int translator;
|
||||
private int behaviorWithAttachments;
|
||||
|
@ -126,12 +124,12 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
private String targetedId;
|
||||
private HashMap<String, String> urlConversion;
|
||||
private HashMap<String, String> tagConversion;
|
||||
private final int HIDDEN_STATUS = 0;
|
||||
private final int DISPLAYED_STATUS = 1;
|
||||
private List<Status> pins;
|
||||
private int conversationPosition;
|
||||
|
||||
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
|
||||
super();
|
||||
this.context = context;
|
||||
this.statuses = statuses;
|
||||
this.isOnWifi = isOnWifi;
|
||||
|
@ -158,24 +156,119 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
pins = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return statuses.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return statuses.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 2;
|
||||
public int getItemCount() {
|
||||
return statuses.size();
|
||||
}
|
||||
|
||||
private class ViewHolderEmpty extends RecyclerView.ViewHolder{
|
||||
ViewHolderEmpty(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder{
|
||||
LinearLayout status_content_container;
|
||||
LinearLayout status_spoiler_container;
|
||||
TextView status_spoiler;
|
||||
Button status_spoiler_button;
|
||||
CardView card_status_container;
|
||||
TextView status_content;
|
||||
TextView status_content_translated;
|
||||
LinearLayout status_content_translated_container;
|
||||
TextView status_account_username;
|
||||
TextView status_account_displayname;
|
||||
ImageView status_account_profile;
|
||||
ImageView status_account_profile_boost;
|
||||
ImageView status_account_profile_boost_by;
|
||||
TextView status_favorite_count;
|
||||
TextView status_reblog_count;
|
||||
TextView status_toot_date;
|
||||
Button status_show_more;
|
||||
ImageView status_more;
|
||||
LinearLayout status_document_container;
|
||||
ImageView status_prev1;
|
||||
ImageView status_prev2;
|
||||
ImageView status_prev3;
|
||||
ImageView status_prev4;
|
||||
ImageView status_prev1_play;
|
||||
ImageView status_prev2_play;
|
||||
ImageView status_prev3_play;
|
||||
ImageView status_prev4_play;
|
||||
RelativeLayout status_prev4_container;
|
||||
ImageView status_reply;
|
||||
ImageView status_pin;
|
||||
ImageView status_privacy;
|
||||
FloatingActionButton status_translate;
|
||||
LinearLayout status_container2;
|
||||
LinearLayout status_container3;
|
||||
LinearLayout main_container;
|
||||
TextView yandex_translate;
|
||||
TextView google_translate;
|
||||
LinearLayout status_action_container;
|
||||
LinearLayout status_replies;
|
||||
LinearLayout status_replies_profile_pictures;
|
||||
TextView status_replies_text;
|
||||
LinearLayout loader_replies;
|
||||
|
||||
ImageView new_element;
|
||||
|
||||
public View getView(){
|
||||
return itemView;
|
||||
}
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
loader_replies = itemView.findViewById(R.id.loader_replies);
|
||||
card_status_container = itemView.findViewById(R.id.card_status_container);
|
||||
status_document_container = itemView.findViewById(R.id.status_document_container);
|
||||
status_content = itemView.findViewById(R.id.status_content);
|
||||
status_content_translated = itemView.findViewById(R.id.status_content_translated);
|
||||
status_account_username = itemView.findViewById(R.id.status_account_username);
|
||||
status_account_displayname = itemView.findViewById(R.id.status_account_displayname);
|
||||
status_account_profile = itemView.findViewById(R.id.status_account_profile);
|
||||
status_account_profile_boost = itemView.findViewById(R.id.status_account_profile_boost);
|
||||
status_account_profile_boost_by = itemView.findViewById(R.id.status_account_profile_boost_by);
|
||||
status_favorite_count = itemView.findViewById(R.id.status_favorite_count);
|
||||
status_reblog_count = itemView.findViewById(R.id.status_reblog_count);
|
||||
status_pin = itemView.findViewById(R.id.status_pin);
|
||||
status_toot_date = itemView.findViewById(R.id.status_toot_date);
|
||||
status_show_more = itemView.findViewById(R.id.status_show_more);
|
||||
status_more = itemView.findViewById(R.id.status_more);
|
||||
status_prev1 = itemView.findViewById(R.id.status_prev1);
|
||||
status_prev2 = itemView.findViewById(R.id.status_prev2);
|
||||
status_prev3 = itemView.findViewById(R.id.status_prev3);
|
||||
status_prev4 = itemView.findViewById(R.id.status_prev4);
|
||||
status_prev1_play = itemView.findViewById(R.id.status_prev1_play);
|
||||
status_prev2_play = itemView.findViewById(R.id.status_prev2_play);
|
||||
status_prev3_play = itemView.findViewById(R.id.status_prev3_play);
|
||||
status_prev4_play = itemView.findViewById(R.id.status_prev4_play);
|
||||
status_container2 = itemView.findViewById(R.id.status_container2);
|
||||
status_container3 = itemView.findViewById(R.id.status_container3);
|
||||
status_prev4_container = itemView.findViewById(R.id.status_prev4_container);
|
||||
status_reply = itemView.findViewById(R.id.status_reply);
|
||||
status_privacy = itemView.findViewById(R.id.status_privacy);
|
||||
status_translate = itemView.findViewById(R.id.status_translate);
|
||||
status_content_translated_container = itemView.findViewById(R.id.status_content_translated_container);
|
||||
main_container = itemView.findViewById(R.id.main_container);
|
||||
status_spoiler_container = itemView.findViewById(R.id.status_spoiler_container);
|
||||
status_content_container = itemView.findViewById(R.id.status_content_container);
|
||||
status_spoiler = itemView.findViewById(R.id.status_spoiler);
|
||||
status_spoiler_button = itemView.findViewById(R.id.status_spoiler_button);
|
||||
yandex_translate = itemView.findViewById(R.id.yandex_translate);
|
||||
google_translate = itemView.findViewById(R.id.google_translate);
|
||||
status_replies = itemView.findViewById(R.id.status_replies);
|
||||
status_replies_profile_pictures = itemView.findViewById(R.id.status_replies_profile_pictures);
|
||||
status_replies_text = itemView.findViewById(R.id.status_replies_text);
|
||||
new_element = itemView.findViewById(R.id.new_element);
|
||||
status_action_container = itemView.findViewById(R.id.status_action_container);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,6 +276,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
if( type == RetrieveFeedsAsyncTask.Type.HOME) {
|
||||
Status status = statuses.get(position);
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int HIDDEN_STATUS = 0;
|
||||
if (status.getReblog() != null && !sharedpreferences.getBoolean(Helper.SET_SHOW_BOOSTS, true))
|
||||
return HIDDEN_STATUS;
|
||||
else if (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null") && !sharedpreferences.getBoolean(Helper.SET_SHOW_REPLIES, true)) {
|
||||
|
@ -195,11 +289,20 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if( viewType == DISPLAYED_STATUS)
|
||||
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status, parent, false));
|
||||
else
|
||||
return new ViewHolderEmpty(layoutInflater.inflate(R.layout.drawer_empty, parent, false));
|
||||
}
|
||||
|
||||
if( getItemViewType(position) == HIDDEN_STATUS){
|
||||
return new View(context);
|
||||
}else if( getItemViewType(position) == DISPLAYED_STATUS){
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, @SuppressLint("RecyclerView") final int position) {
|
||||
|
||||
if( viewHolder.getItemViewType() == DISPLAYED_STATUS){
|
||||
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||
holder.card_status_container.setVisibility(View.VISIBLE);
|
||||
final Status status = statuses.get(position);
|
||||
imageLoader = ImageLoader.getInstance();
|
||||
File cacheDir = new File(context.getCacheDir(), context.getString(R.string.app_name));
|
||||
|
@ -214,58 +317,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
imageLoader.init(configImg);
|
||||
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(10)).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
optionsAttachment = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_status, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.loader_replies = convertView.findViewById(R.id.loader_replies);
|
||||
holder.card_status_container = convertView.findViewById(R.id.card_status_container);
|
||||
holder.status_document_container = convertView.findViewById(R.id.status_document_container);
|
||||
holder.status_content = convertView.findViewById(R.id.status_content);
|
||||
holder.status_content_translated = convertView.findViewById(R.id.status_content_translated);
|
||||
holder.status_account_username = convertView.findViewById(R.id.status_account_username);
|
||||
holder.status_account_displayname = convertView.findViewById(R.id.status_account_displayname);
|
||||
holder.status_account_profile = convertView.findViewById(R.id.status_account_profile);
|
||||
holder.status_account_profile_boost = convertView.findViewById(R.id.status_account_profile_boost);
|
||||
holder.status_account_profile_boost_by = convertView.findViewById(R.id.status_account_profile_boost_by);
|
||||
holder.status_favorite_count = convertView.findViewById(R.id.status_favorite_count);
|
||||
holder.status_reblog_count = convertView.findViewById(R.id.status_reblog_count);
|
||||
holder.status_pin = convertView.findViewById(R.id.status_pin);
|
||||
holder.status_toot_date = convertView.findViewById(R.id.status_toot_date);
|
||||
holder.status_show_more = convertView.findViewById(R.id.status_show_more);
|
||||
holder.status_more = convertView.findViewById(R.id.status_more);
|
||||
holder.status_prev1 = convertView.findViewById(R.id.status_prev1);
|
||||
holder.status_prev2 = convertView.findViewById(R.id.status_prev2);
|
||||
holder.status_prev3 = convertView.findViewById(R.id.status_prev3);
|
||||
holder.status_prev4 = convertView.findViewById(R.id.status_prev4);
|
||||
holder.status_prev1_play = convertView.findViewById(R.id.status_prev1_play);
|
||||
holder.status_prev2_play = convertView.findViewById(R.id.status_prev2_play);
|
||||
holder.status_prev3_play = convertView.findViewById(R.id.status_prev3_play);
|
||||
holder.status_prev4_play = convertView.findViewById(R.id.status_prev4_play);
|
||||
holder.status_container2 = convertView.findViewById(R.id.status_container2);
|
||||
holder.status_container3 = convertView.findViewById(R.id.status_container3);
|
||||
holder.status_prev4_container = convertView.findViewById(R.id.status_prev4_container);
|
||||
holder.status_reply = convertView.findViewById(R.id.status_reply);
|
||||
holder.status_privacy = convertView.findViewById(R.id.status_privacy);
|
||||
holder.status_translate = convertView.findViewById(R.id.status_translate);
|
||||
holder.status_content_translated_container = convertView.findViewById(R.id.status_content_translated_container);
|
||||
holder.main_container = convertView.findViewById(R.id.main_container);
|
||||
holder.status_spoiler_container = convertView.findViewById(R.id.status_spoiler_container);
|
||||
holder.status_content_container = convertView.findViewById(R.id.status_content_container);
|
||||
holder.status_spoiler = convertView.findViewById(R.id.status_spoiler);
|
||||
holder.status_spoiler_button = convertView.findViewById(R.id.status_spoiler_button);
|
||||
holder.yandex_translate = convertView.findViewById(R.id.yandex_translate);
|
||||
holder.google_translate = convertView.findViewById(R.id.google_translate);
|
||||
holder.status_replies = convertView.findViewById(R.id.status_replies);
|
||||
holder.status_replies_profile_pictures = convertView.findViewById(R.id.status_replies_profile_pictures);
|
||||
holder.status_replies_text = convertView.findViewById(R.id.status_replies_text);
|
||||
holder.new_element = convertView.findViewById(R.id.new_element);
|
||||
holder.status_action_container = convertView.findViewById(R.id.status_action_container);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
||||
|
@ -418,12 +470,16 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
|
||||
String content;
|
||||
final String displayName;
|
||||
final String username;
|
||||
final String ppurl;
|
||||
String name;
|
||||
if( status.getReblog() != null){
|
||||
content = status.getReblog().getContent();
|
||||
displayName = Helper.shortnameToUnicode(status.getReblog().getAccount().getDisplay_name(), true);
|
||||
username = status.getReblog().getAccount().getUsername();
|
||||
holder.status_account_displayname.setText(String.format("%s @%s",displayName, username));
|
||||
ppurl = status.getReblog().getAccount().getAvatar();
|
||||
holder.status_account_displayname.setVisibility(View.VISIBLE);
|
||||
holder.status_account_displayname.setText(context.getResources().getString(R.string.reblog_by, status.getAccount().getUsername()));
|
||||
name = String.format("%s @%s",displayName,status.getReblog().getAccount().getAcct());
|
||||
}else {
|
||||
|
@ -466,16 +522,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
return false;
|
||||
}
|
||||
});
|
||||
holder.status_content_translated.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
holder.status_content_translated.setFocusableInTouchMode(false);
|
||||
holder.status_content_translated.clearFocus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
holder.status_content_translated.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
|
@ -502,17 +548,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
}
|
||||
});
|
||||
|
||||
holder.status_content.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
holder.status_content.setFocusableInTouchMode(false);
|
||||
holder.status_content.clearFocus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
holder.status_content.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
if( status.getReblog() == null)
|
||||
|
@ -699,6 +734,11 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
holder.status_reblog_count.setCompoundDrawables(imgReblog, null, null, null);
|
||||
holder.status_pin.setImageDrawable(imgPinned);
|
||||
|
||||
if( theme == Helper.THEME_LIGHT) {
|
||||
holder.status_show_more.setTextColor(ContextCompat.getColor(context, R.color.white));
|
||||
holder.status_spoiler_button.setTextColor(ContextCompat.getColor(context, R.color.white));
|
||||
}
|
||||
|
||||
boolean isOwner = status.getAccount().getId().equals(userId);
|
||||
|
||||
// Pinning toots is only available on Mastodon 1._6_.0 instances.
|
||||
|
@ -871,13 +911,13 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
i++;
|
||||
}
|
||||
if (translator == Helper.TRANS_YANDEX)
|
||||
new YandexQuery(StatusListAdapter.this).getYandexTextview(position, text, currentLocale);
|
||||
new YandexQuery(StatusListAdapter.this).getYandexTextview(status, text, currentLocale);
|
||||
else if( translator == Helper.TRANS_GOOGLE) {
|
||||
|
||||
while( text.charAt(text.length() -1) == '\n' && text.length() > 0)
|
||||
text = text.substring(0, text.length() -1);
|
||||
text += ".";
|
||||
new GoogleTranslateQuery(StatusListAdapter.this).getGoogleTextview(position, text.trim(), currentLocale);
|
||||
new GoogleTranslateQuery(StatusListAdapter.this).getGoogleTextview(status, text.trim(), currentLocale);
|
||||
}
|
||||
}else {
|
||||
status.setTranslationShown(!status.isTranslationShown());
|
||||
|
@ -950,7 +990,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
|
||||
|
||||
|
||||
final View finalConvertView = convertView;
|
||||
final View attached = holder.status_more;
|
||||
holder.status_more.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -1016,8 +1055,10 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
//noinspection deprecation
|
||||
content = Html.fromHtml(status.getContent()).toString();
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(context,R.string.clipboard,Toast.LENGTH_LONG).show();
|
||||
if( clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(context, R.string.clipboard, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_share:
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
|
@ -1034,7 +1075,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
Bitmap bitmap = Helper.convertTootIntoBitmap(context, finalConvertView);
|
||||
Bitmap bitmap = Helper.convertTootIntoBitmap(context, holder.getView());
|
||||
status.setTakingScreenShot(false);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
Intent intent = new Intent(context, TootActivity.class);
|
||||
|
@ -1134,9 +1175,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
}
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1203,9 +1242,13 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
url = attachment.getUrl();
|
||||
else if( attachment.getType().equals("unknown"))
|
||||
url = attachment.getRemote_url();
|
||||
DisplayImageOptions optionsAttachment = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
if( !url.trim().contains("missing.png"))
|
||||
imageLoader.displayImage(url, imageView, optionsAttachment);
|
||||
final int finalPosition = position;
|
||||
if( attachment.getDescription() != null && !attachment.getDescription().equals("null"))
|
||||
imageView.setContentDescription(attachment.getDescription());
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -1349,10 +1392,10 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onTranslatedTextview(int position, String translatedResult, Boolean error) {
|
||||
public void onTranslatedTextview(Status status, String translatedResult, Boolean error) {
|
||||
if( error){
|
||||
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
||||
}else if( statuses.size() > position) {
|
||||
}else {
|
||||
try {
|
||||
String aJsonString = null;
|
||||
if (translator == Helper.TRANS_YANDEX)
|
||||
|
@ -1373,9 +1416,9 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
aJsonString = aJsonString.replace(pair.getKey().toString(), pair.getValue().toString());
|
||||
itT.remove();
|
||||
}
|
||||
statuses.get(position).setTranslated(true);
|
||||
statuses.get(position).setTranslationShown(true);
|
||||
statuses.get(position).setContent_translated(aJsonString);
|
||||
status.setTranslated(true);
|
||||
status.setTranslationShown(true);
|
||||
status.setContent_translated(aJsonString);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
} catch (JSONException | UnsupportedEncodingException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1405,25 +1448,25 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
private String googleTranslateToText(String text) throws JSONException, UnsupportedEncodingException{
|
||||
|
||||
int i = 0;
|
||||
String aJsonString = "";
|
||||
StringBuilder aJsonString = new StringBuilder();
|
||||
while( i < new JSONArray(new JSONArray(text).get(0).toString()).length() ) {
|
||||
aJsonString += new JSONArray(new JSONArray(new JSONArray(text).get(0).toString()).get(i).toString()).get(0).toString();
|
||||
aJsonString.append(new JSONArray(new JSONArray(new JSONArray(text).get(0).toString()).get(i).toString()).get(0).toString());
|
||||
i++;
|
||||
}
|
||||
//Some fixes due to translation with Google
|
||||
aJsonString = aJsonString.trim();
|
||||
aJsonString = aJsonString.replace("< / ","</");
|
||||
aJsonString = aJsonString.replace("</ ","</");
|
||||
aJsonString = aJsonString.replace("> ",">");
|
||||
aJsonString = aJsonString.replace(" <","<");
|
||||
aJsonString = aJsonString.replace(" // ","//");
|
||||
aJsonString = aJsonString.replace("// ","//");
|
||||
aJsonString = aJsonString.replace(" //","//");
|
||||
aJsonString = aJsonString.replace(" www .","www.");
|
||||
aJsonString = aJsonString.replace("www .","www.");
|
||||
aJsonString = new StringBuilder(aJsonString.toString().trim());
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace("< / ", "</"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace("</ ", "</"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace("> ", ">"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace(" <", "<"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace(" // ", "//"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace("// ", "//"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace(" //", "//"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace(" www .", "www."));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replace("www .", "www."));
|
||||
|
||||
// This one might cause more trouble than it's worth
|
||||
aJsonString = aJsonString.replaceAll("\\* \\.", "*.");
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replaceAll("\\* \\.", "*."));
|
||||
|
||||
/*
|
||||
Noticed that sometimes the special tags were getting messed up by Google,
|
||||
|
@ -1431,63 +1474,16 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
|
||||
But, pre-planning might save some time later...
|
||||
*/
|
||||
aJsonString = aJsonString.replaceAll("__\\s?(u|t)\\s?(\\d+)\\s?__", "__$1$2__");
|
||||
aJsonString = aJsonString.replaceAll("%(?![0-9a-fA-F]{2})", "%25");
|
||||
aJsonString = aJsonString.replaceAll("\\+", "%2B");
|
||||
aJsonString = URLDecoder.decode(aJsonString, "UTF-8");
|
||||
return aJsonString;
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replaceAll("__\\s?([ut])\\s?(\\d+)\\s?__", "__$1$2__"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replaceAll("%(?![0-9a-fA-F]{2})", "%25"));
|
||||
aJsonString = new StringBuilder(aJsonString.toString().replaceAll("\\+", "%2B"));
|
||||
aJsonString = new StringBuilder(URLDecoder.decode(aJsonString.toString(), "UTF-8"));
|
||||
return aJsonString.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private class ViewHolder {
|
||||
LinearLayout status_content_container;
|
||||
LinearLayout status_spoiler_container;
|
||||
TextView status_spoiler;
|
||||
Button status_spoiler_button;
|
||||
CardView card_status_container;
|
||||
TextView status_content;
|
||||
TextView status_content_translated;
|
||||
LinearLayout status_content_translated_container;
|
||||
TextView status_account_username;
|
||||
TextView status_account_displayname;
|
||||
ImageView status_account_profile;
|
||||
ImageView status_account_profile_boost;
|
||||
ImageView status_account_profile_boost_by;
|
||||
TextView status_favorite_count;
|
||||
TextView status_reblog_count;
|
||||
TextView status_toot_date;
|
||||
Button status_show_more;
|
||||
ImageView status_more;
|
||||
LinearLayout status_document_container;
|
||||
ImageView status_prev1;
|
||||
ImageView status_prev2;
|
||||
ImageView status_prev3;
|
||||
ImageView status_prev4;
|
||||
ImageView status_prev1_play;
|
||||
ImageView status_prev2_play;
|
||||
ImageView status_prev3_play;
|
||||
ImageView status_prev4_play;
|
||||
RelativeLayout status_prev4_container;
|
||||
ImageView status_reply;
|
||||
ImageView status_pin;
|
||||
ImageView status_privacy;
|
||||
FloatingActionButton status_translate;
|
||||
LinearLayout status_container2;
|
||||
LinearLayout status_container3;
|
||||
LinearLayout main_container;
|
||||
TextView yandex_translate;
|
||||
TextView google_translate;
|
||||
LinearLayout status_action_container;
|
||||
LinearLayout status_replies;
|
||||
LinearLayout status_replies_profile_pictures;
|
||||
TextView status_replies_text;
|
||||
LinearLayout loader_replies;
|
||||
|
||||
ImageView new_element;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -22,11 +22,11 @@ import android.os.Parcelable;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
private String targetedId;
|
||||
private boolean swiped;
|
||||
private ListView lv_accounts;
|
||||
private RecyclerView lv_accounts;
|
||||
boolean hideHeader;
|
||||
|
||||
@Override
|
||||
|
@ -109,23 +109,28 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
//Hide account header when scrolling for ShowAccountActivity
|
||||
if (hideHeader && Build.VERSION.SDK_INT >= 21)
|
||||
ViewCompat.setNestedScrollingEnabled(lv_accounts, true);
|
||||
lv_accounts.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
||||
}
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||
if (!flag_loading) {
|
||||
flag_loading = true;
|
||||
if (type != RetrieveAccountsAsyncTask.Type.FOLLOWERS && type != RetrieveAccountsAsyncTask.Type.FOLLOWING)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
mLayoutManager = new LinearLayoutManager(context);
|
||||
lv_accounts.setLayoutManager(mLayoutManager);
|
||||
lv_accounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
|
||||
{
|
||||
if(dy > 0) {
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||
if (!flag_loading) {
|
||||
flag_loading = true;
|
||||
if (type != RetrieveAccountsAsyncTask.Type.FOLLOWERS && type != RetrieveAccountsAsyncTask.Type.FOLLOWING)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,12 +19,11 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
import java.util.ArrayList;
|
||||
|
@ -60,9 +59,10 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
private boolean firstLoad;
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
private boolean swiped;
|
||||
private ListView lv_notifications;
|
||||
private RecyclerView lv_notifications;
|
||||
private String lastReadNotifications;
|
||||
private String userId;
|
||||
LinearLayoutManager mLayoutManager;
|
||||
|
||||
public DisplayNotificationsFragment(){
|
||||
}
|
||||
|
@ -78,12 +78,12 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
notifications = new ArrayList<>();
|
||||
swiped = false;
|
||||
|
||||
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer);
|
||||
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
lv_notifications = (ListView) rootView.findViewById(R.id.lv_notifications);
|
||||
mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
|
||||
nextElementLoader = (RelativeLayout) rootView.findViewById(R.id.loading_next_notifications);
|
||||
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
|
||||
lv_notifications = rootView.findViewById(R.id.lv_notifications);
|
||||
mainLoader = rootView.findViewById(R.id.loader);
|
||||
nextElementLoader = rootView.findViewById(R.id.loading_next_notifications);
|
||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||
mainLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
boolean isOnWifi = Helper.isOnWIFI(context);
|
||||
|
@ -92,21 +92,24 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
lastReadNotifications = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null);
|
||||
notificationsListAdapter = new NotificationsListAdapter(context,isOnWifi, behaviorWithAttachments,this.notifications);
|
||||
lv_notifications.setAdapter(notificationsListAdapter);
|
||||
lv_notifications.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
||||
}
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
|
||||
if(firstVisibleItem + visibleItemCount == totalItemCount ) {
|
||||
if(!flag_loading ) {
|
||||
flag_loading = true;
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, null, null, max_id, null, null,DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
mLayoutManager = new LinearLayoutManager(context);
|
||||
lv_notifications.setLayoutManager(mLayoutManager);
|
||||
lv_notifications.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
|
||||
{
|
||||
if(dy > 0) {
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||
if (!flag_loading) {
|
||||
flag_loading = true;
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, null, null, max_id, null, null, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -256,13 +259,13 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
if( notification != null){
|
||||
//Update the id of the last notification retrieved
|
||||
MainActivity.lastNotificationId = notification.getId();
|
||||
int index = lv_notifications.getFirstVisiblePosition() + 1;
|
||||
View v = lv_notifications.getChildAt(0);
|
||||
int top = (v == null) ? 0 : v.getTop();
|
||||
notifications.add(0, notification);
|
||||
MainActivity.countNewNotifications++;
|
||||
notificationsListAdapter.notifyDataSetChanged();
|
||||
lv_notifications.setSelectionFromTop(index, top);
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if( firstVisibleItem > 0)
|
||||
notificationsListAdapter.notifyItemInserted(0);
|
||||
else
|
||||
notificationsListAdapter.notifyDataSetChanged();
|
||||
if( textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -22,11 +22,12 @@ import android.os.Parcelable;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
import java.util.ArrayList;
|
||||
|
@ -69,13 +70,14 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
private String targetedId;
|
||||
private String tag;
|
||||
private boolean swiped;
|
||||
private ListView lv_status;
|
||||
private RecyclerView lv_status;
|
||||
private boolean isOnWifi;
|
||||
private int behaviorWithAttachments;
|
||||
private boolean showMediaOnly, showPinned;
|
||||
private int positionSpinnerTrans;
|
||||
private String lastReadStatus;
|
||||
private Intent streamingFederatedIntent, streamingLocalIntent;
|
||||
LinearLayoutManager mLayoutManager;
|
||||
|
||||
public DisplayStatusFragment(){
|
||||
}
|
||||
|
@ -122,39 +124,43 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
lastReadStatus = sharedpreferences.getString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, null);
|
||||
lv_status = rootView.findViewById(R.id.lv_status);
|
||||
mainLoader = rootView.findViewById(R.id.loader);
|
||||
mainLoader = rootView.findViewById(R.id.loader);
|
||||
nextElementLoader = rootView.findViewById(R.id.loading_next_status);
|
||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||
mainLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
mLayoutManager = new LinearLayoutManager(context);
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
if( !comesFromSearch){
|
||||
|
||||
//Hide account header when scrolling for ShowAccountActivity
|
||||
if (hideHeader)
|
||||
ViewCompat.setNestedScrollingEnabled(lv_status, true);
|
||||
|
||||
lv_status.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
|
||||
{
|
||||
if(dy > 0){
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if(firstVisibleItem + visibleItemCount == totalItemCount ) {
|
||||
if(!flag_loading ) {
|
||||
flag_loading = true;
|
||||
if( type == RetrieveFeedsAsyncTask.Type.USER)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if( type == RetrieveFeedsAsyncTask.Type.TAG)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
}
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
if(firstVisibleItem + visibleItemCount == totalItemCount ) {
|
||||
if(!flag_loading ) {
|
||||
flag_loading = true;
|
||||
if( type == RetrieveFeedsAsyncTask.Type.USER)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if( type == RetrieveFeedsAsyncTask.Type.TAG)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -307,9 +313,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
if (status != null && !knownId.contains(status.getId())) {
|
||||
//Update the id of the last toot retrieved
|
||||
MainActivity.lastHomeId = status.getId();
|
||||
int index = lv_status.getFirstVisiblePosition() + 1;
|
||||
View v = lv_status.getChildAt(0);
|
||||
int top = (v == null) ? 0 : v.getTop();
|
||||
status.setReplies(new ArrayList<Status>());
|
||||
statuses.add(0,status);
|
||||
knownId.add(0,status.getId());
|
||||
|
@ -317,8 +320,11 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if( !status.getAccount().getId().equals(userId))
|
||||
MainActivity.countNewStatus++;
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
lv_status.setSelectionFromTop(index, top);
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if( firstVisibleItem > 0)
|
||||
statusListAdapter.notifyItemInserted(0);
|
||||
else
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
if (textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -328,17 +334,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
if (status != null && !knownId.contains(status.getId())) {
|
||||
status.setReplies(new ArrayList<Status>());
|
||||
status.setNew(false);
|
||||
if (lv_status.getFirstVisiblePosition() == 0) {
|
||||
statuses.add(0, status);
|
||||
statuses.add(0, status);
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if( firstVisibleItem > 0)
|
||||
statusListAdapter.notifyItemInserted(0);
|
||||
else
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
int index = lv_status.getFirstVisiblePosition() + 1;
|
||||
View v = lv_status.getChildAt(0);
|
||||
int top = (v == null) ? 0 : v.getTop();
|
||||
statuses.add(0, status);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
lv_status.setSelectionFromTop(index, top);
|
||||
}
|
||||
knownId.add(0, status.getId());
|
||||
if (textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
|
@ -350,11 +351,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
* Refresh status in list
|
||||
*/
|
||||
public void refreshFilter(){
|
||||
int index = lv_status.getFirstVisiblePosition() + 1;
|
||||
View v = lv_status.getChildAt(0);
|
||||
int top = (v == null) ? 0 : v.getTop();
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
lv_status.setSelectionFromTop(index, top);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -387,11 +384,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
retrieveMissingToots(statuses.get(0).getId());
|
||||
}
|
||||
}
|
||||
int index = lv_status.getFirstVisiblePosition();
|
||||
View v = lv_status.getChildAt(0);
|
||||
int top = (v == null) ? 0 : v.getTop();
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
lv_status.setSelectionFromTop(index, top);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -520,43 +512,27 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
@Override
|
||||
public void onRetrieveMissingFeeds(List<Status> statuses) {
|
||||
if( statuses != null && statuses.size() > 0) {
|
||||
if( lv_status.getFirstVisiblePosition() > 1 ) {
|
||||
int index = lv_status.getFirstVisiblePosition() + statuses.size();
|
||||
View v = lv_status.getChildAt(0);
|
||||
int top = (v == null) ? 0 : v.getTop();
|
||||
for (int i = statuses.size() - 1; i >= 0; i--) {
|
||||
if (!knownId.contains(statuses.get(i).getId())) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
statuses.get(i).setNew(true);
|
||||
knownId.add(0, statuses.get(i).getId());
|
||||
statuses.get(i).setReplies(new ArrayList<Status>());
|
||||
this.statuses.add(0, statuses.get(i));
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME && !statuses.get(i).getAccount().getId().equals(userId))
|
||||
MainActivity.countNewStatus++;
|
||||
}
|
||||
int inserted = 0;
|
||||
for (int i = statuses.size() - 1; i >= 0; i--) {
|
||||
if (!knownId.contains(statuses.get(i).getId())) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
statuses.get(i).setNew(true);
|
||||
knownId.add(0,statuses.get(i).getId());
|
||||
inserted++;
|
||||
statuses.get(i).setReplies(new ArrayList<Status>());
|
||||
this.statuses.add(0, statuses.get(i));
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME && !statuses.get(i).getAccount().getId().equals(userId))
|
||||
MainActivity.countNewStatus++;
|
||||
}
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
lv_status.setSelectionFromTop(index, top);
|
||||
}else {
|
||||
for (int i = statuses.size() - 1; i >= 0; i--) {
|
||||
if (!knownId.contains(statuses.get(i).getId())) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
statuses.get(i).setNew(true);
|
||||
knownId.add(0,statuses.get(i).getId());
|
||||
statuses.get(i).setReplies(new ArrayList<Status>());
|
||||
this.statuses.add(0, statuses.get(i));
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME && !statuses.get(i).getAccount().getId().equals(userId))
|
||||
MainActivity.countNewStatus++;
|
||||
}
|
||||
}
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
statusListAdapter.notifyItemRangeInserted(0, inserted - 1);
|
||||
try {
|
||||
((MainActivity) context).updateHomeCounter();
|
||||
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
((MainActivity) context).updateHomeCounter();
|
||||
else
|
||||
((MainActivity) context).updateTimeLine(type, inserted);
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.widget.BaseAdapter;
|
||||
|
@ -50,15 +51,69 @@ import mastodon.etalab.gouv.fr.mastodon.R;
|
|||
public class CrossActions {
|
||||
|
||||
|
||||
private static API.StatusAction doAction;
|
||||
|
||||
public static void doCrossAction(final Context context, final Status status, API.StatusAction makeAction, final BaseAdapter baseAdapter, final OnPostActionInterface onPostActionInterface, boolean limitedToOwner){
|
||||
|
||||
/**
|
||||
* Returns the list of connected accounts when cross actions are allowed otherwise, returns the current account
|
||||
* @param context Context
|
||||
* @return List<Account>
|
||||
*/
|
||||
private static List<Account> connectedAccounts(Context context, Status status, boolean limitedToOwner){
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountstmp = new AccountDAO(context, db).getAllAccount();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
|
||||
List<Account> accounts = new ArrayList<>();
|
||||
if( !limitedToOwner && sharedpreferences.getBoolean(Helper.SET_ALLOW_CROSS_ACTIONS, true) && accountstmp.size() > 1 ){
|
||||
//It's for a reply
|
||||
if( status != null){
|
||||
//Status is private or direct
|
||||
if( status.getVisibility().equals("private") || status.getVisibility().equals("direct") ){
|
||||
//Retrieves mentioned accounts and compares them to the list of accounts in the device.
|
||||
List<Mention> mentions = status.getMentions();
|
||||
List<String> addedAccount = new ArrayList<>();
|
||||
//Adds the owner
|
||||
accounts.add(currentAccount);
|
||||
addedAccount.add(currentAccount.getId() + "|" + currentAccount.getAcct());
|
||||
for(Mention mention: mentions){
|
||||
for(Account account: accountstmp){
|
||||
String mentionAcct = (mention.getAcct().contains("@"))?mention.getAcct():mention.getAcct()+"@"+currentAccount.getInstance();
|
||||
if( (account.getAcct() + "@" + account.getInstance()).equals(mentionAcct) && !addedAccount.contains(account.getId() + "|" + account.getAcct())) {
|
||||
accounts.add(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Account account: accountstmp){
|
||||
Account tootOwner = status.getAccount();
|
||||
String mentionAcct = (tootOwner.getAcct().contains("@"))?tootOwner.getAcct():tootOwner.getAcct()+"@"+currentAccount.getInstance();
|
||||
if( (account.getAcct() + "@" + account.getInstance()).equals(mentionAcct) && !addedAccount.contains(account.getId() + "|" + account.getAcct())) {
|
||||
accounts.add(account);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
accounts = accountstmp;
|
||||
}
|
||||
}else {
|
||||
accounts = accountstmp;
|
||||
}
|
||||
return accounts;
|
||||
}else {
|
||||
List<Account> oneAccount = new ArrayList<>();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
oneAccount.add(account);
|
||||
return oneAccount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void doCrossAction(final Context context, final Status status, final API.StatusAction doAction, final RecyclerView.Adapter baseAdapter, final OnPostActionInterface onPostActionInterface, boolean limitedToOwner){
|
||||
List<Account> accounts = connectedAccounts(context, status, limitedToOwner);
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
doAction = makeAction;
|
||||
|
||||
boolean undoAction = (doAction == API.StatusAction.UNPIN || doAction == API.StatusAction.UNREBLOG || doAction == API.StatusAction.UNFAVOURITE );
|
||||
//Undo actions won't ask for choosing a user
|
||||
if( accounts.size() == 1 || (undoAction && limitedToOwner) ) {
|
||||
if( accounts.size() == 1 || undoAction ) {
|
||||
|
||||
boolean confirmation = false;
|
||||
if( doAction == API.StatusAction.UNFAVOURITE || doAction == API.StatusAction.FAVOURITE)
|
||||
|
@ -85,7 +140,6 @@ public class CrossActions {
|
|||
accountArray[i] = account;
|
||||
i++;
|
||||
}
|
||||
|
||||
builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -95,17 +149,10 @@ public class CrossActions {
|
|||
builderSingle.setAdapter(accountsSearchAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
Account selectedAccount = accountArray[which];
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account loggedAccount = new AccountDAO(context, db).getAccountByID(userId);
|
||||
//Cross action can only be create elements (boost/fav)
|
||||
if( doAction == API.StatusAction.UNREBLOG)
|
||||
doAction = API.StatusAction.REBLOG;
|
||||
else if( doAction == API.StatusAction.UNFAVOURITE)
|
||||
doAction = API.StatusAction.FAVOURITE;
|
||||
|
||||
if(loggedAccount.getInstance().equals(selectedAccount.getInstance())){
|
||||
new PostActionAsyncTask(context, selectedAccount, doAction, status.getId(), onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}else{ //Account is from another instance
|
||||
|
@ -196,7 +243,7 @@ public class CrossActions {
|
|||
* @param action int
|
||||
* @param status Status
|
||||
*/
|
||||
private static void displayConfirmationDialog(final Context context, final API.StatusAction action, final Status status, final BaseAdapter baseAdapter, final OnPostActionInterface onPostActionInterface){
|
||||
private static void displayConfirmationDialog(final Context context, final API.StatusAction action, final Status status, final RecyclerView.Adapter baseAdapter, final OnPostActionInterface onPostActionInterface){
|
||||
|
||||
String title = null;
|
||||
if( action == API.StatusAction.FAVOURITE){
|
||||
|
@ -248,7 +295,7 @@ public class CrossActions {
|
|||
* Favourites/Unfavourites a status
|
||||
* @param status Status
|
||||
*/
|
||||
private static void favouriteAction(Context context, Status status, BaseAdapter baseAdapter, OnPostActionInterface onPostActionInterface){
|
||||
private static void favouriteAction(Context context, Status status, RecyclerView.Adapter baseAdapter, OnPostActionInterface onPostActionInterface){
|
||||
if( status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())){
|
||||
new PostActionAsyncTask(context, API.StatusAction.UNFAVOURITE, status.getId(), onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
status.setFavourited(false);
|
||||
|
@ -263,7 +310,7 @@ public class CrossActions {
|
|||
* Reblog/Unreblog a status
|
||||
* @param status Status
|
||||
*/
|
||||
private static void reblogAction(Context context, Status status, BaseAdapter baseAdapter, OnPostActionInterface onPostActionInterface){
|
||||
private static void reblogAction(Context context, Status status, RecyclerView.Adapter baseAdapter, OnPostActionInterface onPostActionInterface){
|
||||
if( status.isReblogged() || (status.getReblog()!= null && status.getReblog().isReblogged())){
|
||||
String statusId = status.getReblog()!=null?status.getReblog().getId():status.getId();
|
||||
new PostActionAsyncTask(context, API.StatusAction.UNREBLOG, statusId, onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -279,7 +326,7 @@ public class CrossActions {
|
|||
* Pin or unpin a status
|
||||
* @param status Status
|
||||
*/
|
||||
private static void pinAction(Context context, Status status, BaseAdapter baseAdapter, OnPostActionInterface onPostActionInterface) {
|
||||
private static void pinAction(Context context, Status status, RecyclerView.Adapter baseAdapter, OnPostActionInterface onPostActionInterface) {
|
||||
|
||||
if (status.isPinned()) {
|
||||
new PostActionAsyncTask(context, API.StatusAction.UNPIN, status.getId(), onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -292,58 +339,6 @@ public class CrossActions {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the list of connected accounts when cross actions are allowed otherwise, returns the current account
|
||||
* @param context Context
|
||||
* @return List<Account>
|
||||
*/
|
||||
private static List<Account> connectedAccounts(Context context, Status status, boolean limitedToOwner){
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountstmp = new AccountDAO(context, db).getAllAccount();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
|
||||
List<Account> accounts = new ArrayList<>();
|
||||
if( !limitedToOwner && sharedpreferences.getBoolean(Helper.SET_ALLOW_CROSS_ACTIONS, true) && accountstmp.size() > 1 ){
|
||||
//It's for a reply
|
||||
if( status != null){
|
||||
//Status is private or direct
|
||||
if( status.getVisibility().equals("private") || status.getVisibility().equals("direct") ){
|
||||
//Retrieves mentioned accounts and compares them to the list of accounts in the device.
|
||||
List<Mention> mentions = status.getMentions();
|
||||
List<String> addedAccount = new ArrayList<>();
|
||||
//Adds the owner
|
||||
accounts.add(currentAccount);
|
||||
addedAccount.add(currentAccount.getId() + "|" + currentAccount.getAcct());
|
||||
for(Mention mention: mentions){
|
||||
for(Account account: accountstmp){
|
||||
String mentionAcct = (mention.getAcct().contains("@"))?mention.getAcct():mention.getAcct()+"@"+currentAccount.getInstance();
|
||||
if( (account.getAcct() + "@" + account.getInstance()).equals(mentionAcct) && !addedAccount.contains(account.getId() + "|" + account.getAcct())) {
|
||||
accounts.add(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Account account: accountstmp){
|
||||
Account tootOwner = status.getAccount();
|
||||
String mentionAcct = (tootOwner.getAcct().contains("@"))?tootOwner.getAcct():tootOwner.getAcct()+"@"+currentAccount.getInstance();
|
||||
if( (account.getAcct() + "@" + account.getInstance()).equals(mentionAcct) && !addedAccount.contains(account.getId() + "|" + account.getAcct())) {
|
||||
accounts.add(account);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
accounts = accountstmp;
|
||||
}
|
||||
}else {
|
||||
accounts = accountstmp;
|
||||
}
|
||||
return accounts;
|
||||
}else {
|
||||
List<Account> oneAccount = new ArrayList<>();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
oneAccount.add(account);
|
||||
return oneAccount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ import android.text.TextPaint;
|
|||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -80,7 +79,6 @@ import android.webkit.WebSettings;
|
|||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -213,7 +211,7 @@ public class Helper {
|
|||
public static final String SET_LED_COLOUR = "set_led_colour";
|
||||
public static final String SET_SHOW_BOOSTS = "set_show_boost";
|
||||
public static final String SET_SHOW_REPLIES = "set_show_replies";
|
||||
|
||||
public static final String INSTANCE_VERSION = "instance_version";
|
||||
|
||||
public static final int ATTACHMENT_ALWAYS = 1;
|
||||
public static final int ATTACHMENT_WIFI = 2;
|
||||
|
@ -260,7 +258,6 @@ public class Helper {
|
|||
public static final String INTENT_ACTION = "intent_action";
|
||||
|
||||
//Receiver
|
||||
public static final String HEADER_ACCOUNT = "header_account";
|
||||
public static final String RECEIVE_DATA = "receive_data";
|
||||
public static final String RECEIVE_FEDERATED_DATA = "receive_federated_data";
|
||||
public static final String RECEIVE_LOCAL_DATA = "receive_local_data";
|
||||
|
@ -279,7 +276,7 @@ public class Helper {
|
|||
"(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
|
||||
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_À-ú-]{1,})");
|
||||
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_À-ú-]+)");
|
||||
/**
|
||||
* Converts emojis in input to unicode
|
||||
* @param input String
|
||||
|
@ -340,8 +337,11 @@ public class Helper {
|
|||
* Check if the user is connected to Internet
|
||||
* @return boolean
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean isConnectedToInternet(Context context, String instance) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if( cm == null)
|
||||
return true;
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
if ( ni != null && ni.isConnected()) {
|
||||
try {
|
||||
|
@ -459,6 +459,7 @@ public class Helper {
|
|||
*/
|
||||
public static boolean isOnWIFI(Context context) {
|
||||
ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
assert connManager != null;
|
||||
NetworkInfo activeNetwork = connManager.getActiveNetworkInfo();
|
||||
return (activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
|
||||
}
|
||||
|
@ -572,6 +573,7 @@ public class Helper {
|
|||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
|
||||
assert dm != null;
|
||||
dm.enqueue(request);
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
@ -618,6 +620,7 @@ public class Helper {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(channelId, title, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
assert mNotificationManager != null;
|
||||
mNotificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
|
@ -746,8 +749,10 @@ public class Helper {
|
|||
*/
|
||||
public static void copy(File src, File dst) throws IOException {
|
||||
InputStream in = new FileInputStream(src);
|
||||
//noinspection TryFinallyCanBeTryWithResources
|
||||
try {
|
||||
OutputStream out = new FileOutputStream(dst);
|
||||
//noinspection TryFinallyCanBeTryWithResources
|
||||
try {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
|
@ -800,10 +805,10 @@ public class Helper {
|
|||
*/
|
||||
public static void menuAccounts(final Activity activity){
|
||||
|
||||
final NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
|
||||
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
|
||||
SharedPreferences mSharedPreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String currrentUserId = mSharedPreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
final ImageView arrow = (ImageView) navigationView.getHeaderView(0).findViewById(R.id.owner_accounts);
|
||||
final ImageView arrow = navigationView.getHeaderView(0).findViewById(R.id.owner_accounts);
|
||||
if( currrentUserId == null)
|
||||
return;
|
||||
|
||||
|
@ -882,7 +887,7 @@ public class Helper {
|
|||
}
|
||||
});
|
||||
item.setActionView(R.layout.update_account);
|
||||
ImageView deleteButton = (ImageView) item.getActionView().findViewById(R.id.account_remove_button);
|
||||
ImageView deleteButton = item.getActionView().findViewById(R.id.account_remove_button);
|
||||
deleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -937,7 +942,7 @@ public class Helper {
|
|||
public static void changeUser(Activity activity, String userID, boolean checkItem) {
|
||||
|
||||
|
||||
final NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
|
||||
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
|
||||
navigationView.getMenu().clear();
|
||||
MainActivity.lastNotificationId = null;
|
||||
MainActivity.lastHomeId = null;
|
||||
|
@ -954,7 +959,6 @@ public class Helper {
|
|||
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
|
||||
}
|
||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String oldUserId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
|
||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||
|
@ -968,7 +972,8 @@ public class Helper {
|
|||
}
|
||||
|
||||
|
||||
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap,int roundPixelSize) {
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int roundPixelSize) {
|
||||
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(output);
|
||||
final Paint paint = new Paint();
|
||||
|
@ -1019,11 +1024,11 @@ public class Helper {
|
|||
* @param options DisplayImageOptions - current configuration of ImageLoader
|
||||
*/
|
||||
public static void updateHeaderAccountInfo(final Activity activity, final Account account, final View headerLayout, ImageLoader imageLoader, DisplayImageOptions options){
|
||||
ImageView profilePicture = (ImageView) headerLayout.findViewById(R.id.profilePicture);
|
||||
ImageView profilePicture = headerLayout.findViewById(R.id.profilePicture);
|
||||
|
||||
TextView username = (TextView) headerLayout.findViewById(R.id.username);
|
||||
TextView displayedName = (TextView) headerLayout.findViewById(R.id.displayedName);
|
||||
ImageView header_edit_profile = (ImageView) headerLayout.findViewById(R.id.header_edit_profile);
|
||||
TextView username = headerLayout.findViewById(R.id.username);
|
||||
TextView displayedName = headerLayout.findViewById(R.id.displayedName);
|
||||
ImageView header_edit_profile = headerLayout.findViewById(R.id.header_edit_profile);
|
||||
header_edit_profile.setOnClickListener(null);
|
||||
if( account == null ) {
|
||||
Helper.logout(activity);
|
||||
|
@ -1051,7 +1056,7 @@ public class Helper {
|
|||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||
LinearLayout main_header_container = (LinearLayout) headerLayout.findViewById(R.id.main_header_container);
|
||||
LinearLayout main_header_container = headerLayout.findViewById(R.id.main_header_container);
|
||||
Bitmap workingBitmap = Bitmap.createBitmap(loadedImage);
|
||||
Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
Canvas canvas = new Canvas(mutableBitmap);
|
||||
|
@ -1066,7 +1071,7 @@ public class Helper {
|
|||
|
||||
@Override
|
||||
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason) {
|
||||
LinearLayout main_header_container = (LinearLayout) headerLayout.findViewById(R.id.main_header_container);
|
||||
LinearLayout main_header_container = headerLayout.findViewById(R.id.main_header_container);
|
||||
main_header_container.setBackgroundResource(R.drawable.side_nav_bar);
|
||||
}
|
||||
});
|
||||
|
@ -1143,6 +1148,7 @@ public class Helper {
|
|||
* @param mentions List<Mention>
|
||||
* @return TextView
|
||||
*/
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public static SpannableString clickableElements(final Context context, String fullContent, List<Mention> mentions, final List<Emojis> emojis, final int position, boolean useHTML, final OnRetrieveEmojiInterface listener) {
|
||||
final SpannableString spannableString;
|
||||
|
||||
|
@ -1365,7 +1371,7 @@ public class Helper {
|
|||
|
||||
public static WebView initializeWebview(Activity activity, int webviewId){
|
||||
|
||||
WebView webView = (WebView) activity.findViewById(webviewId);
|
||||
WebView webView = activity.findViewById(webviewId);
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean javascript = sharedpreferences.getBoolean(Helper.SET_JAVASCRIPT, true);
|
||||
|
||||
|
@ -1414,9 +1420,9 @@ public class Helper {
|
|||
// Create Hex String
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aMessageDigest : messageDigest) {
|
||||
String h = Integer.toHexString(0xFF & aMessageDigest);
|
||||
StringBuilder h = new StringBuilder(Integer.toHexString(0xFF & aMessageDigest));
|
||||
while (h.length() < 2)
|
||||
h = "0" + h;
|
||||
h.insert(0, "0");
|
||||
hexString.append(h);
|
||||
}
|
||||
return hexString.toString();
|
||||
|
@ -1585,15 +1591,6 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a ListView is at its top position
|
||||
* @param listView ListView
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean listIsAtTop(ListView listView) {
|
||||
return listView.getChildCount() == 0 || listView.getChildAt(0).getTop() == 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the menu layout
|
||||
|
@ -1602,8 +1599,8 @@ public class Helper {
|
|||
public static void switchLayout(Activity activity){
|
||||
//Check if the class calling the method is an instance of MainActivity
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
|
||||
android.support.design.widget.TabLayout tableLayout = (android.support.design.widget.TabLayout) activity.findViewById(R.id.tabLayout);
|
||||
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
|
||||
android.support.design.widget.TabLayout tableLayout = activity.findViewById(R.id.tabLayout);
|
||||
String userID = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(activity,db).getAccountByID(userID);
|
||||
|
@ -1628,15 +1625,15 @@ public class Helper {
|
|||
*/
|
||||
public static Bitmap convertTootIntoBitmap(Context context, View view) {
|
||||
|
||||
int new_element_v = 0, notification_delete_v = 0;
|
||||
int new_element_v = View.VISIBLE, notification_delete_v = View.VISIBLE;
|
||||
//Removes some elements
|
||||
ImageView new_element = (ImageView) view.findViewById(R.id.new_element);
|
||||
ImageView new_element = view.findViewById(R.id.new_element);
|
||||
if( new_element != null) {
|
||||
new_element_v = new_element.getVisibility();
|
||||
new_element.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ImageView notification_delete = (ImageView) view.findViewById(R.id.notification_delete);
|
||||
ImageView notification_delete = view.findViewById(R.id.notification_delete);
|
||||
if( notification_delete != null) {
|
||||
notification_delete_v = notification_delete.getVisibility();
|
||||
notification_delete.setVisibility(View.GONE);
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Mastalab 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 Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.interfaces;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 25/10/2017.
|
||||
* Interface when accounts of a conversation have been retrieved
|
||||
*/
|
||||
public interface OnRetrieveAccountsReplyInterface {
|
||||
void onRetrieveAccountsReply(ArrayList<Account> accounts);
|
||||
}
|
|
@ -14,10 +14,12 @@
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.interfaces;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 03/07/2017.
|
||||
* Yandex client API Handler
|
||||
*/
|
||||
public interface OnTranslatedInterface {
|
||||
void onTranslatedTextview(int position, String translatedResult, Boolean error);
|
||||
void onTranslatedTextview(Status status, String translatedResult, Boolean error);
|
||||
}
|
||||
|
|
|
@ -14,14 +14,11 @@
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.translation;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.loopj.android.http.AsyncHttpResponseHandler;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import cz.msebera.android.httpclient.Header;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnTranslatedInterface;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +34,7 @@ public class GoogleTranslateQuery {
|
|||
this.listener = listenner;
|
||||
}
|
||||
|
||||
public void getGoogleTextview(final int position, final String text, final String toLanguage) throws JSONException {
|
||||
public void getGoogleTextview(final Status status, final String text, final String toLanguage) throws JSONException {
|
||||
|
||||
GoogleTranslateClient.get(text, toLanguage, new AsyncHttpResponseHandler() {
|
||||
@Override
|
||||
|
@ -47,12 +44,12 @@ public class GoogleTranslateQuery {
|
|||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers, byte[] response) {
|
||||
String str_response = new String(response);
|
||||
listener.onTranslatedTextview(position, str_response,false);
|
||||
listener.onTranslatedTextview(status, str_response,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
|
||||
listener.onTranslatedTextview(position, null, true);
|
||||
listener.onTranslatedTextview(status, null, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -16,6 +16,7 @@ package fr.gouv.etalab.mastodon.translation;
|
|||
import com.loopj.android.http.AsyncHttpResponseHandler;
|
||||
import org.json.JSONException;
|
||||
import cz.msebera.android.httpclient.Header;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnTranslatedInterface;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +30,7 @@ public class YandexQuery {
|
|||
this.listener = listenner;
|
||||
}
|
||||
|
||||
public void getYandexTextview(final int position, final String text, final String toLanguage) throws JSONException {
|
||||
public void getYandexTextview(final Status status, final String text, final String toLanguage) throws JSONException {
|
||||
|
||||
YandexClient.get(text, toLanguage, new AsyncHttpResponseHandler() {
|
||||
@Override
|
||||
|
@ -40,12 +41,12 @@ public class YandexQuery {
|
|||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers, byte[] response) {
|
||||
String str_response = new String(response);
|
||||
listener.onTranslatedTextview(position, str_response,false);
|
||||
listener.onTranslatedTextview(status, str_response,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
|
||||
listener.onTranslatedTextview(position, null, true);
|
||||
listener.onTranslatedTextview(status, null, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -13,6 +13,7 @@ package fr.gouv.etalab.mastodon.webview;
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.MediaPlayer;
|
||||
|
@ -59,7 +60,7 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
|
|||
this.activity = activity;
|
||||
this.isVideoFullscreen = false;
|
||||
this.webView = webView;
|
||||
this.pbar = (ProgressBar) activity.findViewById(R.id.progress_bar);
|
||||
this.pbar = activity.findViewById(R.id.progress_bar);
|
||||
this.activityNonVideoView = activityNonVideoView;
|
||||
this.activityVideoView = activityVideoView;
|
||||
}
|
||||
|
@ -84,10 +85,10 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
|
|||
LayoutInflater mInflater = LayoutInflater.from(activity);
|
||||
ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
|
||||
if( actionBar != null){
|
||||
View webview_actionbar = mInflater.inflate(R.layout.webview_actionbar, null);
|
||||
TextView webview_title = (TextView) webview_actionbar.findViewById(R.id.webview_title);
|
||||
@SuppressLint("InflateParams") View webview_actionbar = mInflater.inflate(R.layout.webview_actionbar, null);
|
||||
TextView webview_title = webview_actionbar.findViewById(R.id.webview_title);
|
||||
webview_title.setText(view.getTitle());
|
||||
ImageView webview_favicon = (ImageView) webview_actionbar.findViewById(R.id.webview_favicon);
|
||||
ImageView webview_favicon = webview_actionbar.findViewById(R.id.webview_favicon);
|
||||
if( icon != null)
|
||||
webview_favicon.setImageBitmap(icon);
|
||||
actionBar.setCustomView(webview_actionbar);
|
||||
|
@ -113,6 +114,7 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
|
|||
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
|
||||
if (view instanceof FrameLayout) {
|
||||
if( ((AppCompatActivity) activity).getSupportActionBar() != null)
|
||||
//noinspection ConstantConditions
|
||||
((AppCompatActivity) activity).getSupportActionBar().hide();
|
||||
// A video wants to be shown
|
||||
FrameLayout frameLayout = (FrameLayout) view;
|
||||
|
@ -176,6 +178,7 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
|
|||
@Override
|
||||
public void onHideCustomView() {
|
||||
if( ((AppCompatActivity) activity).getSupportActionBar() != null)
|
||||
//noinspection ConstantConditions
|
||||
((AppCompatActivity) activity).getSupportActionBar().show();
|
||||
// This method should be manually called on video end in all cases because it's not always called automatically.
|
||||
// This method must be manually called on back key press (from this class' onBackPressed() method).
|
||||
|
|
|
@ -13,6 +13,7 @@ package fr.gouv.etalab.mastodon.webview;
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.v7.app.ActionBar;
|
||||
|
@ -51,8 +52,8 @@ public class MastalabWebViewClient extends WebViewClient {
|
|||
ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
|
||||
LayoutInflater mInflater = LayoutInflater.from(activity);
|
||||
if( actionBar != null){
|
||||
View webview_actionbar = mInflater.inflate(R.layout.webview_actionbar, null);
|
||||
TextView webview_title = (TextView) webview_actionbar.findViewById(R.id.webview_title);
|
||||
@SuppressLint("InflateParams") View webview_actionbar = mInflater.inflate(R.layout.webview_actionbar, null);
|
||||
TextView webview_title = webview_actionbar.findViewById(R.id.webview_title);
|
||||
webview_title.setText(url);
|
||||
actionBar.setCustomView(webview_actionbar);
|
||||
actionBar.setDisplayShowCustomEnabled(true);
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
android:text="@string/action_search" />
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
<fr.gouv.etalab.mastodon.helper.ExpandableHeightListView
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="30dp"
|
||||
android:id="@+id/lv_account"
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
android:layout_width="match_parent"
|
||||
android:id="@+id/swipeContainer"
|
||||
android:layout_height="match_parent">
|
||||
<ListView
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/lv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:divider="@null"
|
||||
>
|
||||
</ListView>
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_action"
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context="mastodon.etalab.gouv.fr.mastodon.fr.etalab.gouv.fr.mastodon.activities.MainActivity"
|
||||
tools:context="fr.gouv.etalab.mastodon.activities.MainActivity"
|
||||
>
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
|
@ -107,11 +107,10 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context="mastodon.etalab.gouv.fr.mastodon.fr.etalab.gouv.fr.mastodon.activities.MainActivity"
|
||||
tools:context="fr.gouv.etalab.mastodon.activities.MainActivity"
|
||||
>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/toot"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
android:text="@string/action_search" />
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
<fr.gouv.etalab.mastodon.helper.ExpandableHeightListView
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="30dp"
|
||||
android:id="@+id/lv_account"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:id="@+id/swipeContainer"
|
||||
android:layout_height="match_parent">
|
||||
<ListView
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/lv_status"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Thomas Schneider
|
||||
|
||||
This file is a part of Mastalab
|
||||
|
||||
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.
|
||||
|
||||
Mastalab 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 Mastalab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="2dp"
|
||||
android:id="@+id/account_container"
|
||||
android:orientation="horizontal">
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<ImageView
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/account_pp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
<TextView
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:maxLines="1"
|
||||
android:id="@+id/account_dn"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Thomas Schneider
|
||||
|
||||
This file is a part of Mastalab
|
||||
|
||||
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.
|
||||
|
||||
Mastalab 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 Mastalab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
|
@ -27,14 +27,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:id="@+id/swipeContainer"
|
||||
android:layout_height="match_parent">
|
||||
<ListView
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/lv_accounts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:divider="@null"
|
||||
>
|
||||
</ListView>
|
||||
/>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_action"
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
android:layout_width="match_parent"
|
||||
android:id="@+id/swipeContainer"
|
||||
android:layout_height="match_parent">
|
||||
<ListView
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/lv_notifications"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:divider="@null"
|
||||
>
|
||||
</ListView>
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_action"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:id="@+id/swipeContainer"
|
||||
android:layout_height="match_parent">
|
||||
<ListView
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/lv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -426,4 +426,6 @@
|
|||
<string name="thanks_text_dev">Danke an:</string>
|
||||
<string name="set_multiaccount_actions">Erlauben Interaktionen zwischen den accounts?</string>
|
||||
<string name="action_open_in_web">Im Browser öffnen</string>
|
||||
<string name="select_accounts">Select some accounts</string>
|
||||
<string name="upload_form_description">Für Menschen mit Sehbehinderung beschreiben</string>
|
||||
</resources>
|
||||
|
|
|
@ -433,4 +433,6 @@
|
|||
<string name="toast_unpin">Le pouet a été désépinglé !</string>
|
||||
<string name="pins_cnt">Epinglés %d</string>
|
||||
<string name="action_open_in_web">Ouvrir dans le navigateur</string>
|
||||
<string name="select_accounts">Sélectionnez des comptes</string>
|
||||
<string name="upload_form_description">Décrire pour les malvoyants</string>
|
||||
</resources>
|
|
@ -97,8 +97,7 @@
|
|||
<string name="fav_removed">De toot is uit jouw favorieten verwijderd!</string>
|
||||
<string name="reblog_added">De toot is geboost!</string>
|
||||
<string name="reblog_removed">De toot is niet meer geboost!</string>
|
||||
<string name="reblog_by">Gedeeld via %1$s</string>
|
||||
|
||||
<string name="reblog_by">Geboost door %1$s</string>
|
||||
|
||||
<string name="favourite_add">Deze toot aan jouw favorieten toevoegen?</string>
|
||||
<string name="favourite_remove">Deze toot uit jouw favorieten verwijderen?</string>
|
||||
|
@ -107,8 +106,6 @@
|
|||
<string name="pin_add">Deze toot aan jouw profielpagina vastmaken?</string>
|
||||
<string name="pin_remove">Deze toot van profielpagina losmaken?</string>
|
||||
|
||||
|
||||
|
||||
<string name="more_action_1">Negeren</string>
|
||||
<string name="more_action_2">Blokkeren</string>
|
||||
<string name="more_action_3">Rapporteren</string>
|
||||
|
@ -344,7 +341,7 @@
|
|||
<string name="set_led_colour">LED-kleur instellen:</string>
|
||||
|
||||
<string-array name="led_colours">
|
||||
<item>Blaauw</item>
|
||||
<item>Blauw</item>
|
||||
<item>Cyaan</item>
|
||||
<item>Magenta</item>
|
||||
<item>Groen</item>
|
||||
|
@ -433,4 +430,6 @@
|
|||
<string name="thanks_text_dev">
|
||||
Met dank aan:
|
||||
</string>
|
||||
</resources>
|
||||
<string name="select_accounts">Kies enkele accounts</string>
|
||||
<string name="upload_form_description">Omschrijf dit voor mensen met een visuele beperking</string>
|
||||
</resources>
|
||||
|
|
|
@ -432,4 +432,6 @@
|
|||
Agradecimentos a:
|
||||
</string>
|
||||
<string name="action_open_in_web">Open in browser</string>
|
||||
<string name="select_accounts">Select some accounts</string>
|
||||
<string name="upload_form_description">Describe for the visually impaired</string>
|
||||
</resources>
|
||||
|
|
|
@ -182,8 +182,11 @@
|
|||
<string name="no_draft">No draft!</string>
|
||||
<string name="choose_toot">Choose a toot</string>
|
||||
<string name="choose_accounts">Choose an account</string>
|
||||
<string name="select_accounts">Select some accounts</string>
|
||||
<string name="remove_draft">Remove draft?</string>
|
||||
<string name="show_reply">Click on the button to display the original toot</string>
|
||||
|
||||
<string name="upload_form_description">Describe for the visually impaired</string>
|
||||
<!-- Instance -->
|
||||
<string name="instance_no_description">No description available!</string>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.3'
|
||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Sun Apr 23 09:30:57 CEST 2017
|
||||
#Thu Oct 26 16:05:35 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
|
|
Loading…
Reference in New Issue