Compare commits

..
Author SHA1 Message Date
khanhduytran0 c269c4758f Update OptiFine supported 2020-04-01 13:22:18 +07:00
khanhduytran0 ceefb281c6 Added OptiFine table 2020-04-01 13:21:37 +07:00
khanhduytran0 ff09a46d68 Update README.md
Remove 2.4 table
2020-03-29 10:40:59 +07:00
khanhduytran0 a635772c91 Update README.md
Tested by @artdeell in Android 10
2020-03-24 19:49:48 +07:00
khanhduytran0 66ea82a9be Android 9 Minecraft 1.9 ? 2020-03-23 05:17:37 +07:00
khanhduytran0 6b5cbd171d Update README.md 2020-03-21 18:38:21 +07:00
khanhduytran0 d95049affb Update README.md 2020-03-21 18:36:32 +07:00
khanhduytran0 138b6ade98 Update README.md 2020-03-21 15:34:05 +07:00
khanhduytran0 223967a61b Begin table supported version 2.4.2
Not fully correctly.
2020-03-21 15:32:47 +07:00
khanhduytran0 94c80d91b7 Update supported version
Reported by https://www.youtube.com/channel/UClIJr2Jtv22ui89s5r7HFNA
2020-03-20 21:17:50 +07:00
khanhduytran0 56c8e2b485 Update README.md 2020-03-20 05:09:41 +07:00
khanhduytran0 6b8b28d91c Update README.md 2020-03-19 17:03:46 +07:00
khanhduytran0 99b699ad9d Fix wrong words
My English is not good.
2020-03-19 07:06:39 +07:00
khanhduytran0 96a15dd235 Add supported table 2020-03-19 07:04:40 +07:00
khanhduytran0 93bad479d5 Cancel v3 2020-03-19 05:21:56 +07:00
khanhduytran0 1aed2b82ee Cancel v3, add description 2020-03-19 05:17:53 +07:00
khanhduytran0 ba24131901 Cancel v3 2020-03-19 05:15:55 +07:00
khanhduytran0 9e0584deab Update README.md 2020-03-11 10:31:39 +07:00
khanhduytran0 35d33e836c Initial commit 2020-03-11 10:22:55 +07:00
535 changed files with 103 additions and 84421 deletions

No files matched your search

-33
View File
@@ -1,33 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Start PojavLauncher
...
**Expected behavior**
I expected ...
**Screenshots**
**Platform:**
- Device Model [e.g. Mi 8 Pro 8/128]
- CPU architecture [e.g. aarch64]
- Android Version [e.g. 10]
<details> <summary><b>Additional context</b></summary>
<br>
<pre>
Add any other context about the problem here.
</pre>
</details>
-20
View File
@@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[F-REQ]"
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
-17
View File
@@ -1,17 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 4
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 1
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: true
-55
View File
@@ -1,55 +0,0 @@
name: Android CI
on:
push:
branches-ignore:
- 'l10n_*'
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build APK with Gradle
run: |
chmod +x scripts/languagelist_updater.sh
bash scripts/languagelist_updater.sh
mkdir -p out
chmod +x gradlew
./gradlew clean
# Build JRE JAR files (security manager, etc...)
./gradlew :jre_lwjgl3glfw:build
# mkdir app_pojavlauncher/src/main/assets/components/internal_libs
rm app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar
cp jre_lwjgl3glfw/build/libs/jre_lwjgl3glfw-3.2.3.jar app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar
# Build the launcher
./gradlew :app_pojavlauncher:assembleDebug
mv app_pojavlauncher/build/outputs/apk/debug/app_pojavlauncher-debug.apk out/app-debug.apk
# mv app_pojavlauncher/build/intermediates/merged_native_libs/debug/out/lib out/debug_lib
- name: Build APK without runtime
run: |
rm -r app_pojavlauncher/src/main/assets/components/jre
./gradlew assembleDebug
mv app_pojavlauncher/build/outputs/apk/debug/app_pojavlauncher-debug.apk out/app-debug-noruntime.apk
- name: Upload APK
uses: actions/upload-artifact@v2
with:
name: app-debug
path: out/app-debug.apk
- name: Upload APK (without runtime)
uses: actions/upload-artifact@v2
with:
name: app-debug-noruntime
path: out/app-debug-noruntime.apk
-2
View File
@@ -1,2 +0,0 @@
/build
/*/build
-3
View File
@@ -1,3 +0,0 @@
1. This app (while idle) does NOT collect any sensitive information, and does NOT use network (exception is the "News" page, it uses network to load the launcher news)
2. While running Minecraft, app also does NOT collect any sensitive information about your device. Snooper by Mojang does.
3. Some sensitive data is stored in crash reports after the game crashes, but it's not being shared to anyone except the current user.
-674
View File
@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+103 -62
View File
@@ -1,70 +1,111 @@
[![Android CI](https://github.com/PojavLauncherTeam/PojavLauncher/workflows/Android%20CI/badge.svg)](https://github.com/PojavLauncherTeam/PojavLauncher/actions)
[![Crowdin](https://badges.crowdin.net/pojavlauncher/localized.svg)](https://crowdin.com/project/pojavlauncher)
[![Discord](https://img.shields.io/discord/724163890803638273.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/6RpEJda)
[![Reddit](https://img.shields.io/badge/dynamic/json.svg?label=r/PojavLauncher%20member%20count&query=$.data.subscribers&url=https://www.reddit.com/r/PojavLauncher/about.json)](https://reddit.com/r/PojavLauncher)
# PojavLauncher
A Minecraft: Java Edition launcher for Android based from Boardwalk. Support up-to Minecraft 1.12
## Navigation
- [Introduction](#introduction)
- [Building](#building)
- [Current status](#current-status)
- [License](#license)
- [Contributing](#contributing)
- [Credits & Third party components and their licenses](#credits--third-party-components-and-their-licenses)
# Source code
Not yet, this repository currently for bug tracking.
## Introduction
PojavLauncher is a Minecraft: Java Edition launcher for Android based on [Boardwalk](https://github.com/zhuowei/Boardwalk). This launcher can launch almost all available Minecraft versions (from rd-132211 to latest 1.17 snapshot, including Combat Test versions). Modding via Forge and Fabric are also supported.
# Planning
- ~~If [exagear_windows_emulator](https://github.com/khanhduytran0/exagear_windows_emulator) repository is runnable then I will make PojavLauncher v3.~~ There are too many probelms when switching to Exagear Windows Emulator code, read below.
- Adding custom version.
## Problem before switching to
- Source code not working.
## Problem after switching to
- Low performance.
- No mouse pointer.
- Can't compatible with some devices running Android 10 and above. [Reason?](https://issuetracker.google.com/issues/128554619)
## Building
To get started, you can just get prebuilt app from [stable release](https://github.com/PojavLauncherTeam/PojavLauncher/releases) or [automatic builds](https://github.com/PojavLauncherTeam/PojavLauncher/actions). If you want to build after launcher code changes, follow steps below.
Will be moved to **BUILDING.md**
### Java Runtime Environment (JRE)
- JRE for Android is [here](https://github.com/PojavLauncherTeam/openjdk-multiarch-jdk8u), also the build script [here](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch).
- Follow build instruction on build script [README.md](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch/blob/buildjre8/README.md).
- You can also get [CI auto builds](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch/actions).
- Spliting JRE and put to the launcher: **coming soon**.
# Minecraft versions worked in PojavLauncher 2.4.2
### LWJGL and GLFW
- **Coming soon**
<table>
<thead>
<tr>
<th></th>
<th align="center" colspan="7">Minecraft version</th>
</tr>
<tr>
<th>Android</th>
<th align="center">1.7.10</th>
<th align="center">1.8</th>
<th align="center">1.9</th>
<th align="center">1.10</th>
<th align="center">1.11</th>
<th align="center">1.12</th>
<th align="center">1.12.2</th>
</tr>
</thead>
<tbody>
<tr>
<td>5.x</td>
<td align="center"><b>Yes</b></td>
<td align="center"><b>Yes</b></td>
<td align="center"><b>Yes</b></td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">No</a></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">No</a></td>
</tr>
<tr>
<td>6.0</td>
<td align="center"><b>Yes</b></td>
<td align="center"><b>Yes</b></td>
<td align="center"><b>Yes</b></td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">No</a></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">No</a></td>
</tr>
</tbody>
<tbody>
<tr>
<td>7.x</td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">No</a></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">No</a></td>
</tr>
<tr>
<td>8.x</td>
<td align="center"><b>Yes</b></td>
<td align="center"><b>Yes</b></td>
<td align="center"><b>Yes</b></td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">Java8</a></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">Java8</a></td>
</tr>
</tbody>
<tbody>
<tr>
<td>9.0</td>
<td align="center">???</td>
<td align="center"><b>Yes</b></td>
<td align="center">???</td>
<td align="center">???</td>
<td align="center"><b>Yes</b></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">Java8</a></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">Java8</a></td>
</tr>
<tr>
<td>10.0</td>
<td align="center"><a href="https://github.com/khanhduytran0/PojavLauncher/issues/7#issue-586928527"><b>Yes</b></a></td>
<td align="center"><a href="https://github.com/khanhduytran0/PojavLauncher/issues/7#issue-586928527"><b>Yes</b></a></td>
<td align="center"><a href="https://github.com/khanhduytran0/PojavLauncher/issues/7#issue-586928527"><b>Yes</b></a></td>
<td align="center"><a href="https://github.com/khanhduytran0/PojavLauncher/issues/7#issue-586928527"><b>Yes</b></a></td>
<td align="center"><a href="https://github.com/khanhduytran0/PojavLauncher/issues/7#issue-586928527"><b>Yes</b></a></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">Java8</a></td>
<td align="center"><a href="https://stackoverflow.com/a/57861173">Java8</a></td>
</tr>
</tbody>
</table>
### The Launcher
- Because languages are auto added by Crowdin, so need to run language list generator before building. In this directory, run:
```
# On Linux, Mac OS:
chmod +x scripts/languagelist_updater.sh
bash scripts/languagelist_updater.sh
# On Windows:
scripts\languagelist_updater.bat
```
- Then, build use Android Studio.
## Current status
- [x] ~~OpenJDK 9 Mobile port: ARM32, ARM64, x86, x86_64.~~ Replaced by JRE8.
- [x] OpenJDK 8 Mobile port: ARM64, x86, x86_64
- [x] Mod installer headless
- [ ] Mod installer with GUI. Little run on `Caciocavallo` project.
- [x] OpenGL in OpenJDK environment
- [x] OpenAL (work on most devices)
- [x] Support Minecraft 1.12.2 and below. Used [lwjglx](https://github.com/PojavLauncherTeam/lwjglx), a LWJGL2 compatibility layer for LWJGL3.
- [x] Support Minecraft 1.13 and above. Used [GLFW stub](https://github.com/PojavLauncherTeam/lwjgl3-glfw-java).
- [ ] Game surface zooming.
- [x] New input pipe rewritten to native code to boost performance.
- [ ] More...
## License
- PojavLauncher is licensed under [GNU GPLv3](https://github.com/khanhduytran0/PojavLauncher/blob/master/LICENSE).
## Contributing
Contributions are welcome! We welcome any type of contribution, not only code. Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it.
## Credits & Third party components and their licenses
- [Boardwalk](https://github.com/zhuowei/Boardwalk) (JVM Launcher): Unknown License/[Apache License 2.0](https://github.com/zhuowei/Boardwalk/blob/master/LICENSE) or GNU GPLv2.
- Android Support Libraries: [Apache License 2.0](https://android.googlesource.com/platform/prebuilts/maven_repo/android/+/master/NOTICE.txt).
- [GL4ES](https://github.com/ptitSeb/gl4es): [MIT License](https://github.com/ptitSeb/gl4es/blob/master/LICENSE).<br>
- [OpenJDK](https://github.com/PojavLauncherTeam/openjdk-multiarch-jdk8u): [GNU GPLv2 License](https://openjdk.java.net/legal/gplv2+ce.html).<br>
- [LWJGL3](https://github.com/PojavLauncherTeam/lwjgl3): [BSD-3 License](https://github.com/LWJGL/lwjgl3/blob/master/LICENSE.md).
- [LWJGLX](https://github.com/PojavLauncherTeam/lwjglx) (LWJGL2 API compatibility layer for LWJGL3): unknown license.<br>
- [pro-grade](https://github.com/pro-grade/pro-grade) (Java sandboxing security manager): [Apache License 2.0](https://github.com/pro-grade/pro-grade/blob/master/LICENSE.txt).
# OptiFine worked in PojavLauncher 2.4.2
|Android version | ??? |???|???|Tested in Android 10| ??? |
|-----------------|------|---|---|-----|-----|
|Minecraft version|1.7.10|1.8|1.9| 1.10| 1.11|
|OptiFine |Any versions|???|???|OptiFine_1.10_HD_U_H5| ??? |
|Status |Show splash screen then crash|???|???|[Worked](https://github.com/khanhduytran0/PojavLauncher/issues/27#issuecomment-607037705)|???
-153
View File
@@ -1,153 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app_pojavlauncher" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app_pojavlauncher" />
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" value="3.5.3" />
<option name="LAST_KNOWN_AGP_VERSION" value="3.5.3" />
</configuration>
</facet>
<facet type="native-android-gradle" name="Native-Android-Gradle">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug-x86" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni/awt_xawt" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.cxx" />
<excludeFolder url="file://$MODULE_DIR$/.externalNativeBuild" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: __local_aars__:C.\Users\Admin\AndroidStudioProjects\PojavLauncher\app_pojavlauncher\libs\ExagearApacheCommons.jar:unspecified@jar" level="project" />
<orderEntry type="library" name="Gradle: __local_aars__:C.\Users\Admin\AndroidStudioProjects\PojavLauncher\app_pojavlauncher\libs\gson-2.8.6.jar:unspecified@jar" level="project" />
<orderEntry type="library" name="Gradle: __local_aars__:C.\Users\Admin\AndroidStudioProjects\PojavLauncher\app_pojavlauncher\libs\PointerCapture26Wrapper.jar:unspecified@jar" level="project" />
<orderEntry type="library" name="Gradle: javax.annotation:javax.annotation-api:1.3.2@jar" level="project" />
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.14@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.collection:collection:1.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-common:2.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.arch.core:core-common:2.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.annotation:annotation:1.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: org.tukaani:xz:1.8@jar" level="project" />
<orderEntry type="library" name="Gradle: net.objecthunter:exp4j:0.4.8@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-v4:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-preference-v14:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.preference:preference:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.material:material:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.browser:browser:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.media:media:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.fragment:fragment:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.recyclerview:recyclerview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable-animated:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-ui:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-utils:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.transition:transition:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.loader:loader:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.viewpager:viewpager:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.coordinatorlayout:coordinatorlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.drawerlayout:drawerlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.slidingpanelayout:slidingpanelayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.customview:customview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.swiperefreshlayout:swiperefreshlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.asynclayoutinflater:asynclayoutinflater:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.core:core:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.versionedparcelable:versionedparcelable:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cursoradapter:cursoradapter:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cardview:cardview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.interpolator:interpolator:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-runtime:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.documentfile:documentfile:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.print:print:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-viewmodel:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata-core:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.arch.core:core-runtime:2.0.0@aar" level="project" />
</component>
</module>
-88
View File
@@ -1,88 +0,0 @@
apply plugin: 'com.android.application'
def getDate() {
return new Date().format('yyyyMMdd')
}
android {
compileSdkVersion 29
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
abortOnError false
}
signingConfigs {
customDebug {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
defaultConfig {
applicationId "net.kdt.pojavlaunch"
minSdkVersion 21
targetSdkVersion 29
versionCode 156239
versionName "3.3.1_rel_" + getDate()
multiDexEnabled true //important
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.customDebug
}
release {
// Don't set to true or java.awt will be a.a or something similar.
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// defaultConfig already set
// multiDexEnabled = true
// debuggable = true
}
}
externalNativeBuild {
ndkBuild {
path file('src/main/jni/Android.mk')
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '30.0.2'
}
dependencies {
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'commons-codec:commons-codec:1.14'
// implementation 'com.wu-man:android-bsf-api:3.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.browser:browser:1.3.0'
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
// implementation 'com.intuit.sdp:sdp-android:1.0.5'
// implementation 'com.intuit.ssp:ssp-android:1.0.5'
implementation 'org.tukaani:xz:1.8'
implementation 'net.objecthunter:exp4j:0.4.8'
// implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
-18
View File
@@ -1,18 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\tools\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.kdt.pojavlaunch">
<uses-feature android:glEsVersion="0x00020000"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:name=".PojavApplication"
android:theme="@style/AppTheme"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:roundIcon="@drawable/ic_launcher"
android:resizeableActivity="true"
android:requestLegacyExternalStorage="true">
<meta-data
android:name="android.max_aspect"
android:value="ratio_float"/>
<activity
android:launchMode="singleTop"
android:screenOrientation="sensorLandscape"
android:label="@string/app_short_name"
android:name=".PojavLoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="ms-xal-00000000402b5328"
android:host="auth"/>
</intent-filter>
</activity>
<activity
android:theme="@style/MenuDialog"
android:screenOrientation="sensorLandscape"
android:name=".FatalErrorActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
<activity
android:screenOrientation="sensorLandscape"
android:name=".MCLauncherActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
<activity
android:screenOrientation="sensorLandscape"
android:name=".PojavLauncherActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
<activity
android:screenOrientation="sensorLandscape"
android:name=".JavaGUILauncherActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
<activity
android:screenOrientation="sensorLandscape"
android:name=".CustomControlsActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
<activity
android:launchMode="standard"
android:multiprocess="true"
android:screenOrientation="sensorLandscape"
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
<activity
android:screenOrientation="sensorLandscape"
android:name=".prefs.LauncherPreferenceActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
</application>
</manifest>
@@ -1,20 +0,0 @@
%s (Minecraft Java Launcher for Android), version %s by Tran Khanh Duy (based on "Boardwalk" app)<br>
* License:<br>
• This application is licensed under <a href="https://github.com/khanhduytran0/PojavLauncher/blob/master/LICENSE">GNU GPLv3</a>.<br>
* Third party components and their licenses:<br>
• Apache Commons Compress (unknown or Apache License 2.0).<br>
• exp4j: <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.<br>
• GL4ES: <a href="https://github.com/ptitSeb/gl4es/blob/master/LICENSE">MIT License</a>.<br>
• LegacyLauncher: (unknown license).<br>
• OpenJDK: <a href="https://openjdk.java.net/legal/gplv2+ce.html">GNU GPLv2 License</a>.<br>
• LWJGL: <a href="http://legacy.lwjgl.org/license.php.html">LWJGL 2's License</a>.<br><br>
• pro-gradle: <a href="https://github.com/pro-grade/pro-grade/blob/master/LICENSE.txt">Apache License 2.0</a>.<br>
* Notes:<br>
- This app is under development and will not be stable.<br>
- This app is not affiliated with Minecraft, Mojang or Microsoft.<br><br>
* Translators can be found at <a href="https://crowdin.com/project/pojavlauncher">Crowdin</a>
@@ -1,3 +0,0 @@
From https://github.com/xfl03/ForgeInstallerHeadless
No changes on source code.
@@ -1 +0,0 @@
20210116:2
@@ -1 +0,0 @@
20201127:1
@@ -1 +0,0 @@
20210117
@@ -1,16 +0,0 @@
// PojavLauncher JRE Sandbox
// DO NOT EDIT THIS FILE WITHOUT KNOWLEDGE!
// This file is important to protect you against viruses/malwares that could be come from unknown Java Programs (run on mod install) or a mod.
priority "grant";
grant {
permission java.io.FilePermission "${java.io.tmpdir}/-", "read, write, delete";
permission java.io.FilePermission "${user.home}/-", "read, write, delete";
};
deny {
permission java.io.FilePermission "${pojav.path.private.account}/-", "read, write, delete";
permission java.io.FilePermission "<<ALL FILES>>", "write, delete, execute";
};
@@ -1,92 +0,0 @@
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

@@ -1,34 +0,0 @@
values-af-rZA
values-ar-rSA
values-ba-rRU
values-ca-rES
values-cs-rCZ
values-da-rDK
values-de-rDE
values-el-rGR
values-en-rGB
values-en-rUS
values-es-rES
values-fi-rFI
values-fr-rFR
values-hu-rHU
values-in-rID
values-it-rIT
values-iw-rIL
values-ja-rJP
values-kk-rKZ
values-ko-rKR
values-nl-rNL
values-no-rNO
values-pl-rPL
values-pt-rBR
values-pt-rPT
values-ro-rRO
values-ru-rRU
values-sr-rSP
values-sv-rSE
values-tr-rTR
values-uk-rUA
values-vi-rVN
values-zh-rCN
values-zh-rTW
@@ -1,9 +0,0 @@
{
"profiles": {
"(Default)": {
"name": "(Default)",
"lastVersionId": "Unknown"
}
},
"selectedProfile": "(Default)"
}
@@ -1,96 +0,0 @@
invertYMouse:false
mouseSensitivity:0.5
fov:0.0
gamma:0.5070422
saturation:0.0
renderDistance:2
guiScale:3
particles:1
bobView:false
anaglyph3d:false
advancedOpengl:false
maxFps:260
fboEnable:true
difficulty:2
fancyGraphics:false
ao:0
clouds:true
resourcePacks:[]
lastServer:
lang:en_US
chatVisibility:0
chatColors:true
chatLinks:true
chatLinksPrompt:true
chatOpacity:1.0
snooperEnabled:true
fullscreen:true
enableVsync:false
hideServerAddress:false
advancedItemTooltips:false
pauseOnLostFocus:true
showCape:true
touchscreen:false
overrideWidth:0
overrideHeight:0
heldItemTooltips:true
chatHeightFocused:1.0
chatHeightUnfocused:0.44366196
chatScale:1.0
chatWidth:1.0
showInventoryAchievementHint:false
mipmapLevels:0
anisotropicFiltering:1
streamBytesPerPixel:0.5
streamMicVolume:1.0
streamSystemVolume:1.0
streamKbps:0.5412844
streamFps:0.31690142
streamCompression:1
streamSendMetadata:true
streamPreferredServer:
streamChatEnabled:0
streamChatUserFilter:0
streamMicToggleBehavior:0
forceUnicodeFont:false
key_key.attack:-100
key_key.use:-99
key_key.forward:17
key_key.left:30
key_key.back:31
key_key.right:32
key_key.jump:57
key_key.sneak:42
key_key.drop:16
key_key.inventory:18
key_key.chat:20
key_key.playerlist:15
key_key.pickItem:-98
key_key.command:53
key_key.screenshot:60
key_key.togglePerspective:63
key_key.smoothCamera:0
key_key.sprint:29
key_key.streamStartStop:64
key_key.streamPauseUnpause:65
key_key.streamCommercial:0
key_key.streamToggleMic:0
key_key.fullscreen:87
key_key.hotbar.1:2
key_key.hotbar.2:3
key_key.hotbar.3:4
key_key.hotbar.4:5
key_key.hotbar.5:6
key_key.hotbar.6:7
key_key.hotbar.7:8
key_key.hotbar.8:9
key_key.hotbar.9:10
soundCategory_master:1.0
soundCategory_music:1.0
soundCategory_record:1.0
soundCategory_weather:1.0
soundCategory_block:1.0
soundCategory_hostile:1.0
soundCategory_neutral:1.0
soundCategory_player:1.0
soundCategory_ambient:1.0
@@ -1,120 +0,0 @@
/*
* Copyright (C) 2012 Paul Burke
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ipaulpro.afilechooser;
import android.content.*;
import android.view.*;
import android.widget.*;
import java.io.*;
import java.util.*;
import net.kdt.pojavlaunch.*;
/**
* List adapter for Files.
*
* @version 2013-12-11
* @author paulburke (ipaulpro)
*
* @addDate 2018-08-08
* @addToMyProject khanhduy032
*/
public class FileListAdapter extends BaseAdapter {
private final static int ICON_FOLDER = R.drawable.ic_folder;
private final static int ICON_FILE = R.drawable.ic_file;
private final LayoutInflater mInflater;
private List<File> mData = new ArrayList<File>();
public FileListAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public void add(File file) {
mData.add(file);
notifyDataSetChanged();
}
public void remove(File file) {
mData.remove(file);
notifyDataSetChanged();
}
public void insert(File file, int index) {
mData.add(index, file);
notifyDataSetChanged();
}
public void clear() {
mData.clear();
notifyDataSetChanged();
}
@Override
public File getItem(int position) {
return mData.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public int getCount() {
return mData.size();
}
public List<File> getListItems() {
return mData;
}
/**
* Set the list items without notifying on the clear. This prevents loss of
* scroll position.
*
* @param data
*/
public void setListItems(List<File> data) {
mData = data;
notifyDataSetChanged();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null)
row = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
TextView view = (TextView) row;
// Get the file at the current position
final File file = getItem(position);
// Set the TextView as the file name
view.setText(file.getName());
// If the item is not a directory, use the file icon
int icon = file.isDirectory() ? ICON_FOLDER : ICON_FILE;
view.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
return row;
}
}
@@ -1,103 +0,0 @@
package com.kdt.mcgui;
import android.content.*;
import android.graphics.*;
import android.graphics.drawable.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import android.view.View.*;
import net.kdt.pojavlaunch.*;
public class MineButton extends Button
{
private ColorDrawable left = new ColorDrawable(Color.parseColor("#80000000"));
private ColorDrawable top = new ColorDrawable(Color.parseColor("#64FC20"));
private ColorDrawable right = new ColorDrawable(Color.parseColor("#40000000"));
private ColorDrawable bottom = new ColorDrawable(Color.parseColor("#80000000"));
private ColorDrawable bgNormal = new ColorDrawable(Color.parseColor("#36b030"));
private ColorDrawable leftFocus = new ColorDrawable(Color.parseColor("#C2000000"));
private ColorDrawable topFocus = new ColorDrawable(Color.parseColor("#80313131"));
private ColorDrawable rightFocus = new ColorDrawable(Color.parseColor("#C2000000"));
private ColorDrawable bottomFocus = new ColorDrawable(Color.parseColor("#C2000000"));
private ColorDrawable bgFocus = new ColorDrawable(Color.parseColor("#313131"));
private boolean isUp = true;
private Drawable[] DrawableArray = new Drawable[]{
top,
left,
right,
bottom,
bgNormal
};
private Drawable[] DrawableArrayFocus = new Drawable[]{
topFocus,
leftFocus,
rightFocus,
bottomFocus,
bgFocus
};
private LayerDrawable layerdrawable, layerdrawablefocus;
public MineButton(Context ctx) {
this(ctx, null);
}
public MineButton(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
init();
}
public void init() {
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
layerdrawable = new LayerDrawable(DrawableArray);
layerdrawable.setLayerInset(0, 0, 0, 0, 0); // top
layerdrawable.setLayerInset(1, 0, 8, getWidth() - 8,0); // left
layerdrawable.setLayerInset(2, getWidth() - 8, 8, 0, 0); // right
layerdrawable.setLayerInset(3, 0, getHeight() - 8, 0, 0); // bottom
layerdrawable.setLayerInset(4, 8, 8, 8, 8); // bg
layerdrawablefocus = new LayerDrawable(DrawableArrayFocus);
layerdrawablefocus.setLayerInset(0, 0, 0, 0, 0); // top
layerdrawablefocus.setLayerInset(1, 0, 8, getWidth() - 8,0); // left
layerdrawablefocus.setLayerInset(2, getWidth() - 8, 8, 0, 0); // right
layerdrawablefocus.setLayerInset(3, 0, getHeight() - 8, 0, 0); // bottom
layerdrawablefocus.setLayerInset(4, 8, 8, 8, 8); // bg
setBackgroundDrawable(layerdrawable);
setTextColor(Color.WHITE);
setPadding(10, 10, 10, 10);
//setOnTouchListener(null);
}
});
setTypeface(Typeface.createFromAsset(getContext().getAssets(), "font/NotoSans-Bold.ttf"));
}
@Override
public void setEnabled(boolean enabled)
{
super.setEnabled(enabled);
setBackgroundDrawable(enabled ? layerdrawable : layerdrawablefocus);
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
if ((event.getAction() == event.ACTION_UP) && !isUp && isEnabled()) {
setBackgroundDrawable(layerdrawable);
isUp = true;
} else if (event.getAction() == event.ACTION_DOWN && isUp) {
setBackgroundDrawable(layerdrawablefocus);
isUp = false;
}
return super.onTouchEvent(event);
}
}
@@ -1,29 +0,0 @@
package com.kdt.mcgui;
import android.content.*;
import android.util.*;
import android.widget.*;
import net.kdt.pojavlaunch.*;
import android.graphics.*;
public class MineEditText extends com.google.android.material.textfield.TextInputEditText
{
public MineEditText(Context ctx)
{
super(ctx);
init();
}
public MineEditText(Context ctx, AttributeSet attrs)
{
super(ctx, attrs);
init();
}
public void init()
{
// setBackgroundResource(R.drawable.border_edittext);
setBackgroundColor(Color.parseColor("#131313"));
setPadding(5, 5, 5, 5);
}
}
@@ -1,131 +0,0 @@
package com.kdt.mcgui.app;
import android.content.pm.*;
import android.os.*;
import androidx.appcompat.app.*;
import android.view.*;
import android.widget.*;
import net.kdt.pojavlaunch.*;
public class MineActivity extends BaseActivity implements View.OnClickListener
{
private int topId = 150001;
private boolean showBeforeView = true;
private ImageButton menu;
private LinearLayout content, undertop;
private LayoutInflater li;
@Override
protected void onCreate(Bundle savedInstanceState) {
this.onCreate(savedInstanceState, true);
}
protected void onCreate(Bundle savedInstanceState, boolean showBeforeView) {
super.onCreate(savedInstanceState);
this.showBeforeView = showBeforeView;
if (showBeforeView) {
mcUIInit();
}
}
private void mcUIInit() {
RelativeLayout root = new RelativeLayout(this);
LinearLayout top = new LinearLayout(this);
top.setId(topId);
content = new LinearLayout(this);
RelativeLayout btm = new RelativeLayout(this);
li = LayoutInflater.from(this);
li.inflate(R.layout.top_bar, top, true);
li.inflate(R.layout.bottom_bar, btm, true);
FontChanger.changeFonts(btm);
// replaceFont((TextView) top.findViewById(R.id.topbar_navmenu_changelang));
Spinner changeLangSpinner = ((Spinner) top.findViewById(R.id.topbar_navmenu_changelang));
// Locale l = getResources().getConfiguration().locale;
RelativeLayout.LayoutParams conLay = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
conLay.addRule(root.BELOW, topId);
conLay.bottomMargin = 66;
content.setLayoutParams(conLay);
root.addView(top, new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
root.addView(content);
root.addView(btm);
super.setContentView(root);
TextView ver = (TextView) findViewById(R.id.bottombar_version_view);
menu = (ImageButton) findViewById(R.id.topbar_navmenu_icon);
setMenuVisible(false);
undertop = (LinearLayout) findViewById(R.id.topbar_undertop_view);
try {
ver.setText(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
} catch (PackageManager.NameNotFoundException e) {} // Never happend!
setClick(R.id.topbar_help_text);
setClick(R.id.topbar_logo);
setClick(R.id.bottombar_author_logo);
}
@Override
public void setContentView(int resource)
{
if (!showBeforeView) {
mcUIInit();
}
li.inflate(resource, content, true);
FontChanger.changeFonts(content);
}
@Override
public void setContentView(View view)
{
if (!showBeforeView) {
mcUIInit();
}
content.addView(view);
if (view instanceof ViewGroup) {
FontChanger.changeFonts((ViewGroup) view);
}
}
@Override
public void onClick(View view)
{
switch (view.getId()) {
case R.id.topbar_help_text: Tools.openURL(this, "https://www.minecraft.net/help");
break;
case R.id.topbar_logo: Tools.openURL(this, "https://github.com/PojavLauncherTeam/PojavLauncher");
break;
case R.id.bottombar_author_logo: Tools.openURL(this, "https://github.com/PojavLauncherTeam");
break;
}
}
public void setUndertopView(View view) {
if (undertop.getChildCount() > 0) {
undertop.removeAllViews();
}
undertop.addView(view);
}
public void setMenuVisible(boolean value) {
menu.setVisibility(value ? View.VISIBLE : View.GONE);
}
public void setClick(int id) {
findViewById(id).setOnClickListener(this);
}
}
@@ -1,26 +0,0 @@
package com.kdt.mcgui.app;
import androidx.appcompat.app.*;
import android.os.*;
import androidx.core.app.*;
import android.widget.*;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
public class MinePrefActivity extends MineActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout fl = new FrameLayout(this);
fl.setId(65535);
setContentView(fl);
}
public void setFragment(Fragment fm) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(65535, fm);
ft.commit();
}
}
@@ -1,491 +0,0 @@
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kdt.mcgui.pref;
import android.content.*;
import android.content.res.*;
import android.os.*;
import androidx.preference.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import android.widget.SeekBar.*;
import android.view.View.BaseSavedState;
import net.kdt.pojavlaunch.R;
/**
* Preference based on android.preference.SeekBarPreference but uses support preference as a base
* . It contains a title and a {@link SeekBar} and an optional SeekBar value {@link TextView}.
* The actual preference layout is customizable by setting {@code android:layout} on the
* preference widget layout or {@code seekBarPreferenceStyle} attribute.
*
* <p>The {@link SeekBar} within the preference can be defined adjustable or not by setting {@code
* adjustable} attribute. If adjustable, the preference will be responsive to DPAD left/right keys.
* Otherwise, it skips those keys.
*
* <p>The {@link SeekBar} value view can be shown or disabled by setting {@code showSeekBarValue}
* attribute to true or false, respectively.
*
* <p>Other {@link SeekBar} specific attributes (e.g. {@code title, summary, defaultValue, min,
* max})
* can be set directly on the preference widget layout.
*/
public class MineSeekBarPref extends Preference {
private static final String TAG = "SeekBarPreference";
@SuppressWarnings("WeakerAccess") /* synthetic access */
int mSeekBarValue;
@SuppressWarnings("WeakerAccess") /* synthetic access */
int mMin;
private int mMax;
private int mSeekBarIncrement;
@SuppressWarnings("WeakerAccess") /* synthetic access */
boolean mTrackingTouch;
@SuppressWarnings("WeakerAccess") /* synthetic access */
SeekBar mSeekBar;
private TextView mSeekBarValueTextView;
// Whether the SeekBar should respond to the left/right keys
@SuppressWarnings("WeakerAccess") /* synthetic access */
boolean mAdjustable;
// Whether to show the SeekBar value TextView next to the bar
private boolean mShowSeekBarValue;
// Whether the SeekBarPreference should continuously save the Seekbar value while it is being
// dragged.
@SuppressWarnings("WeakerAccess") /* synthetic access */
boolean mUpdatesContinuously;
/**
* Listener reacting to the {@link SeekBar} changing value by the user
*/
private OnSeekBarChangeListener mSeekBarChangeListener = new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser && (mUpdatesContinuously || !mTrackingTouch)) {
syncValueInternal(seekBar);
} else {
// We always want to update the text while the seekbar is being dragged
updateLabelValue(progress + mMin);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
mTrackingTouch = true;
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
mTrackingTouch = false;
if (seekBar.getProgress() + mMin != mSeekBarValue) {
syncValueInternal(seekBar);
}
}
};
/**
* Listener reacting to the user pressing DPAD left/right keys if {@code
* adjustable} attribute is set to true; it transfers the key presses to the {@link SeekBar}
* to be handled accordingly.
*/
private View.OnKeyListener mSeekBarKeyListener = new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() != KeyEvent.ACTION_DOWN) {
return false;
}
if (!mAdjustable && (keyCode == KeyEvent.KEYCODE_DPAD_LEFT
|| keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) {
// Right or left keys are pressed when in non-adjustable mode; Skip the keys.
return false;
}
// We don't want to propagate the click keys down to the SeekBar view since it will
// create the ripple effect for the thumb.
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
return false;
}
if (mSeekBar == null) {
Log.e(TAG, "SeekBar view is null and hence cannot be adjusted.");
return false;
}
return mSeekBar.onKeyDown(keyCode, event);
}
};
public MineSeekBarPref(
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.SeekBarPreference, defStyleAttr, defStyleRes);
// The ordering of these two statements are important. If we want to set max first, we need
// to perform the same steps by changing min/max to max/min as following:
// mMax = a.getInt(...) and setMin(...).
mMin = a.getInt(R.styleable.SeekBarPreference_min, 0);
setMax(a.getInt(R.styleable.SeekBarPreference_android_max, 100));
setSeekBarIncrement(a.getInt(R.styleable.SeekBarPreference_seekBarIncrement, 0));
mAdjustable = a.getBoolean(R.styleable.SeekBarPreference_adjustable, true);
mShowSeekBarValue = a.getBoolean(R.styleable.SeekBarPreference_showSeekBarValue, false);
// mUpdatesContinuously = a.getBoolean(R.styleable.SeekBarPreference_updatesContinuously, false);
a.recycle();
}
public MineSeekBarPref(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public MineSeekBarPref(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.seekBarPreferenceStyle);
}
public MineSeekBarPref(Context context) {
this(context, null);
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
view.itemView.setOnKeyListener(mSeekBarKeyListener);
mSeekBar = (SeekBar) view.findViewById(R.id.seekbar);
mSeekBarValueTextView = (TextView) view.findViewById(R.id.seekbar_value);
mSeekBarValueTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
if (mShowSeekBarValue) {
mSeekBarValueTextView.setVisibility(View.VISIBLE);
} else {
mSeekBarValueTextView.setVisibility(View.GONE);
mSeekBarValueTextView = null;
}
if (mSeekBar == null) {
Log.e(TAG, "SeekBar view is null in onBindViewHolder.");
return;
}
mSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);
mSeekBar.setMax(mMax - mMin);
// If the increment is not zero, use that. Otherwise, use the default mKeyProgressIncrement
// in AbsSeekBar when it's zero. This default increment value is set by AbsSeekBar
// after calling setMax. That's why it's important to call setKeyProgressIncrement after
// calling setMax() since setMax() can change the increment value.
if (mSeekBarIncrement != 0) {
mSeekBar.setKeyProgressIncrement(mSeekBarIncrement);
} else {
mSeekBarIncrement = mSeekBar.getKeyProgressIncrement();
}
mSeekBar.setProgress(mSeekBarValue - mMin);
updateLabelValue(mSeekBarValue);
mSeekBar.setEnabled(isEnabled());
}
// @Override
protected void onSetInitialValue(Object defaultValue) {
if (defaultValue == null) {
defaultValue = 0;
}
setValue(getPersistedInt((Integer) defaultValue));
}
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
return a.getInt(index, 0);
}
/**
* Gets the lower bound set on the {@link SeekBar}.
*
* @return The lower bound set
*/
public int getMin() {
return mMin;
}
/**
* Sets the lower bound on the {@link SeekBar}.
*
* @param min The lower bound to set
*/
public void setMin(int min) {
if (min > mMax) {
min = mMax;
}
if (min != mMin) {
mMin = min;
notifyChanged();
}
}
/**
* Returns the amount of increment change via each arrow key click. This value is derived from
* user's specified increment value if it's not zero. Otherwise, the default value is picked
* from the default mKeyProgressIncrement value in {@link android.widget.AbsSeekBar}.
*
* @return The amount of increment on the {@link SeekBar} performed after each user's arrow
* key press
*/
public final int getSeekBarIncrement() {
return mSeekBarIncrement;
}
/**
* Sets the increment amount on the {@link SeekBar} for each arrow key press.
*
* @param seekBarIncrement The amount to increment or decrement when the user presses an
* arrow key.
*/
public final void setSeekBarIncrement(int seekBarIncrement) {
if (seekBarIncrement != mSeekBarIncrement) {
mSeekBarIncrement = Math.min(mMax - mMin, Math.abs(seekBarIncrement));
notifyChanged();
}
}
/**
* Gets the upper bound set on the {@link SeekBar}.
*
* @return The upper bound set
*/
public int getMax() {
return mMax;
}
/**
* Sets the upper bound on the {@link SeekBar}.
*
* @param max The upper bound to set
*/
public final void setMax(int max) {
if (max < mMin) {
max = mMin;
}
if (max != mMax) {
mMax = max;
notifyChanged();
}
}
/**
* Gets whether the {@link SeekBar} should respond to the left/right keys.
*
* @return Whether the {@link SeekBar} should respond to the left/right keys
*/
public boolean isAdjustable() {
return mAdjustable;
}
/**
* Sets whether the {@link SeekBar} should respond to the left/right keys.
*
* @param adjustable Whether the {@link SeekBar} should respond to the left/right keys
*/
public void setAdjustable(boolean adjustable) {
mAdjustable = adjustable;
}
/**
* Gets whether the {@link SeekBarPreference} should continuously save the {@link SeekBar} value
* while it is being dragged. Note that when the value is true,
* {@link Preference.OnPreferenceChangeListener} will be called continuously as well.
*
* @return Whether the {@link SeekBarPreference} should continuously save the {@link SeekBar}
* value while it is being dragged
* @see #setUpdatesContinuously(boolean)
*/
public boolean getUpdatesContinuously() {
return mUpdatesContinuously;
}
/**
* Sets whether the {@link SeekBarPreference} should continuously save the {@link SeekBar} value
* while it is being dragged.
*
* @param updatesContinuously Whether the {@link SeekBarPreference} should continuously save
* the {@link SeekBar} value while it is being dragged
* @see #getUpdatesContinuously()
*/
public void setUpdatesContinuously(boolean updatesContinuously) {
mUpdatesContinuously = updatesContinuously;
}
/**
* Gets whether the current {@link SeekBar} value is displayed to the user.
*
* @return Whether the current {@link SeekBar} value is displayed to the user
* @see #setShowSeekBarValue(boolean)
*/
public boolean getShowSeekBarValue() {
return mShowSeekBarValue;
}
/**
* Sets whether the current {@link SeekBar} value is displayed to the user.
*
* @param showSeekBarValue Whether the current {@link SeekBar} value is displayed to the user
* @see #getShowSeekBarValue()
*/
public void setShowSeekBarValue(boolean showSeekBarValue) {
mShowSeekBarValue = showSeekBarValue;
notifyChanged();
}
private void setValueInternal(int seekBarValue, boolean notifyChanged) {
if (seekBarValue < mMin) {
seekBarValue = mMin;
}
if (seekBarValue > mMax) {
seekBarValue = mMax;
}
if (seekBarValue != mSeekBarValue) {
mSeekBarValue = seekBarValue;
updateLabelValue(mSeekBarValue);
persistInt(seekBarValue);
if (notifyChanged) {
notifyChanged();
}
}
}
/**
* Gets the current progress of the {@link SeekBar}.
*
* @return The current progress of the {@link SeekBar}
*/
public int getValue() {
return mSeekBarValue;
}
/**
* Sets the current progress of the {@link SeekBar}.
*
* @param seekBarValue The current progress of the {@link SeekBar}
*/
public void setValue(int seekBarValue) {
setValueInternal(seekBarValue, true);
}
/**
* Persist the {@link SeekBar}'s SeekBar value if callChangeListener returns true, otherwise
* set the {@link SeekBar}'s value to the stored value.
*/
@SuppressWarnings("WeakerAccess") /* synthetic access */
void syncValueInternal(SeekBar seekBar) {
int seekBarValue = mMin + seekBar.getProgress();
if (seekBarValue != mSeekBarValue) {
if (callChangeListener(seekBarValue)) {
setValueInternal(seekBarValue, false);
} else {
seekBar.setProgress(mSeekBarValue - mMin);
updateLabelValue(mSeekBarValue);
}
}
}
/**
* Attempts to update the TextView label that displays the current value.
*
* @param value the value to display next to the {@link SeekBar}
*/
@SuppressWarnings("WeakerAccess") /* synthetic access */
void updateLabelValue(int value) {
if (mSeekBarValueTextView != null) {
mSeekBarValueTextView.setText(String.valueOf(value));
}
}
@Override
protected Parcelable onSaveInstanceState() {
final Parcelable superState = super.onSaveInstanceState();
if (isPersistent()) {
// No need to save instance state since it's persistent
return superState;
}
// Save the instance state
final SavedState myState = new SavedState(superState);
myState.mSeekBarValue = mSeekBarValue;
myState.mMin = mMin;
myState.mMax = mMax;
return myState;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (!state.getClass().equals(SavedState.class)) {
// Didn't save state for us in onSaveInstanceState
super.onRestoreInstanceState(state);
return;
}
// Restore the instance state
SavedState myState = (SavedState) state;
super.onRestoreInstanceState(myState.getSuperState());
mSeekBarValue = myState.mSeekBarValue;
mMin = myState.mMin;
mMax = myState.mMax;
notifyChanged();
}
/**
* SavedState, a subclass of {@link BaseSavedState}, will store the state of this preference.
*
* <p>It is important to always call through to super methods.
*/
private static class SavedState extends BaseSavedState {
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
int mSeekBarValue;
int mMin;
int mMax;
SavedState(Parcel source) {
super(source);
// Restore the click counter
mSeekBarValue = source.readInt();
mMin = source.readInt();
mMax = source.readInt();
}
SavedState(Parcelable superState) {
super(superState);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
// Save the click counter
dest.writeInt(mSeekBarValue);
dest.writeInt(mMin);
dest.writeInt(mMax);
}
}
}
@@ -1,173 +0,0 @@
package com.kdt.pickafile;
import androidx.appcompat.app.*;
import android.content.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import android.widget.AdapterView.*;
import com.ipaulpro.afilechooser.*;
import java.io.*;
import java.util.*;
import net.kdt.pojavlaunch.*;
import android.os.*;
public class FileListView extends LinearLayout
{
//For list view:
private String fullPath;
private ListView mainLv;
private Context context;
//For File selected listener:
private FileSelectedListener listener;
private AlertDialog build;
private String lockPath = "/";
//For filtering by file types:
private final String[] fileSuffixes;
public FileListView(AlertDialog build) {
this(build.getContext(), null, new String[0]);
this.build = build;
}
public FileListView(AlertDialog build, String fileSuffix) {
this(build.getContext(), null, new String[]{fileSuffix});
this.build = build;
}
public FileListView(AlertDialog build, String[] fileSuffixes){
this(build.getContext(), null, fileSuffixes);
this.build = build;
}
public FileListView(Context context, AttributeSet attrs, String[] fileSuffixes) {
this(context, attrs, 0, fileSuffixes);
}
public FileListView(Context context, AttributeSet attrs, int defStyle, String[] fileSuffixes) {
super(context, attrs, defStyle);
this.fileSuffixes = fileSuffixes;
init(context);
}
public void init(final Context context) {
//Main setup:
this.context = context;
LayoutParams layParam = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
setOrientation(VERTICAL);
mainLv = new ListView(context);
//listFileAt(Environment.getExternalStorageDirectory().getPath());
mainLv.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4)
{
// TODO: Implement this method
File mainFile = new File(p1.getItemAtPosition(p3).toString());
if (p3 == 0 && !lockPath.equals(fullPath)) {
parentDir();
} else {
listFileAt(mainFile.getAbsolutePath());
}
}
});
mainLv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
@Override
public boolean onItemLongClick(AdapterView<?> p1, View p2, int p3, long p4)
{
// TODO: Implement this method
File mainFile = new File(p1.getItemAtPosition(p3).toString());
if (mainFile.isFile()) {
listener.onFileLongClick(mainFile, mainFile.getAbsolutePath());
return true;
}
return false;
}
});
addView(mainLv, layParam);
listFileAt(Environment.getExternalStorageDirectory().getAbsolutePath());
}
public void setFileSelectedListener(FileSelectedListener listener)
{
this.listener = listener;
}
public void listFileAt(final String path)
{
try{
final File mainPath = new File(path);
if(mainPath.exists()){
if(mainPath.isDirectory()){
fullPath = path;
File[] listFile = mainPath.listFiles();
FileListAdapter fileAdapter = new FileListAdapter(context);
if(!path.equals(lockPath)){
//fileAdapter.add(new File(path, "Path=\""+path+"\".noEquals(homePath=\""+homePath+"\")"));
fileAdapter.add(new File(path, ".."));
}
if(listFile.length != 0){
Arrays.sort(listFile, new SortFileName());
if(fileSuffixes.length > 0){ //Meaning we want only specific files
for(File file : listFile){
if(file.isDirectory()){
fileAdapter.add(file);
continue;
}
for(String suffix : fileSuffixes){
if(file.getName().endsWith("." + suffix)){
fileAdapter.add(file);
break;
}
}
}
}else{ //We get every file
for(File file : listFile){
fileAdapter.add(file);
}
}
}
mainLv.setAdapter(fileAdapter);
if (build != null) build.setTitle(new File(path).getName());
} else {
listener.onFileSelected(mainPath, path);
}
} else {
Toast.makeText(context, "This folder (or file) doesn't exist", Toast.LENGTH_SHORT).show();
refreshPath();
}
} catch (Exception e){
Tools.showError(context, e);
}
}
public String getFullPath(){
return fullPath;
}
public void refreshPath() {
listFileAt(getFullPath());
}
public void parentDir() {
File pathFile = new File(fullPath);
if(!pathFile.getAbsolutePath().equals("/")){
listFileAt(pathFile.getParent());
}
}
public void lockPathAt(String path) {
lockPath = path;
listFileAt(path);
}
}
@@ -1,9 +0,0 @@
package com.kdt.pickafile;
import java.io.File;
public abstract class FileSelectedListener
{
public abstract void onFileSelected(File file, String path);
public void onFileLongClick(File file, String path) {}
}
@@ -1,13 +0,0 @@
package com.kdt.pickafile;
import java.io.*;
import java.util.*;
public class SortFileName implements Comparator<File>
{
@Override
public int compare(File f1, File f2) {
return f1.getName().compareToIgnoreCase(f2.getName());
}
}
@@ -1,7 +0,0 @@
package com.oracle.dalvik;
public final class VMLauncher {
private VMLauncher() {
}
public static native int launchJVM(String[] args);
}
@@ -1,107 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.*;
import android.graphics.*;
import android.text.*;
import android.util.*;
import android.view.*;
import java.util.*;
import net.kdt.pojavlaunch.utils.*;
import org.lwjgl.glfw.*;
public class AWTCanvasView extends TextureView implements TextureView.SurfaceTextureListener, Runnable {
private int mWidth, mHeight;
private boolean mIsDestroyed = false;
private TextPaint fpsPaint;
private boolean attached = false;
// Temporary count fps https://stackoverflow.com/a/13729241
private LinkedList<Long> times = new LinkedList<Long>(){{add(System.nanoTime());}};
private final int MAX_SIZE = 100;
private final double NANOS = 1000000000.0;
/** Calculates and returns frames per second */
private double fps() {
long lastTime = System.nanoTime();
double difference = (lastTime - times.getFirst()) / NANOS;
times.addLast(lastTime);
int size = times.size();
if (size > MAX_SIZE) {
times.removeFirst();
}
return difference > 0 ? times.size() / difference : 0.0;
}
public AWTCanvasView(Context ctx) {
this(ctx, null);
}
public AWTCanvasView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
// setWillNotDraw(false);
fpsPaint = new TextPaint();
fpsPaint.setColor(Color.WHITE);
fpsPaint.setTextSize(20);
setSurfaceTextureListener(this);
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture texture, int w, int h) {
mWidth = w;
mHeight = h;
mIsDestroyed = false;
new Thread(this, "AndroidAWTRenderer").start();
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture texture) {
mIsDestroyed = true;
return true;
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture texture, int w, int h) {
mWidth = w;
mHeight = h;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture texture) {
}
private boolean mDrawing;
private Surface mSurface;
@Override
public void run() {
Canvas canvas;
mSurface = new Surface(getSurfaceTexture());
try {
while (!mIsDestroyed && mSurface.isValid()) {
canvas = mSurface.lockCanvas(null);
canvas.drawRGB(0, 0, 0);
if (!attached) {
attached = CallbackBridge.nativeAttachThreadToOther(true, BaseMainActivity.isInputStackCall);
} else {
int[] rgbArray = JREUtils.renderAWTScreenFrame(/* canvas, mWidth, mHeight */);
mDrawing = rgbArray != null;
if (rgbArray != null) {
canvas.drawBitmap(rgbArray, 0, CallbackBridge.windowWidth, 0, 0, CallbackBridge.windowWidth, CallbackBridge.windowHeight, true, null);
}
rgbArray = null;
// System.gc();
}
canvas.drawText("FPS: " + (Math.round(fps() * 10) / 10) + ", attached=" + attached + ", drawing=" + mDrawing, 50, 50, fpsPaint);
mSurface.unlockCanvasAndPost(canvas);
}
} catch (Throwable th) {
Tools.showError(getContext(), th);
}
}
}
@@ -1,217 +0,0 @@
package net.kdt.pojavlaunch;
import android.util.*;
import android.view.*;
import java.net.CookieHandler;
import java.util.*;
import org.lwjgl.glfw.*;
public class AndroidLWJGLKeycode {
// Fix double letters on MC 1.9 and above
public static boolean isBackspaceAfterChar = true;
public static final ArrayMap<Integer, Integer> androidToLwjglMap;
public static String[] androidKeyNameArray;
static {
// Mapping Android Keycodes to LWJGL Keycodes
androidToLwjglMap = new ArrayMap<Integer, Integer>();
// 0-9 keys
androidToLwjglMap.put(KeyEvent.KEYCODE_0, LWJGLGLFWKeycode.GLFW_KEY_0);
androidToLwjglMap.put(KeyEvent.KEYCODE_1, LWJGLGLFWKeycode.GLFW_KEY_1);
androidToLwjglMap.put(KeyEvent.KEYCODE_2, LWJGLGLFWKeycode.GLFW_KEY_2);
androidToLwjglMap.put(KeyEvent.KEYCODE_3, LWJGLGLFWKeycode.GLFW_KEY_3);
androidToLwjglMap.put(KeyEvent.KEYCODE_4, LWJGLGLFWKeycode.GLFW_KEY_4);
androidToLwjglMap.put(KeyEvent.KEYCODE_5, LWJGLGLFWKeycode.GLFW_KEY_5);
androidToLwjglMap.put(KeyEvent.KEYCODE_6, LWJGLGLFWKeycode.GLFW_KEY_6);
androidToLwjglMap.put(KeyEvent.KEYCODE_7, LWJGLGLFWKeycode.GLFW_KEY_7);
androidToLwjglMap.put(KeyEvent.KEYCODE_8, LWJGLGLFWKeycode.GLFW_KEY_8);
androidToLwjglMap.put(KeyEvent.KEYCODE_9, LWJGLGLFWKeycode.GLFW_KEY_9);
// A-Z keys
androidToLwjglMap.put(KeyEvent.KEYCODE_A, LWJGLGLFWKeycode.GLFW_KEY_A);
androidToLwjglMap.put(KeyEvent.KEYCODE_B, LWJGLGLFWKeycode.GLFW_KEY_B);
androidToLwjglMap.put(KeyEvent.KEYCODE_C, LWJGLGLFWKeycode.GLFW_KEY_C);
androidToLwjglMap.put(KeyEvent.KEYCODE_D, LWJGLGLFWKeycode.GLFW_KEY_D);
androidToLwjglMap.put(KeyEvent.KEYCODE_E, LWJGLGLFWKeycode.GLFW_KEY_E);
androidToLwjglMap.put(KeyEvent.KEYCODE_F, LWJGLGLFWKeycode.GLFW_KEY_F);
androidToLwjglMap.put(KeyEvent.KEYCODE_G, LWJGLGLFWKeycode.GLFW_KEY_G);
androidToLwjglMap.put(KeyEvent.KEYCODE_H, LWJGLGLFWKeycode.GLFW_KEY_H);
androidToLwjglMap.put(KeyEvent.KEYCODE_I, LWJGLGLFWKeycode.GLFW_KEY_I);
androidToLwjglMap.put(KeyEvent.KEYCODE_J, LWJGLGLFWKeycode.GLFW_KEY_J);
androidToLwjglMap.put(KeyEvent.KEYCODE_K, LWJGLGLFWKeycode.GLFW_KEY_K);
androidToLwjglMap.put(KeyEvent.KEYCODE_L, LWJGLGLFWKeycode.GLFW_KEY_L);
androidToLwjglMap.put(KeyEvent.KEYCODE_M, LWJGLGLFWKeycode.GLFW_KEY_M);
androidToLwjglMap.put(KeyEvent.KEYCODE_N, LWJGLGLFWKeycode.GLFW_KEY_M);
androidToLwjglMap.put(KeyEvent.KEYCODE_O, LWJGLGLFWKeycode.GLFW_KEY_O);
androidToLwjglMap.put(KeyEvent.KEYCODE_P, LWJGLGLFWKeycode.GLFW_KEY_P);
androidToLwjglMap.put(KeyEvent.KEYCODE_Q, LWJGLGLFWKeycode.GLFW_KEY_Q);
androidToLwjglMap.put(KeyEvent.KEYCODE_R, LWJGLGLFWKeycode.GLFW_KEY_R);
androidToLwjglMap.put(KeyEvent.KEYCODE_S, LWJGLGLFWKeycode.GLFW_KEY_S);
androidToLwjglMap.put(KeyEvent.KEYCODE_T, LWJGLGLFWKeycode.GLFW_KEY_T);
androidToLwjglMap.put(KeyEvent.KEYCODE_U, LWJGLGLFWKeycode.GLFW_KEY_U);
androidToLwjglMap.put(KeyEvent.KEYCODE_V, LWJGLGLFWKeycode.GLFW_KEY_V);
androidToLwjglMap.put(KeyEvent.KEYCODE_W, LWJGLGLFWKeycode.GLFW_KEY_W);
androidToLwjglMap.put(KeyEvent.KEYCODE_X, LWJGLGLFWKeycode.GLFW_KEY_X);
androidToLwjglMap.put(KeyEvent.KEYCODE_Y, LWJGLGLFWKeycode.GLFW_KEY_Y);
androidToLwjglMap.put(KeyEvent.KEYCODE_Z, LWJGLGLFWKeycode.GLFW_KEY_Z);
// Alt keys
androidToLwjglMap.put(KeyEvent.KEYCODE_ALT_LEFT, LWJGLGLFWKeycode.GLFW_KEY_LEFT_ALT);
androidToLwjglMap.put(KeyEvent.KEYCODE_ALT_RIGHT, LWJGLGLFWKeycode.GLFW_KEY_RIGHT_ALT);
// Escape key
androidToLwjglMap.put(KeyEvent.KEYCODE_BACK, LWJGLGLFWKeycode.GLFW_KEY_ESCAPE);
androidToLwjglMap.put(KeyEvent.KEYCODE_BACKSLASH, LWJGLGLFWKeycode.GLFW_KEY_BACKSLASH);
androidToLwjglMap.put(KeyEvent.KEYCODE_BREAK, LWJGLGLFWKeycode.GLFW_KEY_PAUSE);
androidToLwjglMap.put(KeyEvent.KEYCODE_CAPS_LOCK, LWJGLGLFWKeycode.GLFW_KEY_CAPS_LOCK);
androidToLwjglMap.put(KeyEvent.KEYCODE_COMMA, LWJGLGLFWKeycode.GLFW_KEY_COMMA);
// Control keys
androidToLwjglMap.put(KeyEvent.KEYCODE_CTRL_LEFT, LWJGLGLFWKeycode.GLFW_KEY_LEFT_CONTROL);
androidToLwjglMap.put(KeyEvent.KEYCODE_CTRL_RIGHT, LWJGLGLFWKeycode.GLFW_KEY_RIGHT_CONTROL);
androidToLwjglMap.put(KeyEvent.KEYCODE_DEL, LWJGLGLFWKeycode.GLFW_KEY_BACKSPACE); // Backspace
// Arrow keys
androidToLwjglMap.put(KeyEvent.KEYCODE_DPAD_DOWN, LWJGLGLFWKeycode.GLFW_KEY_DOWN);
androidToLwjglMap.put(KeyEvent.KEYCODE_DPAD_LEFT, LWJGLGLFWKeycode.GLFW_KEY_LEFT);
androidToLwjglMap.put(KeyEvent.KEYCODE_DPAD_RIGHT, LWJGLGLFWKeycode.GLFW_KEY_RIGHT);
androidToLwjglMap.put(KeyEvent.KEYCODE_DPAD_UP, LWJGLGLFWKeycode.GLFW_KEY_UP);
androidToLwjglMap.put(KeyEvent.KEYCODE_ENTER, LWJGLGLFWKeycode.GLFW_KEY_ENTER);
androidToLwjglMap.put(KeyEvent.KEYCODE_EQUALS, LWJGLGLFWKeycode.GLFW_KEY_EQUAL);
androidToLwjglMap.put(KeyEvent.KEYCODE_ESCAPE, LWJGLGLFWKeycode.GLFW_KEY_ESCAPE);
// Fn keys
androidToLwjglMap.put(KeyEvent.KEYCODE_F1, LWJGLGLFWKeycode.GLFW_KEY_F1);
androidToLwjglMap.put(KeyEvent.KEYCODE_F2, LWJGLGLFWKeycode.GLFW_KEY_F2);
androidToLwjglMap.put(KeyEvent.KEYCODE_F3, LWJGLGLFWKeycode.GLFW_KEY_F3);
androidToLwjglMap.put(KeyEvent.KEYCODE_F4, LWJGLGLFWKeycode.GLFW_KEY_F4);
androidToLwjglMap.put(KeyEvent.KEYCODE_F5, LWJGLGLFWKeycode.GLFW_KEY_F5);
androidToLwjglMap.put(KeyEvent.KEYCODE_F6, LWJGLGLFWKeycode.GLFW_KEY_F6);
androidToLwjglMap.put(KeyEvent.KEYCODE_F7, LWJGLGLFWKeycode.GLFW_KEY_F7);
androidToLwjglMap.put(KeyEvent.KEYCODE_F8, LWJGLGLFWKeycode.GLFW_KEY_F8);
androidToLwjglMap.put(KeyEvent.KEYCODE_F9, LWJGLGLFWKeycode.GLFW_KEY_F9);
androidToLwjglMap.put(KeyEvent.KEYCODE_F10, LWJGLGLFWKeycode.GLFW_KEY_F10);
androidToLwjglMap.put(KeyEvent.KEYCODE_F11, LWJGLGLFWKeycode.GLFW_KEY_F11);
androidToLwjglMap.put(KeyEvent.KEYCODE_F12, LWJGLGLFWKeycode.GLFW_KEY_F12);
// FIXME GLFW Function key
// androidToLwjglMap.put(KeyEvent.KEYCODE_FUNCTION, LWJGLGLFWKeycode.GLFW_KEY_FUNCTION);
androidToLwjglMap.put(KeyEvent.KEYCODE_GRAVE, LWJGLGLFWKeycode.GLFW_KEY_GRAVE_ACCENT);
androidToLwjglMap.put(KeyEvent.KEYCODE_HOME, LWJGLGLFWKeycode.GLFW_KEY_HOME);
androidToLwjglMap.put(KeyEvent.KEYCODE_INSERT, LWJGLGLFWKeycode.GLFW_KEY_INSERT);
androidToLwjglMap.put(KeyEvent.KEYCODE_KANA, LWJGLGLFWKeycode.GLFW_KEY_K);
androidToLwjglMap.put(KeyEvent.KEYCODE_LEFT_BRACKET, LWJGLGLFWKeycode.GLFW_KEY_LEFT_BRACKET);
androidToLwjglMap.put(KeyEvent.KEYCODE_MINUS, LWJGLGLFWKeycode.GLFW_KEY_MINUS);
// Num keys
androidToLwjglMap.put(KeyEvent.KEYCODE_NUM_LOCK, LWJGLGLFWKeycode.GLFW_KEY_NUM_LOCK);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_0, LWJGLGLFWKeycode.GLFW_KEY_0);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_1, LWJGLGLFWKeycode.GLFW_KEY_1);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_2, LWJGLGLFWKeycode.GLFW_KEY_2);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_3, LWJGLGLFWKeycode.GLFW_KEY_3);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_4, LWJGLGLFWKeycode.GLFW_KEY_4);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_5, LWJGLGLFWKeycode.GLFW_KEY_5);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_6, LWJGLGLFWKeycode.GLFW_KEY_6);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_7, LWJGLGLFWKeycode.GLFW_KEY_7);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_8, LWJGLGLFWKeycode.GLFW_KEY_8);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_9, LWJGLGLFWKeycode.GLFW_KEY_9);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_ADD, LWJGLGLFWKeycode.GLFW_KEY_KP_ADD);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_COMMA, LWJGLGLFWKeycode.GLFW_KEY_COMMA);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_DIVIDE, LWJGLGLFWKeycode.GLFW_KEY_KP_DIVIDE);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_DOT, LWJGLGLFWKeycode.GLFW_KEY_PERIOD);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_ENTER, LWJGLGLFWKeycode.GLFW_KEY_ENTER);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_EQUALS, LWJGLGLFWKeycode.GLFW_KEY_EQUAL);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_MULTIPLY, LWJGLGLFWKeycode.GLFW_KEY_KP_MULTIPLY);
androidToLwjglMap.put(KeyEvent.KEYCODE_NUMPAD_SUBTRACT, LWJGLGLFWKeycode.GLFW_KEY_KP_SUBTRACT);
// Page keys
androidToLwjglMap.put(KeyEvent.KEYCODE_PAGE_DOWN, LWJGLGLFWKeycode.GLFW_KEY_PAGE_DOWN);
androidToLwjglMap.put(KeyEvent.KEYCODE_PAGE_UP, LWJGLGLFWKeycode.GLFW_KEY_PAGE_UP);
androidToLwjglMap.put(KeyEvent.KEYCODE_PERIOD, LWJGLGLFWKeycode.GLFW_KEY_PERIOD);
androidToLwjglMap.put(KeyEvent.KEYCODE_PLUS, LWJGLGLFWKeycode.GLFW_KEY_KP_ADD);
// androidToLwjglMap.put(KeyEvent.KEYCODE_POWER, LWJGLGLFWKeycode.GLFW_KEY_POWER);
androidToLwjglMap.put(KeyEvent.KEYCODE_RIGHT_BRACKET, LWJGLGLFWKeycode.GLFW_KEY_RIGHT_BRACKET);
androidToLwjglMap.put(KeyEvent.KEYCODE_SEMICOLON, LWJGLGLFWKeycode.GLFW_KEY_SEMICOLON);
// Shift keys
androidToLwjglMap.put(KeyEvent.KEYCODE_SHIFT_LEFT, LWJGLGLFWKeycode.GLFW_KEY_LEFT_SHIFT);
androidToLwjglMap.put(KeyEvent.KEYCODE_SHIFT_RIGHT, LWJGLGLFWKeycode.GLFW_KEY_RIGHT_SHIFT);
androidToLwjglMap.put(KeyEvent.KEYCODE_SLASH, LWJGLGLFWKeycode.GLFW_KEY_SLASH);
// androidToLwjglMap.put(KeyEvent.KEYCODE_SLEEP, LWJGLGLFWKeycode.GLFW_KEY_SLEEP);
androidToLwjglMap.put(KeyEvent.KEYCODE_SPACE, LWJGLGLFWKeycode.GLFW_KEY_SPACE);
// androidToLwjglMap.put(KeyEvent.KEYCODE_SYSRQ, LWJGLGLFWKeycode.GLFW_KEY_SYSRQ);
androidToLwjglMap.put(KeyEvent.KEYCODE_TAB, LWJGLGLFWKeycode.GLFW_KEY_TAB);
// androidToLwjglMap.put(KeyEvent.KEYCODE_YEN, LWJGLGLFWKeycode.GLFW_KEY_YEN);
// androidToLwjglMap.put(KeyEvent.KEYCODE_BUTTON_1, LWJGLGLFWKeycode.G
}
public static String[] generateKeyName() {
if (androidKeyNameArray == null) {
List<String> keyName = new ArrayList<String>();
for (Integer perKey : androidToLwjglMap.keySet()) {
keyName.add(KeyEvent.keyCodeToString(perKey.intValue()).replace("KEYCODE_", ""));
}
androidKeyNameArray = keyName.toArray(new String[0]);
}
return androidKeyNameArray;
}
public static void execKey(KeyEvent keyEvent, int i, boolean isDown) {
CallbackBridge.holdingAlt = keyEvent.isAltPressed();
CallbackBridge.holdingCapslock = keyEvent.isCapsLockOn();
CallbackBridge.holdingCtrl = keyEvent.isCtrlPressed();
CallbackBridge.holdingNumlock = keyEvent.isNumLockOn();
CallbackBridge.holdingShift = keyEvent.isShiftPressed();
try {
/*
if (keyEvent.isPrintingKey()) {
BaseMainActivity.sendKeyPress(androidToLwjglMap.get(keyEvent.getKeyCode()), (char) keyEvent.getUnicodeChar(keyEvent.getMetaState()), keyEvent.getScanCode(), CallbackBridge.getCurrentMods(), isDown);
} else if ((int) keyEvent.getDisplayLabel() != KeyEvent.KEYCODE_UNKNOWN) {
BaseMainActivity.sendKeyPress(androidToLwjglMap.get(keyEvent.getKeyCode()), keyEvent.getDisplayLabel(), keyEvent.getScanCode(), CallbackBridge.getCurrentMods(), isDown);
}
*/
//System.out.println(((int)keyEvent.getDisplayLabel()) + " " +keyEvent.getDisplayLabel());
if(keyEvent.getUnicodeChar() != 0) {
char key = (char)keyEvent.getUnicodeChar();
BaseMainActivity.sendKeyPress(androidToLwjglMap.get(keyEvent.getKeyCode()),key,0,CallbackBridge.getCurrentMods(),keyEvent.getAction() == KeyEvent.ACTION_DOWN);
}else{
BaseMainActivity.sendKeyPress(androidToLwjglMap.get(keyEvent.getKeyCode()),CallbackBridge.getCurrentMods(),keyEvent.getAction()==KeyEvent.ACTION_DOWN);
}
} catch (Throwable th) {
th.printStackTrace();
}
//if (isBackspaceAfterChar && (int) keyEvent.getDisplayLabel() != KeyEvent.KEYCODE_UNKNOWN && !CallbackBridge.isGrabbing() && i != KeyEvent.KEYCODE_DEL) {
// BaseMainActivity.sendKeyPress(LWJGLGLFWKeycode.GLFW_KEY_BACKSPACE, 0, isDown);
//}
}
public static void execKeyIndex(BaseMainActivity mainActivity, int index) {
mainActivity.sendKeyPress(getKeyByIndex(index));
}
public static int getKeyByIndex(int index) {
return androidToLwjglMap.valueAt(index);
}
public static int getIndexByLWJGLKey(int lwjglKey) {
for (int i = 0; i < androidToLwjglMap.size(); i++) {
int currKey = androidToLwjglMap.valueAt(i);
if (currKey == lwjglKey) {
return i;
}
}
return 0;
}
}
@@ -1,21 +0,0 @@
package net.kdt.pojavlaunch;
public class ArchitectureCheck
{
public static String getArch() {
String arch = System.getProperty("os.arch");
String archConverted = null;
if (arch.equals("aarch64") ||
arch.endsWith("v8a") ||
arch.startsWith("arm64")) {
archConverted = "arm64";
} else if (arch.startsWith("arm") || arch.endsWith("v7a")) {
archConverted = "arm32";
} else if (arch.startsWith("x86") || arch.startsWith("amd")) {
archConverted = "x86";
}
return archConverted;
}
}
@@ -1,27 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.*;
import android.os.*;
import androidx.appcompat.app.*;
import net.kdt.pojavlaunch.utils.*;
public class BaseActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Tools.setFullscreen(this);
Tools.updateWindowSize(this);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleUtils.setLocale(base));
}
@Override
public void startActivity(Intent i) {
super.startActivity(i);
new Throwable("StartActivity").printStackTrace();
}
}
@@ -1,253 +0,0 @@
package net.kdt.pojavlaunch;
import android.app.*;
import android.content.*;
import android.text.*;
import android.text.method.*;
import android.view.*;
import android.widget.*;
import androidx.appcompat.app.*;
import com.kdt.pickafile.*;
import java.io.*;
import net.kdt.pojavlaunch.fragments.*;
import net.kdt.pojavlaunch.prefs.*;
import net.kdt.pojavlaunch.tasks.*;
import androidx.appcompat.app.AlertDialog;
import net.kdt.pojavlaunch.value.*;
public abstract class BaseLauncherActivity extends BaseActivity {
public Button mPlayButton;
public ConsoleFragment mConsoleView;
public CrashFragment mCrashView;
public ProgressBar mLaunchProgress;
public Spinner mVersionSelector;
public TextView mLaunchTextStatus, mTextVersion;
public JMinecraftVersionList mVersionList;
public MinecraftDownloaderTask mTask;
public MinecraftAccount mProfile;
public String[] mAvailableVersions;
public boolean mIsAssetsProcessing = false;
protected boolean canBack = false;
public abstract void statusIsLaunching(boolean isLaunching);
public void mcaccSwitchUser(View view) {
showProfileInfo();
}
public void mcaccLogout(View view) {
//PojavProfile.reset();
finish();
}
private void showProfileInfo() {
/*
new AlertDialog.Builder(this)
.setTitle("Info player")
.setMessage(
"AccessToken=" + profile.getAccessToken() + "\n" +
"ClientID=" + profile.getClientID() + "\n" +
"ProfileID=" + profile.getProfileID() + "\n" +
"Username=" + profile.getUsername() + "\n" +
"Version=" + profile.getVersion()
).show();
*/
}
public void launcherMenu(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.mcl_options);
builder.setItems(R.array.mcl_options, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2)
{
switch (p2) {
case 0: // Mod installer
installMod(false);
break;
case 1: // Mod installer with java args
installMod(true);
break;
case 2: // Custom controls
startActivity(new Intent(BaseLauncherActivity.this, CustomControlsActivity.class));
break;
case 3: { // About
final AlertDialog.Builder aboutB = new AlertDialog.Builder(BaseLauncherActivity.this);
aboutB.setTitle(R.string.mcl_option_about);
try {
aboutB.setMessage(Html.fromHtml(String.format(Tools.read(getAssets().open("about_en.txt")),
Tools.APP_NAME,
BuildConfig.VERSION_NAME,
"3.2.3")
));
} catch (Exception e) {
throw new RuntimeException(e);
}
aboutB.setPositiveButton(android.R.string.ok, null);
AlertDialog aboutDialog = aboutB.show();
TextView aboutTv = aboutDialog.findViewById(android.R.id.message);
aboutTv.setMovementMethod(LinkMovementMethod.getInstance());
} break;
}
}
});
builder.show();
}
private void installMod(boolean customJavaArgs) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.alerttitle_installmod);
builder.setNegativeButton(android.R.string.cancel, null);
final AlertDialog dialog;
if (customJavaArgs) {
final EditText edit = new EditText(this);
edit.setSingleLine();
edit.setHint("-jar/-cp /path/to/file.jar ...");
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface di, int i) {
Intent intent = new Intent(BaseLauncherActivity.this, JavaGUILauncherActivity.class);
intent.putExtra("skipDetectMod", true);
intent.putExtra("javaArgs", edit.getText().toString());
startActivity(intent);
}
});
dialog = builder.create();
dialog.setView(edit);
} else {
dialog = builder.create();
FileListView flv = new FileListView(dialog,"jar");
flv.setFileSelectedListener(new FileSelectedListener(){
@Override
public void onFileSelected(File file, String path) {
Intent intent = new Intent(BaseLauncherActivity.this, JavaGUILauncherActivity.class);
intent.putExtra("modFile", file);
startActivity(intent);
dialog.dismiss();
}
});
dialog.setView(flv);
}
dialog.show();
}
public void launchGame(View v) {
if (!canBack && mIsAssetsProcessing) {
mIsAssetsProcessing = false;
statusIsLaunching(false);
} else if (canBack) {
v.setEnabled(false);
mTask = new MinecraftDownloaderTask(this);
mTask.execute(mProfile.selectedVersion);
mCrashView.resetCrashLog = true;
}
}
@Override
public void onBackPressed() {
if (canBack) {
super.onBackPressed();
}
}
@Override
protected void onPostResume() {
super.onPostResume();
System.out.println("call to onPostResume");
Tools.updateWindowSize(this);
System.out.println("call to onPostResume; E");
}
@Override
protected void onResume(){
super.onResume();
System.out.println("call to onResume");
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
final View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(uiOptions);
System.out.println("call to onResume; E");
}
SharedPreferences.OnSharedPreferenceChangeListener listRefreshListener = null;
@Override
protected void onResumeFragments() {
super.onResumeFragments();
if(listRefreshListener == null) {
final BaseLauncherActivity thiz = this;
listRefreshListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.startsWith("vertype_")) {
System.out.println("Verlist update needed!");
new RefreshVersionListTask(thiz).execute();
}
}
};
LauncherPreferences.DEFAULT_PREF.registerOnSharedPreferenceChangeListener(listRefreshListener);
}
new RefreshVersionListTask(this).execute();
System.out.println("call to onResumeFragments");
try{
final ProgressDialog barrier = new ProgressDialog(this);
barrier.setMessage(getString(R.string.global_waiting));
barrier.setProgressStyle(barrier.STYLE_SPINNER);
barrier.setCancelable(false);
barrier.show();
new Thread(new Runnable(){
@Override
public void run()
{
while (mConsoleView == null) {
try {
Thread.sleep(20);
} catch (Throwable th) {}
}
try {
Thread.sleep(100);
} catch (Throwable th) {}
runOnUiThread(new Runnable() {
@Override
public void run()
{
try {
mConsoleView.putLog("");
barrier.dismiss();
} catch (Throwable th) {
startActivity(getIntent());
finish();
}
}
});
}
}).start();
File lastCrashFile = Tools.lastFileModified(Tools.DIR_HOME_CRASH);
if(CrashFragment.isNewCrash(lastCrashFile) || !mCrashView.getLastCrash().isEmpty()){
mCrashView.resetCrashLog = false;
initTabs(2);
} /*else throw new Exception();*/
} catch(Throwable e) {
e.printStackTrace();
// selectTabPage(tabLayout.getSelectedTabPosition());
}
System.out.println("call to onResumeFragments; E");
}
// Catching touch exception
@Override
public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}
protected abstract void initTabs(int pageIndex);
}
File diff suppressed because it is too large. Load diff
@@ -1,208 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.*;
import android.os.*;
import androidx.core.widget.*;
import androidx.appcompat.app.*;
import androidx.preference.*;
import android.view.*;
import android.widget.*;
import androidx.drawerlayout.widget.DrawerLayout;
import com.google.android.material.navigation.NavigationView;
import com.kdt.pickafile.*;
import java.io.*;
import net.kdt.pojavlaunch.prefs.*;
import net.kdt.pojavlaunch.customcontrols.*;
public class CustomControlsActivity extends BaseActivity
{
private DrawerLayout drawerLayout;
private NavigationView navDrawer;
private ControlLayout ctrlLayout;
private SharedPreferences mPref;
public boolean isModified = false;
private String selectedName = "new_control";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.control_mapping);
mPref = PreferenceManager.getDefaultSharedPreferences(this);
ctrlLayout = (ControlLayout) findViewById(R.id.customctrl_controllayout);
// Menu
drawerLayout = (DrawerLayout) findViewById(R.id.customctrl_drawerlayout);
navDrawer = (NavigationView) findViewById(R.id.customctrl_navigation_view);
navDrawer.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.menu_ctrl_load:
actionLoad();
break;
case R.id.menu_ctrl_add:
ctrlLayout.addControlButton(new ControlData("New", LWJGLGLFWKeycode.GLFW_KEY_UNKNOWN, 100, 100));
break;
case R.id.menu_ctrl_selectdefault:
dialogSelectDefaultCtrl();
break;
case R.id.menu_ctrl_save:
save(false);
break;
}
//Toast.makeText(MainActivity.this, menuItem.getTitle() + ":" + menuItem.getItemId(), Toast.LENGTH_SHORT).show();
drawerLayout.closeDrawers();
return true;
}
});
ctrlLayout.setActivity(this);
ctrlLayout.setModifiable(true);
loadControl(LauncherPreferences.PREF_DEFAULTCTRL_PATH);
}
@Override
public void onBackPressed() {
if (!isModified) {
super.onBackPressed();
return;
}
save(true);
}
private void setDefaultControlJson(String path) {
try {
// Load before save to make sure control is not error
ctrlLayout.loadLayout(Tools.GLOBAL_GSON.fromJson(Tools.read(path), CustomControls.class));
LauncherPreferences.DEFAULT_PREF.edit().putString("defaultCtrl", path).commit();
LauncherPreferences.PREF_DEFAULTCTRL_PATH = path;
} catch (Throwable th) {
Tools.showError(this, th);
}
}
private void dialogSelectDefaultCtrl() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.customctrl_selectdefault);
builder.setPositiveButton(android.R.string.cancel, null);
final AlertDialog dialog = builder.create();
FileListView flv = new FileListView(dialog, "json");
flv.lockPathAt(Tools.CTRLMAP_PATH);
flv.setFileSelectedListener(new FileSelectedListener(){
@Override
public void onFileSelected(File file, String path) {
setDefaultControlJson(path);
dialog.dismiss();
}
});
dialog.setView(flv);
dialog.show();
}
private String doSaveCtrl(String name) throws Exception {
String jsonPath = Tools.CTRLMAP_PATH + "/" + name + ".json";
ctrlLayout.saveLayout(jsonPath);
return jsonPath;
}
private void save(final boolean exit) {
final EditText edit = new EditText(this);
edit.setSingleLine();
edit.setText(selectedName);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.global_save);
builder.setView(edit);
builder.setPositiveButton(android.R.string.ok, null);
builder.setNegativeButton(android.R.string.cancel, null);
if (exit) {
builder.setNeutralButton(R.string.mcn_exit_call, new AlertDialog.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
CustomControlsActivity.super.onBackPressed();
}
});
}
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
Button button = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (edit.getText().toString().isEmpty()) {
edit.setError(getResources().getString(R.string.global_error_field_empty));
} else {
try {
String jsonPath = doSaveCtrl(edit.getText().toString());
Toast.makeText(CustomControlsActivity.this, getString(R.string.global_save) + ": " + jsonPath, Toast.LENGTH_SHORT).show();
dialog.dismiss();
if (exit) {
CustomControlsActivity.super.onBackPressed();
}
} catch (Throwable th) {
Tools.showError(CustomControlsActivity.this, th, exit);
}
}
}
});
}
});
dialog.show();
}
private void actionLoad() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.global_load);
builder.setPositiveButton(android.R.string.cancel, null);
final AlertDialog dialog = builder.create();
FileListView flv = new FileListView(dialog, "json");
flv.listFileAt(Tools.CTRLMAP_PATH);
flv.setFileSelectedListener(new FileSelectedListener(){
@Override
public void onFileSelected(File file, String path) {
loadControl(path);
dialog.dismiss();
}
});
dialog.setView(flv);
dialog.show();
}
private void loadControl(String path) {
try {
ctrlLayout.loadLayout(path);
selectedName = new File(path).getName();
// Remove `.json`
selectedName = selectedName.substring(0, selectedName.length() - 5);
} catch (Exception e) {
Tools.showError(CustomControlsActivity.this, e);
}
}
}
@@ -1,17 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.*;
import android.net.*;
import androidx.browser.customtabs.*;
// import androidx.browser.customtabs.*;
public class CustomTabs {
public static void openTab(Context context, String url) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setShowTitle(true);
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, Uri.parse(url));
}
}
@@ -1,38 +0,0 @@
package net.kdt.pojavlaunch;
import java.util.*;
public class DisplayableLocale {
public final Locale mLocale;
public final CharSequence mName;
private static Locale processStringLocale(String locale) {
if (locale.contains("-")) {
String[] split = locale.split("-");
return new Locale(split[0], split[1]);
} else {
return new Locale(locale);
}
}
public DisplayableLocale(String locale) {
this(processStringLocale(locale));
}
public DisplayableLocale(Locale locale) {
this(locale, locale.getDisplayName(locale));
}
public DisplayableLocale(Locale locale, CharSequence name) {
mLocale = locale;
mName = name;
}
public Locale toLocale() {
return mLocale;
}
@Override
public String toString() {
return mName.toString();
}
}
@@ -1,70 +0,0 @@
package net.kdt.pojavlaunch;
import android.app.*;
import android.content.*;
import android.os.*;
import androidx.appcompat.app.*;
import android.util.*;
import androidx.appcompat.app.AlertDialog;
public class FatalErrorActivity extends BaseActivity
{
public static void showError(Context ctx, String savePath, boolean storageAllow, /* boolean isFatalErr, */ Throwable th) {
Intent ferrorIntent = new Intent(ctx, FatalErrorActivity.class);
ferrorIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
ferrorIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ferrorIntent.putExtra("throwable", th);
ferrorIntent.putExtra("savePath", savePath);
ferrorIntent.putExtra("storageAllow", storageAllow);
// ferrorIntent.putExtra("isFatal", isFatalErr);
ctx.startActivity(ferrorIntent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
boolean storageAllow = extras.getBoolean("storageAllow");
final String strStackTrace = Log.getStackTraceString((Throwable) extras.getSerializable("throwable"));
String strSavePath = extras.getString("savePath");
String errHeader = storageAllow ?
"Crash stack trace saved to " + strSavePath + "." :
"Storage permission is required to save crash stack trace!";
// boolean isFatalError = extras.getBoolean("isFatal", false);
new AlertDialog.Builder(this)
.setTitle(R.string.error_fatal)
.setMessage(errHeader + "\n\n" + strStackTrace)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
finish();
}
})
.setNegativeButton(R.string.global_restart, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
startActivity(new Intent(FatalErrorActivity.this, PojavLoginActivity.class));
}
})
.setNeutralButton(android.R.string.copy, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
ClipboardManager mgr = (ClipboardManager) FatalErrorActivity.this.getSystemService(CLIPBOARD_SERVICE);
mgr.setPrimaryClip(ClipData.newPlainText("error", strStackTrace));
finish();
}
})
//.setNegativeButton("Report (not available)", null)
.setCancelable(false)
.show();
// Tools.showError(this, isFatalError ? R.string.error_fatal : R.string.global_error, th, true);
}
}
@@ -1,34 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.res.*;
import android.graphics.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import com.kdt.mcgui.*;
public class FontChanger
{
private static Typeface fNotoSans, fMinecraftTen;
public static void initFonts(Context ctx) {
fNotoSans = Typeface.createFromAsset(ctx.getAssets(), "font/NotoSans-Bold.ttf");
fMinecraftTen = Typeface.createFromAsset(ctx.getAssets(), "font/minecraft-ten.ttf");
}
public static void changeFonts(ViewGroup viewTree) {
View child;
for(int i = 0; i < viewTree.getChildCount(); ++i) {
child = viewTree.getChildAt(i);
if (child instanceof ViewGroup) {
changeFonts((ViewGroup) child);
} else if (child instanceof TextView) {
changeFont((TextView) child);
}
}
}
public static void changeFont(TextView view) {
view.setTypeface(view instanceof MineButton ? fMinecraftTen : fNotoSans);
}
}
File diff suppressed because it is too large. Load diff
@@ -1,52 +0,0 @@
package net.kdt.pojavlaunch;
import android.os.*;
public class InstallerTask extends AsyncTask<String, Void, String>
{
@Override
protected String doInBackground(String[] p1)
{
try
{
downloadLibraries(p1[0]);
dexMinecraftLibs();
downloadMinecraft(p1[0]);
dexMinecraftClient(p1[0]);
downloadAssets(p1[0]);
}
catch (Exception e)
{
return e.getMessage();
}
return null;
}
@Override
protected void onPostExecute(String result)
{
super.onPostExecute(result);
if(result == null){
//No errors
}
}
private void downloadLibraries(String versionName) throws Exception
{
}
private void dexMinecraftLibs() throws Exception
{
}
private void downloadMinecraft(String versionName) throws Exception
{
}
private void dexMinecraftClient(String version) throws Exception
{
}
private void downloadAssets(String versionName) throws Exception
{
}
}
@@ -1,8 +0,0 @@
package net.kdt.pojavlaunch;
public class JAssetInfo
{
public String hash;
public int size;
//public String objects;
}
@@ -1,8 +0,0 @@
package net.kdt.pojavlaunch;
import java.util.Map;
public class JAssets {
public Map<String, JAssetInfo> objects;
}
@@ -1,58 +0,0 @@
package net.kdt.pojavlaunch;
import java.util.Map;
import net.kdt.pojavlaunch.value.*;
import java.util.*;
public class JMinecraftVersionList {
public static final String TYPE_OLD_ALPHA = "old_alpha";
public static final String TYPE_OLD_BETA = "old_beta";
public static final String TYPE_RELEASE = "release";
public static final String TYPE_SNAPSHOT = "snapshot";
public Map<String, String> latest;
public Version[] versions;
public static class Version {
// Since 1.13, so it's one of ways to check
public Arguments arguments;
public AssetIndex assetIndex;
public String assets;
public Map<String, MinecraftClientInfo> downloads;
public String id;
public String inheritsFrom;
public DependentLibrary[] libraries;
public String mainClass;
public String minecraftArguments;
public int minimumLauncherVersion;
public DependentLibrary optifineLib;
public String releaseTime;
public String time;
public String type;
public String url;
}
// Since 1.13
public static class Arguments {
public Object[] game;
public Object[] jvm;
public static class ArgValue {
public ArgRules[] rules;
public String value;
// TLauncher styled argument...
public String[] values;
public static class ArgRules {
public String action;
public String features;
}
}
}
public static class AssetIndex {
public String id, sha1, url;
public long size, totalSize;
}
}
@@ -1,43 +0,0 @@
package net.kdt.pojavlaunch;
public class JVersion extends Object
{
private String version;
private JVersion(String version)
{
this.version = version;
}
public static JVersion from(String version)
{
return new JVersion(version);
}
public boolean isVersionCode()
{
return !version.contains(".");
}
public JVersion toVersionCode()
{
if(!isVersionCode()){
version = version.replace(".", "");
return this;
} else throw new RuntimeException("Can't convert version code to itself");
}
public JVersion toVersionName()
{
if(isVersionCode()){
StringBuilder charList = new StringBuilder();
for(int i=0; i<version.length(); i++){
charList.append(version.substring(i, i+1));
if(i != version.length() - 1){
charList.append(".");
}
}
version = charList.toString();
return this;
} else throw new RuntimeException("Can't convert version name to itself");
}
public String getVersion()
{
return version;
}
}
@@ -1,235 +0,0 @@
package net.kdt.pojavlaunch;
import android.graphics.*;
import android.os.*;
import androidx.appcompat.app.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import java.io.*;
import java.util.*;
import net.kdt.pojavlaunch.installers.*;
import net.kdt.pojavlaunch.utils.*;
import org.lwjgl.glfw.*;
import android.content.*;
public class JavaGUILauncherActivity extends LoggableActivity {
private AWTCanvasView mTextureView;
private LinearLayout contentLog;
private TextView textLog;
private ScrollView contentScroll;
private ToggleButton toggleLog;
private File logFile;
private PrintStream logStream;
private final Object mDialogLock = new Object();
private boolean isLogAllow, mSkipDetectMod;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.install_mod);
try {
logFile = new File(Tools.DIR_GAME_NEW, "latestlog.txt");
logFile.delete();
logFile.createNewFile();
logStream = new PrintStream(logFile.getAbsolutePath());
this.contentLog = findViewById(R.id.content_log_layout);
this.contentScroll = (ScrollView) findViewById(R.id.content_log_scroll);
this.textLog = (TextView) contentScroll.getChildAt(0);
this.toggleLog = (ToggleButton) findViewById(R.id.content_log_toggle_log);
this.toggleLog.setChecked(false);
// this.textLogBehindGL = (TextView) findViewById(R.id.main_log_behind_GL);
// this.textLogBehindGL.setTypeface(Typeface.MONOSPACE);
this.textLog.setTypeface(Typeface.MONOSPACE);
this.toggleLog.setOnCheckedChangeListener(new ToggleButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton button, boolean isChecked) {
isLogAllow = isChecked;
appendToLog("");
}
});
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
final String javaArgs = getIntent().getExtras().getString("javaArgs");
mTextureView = findViewById(R.id.installmod_surfaceview);
mSkipDetectMod = getIntent().getExtras().getBoolean("skipDetectMod", false);
if (mSkipDetectMod) {
new Thread(new Runnable(){
@Override
public void run() {
launchJavaRuntime(modFile, javaArgs);
}
}, "JREMainThread").start();
} else {
openLogOutput(null);
new Thread(new Runnable(){
@Override
public void run() {
try {
final int exit = doCustomInstall(modFile, javaArgs);
appendlnToLog(getString(R.string.toast_optifine_success));
if (exit == 0) {
runOnUiThread(new Runnable(){
@Override
public void run() {
Toast.makeText(JavaGUILauncherActivity.this, R.string.toast_optifine_success, Toast.LENGTH_SHORT).show();
MainActivity.fullyExit();
}
});
} /* else {
throw new ErrnoException(getString(R.string.glo, exit);
} */
} catch (Throwable e) {
appendlnToLog("Install failed:");
appendlnToLog(Log.getStackTraceString(e));
Tools.showError(JavaGUILauncherActivity.this, e);
}
}
}, "Installer").start();
}
} catch (Throwable th) {
Tools.showError(this, th, true);
}
}
public String dialogInput(final String title, final int message) {
final StringBuilder str = new StringBuilder();
runOnUiThread(new Runnable(){
@Override
public void run() {
final EditText editText = new EditText(JavaGUILauncherActivity.this);
editText.setHint(message);
editText.setSingleLine();
AlertDialog.Builder d = new AlertDialog.Builder(JavaGUILauncherActivity.this);
d.setCancelable(false);
d.setTitle(title);
d.setView(editText);
d.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface i, int id) {
str.append(editText.getText().toString());
synchronized (mDialogLock) {
mDialogLock.notifyAll();
}
}
});
d.show();
}
});
try {
synchronized (mDialogLock) {
mDialogLock.wait();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
return str.toString();
}
public void forceClose(View v) {
BaseMainActivity.dialogForceClose(this);
}
public void openLogOutput(View v) {
contentLog.setVisibility(View.VISIBLE);
}
public void closeLogOutput(View view) {
if (mSkipDetectMod) {
contentLog.setVisibility(View.GONE);
} else {
forceClose(null);
}
}
private int doCustomInstall(File modFile, String javaArgs) throws IOException {
isLogAllow = true;
// Attempt to detects some mod installers
BaseInstaller installer = new BaseInstaller();
installer.setInput(modFile);
if (InstallerDetector.isForgeLegacy(installer)) {
appendlnToLog("Detected Forge Installer 1.12.1 or below!");
return new LegacyForgeInstaller(installer).install(this);
} else if (InstallerDetector.isForge1p12p2(installer)) {
appendlnToLog("Detected Forge Installer 1.12.2!");
return new Legacy1p12p2ForgeInstaller(installer).install(this);
} else if (InstallerDetector.isForgeNew(installer)) {
appendlnToLog("Detected Forge Installer 1.13 or above!");
return new NewForgeInstaller(installer).install(this);
} else if (InstallerDetector.isFabric(installer)) {
appendlnToLog("Detected Fabric Installer!");
return new FabricInstaller(installer).install(this);
}else if (InstallerDetector.isOptiFine(installer)) {
appendlnToLog("Detected OptiFine Installer!");
return new LegacyOptifineInstaller(installer).install(this);
} else {
appendlnToLog("No mod detected. Starting JVM");
isLogAllow = false;
mSkipDetectMod = true;
return launchJavaRuntime(modFile, javaArgs);
}
}
public int launchJavaRuntime(File modFile, String javaArgs) {
JREUtils.redirectAndPrintJRELog(this, null);
try {
List<String> javaArgList = new ArrayList<String>();
if (javaArgs != null) {
javaArgList.addAll(Arrays.asList(javaArgs.split(" ")));
} else {
javaArgList.add("-jar");
javaArgList.add(modFile.getAbsolutePath());
}
// System.out.println(Arrays.toString(javaArgList.toArray(new String[0])));
appendlnToLog("Info: Java arguments: " + Arrays.toString(javaArgList.toArray(new String[0])));
// Run java on sandbox, non-overrideable.
Collections.reverse(javaArgList);
javaArgList.add("-Xbootclasspath/a:" + Tools.DIR_DATA + "/pro-grade.jar");
javaArgList.add("-Djava.security.manager=net.sourceforge.prograde.sm.ProGradeJSM");
javaArgList.add("-Djava.security.policy=" + Tools.DIR_DATA + "/java_sandbox.policy");
Collections.reverse(javaArgList);
return JREUtils.launchJavaVM(this, javaArgList);
} catch (Throwable th) {
Tools.showError(this, th, true);
return -1;
}
}
@Override
public void onResume() {
super.onResume();
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
final View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(uiOptions);
}
@Override
public void appendToLog(final String text, boolean checkAllow) {
logStream.print(text);
if (checkAllow && !isLogAllow) return;
textLog.post(new Runnable(){
@Override
public void run() {
textLog.append(text);
contentScroll.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
}
@@ -1,169 +0,0 @@
package net.kdt.pojavlaunch;
public class LWJGLGLFWKeycode
{
/** The unknown key. */
public static final int GLFW_KEY_UNKNOWN = 0; // should be -1
/** Printable keys. */
public static final int
GLFW_KEY_SPACE = 32,
GLFW_KEY_APOSTROPHE = 39,
GLFW_KEY_COMMA = 44,
GLFW_KEY_MINUS = 45,
GLFW_KEY_PERIOD = 46,
GLFW_KEY_SLASH = 47,
GLFW_KEY_0 = 48,
GLFW_KEY_1 = 49,
GLFW_KEY_2 = 50,
GLFW_KEY_3 = 51,
GLFW_KEY_4 = 52,
GLFW_KEY_5 = 53,
GLFW_KEY_6 = 54,
GLFW_KEY_7 = 55,
GLFW_KEY_8 = 56,
GLFW_KEY_9 = 57,
GLFW_KEY_SEMICOLON = 59,
GLFW_KEY_EQUAL = 61,
GLFW_KEY_A = 65,
GLFW_KEY_B = 66,
GLFW_KEY_C = 67,
GLFW_KEY_D = 68,
GLFW_KEY_E = 69,
GLFW_KEY_F = 70,
GLFW_KEY_G = 71,
GLFW_KEY_H = 72,
GLFW_KEY_I = 73,
GLFW_KEY_J = 74,
GLFW_KEY_K = 75,
GLFW_KEY_L = 76,
GLFW_KEY_M = 77,
GLFW_KEY_N = 78,
GLFW_KEY_O = 79,
GLFW_KEY_P = 80,
GLFW_KEY_Q = 81,
GLFW_KEY_R = 82,
GLFW_KEY_S = 83,
GLFW_KEY_T = 84,
GLFW_KEY_U = 85,
GLFW_KEY_V = 86,
GLFW_KEY_W = 87,
GLFW_KEY_X = 88,
GLFW_KEY_Y = 89,
GLFW_KEY_Z = 90,
GLFW_KEY_LEFT_BRACKET = 91,
GLFW_KEY_BACKSLASH = 92,
GLFW_KEY_RIGHT_BRACKET = 93,
GLFW_KEY_GRAVE_ACCENT = 96,
GLFW_KEY_WORLD_1 = 161,
GLFW_KEY_WORLD_2 = 162;
/** Function keys. */
public static final int
GLFW_KEY_ESCAPE = 256,
GLFW_KEY_ENTER = 257,
GLFW_KEY_TAB = 258,
GLFW_KEY_BACKSPACE = 259,
GLFW_KEY_INSERT = 260,
GLFW_KEY_DELETE = 261,
GLFW_KEY_RIGHT = 262,
GLFW_KEY_LEFT = 263,
GLFW_KEY_DOWN = 264,
GLFW_KEY_UP = 265,
GLFW_KEY_PAGE_UP = 266,
GLFW_KEY_PAGE_DOWN = 267,
GLFW_KEY_HOME = 268,
GLFW_KEY_END = 269,
GLFW_KEY_CAPS_LOCK = 280,
GLFW_KEY_SCROLL_LOCK = 281,
GLFW_KEY_NUM_LOCK = 282,
GLFW_KEY_PRINT_SCREEN = 283,
GLFW_KEY_PAUSE = 284,
GLFW_KEY_F1 = 290,
GLFW_KEY_F2 = 291,
GLFW_KEY_F3 = 292,
GLFW_KEY_F4 = 293,
GLFW_KEY_F5 = 294,
GLFW_KEY_F6 = 295,
GLFW_KEY_F7 = 296,
GLFW_KEY_F8 = 297,
GLFW_KEY_F9 = 298,
GLFW_KEY_F10 = 299,
GLFW_KEY_F11 = 300,
GLFW_KEY_F12 = 301,
GLFW_KEY_F13 = 302,
GLFW_KEY_F14 = 303,
GLFW_KEY_F15 = 304,
GLFW_KEY_F16 = 305,
GLFW_KEY_F17 = 306,
GLFW_KEY_F18 = 307,
GLFW_KEY_F19 = 308,
GLFW_KEY_F20 = 309,
GLFW_KEY_F21 = 310,
GLFW_KEY_F22 = 311,
GLFW_KEY_F23 = 312,
GLFW_KEY_F24 = 313,
GLFW_KEY_F25 = 314,
GLFW_KEY_KP_0 = 320,
GLFW_KEY_KP_1 = 321,
GLFW_KEY_KP_2 = 322,
GLFW_KEY_KP_3 = 323,
GLFW_KEY_KP_4 = 324,
GLFW_KEY_KP_5 = 325,
GLFW_KEY_KP_6 = 326,
GLFW_KEY_KP_7 = 327,
GLFW_KEY_KP_8 = 328,
GLFW_KEY_KP_9 = 329,
GLFW_KEY_KP_DECIMAL = 330,
GLFW_KEY_KP_DIVIDE = 331,
GLFW_KEY_KP_MULTIPLY = 332,
GLFW_KEY_KP_SUBTRACT = 333,
GLFW_KEY_KP_ADD = 334,
GLFW_KEY_KP_ENTER = 335,
GLFW_KEY_KP_EQUAL = 336,
GLFW_KEY_LEFT_SHIFT = 340,
GLFW_KEY_LEFT_CONTROL = 341,
GLFW_KEY_LEFT_ALT = 342,
GLFW_KEY_LEFT_SUPER = 343,
GLFW_KEY_RIGHT_SHIFT = 344,
GLFW_KEY_RIGHT_CONTROL = 345,
GLFW_KEY_RIGHT_ALT = 346,
GLFW_KEY_RIGHT_SUPER = 347,
GLFW_KEY_MENU = 348,
GLFW_KEY_LAST = GLFW_KEY_MENU;
/** If this bit is set one or more Shift keys were held down. */
public static final int GLFW_MOD_SHIFT = 0x1;
/** If this bit is set one or more Control keys were held down. */
public static final int GLFW_MOD_CONTROL = 0x2;
/** If this bit is set one or more Alt keys were held down. */
public static final int GLFW_MOD_ALT = 0x4;
/** If this bit is set one or more Super keys were held down. */
public static final int GLFW_MOD_SUPER = 0x8;
/** If this bit is set the Caps Lock key is enabled and the {@link #GLFW_LOCK_KEY_MODS LOCK_KEY_MODS} input mode is set. */
public static final int GLFW_MOD_CAPS_LOCK = 0x10;
/** If this bit is set the Num Lock key is enabled and the {@link #GLFW_LOCK_KEY_MODS LOCK_KEY_MODS} input mode is set. */
public static final int GLFW_MOD_NUM_LOCK = 0x20;
/** Mouse buttons. See <a target="_blank" href="http://www.glfw.org/docs/latest/input.html#input_mouse_button">mouse button input</a> for how these are used. */
public static final int
GLFW_MOUSE_BUTTON_1 = 0,
GLFW_MOUSE_BUTTON_2 = 1,
GLFW_MOUSE_BUTTON_3 = 2,
GLFW_MOUSE_BUTTON_4 = 3,
GLFW_MOUSE_BUTTON_5 = 4,
GLFW_MOUSE_BUTTON_6 = 5,
GLFW_MOUSE_BUTTON_7 = 6,
GLFW_MOUSE_BUTTON_8 = 7,
GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8,
GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1,
GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2,
GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3;
}
@@ -1,19 +0,0 @@
package net.kdt.pojavlaunch;
import androidx.appcompat.app.*;
public abstract class LoggableActivity extends BaseActivity {
public void appendToLog(String text) {
appendToLog(text, true);
}
public void appendlnToLog(String text) {
appendlnToLog(text, true);
}
public void appendlnToLog(String text, boolean checkAllow) {
appendToLog(text + "\n", checkAllow);
}
public abstract void appendToLog(final String text, boolean checkAllow);
}
@@ -1,149 +0,0 @@
package net.kdt.pojavlaunch;
import android.app.*;
import android.content.*;
import android.util.*;
import android.view.*;
import java.io.*;
import net.kdt.pojavlaunch.authenticator.mojang.*;
/**
* This account data format is deprecated.
* The current account data format is JSON on net.kdt.pojavlaunch.value.MinecraftAccount.
* This class remain for account data migrator only.
* Methods for saving/exporting on this format are no longer available.
*/
@Deprecated
public class MCProfile
{
private static String[] emptyBuilder = new String[]{
"1.9", //Version
"ProfileIDEmpty",
"AccessToken",
"AccessTokenEmpty",
"Steve"
};
public static MCProfile.Builder load(String pofFilePath) {
try {
//String th = new String(new byte[]{-128});
String pofContent = Tools.read(pofFilePath);
return parse(pofContent);
} catch (Exception e) {
throw new RuntimeException("Unable to load Profile " + pofFilePath, e);
}
}
public static MCProfile.Builder parse(String content) {
if (content == null || content.isEmpty()) {
return null;
}
MCProfile.Builder builder = new MCProfile.Builder();
String[] profileInfos = content.split(":");
String cltk = profileInfos[0];
String prtk = profileInfos[1];
String acct = profileInfos[2];
String name = profileInfos[3];
String vers = profileInfos[4];
String isAc = profileInfos[5];
//System.out.println("parse THE VER = " + vers);
builder.setClientID(cltk);
builder.setProfileID(prtk);
builder.setAccessToken(acct);
builder.setUsername(name);
builder.setVersion(vers);
builder.setIsMojangAccount(Boolean.parseBoolean(isAc));
return builder;
}
public static MCProfile.Builder loadSafety(String pofFilePath) {
try {
return load(pofFilePath);
} catch (Exception e) {
e.printStackTrace();
// return new MCProfile.Builder();
return null;
}
}
public static class Builder implements Serializable
{
private String[] fullArgs = new String[6];
private boolean isMojangAccount = true;
public Builder()
{
fullArgs = emptyBuilder;
setClientID("0");
setProfileID("00000000-0000-0000-0000-000000000000");
setAccessToken("0");
}
public boolean isMojangAccount()
{
return isMojangAccount;
}
public String getVersion()
{
return fullArgs[0];
}
public String getClientID()
{
return fullArgs[1];
}
public String getProfileID()
{
return fullArgs[2];
}
public String getAccessToken()
{
return fullArgs[3];
}
public String getUsername()
{
return fullArgs[4];
}
public void setIsMojangAccount(boolean value)
{
isMojangAccount = value;
}
public void setVersion(String value)
{
fullArgs[0] = value;
}
public void setClientID(String value)
{
fullArgs[1] = value;
}
public void setProfileID(String value)
{
fullArgs[2] = value;
}
public void setAccessToken(String value)
{
fullArgs[3] = value;
}
public void setUsername(String value)
{
fullArgs[4] = value;
}
}
}
@@ -1,132 +0,0 @@
package net.kdt.pojavlaunch;
import android.os.*;
import android.view.*;
import android.view.View.*;
import android.widget.*;
import net.kdt.pojavlaunch.customcontrols.*;
import net.kdt.pojavlaunch.prefs.*;
import org.lwjgl.glfw.*;
import java.io.*;
import com.google.gson.*;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF;
public class MainActivity extends BaseMainActivity {
private ControlLayout mControlLayout;
private View.OnClickListener mClickListener;
private View.OnTouchListener mTouchListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initLayout(R.layout.main_with_customctrl);
mClickListener = new View.OnClickListener(){
@Override
public void onClick(View view) {
if (view instanceof ControlButton) {
ControlButton button = (ControlButton) view;
switch (button.getProperties().keycode) {
case ControlData.SPECIALBTN_KEYBOARD:
showKeyboard();
break;
case ControlData.SPECIALBTN_TOGGLECTRL:
mControlLayout.toggleControlVisible();
break;
case ControlData.SPECIALBTN_VIRTUALMOUSE:
toggleMouse(button);
break;
}
}
}
};
mTouchListener = new View.OnTouchListener(){
@Override
public boolean onTouch(View view, MotionEvent e) {
boolean isDown;
switch (e.getActionMasked()) {
case MotionEvent.ACTION_DOWN: // 0
case MotionEvent.ACTION_POINTER_DOWN: // 5
isDown = true;
break;
case MotionEvent.ACTION_UP: // 1
case MotionEvent.ACTION_CANCEL: // 3
case MotionEvent.ACTION_POINTER_UP: // 6
isDown = false;
break;
default:
return false;
}
if (view instanceof ControlButton) {
ControlButton button = (ControlButton) view;
switch (button.getProperties().keycode) {
case ControlData.SPECIALBTN_MOUSEPRI:
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown);
break;
case ControlData.SPECIALBTN_MOUSEMID:
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_MIDDLE, isDown);
break;
case ControlData.SPECIALBTN_MOUSESEC:
if (CallbackBridge.isGrabbing()) {
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown);
} else {
CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown ? 1 : 0, CallbackBridge.mouseX, CallbackBridge.mouseY);
setRightOverride(isDown);
}
break;
case ControlData.SPECIALBTN_SCROLLDOWN:
CallbackBridge.sendScroll(0, 0.1d);
break;
case ControlData.SPECIALBTN_SCROLLUP:
CallbackBridge.sendScroll(0, -0.1d);
break;
}
}
return false;
}
};
ControlData[] specialButtons = ControlData.getSpecialButtons();
specialButtons[0].specialButtonListener
= specialButtons[1].specialButtonListener
= specialButtons[4].specialButtonListener
= mClickListener;
specialButtons[2].specialButtonListener
= specialButtons[3].specialButtonListener
= specialButtons[5].specialButtonListener
= specialButtons[6].specialButtonListener
= specialButtons[7].specialButtonListener
= mTouchListener;
mControlLayout = findViewById(R.id.main_control_layout);
mControlLayout.setModifiable(false);
try {
mControlLayout.loadLayout(LauncherPreferences.PREF_DEFAULTCTRL_PATH);
} catch(IOException e) {
try {
mControlLayout.loadLayout(Tools.CTRLDEF_FILE);
DEFAULT_PREF.edit().putString("defaultCtrl",Tools.CTRLDEF_FILE).commit();
} catch (IOException ioException) {
Tools.showError(this, ioException);
}
} catch (Throwable th) {
Tools.showError(this, th);
}
// toggleGui(null);
mControlLayout.toggleControlVisible();
}
}
@@ -1,87 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.Context;
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.text.Spanned;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper;
import android.widget.EditText;
public class MainEditText extends EditText {
public MainKeyWatcher _MainKeyWatcher;
public final int allowedLength;
public final boolean limitInput;
private class MainInputConnection extends InputConnectionWrapper {
MainEditText textbox;
public MainInputConnection(InputConnection target, boolean mutable, MainEditText textbox2) {
super(target, mutable);
this.textbox = textbox2;
}
public boolean sendKeyEvent(KeyEvent event) {
if (this.textbox.getText().length() != 0 || event.getAction() != 0 || event.getKeyCode() != 67) {
return super.sendKeyEvent(event);
}
if (MainEditText.this._MainKeyWatcher != null) {
MainEditText.this._MainKeyWatcher.onDeleteKeyPressed();
}
return false;
}
}
public interface MainKeyWatcher {
void onBackKeyPressed();
void onDeleteKeyPressed();
}
public MainEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this._MainKeyWatcher = null;
this.allowedLength = 160;
this.limitInput = false;
}
public MainEditText(Context context, AttributeSet attrs) {
super(context, attrs);
this._MainKeyWatcher = null;
this.allowedLength = 160;
this.limitInput = false;
}
public MainEditText(Context context, int allowedLength2, boolean limitInput2) {
super(context);
this._MainKeyWatcher = null;
this.allowedLength = allowedLength2;
this.limitInput = limitInput2;
setFilters(limitInput2 ? new InputFilter[]{new LengthFilter(this.allowedLength), new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
return (!source.equals("") && !source.toString().matches("^[a-zA-Z0-9_ -^~'.,;!#&()=`{}]*")) ? "" : source;
}
}} : new InputFilter[]{new LengthFilter(this.allowedLength)});
}
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return new MainInputConnection(super.onCreateInputConnection(outAttrs), true, this);
}
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (keyCode != KeyEvent.KEYCODE_BACK || event.getAction() != KeyEvent.ACTION_UP) {
return super.dispatchKeyEvent(event);
}
if (this._MainKeyWatcher != null) {
this._MainKeyWatcher.onBackKeyPressed();
}
return false;
}
public void setOnMainKeyWatcher(MainKeyWatcher MainKeyWatcher) {
this._MainKeyWatcher = MainKeyWatcher;
}
}
@@ -1,86 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.*;
import android.content.res.Configuration;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.util.*;
import android.view.*;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
public class MinecraftGLView extends TextureView
{
public MinecraftGLView(Context context) {
super(context);
//setPreserveEGLContextOnPause(true);
setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if(!b) {
((InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(),0);
}
}
});
}
public MinecraftGLView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if(!b) {
((InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(),0);
}
}
});
}
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.inputType = EditorInfo.TYPE_NULL;
Log.d("TypeableGLView","onCreateInputConnection");
return new MinecraftInputConnection(this, false);
}
@Override
public boolean onCheckIsTextEditor() {
return false;
}
public static boolean isHardKB(Context ctx) {
return ctx.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
}
}
class MinecraftInputConnection extends BaseInputConnection {
private SpannableStringBuilder _editable;
BaseMainActivity parent;
public MinecraftInputConnection(View targetView, boolean fullEditor) {
super(targetView, fullEditor);
parent = (BaseMainActivity)targetView.getContext();
}
public Editable getEditable() {
if (_editable == null) {
_editable = (SpannableStringBuilder) Editable.Factory.getInstance()
.newEditable("Placeholder");
}
return _editable;
}
public boolean commitText(CharSequence text, int newCursorPosition) {
//parent.sendKeyPress(text.charAt(0));
for(int i = 0; i < text.length(); i++) parent.sendKeyPress(text.charAt(i));
return true;
}
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
for(int i = 0; i < beforeLength; i++) {
parent.sendKeyPress(LWJGLGLFWKeycode.GLFW_KEY_BACKSPACE);
}
return true;
}
}
@@ -1,96 +0,0 @@
package net.kdt.pojavlaunch;
import android.app.*;
import android.content.*;
import android.content.pm.*;
import android.content.res.*;
import android.os.*;
import androidx.core.app.*;
import androidx.preference.*;
import android.util.*;
import java.io.*;
import java.text.*;
import java.util.*;
import net.kdt.pojavlaunch.utils.*;
public class PojavApplication extends Application
{
public static String CRASH_REPORT_TAG = "PojavCrashReport";
@Override
public void onCreate() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){
@Override
public void uncaughtException(Thread thread, Throwable th) {
boolean storagePermAllowed = Build.VERSION.SDK_INT < 23 || ActivityCompat.checkSelfPermission(PojavApplication.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
File crashFile = new File(storagePermAllowed ? Tools.DIR_GAME_NEW : Tools.DIR_DATA, "latestcrash.txt");
try {
// Write to file, since some devices may not able to show error
crashFile.getParentFile().mkdirs();
crashFile.createNewFile();
PrintStream crashStream = new PrintStream(crashFile);
crashStream.append("PojavLauncher crash report\n");
crashStream.append(" - Time: " + DateFormat.getDateTimeInstance().format(new Date()) + "\n");
crashStream.append(" - Device: " + Build.PRODUCT + " " + Build.MODEL + "\n");
crashStream.append(" - Android version: " + Build.VERSION.RELEASE + "\n");
crashStream.append(" - Crash stack trace:\n");
crashStream.append(Log.getStackTraceString(th));
crashStream.close();
} catch (Throwable th2) {
Log.e(CRASH_REPORT_TAG, " - Exception attempt saving crash stack trace:", th2);
Log.e(CRASH_REPORT_TAG, " - The crash stack trace was:", th);
}
FatalErrorActivity.showError(PojavApplication.this, crashFile.getAbsolutePath(), storagePermAllowed, th);
// android.os.Process.killProcess(android.os.Process.myPid());
BaseMainActivity.fullyExit();
}
});
try {
super.onCreate();
Tools.APP_NAME = getResources().getString(R.string.app_short_name);
Tools.DIR_DATA = getDir("files", MODE_PRIVATE).getParent();
Tools.DIR_HOME_JRE = Tools.DIR_DATA + "/jre_runtime";
Tools.DIR_ACCOUNT_OLD = Tools.DIR_DATA + "/Users";
Tools.DIR_ACCOUNT_NEW = Tools.DIR_DATA + "/accounts";
// Tools.FILE_ACCOUNT_JSON = getFilesDir().getAbsolutePath() + "/account_profiles.json";
File nativeLibDir = new File(getApplicationInfo().nativeLibraryDir);
Tools.CURRENT_ARCHITECTURE = nativeLibDir.getName();
switch (Tools.CURRENT_ARCHITECTURE) {
case "arm": Tools.CURRENT_ARCHITECTURE = "arm/aarch32"; break;
case "arm64": Tools.CURRENT_ARCHITECTURE = "arm64/aarch64"; break;
case "x86": Tools.CURRENT_ARCHITECTURE = "x86/i*86"; break;
case "x86_64": Tools.CURRENT_ARCHITECTURE = "x86_64/amd64"; break;
}
// Special case for Asus x86 devixes
if (Build.SUPPORTED_ABIS[0].equals("x86")) {
getApplicationInfo().nativeLibraryDir = nativeLibDir.getParent() + "/x86";
Tools.CURRENT_ARCHITECTURE = "x86/i*86";
}
FontChanger.initFonts(this);
} catch (Throwable th) {
Intent ferrorIntent = new Intent(this, FatalErrorActivity.class);
ferrorIntent.putExtra("throwable", th);
startActivity(ferrorIntent);
}
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleUtils.setLocale(base));
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
LocaleUtils.setLocale(this);
}
}
@@ -1,323 +0,0 @@
package net.kdt.pojavlaunch;
import android.animation.ValueAnimator;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.design.widget.VerticalTabLayout.ViewPagerAdapter;
import android.util.TypedValue;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Guideline;
import androidx.viewpager.widget.ViewPager;
import net.kdt.pojavlaunch.fragments.ConsoleFragment;
import net.kdt.pojavlaunch.fragments.CrashFragment;
import net.kdt.pojavlaunch.fragments.LauncherFragment;
import net.kdt.pojavlaunch.prefs.LauncherPreferenceFragment;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.value.MinecraftAccount;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_HIDE_SIDEBAR;
public class PojavLauncherActivity extends BaseLauncherActivity
{
private ViewPager viewPager;
private TextView tvUsernameView, tvConnectStatus;
private Spinner accountSelector;
private ViewPagerAdapter viewPageAdapter;
private final Button[] Tabs = new Button[4];
private View selected;
private Button switchUsrBtn, logoutBtn; // MineButtons
public PojavLauncherActivity() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.launcher_main_v4);
if (BuildConfig.DEBUG) {
Toast.makeText(this, "Launcher process id: " + android.os.Process.myPid(), Toast.LENGTH_LONG).show();
}
viewPager = findViewById(R.id.launchermainTabPager);
selected = findViewById(R.id.viewTabSelected);
mConsoleView = new ConsoleFragment();
mCrashView = new CrashFragment();
viewPageAdapter = new ViewPagerAdapter(getSupportFragmentManager());
viewPageAdapter.addFragment(new LauncherFragment(), 0, getString(R.string.mcl_tab_news));
viewPageAdapter.addFragment(mConsoleView, 0, getString(R.string.mcl_tab_console));
viewPageAdapter.addFragment(mCrashView, 0, getString(R.string.mcl_tab_crash));
viewPageAdapter.addFragment(new LauncherPreferenceFragment(), 0, getString(R.string.mcl_option_settings));
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
setTabActive(position);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
viewPager.setAdapter(viewPageAdapter);
tvConnectStatus = (TextView) findViewById(R.id.launchermain_text_accountstatus);
tvUsernameView = (TextView) findViewById(R.id.launchermain_text_welcome);
mTextVersion = (TextView) findViewById(R.id.launcherMainVersionView);
//The following line is used to make this TextView horizontally scroll if the version name is larger than the view
mTextVersion.setSelected(true);
Tabs[0] = findViewById(R.id.btnTab1);
Tabs[1] = findViewById(R.id.btnTab2);
Tabs[2] = findViewById(R.id.btnTab3);
Tabs[3] = findViewById(R.id.btnTab4);
pickAccount();
/*
File logFile = new File(Tools.MAIN_PATH, "latestlog.txt");
if (logFile.exists() && logFile.length() < 20480) {
String errMsg = "Error occurred during initialization of ";
try {
String logContent = Tools.read(logFile.getAbsolutePath());
if (logContent.contains(errMsg + "VM") &&
logContent.contains("Could not reserve enough space for")) {
OutOfMemoryError ex = new OutOfMemoryError("Java error: " + logContent);
ex.setStackTrace(null);
Tools.showError(PojavLauncherActivity.this, ex);
// Do it so dialog will not shown for second time
Tools.write(logFile.getAbsolutePath(), logContent.replace(errMsg + "VM", errMsg + "JVM"));
}
} catch (Throwable th) {
Log.w(Tools.APP_NAME, "Could not detect java crash", th);
}
}
*/
//showProfileInfo();
final List<String> accountList = new ArrayList<String>();
final MinecraftAccount tempProfile = PojavProfile.getTempProfileContent(this);
if (tempProfile != null) {
accountList.add(tempProfile.username);
}
for (String s : new File(Tools.DIR_ACCOUNT_NEW).list()) {
accountList.add(s.substring(0, s.length() - 5));
}
ArrayAdapter<String> adapterAcc = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, accountList);
adapterAcc.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
accountSelector = (Spinner) findViewById(R.id.launchermain_spinner_account);
accountSelector.setAdapter(adapterAcc);
if (tempProfile != null) {
accountSelector.setSelection(0);
} else {
for (int i = 0; i < accountList.size(); i++) {
String account = accountList.get(i);
if (account.equals(mProfile.username)) {
accountSelector.setSelection(i);
}
}
}
accountSelector.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> p1, View p2, int position, long p4) {
if (tempProfile != null && position == 0) {
PojavProfile.setCurrentProfile(PojavLauncherActivity.this, tempProfile);
} else {
PojavProfile.setCurrentProfile(PojavLauncherActivity.this,
accountList.get(position + (tempProfile != null ? 1 : 0)));
}
pickAccount();
}
@Override
public void onNothingSelected(AdapterView<?> p1) {
// TODO: Implement this method
}
});
List<String> versions = new ArrayList<String>();
final File fVers = new File(Tools.DIR_HOME_VERSION);
try {
if (fVers.listFiles().length < 1) {
throw new Exception(getString(R.string.error_no_version));
}
for (File fVer : fVers.listFiles()) {
if (fVer.isDirectory())
versions.add(fVer.getName());
}
} catch (Exception e) {
versions.add(getString(R.string.global_error) + ":");
versions.add(e.getMessage());
} finally {
mAvailableVersions = versions.toArray(new String[0]);
}
//mAvailableVersions;
ArrayAdapter<String> adapterVer = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mAvailableVersions);
adapterVer.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
mVersionSelector = (Spinner) findViewById(R.id.launchermain_spinner_version);
mVersionSelector.setAdapter(adapterVer);
mLaunchProgress = (ProgressBar) findViewById(R.id.progressDownloadBar);
mLaunchTextStatus = (TextView) findViewById(R.id.progressDownloadText);
switchUsrBtn = (Button) findViewById(R.id.infoDevBtn);
logoutBtn = (Button) findViewById(R.id.switchUserBtn);
mPlayButton = (Button) findViewById(R.id.launchermainPlayButton);
statusIsLaunching(false);
initTabs(0);
LauncherPreferences.DEFAULT_PREF.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.equals("hideSidebar")) {
restoreOldLook(sharedPreferences.getBoolean("hideSidebar",false));
}
}
});
restoreOldLook(PREF_HIDE_SIDEBAR);
}
private void selectTabPage(int pageIndex){
viewPager.setCurrentItem(pageIndex);
setTabActive(pageIndex);
}
private void pickAccount() {
try {
mProfile = PojavProfile.getCurrentProfileContent(this);
tvUsernameView.setText(getString(R.string.main_welcome, mProfile.username));
tvConnectStatus.setText(mProfile.accessToken.equals("0") ? R.string.mcl_account_offline : R.string.mcl_account_connected);
} catch(Exception e) {
mProfile = new MinecraftAccount();
Tools.showError(this, e, true);
}
}
public void statusIsLaunching(boolean isLaunching) {
int launchVisibility = isLaunching ? View.VISIBLE : View.GONE;
mLaunchProgress.setVisibility(launchVisibility);
mLaunchTextStatus.setVisibility(launchVisibility);
switchUsrBtn.setEnabled(!isLaunching);
logoutBtn.setEnabled(!isLaunching);
mVersionSelector.setEnabled(!isLaunching);
canBack = !isLaunching;
}
public void onTabClicked(View view) {
for(int i=0; i<Tabs.length;i++){
if(view.getId() == Tabs[i].getId()) {
selectTabPage(i);
return;
}
}
}
private void setTabActive(int index){
for (Button tab : Tabs) {
tab.setTypeface(null, Typeface.NORMAL);
tab.setTextColor(Color.rgb(220,220,220)); //Slightly less bright white.
}
Tabs[index].setTypeface(Tabs[index].getTypeface(), Typeface.BOLD);
Tabs[index].setTextColor(Color.WHITE);
//Animating the white bar on the left
ValueAnimator animation = ValueAnimator.ofFloat(selected.getY(), Tabs[index].getY()+(Tabs[index].getHeight()-selected.getHeight())/2f);
animation.setDuration(250);
animation.addUpdateListener(animation1 -> selected.setY((float) animation1.getAnimatedValue()));
animation.start();
}
protected void initTabs(int activeTab){
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 100ms
selectTabPage(activeTab);
}
}, 500);
}
private void restoreOldLook(boolean oldLookState){
if(oldLookState){
//UI v1 Style
//Hide the sidebar
Guideline guideLine = findViewById(R.id.guidelineLeft);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) guideLine.getLayoutParams();
params.guidePercent = 0; // 0%, range: 0 <-> 1
guideLine.setLayoutParams(params);
//Remove the selected Tab
selected.setVisibility(View.GONE);
//Enlarge the button, but just a bit.
params = (ConstraintLayout.LayoutParams) mPlayButton.getLayoutParams();
params.width = (int)(params.width*1.80);
mPlayButton.setLayoutParams(params);
}else{
//UI v2 Style
//Show the sidebar back
Guideline guideLine = findViewById(R.id.guidelineLeft);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) guideLine.getLayoutParams();
params.guidePercent = 0.23f; // 23%, range: 0 <-> 1
guideLine.setLayoutParams(params);
//Show the selected Tab
selected.setVisibility(View.VISIBLE);
//Set the default button size
params = (ConstraintLayout.LayoutParams) mPlayButton.getLayoutParams();
params.width = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
160,
getResources().getDisplayMetrics());
mPlayButton.setLayoutParams(params);
}
}
}
@@ -1,929 +0,0 @@
package net.kdt.pojavlaunch;
import android.Manifest;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.system.Os;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.kdt.pickafile.FileListView;
import com.kdt.pickafile.FileSelectedListener;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Locale;
import net.kdt.pojavlaunch.authenticator.microsoft.MicrosoftAuthTask;
import net.kdt.pojavlaunch.authenticator.mojang.InvalidateTokenTask;
import net.kdt.pojavlaunch.authenticator.mojang.LoginListener;
import net.kdt.pojavlaunch.authenticator.mojang.LoginTask;
import net.kdt.pojavlaunch.authenticator.mojang.RefreshListener;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.CustomControls;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.utils.JREUtils;
import net.kdt.pojavlaunch.utils.LocaleUtils;
import net.kdt.pojavlaunch.value.MinecraftAccount;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
public class PojavLoginActivity extends BaseActivity
// MineActivity
{
private Object mLockStoragePerm = new Object(),
mLockSelectJRE = new Object();
private EditText edit2, edit3;
private int REQUEST_STORAGE_REQUEST_CODE = 1;
private ProgressBar prb;
private CheckBox sRemember, sOffline;
private LinearLayout loginLayout;
private Spinner spinnerChgLang;
private ImageView imageLogo;
private TextView startupTextView;
private SharedPreferences firstLaunchPrefs;
private static boolean isSkipInit = false;
// private final String PREF_IS_DONOTSHOWAGAIN_WARN = "isWarnDoNotShowAgain";
public static final String PREF_IS_INSTALLED_JAVARUNTIME = "isJavaRuntimeInstalled";
public static final String PREF_JAVARUNTIME_VER = "javaRuntimeVersion";
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState); // false);
Tools.updateWindowSize(this);
/*
ControlData.pixelOf2dp = (int) Tools.dpToPx(2);
ControlData.pixelOf30dp = (int) Tools.dpToPx(30);
ControlData.pixelOf50dp = (int) Tools.dpToPx(50);
ControlData.pixelOf80dp = (int) Tools.dpToPx(80);
*/
ControlData[] specialButtons = ControlData.getSpecialButtons();
specialButtons[0].name = getString(R.string.control_keyboard);
specialButtons[1].name = getString(R.string.control_toggle);
specialButtons[2].name = getString(R.string.control_primary);
specialButtons[3].name = getString(R.string.control_secondary);
specialButtons[4].name = getString(R.string.control_mouse);
firstLaunchPrefs = getSharedPreferences("pojav_extract", MODE_PRIVATE);
new InitTask().execute(isSkipInit);
}
private class InitTask extends AsyncTask<Boolean, String, Integer>{
private AlertDialog startAle;
private ProgressBar progress;
private ProgressBar progressSpin;
// private EditText progressLog;
private AlertDialog progDlg;
@Override
protected void onPreExecute()
{
LinearLayout startScr = new LinearLayout(PojavLoginActivity.this);
LayoutInflater.from(PojavLoginActivity.this).inflate(R.layout.start_screen, startScr);
FontChanger.changeFonts(startScr);
progress = (ProgressBar) startScr.findViewById(R.id.startscreenProgress);
startupTextView = (TextView) startScr.findViewById(R.id.startscreen_text);
//startScr.addView(progress);
AlertDialog.Builder startDlg = new AlertDialog.Builder(PojavLoginActivity.this, R.style.AppTheme);
startDlg.setView(startScr);
startDlg.setCancelable(false);
startAle = startDlg.create();
startAle.show();
startAle.getWindow().setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT
);
}
private int revokeCount = -1;
@Override
protected Integer doInBackground(Boolean[] params) {
// If trigger a quick restart
if (params[0] == true) {
return 0;
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {}
publishProgress("visible");
while (Build.VERSION.SDK_INT >= 23 && !isStorageAllowed()){
try {
revokeCount++;
if (revokeCount >= 3) {
Toast.makeText(PojavLoginActivity.this, R.string.toast_permission_denied, Toast.LENGTH_LONG).show();
finish();
return 0;
}
requestStoragePermission();
synchronized (mLockStoragePerm) {
mLockStoragePerm.wait();
}
} catch (InterruptedException e) {}
}
try {
initMain();
} catch (Throwable th) {
Tools.showError(PojavLoginActivity.this, th, true);
return 1;
}
return 0;
}
@Override
protected void onProgressUpdate(String... obj)
{
if (obj[0].equals("visible")) {
progress.setVisibility(View.VISIBLE);
} /* else if (obj.length == 2 && obj[1] != null) {
progressLog.append(obj[1]);
} */
}
@Override
protected void onPostExecute(Integer obj) {
startAle.dismiss();
if (progressSpin != null) progressSpin.setVisibility(View.GONE);
if (obj == 0) {
if (progDlg != null) progDlg.dismiss();
uiInit();
} /* else if (progressLog != null) {
progressLog.setText(getResources().getString(R.string.error_checklog, "\n\n" + progressLog.getText()));
} */
}
}
private void uiInit() {
setContentView(R.layout.launcher_login_v2);
loginLayout = findViewById(R.id.login_layout_linear);
spinnerChgLang = findViewById(R.id.login_spinner_language);
imageLogo = findViewById(R.id.login_image_logo);
loginLayout.postDelayed(new Runnable(){
@Override
public void run(){
imageLogo.setTranslationY(loginLayout.getY() - (imageLogo.getHeight() / 2f));
}
}, 100);
String defaultLang = LocaleUtils.DEFAULT_LOCALE.getDisplayName();
SpannableString defaultLangChar = new SpannableString(defaultLang);
defaultLangChar.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, defaultLang.length(), 0);
final ArrayAdapter<DisplayableLocale> langAdapter = new ArrayAdapter<DisplayableLocale>(this, android.R.layout.simple_spinner_item);
langAdapter.add(new DisplayableLocale(LocaleUtils.DEFAULT_LOCALE, defaultLangChar));
langAdapter.add(new DisplayableLocale(Locale.ENGLISH));
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(getAssets().open("language_list.txt")));
String line;
while ((line = reader.readLine()) != null) {
File currFile = new File("/" + line);
// System.out.println(currFile.getAbsolutePath());
if (currFile.getAbsolutePath().contains("/values-") || currFile.getName().startsWith("values-")) {
// TODO use regex(?)
langAdapter.add(new DisplayableLocale(currFile.getName().replace("values-", "").replace("-r", "-")));
}
}
} catch (IOException e) {
Tools.showError(this, e);
}
langAdapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
int selectedLang = 0;
for (int i = 0; i < langAdapter.getCount(); i++) {
if (Locale.getDefault().getDisplayLanguage().equals(langAdapter.getItem(i).mLocale.getDisplayLanguage())) {
selectedLang = i;
break;
}
}
spinnerChgLang.setAdapter(langAdapter);
spinnerChgLang.setSelection(selectedLang);
spinnerChgLang.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
private boolean isInitCalled;
@Override
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
if (!isInitCalled) {
isInitCalled = true;
return;
}
Locale locale;
if (position == 0) {
locale = LocaleUtils.DEFAULT_LOCALE;
} else if (position == 1) {
locale = Locale.ENGLISH;
} else {
locale = langAdapter.getItem(position).mLocale;
}
LauncherPreferences.PREF_LANGUAGE = locale.getLanguage();
LauncherPreferences.DEFAULT_PREF.edit().putString("language", LauncherPreferences.PREF_LANGUAGE).commit();
// Restart to apply language change
finish();
startActivity(getIntent());
}
@Override
public void onNothingSelected(AdapterView<?> adapter) {}
});
edit2 = (EditText) findViewById(R.id.login_edit_email);
edit3 = (EditText) findViewById(R.id.login_edit_password);
if(prb == null) prb = (ProgressBar) findViewById(R.id.launcherAccProgress);
sRemember = findViewById(R.id.login_switch_remember);
sOffline = findViewById(R.id.login_switch_offline);
sOffline.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton p1, boolean p2) {
// May delete later
edit3.setEnabled(!p2);
}
});
isSkipInit = true;
}
@Override
public void onResume() {
super.onResume();
Tools.updateWindowSize(this);
if (loginLayout != null && imageLogo != null) {
imageLogo.setTranslationY(loginLayout.getY() - (imageLogo.getHeight() / 2f));
}
// Clear current profile
PojavProfile.setCurrentProfile(this, null);
}
private boolean isJavaRuntimeInstalled(AssetManager am) {
boolean prefValue = firstLaunchPrefs.getBoolean(PREF_IS_INSTALLED_JAVARUNTIME, false);
try {
return prefValue && (
am.open("components/jre/bin-" + Tools.CURRENT_ARCHITECTURE.split("/")[0] + ".tar.xz") == null ||
Tools.read(new FileInputStream(Tools.DIR_HOME_JRE+"/version")).equals(Tools.read(am.open("components/jre/version"))));
} catch(IOException e) {
Log.e("JVMCtl","failed to read file",e);
return prefValue;
}
}
private void unpackComponent(AssetManager am, String component) throws IOException {
InputStream is = am.open("components/" + component + "/version");
if(!new File(Tools.DIR_GAME_NEW + "/" + component + "/version").exists()) {
Log.i("UnpackPrep", component + ": Pack was installed manually, or does not exist, unpacking new...");
String[] fileList = am.list("components/" + component);
for(String s : fileList) {
Tools.copyAssetFile(this, "components/" + component + "/" + s, Tools.DIR_GAME_NEW + "/" + component, true);
}
} else {
FileInputStream fis = new FileInputStream(new File(Tools.DIR_GAME_NEW + "/" + component + "/version"));
String release1 = Tools.read(is);
String release2 = Tools.read(fis);
if (!release1.equals(release2)) {
String[] fileList = am.list("components/" + component);
for (String s : fileList) {
Tools.copyAssetFile(this, "components/" + component + "/" + s, Tools.DIR_GAME_NEW + "/" + component, true);
}
} else {
Log.i("UnpackPrep", component + ": Pack is up-to-date with the launcher, continuing...");
}
}
}
private void initMain() throws Throwable {
mkdirs(Tools.DIR_ACCOUNT_NEW);
PojavMigrator.migrateAccountData(this);
mkdirs(Tools.DIR_GAME_HOME);
if (!PojavMigrator.migrateGameDir()) {
mkdirs(Tools.DIR_GAME_NEW);
mkdirs(Tools.DIR_GAME_NEW + "/config");
mkdirs(Tools.DIR_GAME_NEW + "/lwjgl3");
mkdirs(Tools.DIR_GAME_NEW + "/mods");
mkdirs(Tools.DIR_HOME_VERSION);
mkdirs(Tools.DIR_HOME_LIBRARY);
}
File forgeSplashFile = new File(Tools.DIR_GAME_NEW, "config/splash.properties");
String forgeSplashContent = "enabled=true";
try {
if (forgeSplashFile.exists()) {
forgeSplashContent = Tools.read(forgeSplashFile.getAbsolutePath());
}
if (forgeSplashContent.contains("enabled=true")) {
Tools.write(forgeSplashFile.getAbsolutePath(),
forgeSplashContent.replace("enabled=true", "enabled=false"));
}
} catch (IOException e) {
Log.w(Tools.APP_NAME, "Could not disable Forge 1.12.2 and below splash screen!", e);
}
mkdirs(Tools.CTRLMAP_PATH);
try {
new CustomControls(this).save(Tools.CTRLDEF_FILE);
Tools.copyAssetFile(this, "components/ForgeInstallerHeadless/forge-installer-headless-1.0.1.jar",
Tools.DIR_GAME_NEW + "/config", "forge-installer-headless.jar", true);
Tools.copyAssetFile(this, "components/OptiInst.jar",
Tools.DIR_GAME_NEW + "/config", "OptiInst.jar", true);
Tools.copyAssetFile(this, "components/security/pro-grade.jar", Tools.DIR_DATA, true);
Tools.copyAssetFile(this, "components/security/java_sandbox.policy", Tools.DIR_DATA, true);
Tools.copyAssetFile(this, "options.txt", Tools.DIR_GAME_NEW, false);
// TODO: Remove after implement.
Tools.copyAssetFile(this, "launcher_profiles.json", Tools.DIR_GAME_NEW, false);
AssetManager am = this.getAssets();
unpackComponent(am, "caciocavallo");
unpackComponent(am, "lwjgl3");
if (!isJavaRuntimeInstalled(am)) {
if(!installRuntimeAutomatically(am)) {
File jreTarFile = selectJreTarFile();
uncompressTarXZ(jreTarFile, new File(Tools.DIR_HOME_JRE));
} else {
Tools.copyAssetFile(this, "components/jre/version", Tools.DIR_HOME_JRE + "/","version", true);
}
firstLaunchPrefs.edit().putBoolean(PREF_IS_INSTALLED_JAVARUNTIME, true).commit();
}
JREUtils.relocateLibPath(this);
File ftIn = new File(Tools.DIR_HOME_JRE, Tools.DIRNAME_HOME_JRE + "/libfreetype.so.6");
File ftOut = new File(Tools.DIR_HOME_JRE, Tools.DIRNAME_HOME_JRE + "/libfreetype.so");
if (ftIn.exists() && (!ftOut.exists() || ftIn.length() != ftOut.length())) {
ftIn.renameTo(ftOut);
}
// Refresh libraries
copyDummyNativeLib("libawt_xawt.so");
// copyDummyNativeLib("libfontconfig.so");
}
catch(Throwable e){
Tools.showError(this, e);
}
}
private boolean installRuntimeAutomatically(AssetManager am) {
try {
am.open("components/jre/version");
} catch (IOException e) {
Log.e("JREAuto", "JRE was not included on this APK.", e);
return false;
}
File rtUniversal = new File(Tools.DIR_HOME_JRE+"/universal.tar.xz");
File rtPlatformDependent = new File(Tools.DIR_HOME_JRE+"/cust-bin.tar.xz");
if(!new File(Tools.DIR_HOME_JRE).exists()) new File(Tools.DIR_HOME_JRE).mkdirs(); else {
//SANITY: remove the existing files
for (File f : new File(Tools.DIR_HOME_JRE).listFiles()) {
if (f.isDirectory()){
try {
FileUtils.deleteDirectory(f);
} catch(IOException e1) {
Log.e("JREAuto","da fuq is wrong wit ur device? n2",e1);
}
} else{
f.delete();
}
}
}
InputStream is;
FileOutputStream os;
try {
is = am.open("components/jre/universal.tar.xz");
os = new FileOutputStream(rtUniversal);
IOUtils.copy(is,os);
is.close();
os.close();
uncompressTarXZ(rtUniversal, new File(Tools.DIR_HOME_JRE));
} catch (IOException e){
Log.e("JREAuto","Failed to unpack universal. Custom embedded-less build?",e);
return false;
}
try {
is = am.open("components/jre/bin-" + Tools.CURRENT_ARCHITECTURE.split("/")[0] + ".tar.xz");
os = new FileOutputStream(rtPlatformDependent);
IOUtils.copy(is, os);
is.close();
os.close();
uncompressTarXZ(rtPlatformDependent, new File(Tools.DIR_HOME_JRE));
} catch (IOException e) {
// Something's very wrong, or user's using an unsupported arch (MIPS phone? ARMv6 phone?),
// in both cases, redirecting to manual install, and removing the universal stuff
for (File f : new File(Tools.DIR_HOME_JRE).listFiles()) {
if (f.isDirectory()){
try {
FileUtils.deleteDirectory(f);
} catch(IOException e1) {
Log.e("JREAuto","da fuq is wrong wit ur device?",e1);
}
} else{
f.delete();
}
}
return false;
}
return true;
}
private void copyDummyNativeLib(String name) throws Throwable {
File fileLib = new File(Tools.DIR_HOME_JRE, Tools.DIRNAME_HOME_JRE + "/" + name);
fileLib.delete();
FileInputStream is = new FileInputStream(new File(getApplicationInfo().nativeLibraryDir, name));
FileOutputStream os = new FileOutputStream(fileLib);
IOUtils.copy(is, os);
is.close();
os.close();
}
private File selectJreTarFile() throws InterruptedException {
final StringBuilder selectedFile = new StringBuilder();
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(PojavLoginActivity.this);
builder.setTitle(getString(R.string.alerttitle_install_jre, Tools.CURRENT_ARCHITECTURE));
builder.setCancelable(false);
final AlertDialog dialog = builder.create();
FileListView flv = new FileListView(dialog, "tar.xz");
flv.setFileSelectedListener(new FileSelectedListener(){
@Override
public void onFileSelected(File file, String path) {
selectedFile.append(path);
dialog.dismiss();
synchronized (mLockSelectJRE) {
mLockSelectJRE.notifyAll();
}
}
});
dialog.setView(flv);
dialog.show();
}
});
synchronized (mLockSelectJRE) {
mLockSelectJRE.wait();
}
return new File(selectedFile.toString());
}
private void uncompressTarXZ(final File tarFile, final File dest) throws IOException {
dest.mkdirs();
TarArchiveInputStream tarIn = null;
tarIn = new TarArchiveInputStream(
new XZCompressorInputStream(
new BufferedInputStream(
new FileInputStream(tarFile)
)
)
);
TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
// tarIn is a TarArchiveInputStream
while (tarEntry != null) {
/*
* Unpacking very small files in short time cause
* application to ANR or out of memory, so delay
* a little if size is below than 20kb (20480 bytes)
*/
if (tarEntry.getSize() <= 20480) {
try {
// 40 small files per second
Thread.sleep(25);
} catch (InterruptedException e) {}
}
final String tarEntryName = tarEntry.getName();
runOnUiThread(new Runnable(){
@Override
public void run() {
startupTextView.setText(getString(R.string.global_unpacking, tarEntryName));
}
});
// publishProgress(null, "Unpacking " + tarEntry.getName());
File destPath = new File(dest, tarEntry.getName());
if (tarEntry.isSymbolicLink()) {
destPath.getParentFile().mkdirs();
try {
// android.system.Os
// Libcore one support all Android versions
Os.symlink(tarEntry.getName(), tarEntry.getLinkName());
} catch (Throwable e) {
e.printStackTrace();
}
// unpackShell.writeToProcess("ln -s " + tarEntry.getName() + " " + tarEntry.getLinkName());
} else if (tarEntry.isDirectory()) {
destPath.mkdirs();
destPath.setExecutable(true);
} else if (!destPath.exists() || destPath.length() != tarEntry.getSize()) {
destPath.getParentFile().mkdirs();
destPath.createNewFile();
// destPath.setExecutable(true);
FileOutputStream os = new FileOutputStream(destPath);
IOUtils.copy(tarIn, os);
os.close();
/*
byte[] btoRead = new byte[2048];
BufferedOutputStream bout =
new BufferedOutputStream(new FileOutputStream(destPath));
int len = 0;
while((len = tarIn.read(btoRead)) != -1) {
bout.write(btoRead,0,len);
}
bout.close();
btoRead = null;
*/
}
tarEntry = tarIn.getNextTarEntry();
}
tarIn.close();
}
private boolean mkdirs(String path)
{
File file = new File(path);
// check necessary???
if(file.getParentFile().exists())
return file.mkdir();
else return file.mkdirs();
}
/*
public void loginUsername(View view)
{
LinearLayout mainLaun = new LinearLayout(this);
LayoutInflater.from(this).inflate(R.layout.launcher_user, mainLaun, true);
replaceFonts(mainLaun);
//edit1 = mainLaun.findViewById(R.id.launcherAccUsername);
new AlertDialog.Builder(this)
.setTitle("Register with username")
.setView(mainLaun)
.show();
}
*/
public void loginMicrosoft(View view) {
CustomTabs.openTab(this,
"https://login.live.com/oauth20_authorize.srf" +
"?client_id=00000000402b5328" +
"&response_type=code" +
"&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL" +
"&redirect_url=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf");
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Uri data = intent.getData();
//Log.i("MicroAuth", data.toString());
if (data != null && data.getScheme().equals("ms-xal-00000000402b5328") && data.getHost().equals("auth")) {
String error = data.getQueryParameter("error");
String error_description = data.getQueryParameter("error_description");
if (error != null) {
// "The user has denied access to the scope requested by the client application": user pressed Cancel button, skip it
if (!error_description.startsWith("The user has denied access to the scope requested by the client application")) {
Toast.makeText(this, "Error: " + error + ": " + error_description, Toast.LENGTH_LONG).show();
}
} else {
String code = data.getQueryParameter("code");
new MicrosoftAuthTask(this, new RefreshListener(){
@Override
public void onFailed(Throwable e) {
Tools.showError(PojavLoginActivity.this, e);
}
@Override
public void onSuccess(MinecraftAccount b) {
mProfile = b;
playProfile(false);
}
}).execute("false", code);
// Toast.makeText(this, "Logged in to Microsoft account, but NYI", Toast.LENGTH_LONG).show();
}
}
}
private View getViewFromList(int pos, ListView listView) {
final int firstItemPos = listView.getFirstVisiblePosition();
final int lastItemPos = firstItemPos + listView.getChildCount() - 1;
if (pos < firstItemPos || pos > lastItemPos ) {
return listView.getAdapter().getView(pos, null, listView);
} else {
final int childIndex = pos - firstItemPos;
return listView.getChildAt(childIndex);
}
}
public void loginSavedAcc(View view) {
final Dialog accountDialog = new Dialog(PojavLoginActivity.this);
int xScreen = PojavLoginActivity.this.getResources().getDisplayMetrics().widthPixels;
int yScreen = PojavLoginActivity.this.getResources().getDisplayMetrics().heightPixels;
accountDialog.setContentView(R.layout.simple_account_list_holder);
LinearLayout accountListLayout = accountDialog.findViewById(R.id.accountListLayout);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
String[] accountArr = new File(Tools.DIR_ACCOUNT_NEW).list();
for (int accountIndex = 0; accountIndex < accountArr.length; accountIndex++) {
String s = accountArr[accountIndex];
View child = inflater.inflate(R.layout.simple_account_list_item, null);
ImageView accountIcon = child.findViewById(R.id.accountitem_image_icon);
TextView accountName = child.findViewById(R.id.accountitem_text_name);
ImageButton removeButton = child.findViewById(R.id.accountitem_button_remove);
String accNameStr = s.substring(0, s.length() - 5);
String skinFaceBase64 = MinecraftAccount.load(accNameStr).skinFaceBase64;
Bitmap bitmap = Bitmap.createBitmap(8, 8, Bitmap.Config.ARGB_8888);
if (skinFaceBase64 != null) {
byte[] faceIconBytes = Base64.decode(skinFaceBase64, Base64.DEFAULT);
bitmap = BitmapFactory.decodeByteArray(faceIconBytes, 0, faceIconBytes.length);
} else {
try {
bitmap = BitmapFactory.decodeStream(getAssets().open("ic_steve.png"));
} catch (IOException e) {
// Should never happen
e.printStackTrace();
}
}
Bitmap upscaledBitmap = Bitmap.createScaledBitmap(bitmap, 80, 80, false);
accountIcon.setImageBitmap(upscaledBitmap);
accountName.setText(accNameStr);
accountListLayout.addView(child);
accountName.setOnClickListener(new View.OnClickListener() {
final String selectedAccName = accountName.getText().toString();
@Override
public void onClick(View v) {
try {
RefreshListener authListener = new RefreshListener(){
@Override
public void onFailed(Throwable e) {
Tools.showError(PojavLoginActivity.this, e);
}
@Override
public void onSuccess(MinecraftAccount out) {
accountDialog.dismiss();
mProfile = out;
playProfile(true);
}
};
MinecraftAccount acc = MinecraftAccount.load(selectedAccName);
if (acc.isMicrosoft){
new MicrosoftAuthTask(PojavLoginActivity.this, authListener)
.execute("true", acc.msaRefreshToken);
} else if (acc.accessToken.length() >= 5) {
PojavProfile.updateTokens(PojavLoginActivity.this, selectedAccName, authListener);
} else {
accountDialog.dismiss();
PojavProfile.launch(PojavLoginActivity.this, selectedAccName);
}
} catch (Exception e) {
Tools.showError(PojavLoginActivity.this, e);
}
}
});
// Tiny trick to avoid 'const' field
final int accountIndex_final = accountIndex;
removeButton.setOnClickListener(new View.OnClickListener() {
final String selectedAccName = accountName.getText().toString();
@Override
public void onClick(View v) {
AlertDialog.Builder builder2 = new AlertDialog.Builder(PojavLoginActivity.this);
builder2.setTitle(selectedAccName);
builder2.setMessage(R.string.warning_remove_account);
builder2.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
new InvalidateTokenTask(PojavLoginActivity.this).execute(selectedAccName);
accountListLayout.removeViewsInLayout(accountIndex_final, 1);
//Resize the window
accountDialog.getWindow().setLayout((int)(xScreen*0.4),(int) Math.min((yScreen*0.8), (73 + accountListLayout.getChildCount()*55)*(PojavLoginActivity.this.getResources().getDisplayMetrics().densityDpi/160f) ));
}
});
builder2.setNegativeButton(android.R.string.cancel, null);
builder2.show();
}
});
}
//The value 73 and 56 are dp numbers, converted into px in order to resize the layout.
accountDialog.getWindow().setLayout((int)(xScreen*0.4),(int)Math.min((yScreen*0.8), (73 + accountListLayout.getChildCount()*56)*(PojavLoginActivity.this.getResources().getDisplayMetrics().densityDpi/160f) ));
accountDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
accountDialog.show();
}
private MinecraftAccount loginOffline() {
new File(Tools.DIR_ACCOUNT_OLD).mkdir();
String text = edit2.getText().toString();
if(text.isEmpty()){
edit2.setError(getResources().getString(R.string.global_error_field_empty));
} else if(text.length() <= 2){
edit2.setError(getResources().getString(R.string.login_error_short_username));
} else if(new File(Tools.DIR_ACCOUNT_NEW + "/" + text + ".json").exists()){
edit2.setError(getResources().getString(R.string.login_error_exist_username));
} else{
MinecraftAccount builder = new MinecraftAccount();
builder.isMicrosoft = false;
builder.username = text;
return builder;
}
return null;
}
private MinecraftAccount mProfile = null;
public void loginMC(final View v)
{
/*skip it
String proFilePath = MCProfile.build(builder);
MCProfile.launchWithProfile(this, proFilePath);
end skip*/
if (sOffline.isChecked()) {
mProfile = loginOffline();
playProfile(false);
} else {
new LoginTask().setLoginListener(new LoginListener(){
@Override
public void onBeforeLogin() {
v.setEnabled(false);
prb.setVisibility(View.VISIBLE);
}
@Override
public void onLoginDone(String[] result) {
if(result[0].equals("ERROR")){
Tools.dialogOnUiThread(PojavLoginActivity.this,
getResources().getString(R.string.global_error), strArrToString(result));
} else{
MinecraftAccount builder = new MinecraftAccount();
builder.accessToken = result[1];
builder.clientToken = result[2];
builder.profileId = result[3];
builder.username = result[4];
builder.selectedVersion = "1.12.2";
builder.updateSkinFace();
mProfile = builder;
}
runOnUiThread(() -> {
v.setEnabled(true);
prb.setVisibility(View.GONE);
playProfile(false);
});
}
}).execute(edit2.getText().toString(), edit3.getText().toString());
}
}
private void playProfile(boolean notOnLogin) {
if (mProfile != null) {
try {
String profileName = null;
if (sRemember.isChecked() || notOnLogin) {
profileName = mProfile.save();
}
PojavProfile.launch(PojavLoginActivity.this, profileName == null ? mProfile : profileName);
} catch (IOException e) {
Tools.showError(this, e);
}
}
}
public static String strArrToString(String[] strArr)
{
String[] strArrEdit = strArr;
strArrEdit[0] = "";
String str = Arrays.toString(strArrEdit);
str = str.substring(1, str.length() - 1).replace(",", "\n");
return str;
}
//We are calling this method to check the permission status
private boolean isStorageAllowed() {
//Getting the permission status
int result1 = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
int result2 = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
//If permission is granted returning true
return result1 == PackageManager.PERMISSION_GRANTED &&
result2 == PackageManager.PERMISSION_GRANTED;
}
//Requesting permission
private void requestStoragePermission()
{
ActivityCompat.requestPermissions(this, new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_STORAGE_REQUEST_CODE);
}
// This method will be called when the user will tap on allow or deny
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == REQUEST_STORAGE_REQUEST_CODE){
synchronized (mLockStoragePerm) {
mLockStoragePerm.notifyAll();
}
}
}
}
@@ -1,79 +0,0 @@
package net.kdt.pojavlaunch;
import android.content.*;
import java.io.*;
import net.kdt.pojavlaunch.value.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
public class PojavMigrator
{
public static void migrateAccountData(Context ctx) {
File oldAccDir = new File(Tools.DIR_ACCOUNT_OLD);
if (oldAccDir.exists() && oldAccDir.isDirectory()) {
for (String account : oldAccDir.list()) {
File oldAccFile = new File(oldAccDir, account);
try {
MCProfile.Builder oldAccStruct = MCProfile.load(oldAccFile.getAbsolutePath());
MinecraftAccount newAccStruct = new MinecraftAccount();
newAccStruct.accessToken = oldAccStruct.getAccessToken();
newAccStruct.clientToken = oldAccStruct.getClientID();
newAccStruct.isMicrosoft = false;
newAccStruct.profileId = oldAccStruct.getProfileID();
newAccStruct.selectedVersion = oldAccStruct.getVersion();
newAccStruct.username = oldAccStruct.getUsername();
newAccStruct.save();
} catch (IOException e) {
Tools.showError(ctx, e);
}
oldAccFile.delete();
}
}
}
public static boolean migrateGameDir() throws IOException {
File oldGameDir = new File(Tools.DIR_GAME_OLD);
boolean moved = oldGameDir.exists() && oldGameDir.isDirectory();
/*
if (!migrateBugFix20201217() && moved) {
command("mv " + Tools.DIR_GAME_OLD + " " + Tools.DIR_GAME_HOME + "/");
}
*/
if(moved) {
oldGameDir.renameTo(new File(Tools.DIR_GAME_NEW + "/"));
FileUtils.deleteDirectory(new File(Tools.DIR_GAME_NEW + "/lwjgl3"));
}
return moved;
}
public static boolean migrateBugFix20201217() throws IOException, InterruptedException {
File bugGameDir = new File(Tools.DIR_GAME_NEW + "/.minecraft");
File oldGameDir = new File(Tools.DIR_GAME_OLD);
boolean moved = bugGameDir.exists() && bugGameDir.isDirectory();
/*
if (oldGameDir.exists() && oldGameDir.isDirectory() && moved) {
command("rm -rf " + oldGameDir.getAbsolutePath());
}
*/
if (moved) {
command("mv " + bugGameDir.getAbsolutePath() + " " + Tools.DIR_GAME_OLD);
command("rm -rf " + Tools.DIR_GAME_HOME + "/*");
command("mv " + Tools.DIR_GAME_OLD + " " + Tools.DIR_GAME_HOME + "/");
}
return moved;
}
private static void command(String cmd) throws IOException, InterruptedException {
Process p = Runtime.getRuntime().exec(cmd);
int exitCode = p.waitFor();
if (exitCode != 0) {
throw new IOException("Exit code " + exitCode +
", message:\n" + Tools.read(p.getErrorStream()));
}
}
}
@@ -1,111 +0,0 @@
package net.kdt.pojavlaunch;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import com.google.gson.JsonSyntaxException;
import java.io.File;
import java.io.IOException;
import net.kdt.pojavlaunch.authenticator.mojang.RefreshListener;
import net.kdt.pojavlaunch.authenticator.mojang.RefreshTokenTask;
import net.kdt.pojavlaunch.value.MinecraftAccount;
public class PojavProfile
{
private static String PROFILE_PREF = "pojav_profile";
private static String PROFILE_PREF_FILE = "file";
public static String PROFILE_PREF_TEMP_CONTENT = "tempContent";
public static SharedPreferences getPrefs(Context ctx) {
return ctx.getSharedPreferences(PROFILE_PREF, Context.MODE_PRIVATE);
}
public static MinecraftAccount getCurrentProfileContent(Context ctx) throws JsonSyntaxException {
MinecraftAccount build = MinecraftAccount.load(getCurrentProfileName(ctx));
if (build == null) {
System.out.println("isTempProfile null? " + (getTempProfileContent(ctx) == null));
return getTempProfileContent(ctx);
}
return build;
}
public static MinecraftAccount getTempProfileContent(Context ctx) {
try {
MinecraftAccount acc = MinecraftAccount.parse(Tools.read(Tools.DIR_DATA+"/cache/tempacc.json"));
if (acc.accessToken == null) {
acc.accessToken = "0";
}
if (acc.clientToken == null) {
acc.clientToken = "0";
}
if (acc.profileId == null) {
acc.profileId = "0";
}
if (acc.username == null) {
acc.username = "0";
}
if (acc.selectedVersion == null) {
acc.selectedVersion = "1.7.10";
}
if (acc.msaRefreshToken == null) {
acc.msaRefreshToken = "0";
}
return acc;
}catch (IOException e) {
Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the temporary profile",e);
return null;
}
}
public static String getCurrentProfileName(Context ctx) {
String name = getPrefs(ctx).getString(PROFILE_PREF_FILE, "");
// A dirty fix
if (!name.isEmpty() && name.startsWith(Tools.DIR_ACCOUNT_NEW) && name.endsWith(".json")) {
name = name.substring(0, name.length() - 5).replace(Tools.DIR_ACCOUNT_NEW, "").replace(".json", "");
setCurrentProfile(ctx, name);
}
return name;
}
public static boolean setCurrentProfile(Context ctx, Object obj) {
SharedPreferences.Editor pref = getPrefs(ctx).edit();
try {
if (obj instanceof MinecraftAccount) {
try {
MinecraftAccount.saveTempAccount((MinecraftAccount) obj);
} catch (IOException e) {
Tools.showError(ctx, e);
}
} else if (obj instanceof String) {
String acc = (String) obj;
pref.putString(PROFILE_PREF_FILE, acc);
MinecraftAccount.clearTempAccount();
} else if (obj == null) {
pref.putString(PROFILE_PREF_FILE, "");
} else {
throw new IllegalArgumentException("Profile must be MinecraftAccount.class, String.class or null");
}
} finally {
return pref.commit();
}
}
public static boolean isFileType(Context ctx) {
return new File(Tools.DIR_ACCOUNT_NEW + "/" + PojavProfile.getCurrentProfileName(ctx) + ".json").exists();
}
public static void launch(Activity ctx, Object o) {
PojavProfile.setCurrentProfile(ctx, o);
Intent intent = new Intent(ctx, PojavLauncherActivity.class); //MCLauncherActivity.class);
ctx.startActivity(intent);
}
public static void updateTokens(final Activity ctx, final String name, RefreshListener listen) throws Exception {
new RefreshTokenTask(ctx, listen).execute(name);
}
}
@@ -1,85 +0,0 @@
package net.kdt.pojavlaunch;
import java.io.*;
import android.app.*;
public class ShellProcessOperation
{
private OnPrintListener listener;
private Process process;
public ShellProcessOperation(OnPrintListener listener) throws IOException {
this.listener = listener;
process = Runtime.getRuntime().exec("/system/bin/sh");
}
public ShellProcessOperation(OnPrintListener listener, String command) throws IOException {
this.listener = listener;
process = Runtime.getRuntime().exec(
command
); //"/system/bin/sh -c \"" + command + "\"");
}
public void writeToProcess(String[] cmdArr) throws IOException {
StringBuilder sb = new StringBuilder();
for (String cmd : cmdArr) {sb.append(cmd + " ");}
writeToProcess(sb.toString());
}
public void writeToProcess(String cmd) throws IOException {
// listener.onPrintLine(" > " + cmd + "\n");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes(cmd + "\n");
os.flush();
}
public void initInputStream(Activity ctx) {
ctx.runOnUiThread(new Runnable(){
@Override
public void run()
{
printStream(process.getInputStream());
printStream(process.getErrorStream());
}
});
}
public int exitCode() {
return process.exitValue();
}
public int waitFor() throws InterruptedException {
return process.waitFor();
}
public int exit() throws InterruptedException, IOException {
writeToProcess("exit");
return waitFor();
}
private void printStream(final InputStream stream) {
new Thread(new Runnable(){
@Override
public void run()
{
try {
BufferedReader buffStream = new BufferedReader(new InputStreamReader(stream));
String line = null;
while ((line = buffStream.readLine()) != null) {
listener.onPrintLine(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
listener.onPrintLine("PrintStream error: " + e.getMessage() + "\n");
}
}
}).start();
}
public static interface OnPrintListener {
public void onPrintLine(String text);
}
}
@@ -1,12 +0,0 @@
package net.kdt.pojavlaunch;
import android.view.*;
import android.view.GestureDetector.*;
public class SingleTapConfirm extends SimpleOnGestureListener
{
@Override
public boolean onSingleTapUp(MotionEvent event) {
return true;
}
}
@@ -1,801 +0,0 @@
package net.kdt.pojavlaunch;
import android.app.*;
import android.content.*;
import android.content.res.*;
import android.net.*;
import android.os.*;
import android.system.*;
import android.util.*;
import com.google.gson.*;
import com.oracle.dalvik.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.*;
import java.util.*;
import java.util.zip.*;
import net.kdt.pojavlaunch.prefs.*;
import net.kdt.pojavlaunch.utils.*;
import net.kdt.pojavlaunch.value.*;
import org.lwjgl.glfw.*;
import android.view.*;
import android.widget.Toast;
public final class Tools
{
public static final boolean ENABLE_DEV_FEATURES = BuildConfig.DEBUG;
public static String APP_NAME = "null";
public static final Gson GLOBAL_GSON = new GsonBuilder().setPrettyPrinting().create();
public static final String URL_HOME = "https://pojavlauncherteam.github.io/PojavLauncher";
public static String DIR_DATA = "/data/data/" + BuildConfig.APPLICATION_ID;
public static String CURRENT_ARCHITECTURE;
// New since 3.3.1
public static String DIR_ACCOUNT_NEW;
public static String DIR_ACCOUNT_OLD;
public static final String DIR_GAME_HOME = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/PojavLauncher";
public static final String DIR_GAME_NEW = DIR_GAME_HOME + "/.minecraft";
public static final String DIR_GAME_OLD = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/.minecraft";
// New since 3.0.0
public static String DIR_HOME_JRE;
public static String DIRNAME_HOME_JRE = "lib";
// New since 2.4.2
public static final String DIR_HOME_VERSION = DIR_GAME_NEW + "/versions";
public static final String DIR_HOME_LIBRARY = DIR_GAME_NEW + "/libraries";
public static final String DIR_HOME_CRASH = DIR_GAME_NEW + "/crash-reports";
public static final String ASSETS_PATH = DIR_GAME_NEW + "/assets";
public static final String CTRLMAP_PATH = DIR_GAME_NEW + "/controlmap";
public static final String CTRLDEF_FILE = DIR_GAME_NEW + "/controlmap/default.json";
public static final String LIBNAME_OPTIFINE = "optifine:OptiFine";
public static void launchMinecraft(final LoggableActivity ctx, MinecraftAccount profile, JMinecraftVersionList.Version versionInfo) throws Throwable {
String[] launchArgs = getMinecraftArgs(profile, versionInfo);
// ctx.appendlnToLog("Minecraft Args: " + Arrays.toString(launchArgs));
String launchClassPath = generateLaunchClassPath(versionInfo);
List<String> javaArgList = new ArrayList<String>();
int mcReleaseDate = Integer.parseInt(versionInfo.releaseTime.substring(0, 10).replace("-", ""));
// 13w17a: 20130425
// 13w18a: 20130502
if (mcReleaseDate < 20130502 && versionInfo.minimumLauncherVersion < 9){
ctx.appendlnToLog("AWT-enabled version detected! ("+mcReleaseDate+")");
javaArgList.add("-Djava.awt.headless=false");
// Caciocavallo config AWT-enabled version
javaArgList.add("-Dcacio.managed.screensize=" + CallbackBridge.windowWidth + "x" + CallbackBridge.windowHeight);
javaArgList.add("-Dcacio.font.fontmanager=net.java.openjdk.cacio.ctc.CTCFontManager");
// javaArgList.add("-Dcacio.font.fontscaler=sun.font.FreetypeFontScaler");
javaArgList.add("-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel");
javaArgList.add("-Dawt.toolkit=net.java.openjdk.cacio.ctc.CTCToolkit");
javaArgList.add("-Djava.awt.graphicsenv=net.java.openjdk.cacio.ctc.CTCGraphicsEnvironment");
StringBuilder cacioClasspath = new StringBuilder();
cacioClasspath.append("-Xbootclasspath/p");
File cacioDir = new File(DIR_GAME_NEW + "/caciocavallo");
if (cacioDir.exists() && cacioDir.isDirectory()) {
for (File file : cacioDir.listFiles()) {
if (file.getName().endsWith(".jar")) {
cacioClasspath.append(":" + file.getAbsolutePath());
}
}
}
javaArgList.add(cacioClasspath.toString());
}else{
ctx.appendlnToLog("Headless version detected! ("+mcReleaseDate+")");
}
javaArgList.add("-cp");
javaArgList.add(getLWJGL3ClassPath() + ":" + launchClassPath);
javaArgList.add(versionInfo.mainClass);
javaArgList.addAll(Arrays.asList(launchArgs));
ctx.appendlnToLog("full args: "+javaArgList.toString());
JREUtils.launchJavaVM(ctx, javaArgList);
}
public static void getJavaArgs(Context ctx, List<String> javaArgList) {
List<String> overrideableArgList = new ArrayList<String>();
overrideableArgList.add("-Djava.home=" + Tools.DIR_HOME_JRE);
overrideableArgList.add("-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath());
overrideableArgList.add("-Duser.home=" + new File(Tools.DIR_GAME_NEW).getParent());
overrideableArgList.add("-Duser.language=" + System.getProperty("user.language"));
// overrideableArgList.add("-Duser.timezone=GMT");
overrideableArgList.add("-Dos.name=Linux");
overrideableArgList.add("-Dos.version=Android-" + Build.VERSION.RELEASE);
overrideableArgList.add("-Dpojav.path.minecraft=" + Tools.DIR_GAME_NEW);
overrideableArgList.add("-Dpojav.path.private.account=" + Tools.DIR_ACCOUNT_NEW);
// javaArgList.add("-Dorg.lwjgl.libname=liblwjgl3.so");
// javaArgList.add("-Dorg.lwjgl.system.jemalloc.libname=libjemalloc.so");
overrideableArgList.add("-Dorg.lwjgl.opengl.libname=libgl04es.so");
// overrideableArgList.add("-Dorg.lwjgl.opengl.libname=libgl4es_115.so");
// javaArgList.add("-Dorg.lwjgl.opengl.libname=libRegal.so");
// Enable LWJGL3 debug
// overrideableArgList.add("-Dorg.lwjgl.util.Debug=true");
// overrideableArgList.add("-Dorg.lwjgl.util.DebugFunctions=true");
// overrideableArgList.add("-Dorg.lwjgl.util.DebugLoader=true");
// GLFW Stub width height
overrideableArgList.add("-Dglfwstub.windowWidth=" + CallbackBridge.windowWidth);
overrideableArgList.add("-Dglfwstub.windowHeight=" + CallbackBridge.windowHeight);
overrideableArgList.add("-Dglfwstub.initEgl=false");
overrideableArgList.add("-Dnet.minecraft.clientmodname=" + Tools.APP_NAME);
// Disable FML Early Loading Screen to get Forge 1.14+ works
overrideableArgList.add("-Dfml.earlyprogresswindow=false");
// Override args
for (String argOverride : LauncherPreferences.PREF_CUSTOM_JAVA_ARGS.split(" ")) {
for (int i = 0; i < overrideableArgList.size(); i++) {
String arg = overrideableArgList.get(i);
if (arg.startsWith("-D") && argOverride.startsWith(arg.substring(0, arg.indexOf('=') + 1))) {
overrideableArgList.set(i, argOverride);
break;
} else if (i+1 == overrideableArgList.size()) {
javaArgList.add(argOverride);
}
}
}
javaArgList.addAll(overrideableArgList);
}
public static String[] getMinecraftArgs(MinecraftAccount profile, JMinecraftVersionList.Version versionInfo) {
String username = profile.username;
String versionName = versionInfo.id;
if (versionInfo.inheritsFrom != null) {
versionName = versionInfo.inheritsFrom;
}
String userType = "mojang";
File gameDir = new File(Tools.DIR_GAME_NEW);
gameDir.mkdirs();
Map<String, String> varArgMap = new ArrayMap<String, String>();
varArgMap.put("auth_access_token", profile.accessToken);
varArgMap.put("auth_player_name", username);
varArgMap.put("auth_uuid", profile.profileId);
varArgMap.put("assets_root", Tools.ASSETS_PATH);
varArgMap.put("assets_index_name", versionInfo.assets);
varArgMap.put("game_assets", Tools.ASSETS_PATH);
varArgMap.put("game_directory", gameDir.getAbsolutePath());
varArgMap.put("user_properties", "{}");
varArgMap.put("user_type", userType);
varArgMap.put("version_name", versionName);
varArgMap.put("version_type", versionInfo.type);
List<String> minecraftArgs = new ArrayList<String>();
if (versionInfo.arguments != null) {
// Support Minecraft 1.13+
for (Object arg : versionInfo.arguments.game) {
if (arg instanceof String) {
minecraftArgs.add((String) arg);
} else {
/*
JMinecraftVersionList.Arguments.ArgValue argv = (JMinecraftVersionList.Arguments.ArgValue) arg;
if (argv.values != null) {
minecraftArgs.add(argv.values[0]);
} else {
for (JMinecraftVersionList.Arguments.ArgValue.ArgRules rule : arg.rules) {
// rule.action = allow
// TODO implement this
}
}
*/
}
}
}
String[] argsFromJson = JSONUtils.insertJSONValueList(
splitAndFilterEmpty(
versionInfo.minecraftArguments == null ?
fromStringArray(minecraftArgs.toArray(new String[0])):
versionInfo.minecraftArguments
), varArgMap
);
// Tools.dialogOnUiThread(this, "Result args", Arrays.asList(argsFromJson).toString());
return argsFromJson;
}
public static String fromStringArray(String[] strArr) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < strArr.length; i++) {
if (i > 0) builder.append(" ");
builder.append(strArr[i]);
}
return builder.toString();
}
private static String[] splitAndFilterEmpty(String argStr) {
List<String> strList = new ArrayList<String>();
for (String arg : argStr.split(" ")) {
if (!arg.isEmpty()) {
strList.add(arg);
}
}
strList.add("--fullscreen");
return strList.toArray(new String[0]);
}
public static String artifactToPath(String group, String artifact, String version) {
return group.replaceAll("\\.", "/") + "/" + artifact + "/" + version + "/" + artifact + "-" + version + ".jar";
}
public static String getPatchedFile(String version) {
return DIR_HOME_VERSION + "/" + version + "/" + version + ".jar";
}
private static String getLWJGL3ClassPath() {
StringBuilder libStr = new StringBuilder();
File lwjgl3Folder = new File(Tools.DIR_GAME_NEW, "lwjgl3");
if (/* info.arguments != null && */ lwjgl3Folder.exists()) {
for (File file: lwjgl3Folder.listFiles()) {
if (file.getName().endsWith(".jar")) {
libStr.append(file.getAbsolutePath() + ":");
}
}
}
// Remove the ':' at the end
libStr.setLength(libStr.length() - 1);
return libStr.toString();
}
private static boolean isClientFirst = false;
public static String generateLaunchClassPath(JMinecraftVersionList.Version info) {
StringBuilder libStr = new StringBuilder(); //versnDir + "/" + version + "/" + version + ".jar:";
String[] classpath = generateLibClasspath(info);
// Debug: LWJGL 3 override
// File lwjgl2Folder = new File(Tools.MAIN_PATH, "lwjgl2");
/*
File lwjgl3Folder = new File(Tools.MAIN_PATH, "lwjgl3");
if (lwjgl3Folder.exists()) {
for (File file: lwjgl3Folder.listFiles()) {
if (file.getName().endsWith(".jar")) {
libStr.append(file.getAbsolutePath() + ":");
}
}
} else if (lwjgl2Folder.exists()) {
for (File file: lwjgl2Folder.listFiles()) {
if (file.getName().endsWith(".jar")) {
libStr.append(file.getAbsolutePath() + ":");
}
}
}
*/
if (isClientFirst) {
libStr.append(getPatchedFile(info.id));
}
for (String perJar : classpath) {
if (!new File(perJar).exists()) {
Log.d(APP_NAME, "Ignored non-exists file: " + perJar);
continue;
}
libStr.append((isClientFirst ? ":" : "") + perJar + (!isClientFirst ? ":" : ""));
}
if (!isClientFirst) {
libStr.append(getPatchedFile(info.id));
}
return libStr.toString();
}
public static DisplayMetrics getDisplayMetrics(Activity ctx) {
DisplayMetrics displayMetrics = new DisplayMetrics();
ctx.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
return displayMetrics;
}
public static void setFullscreen(Activity act) {
final View decorView = act.getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
});
}
public static DisplayMetrics currentDisplayMetrics;
public static void updateWindowSize(Activity ctx) {
currentDisplayMetrics = getDisplayMetrics(ctx);
CallbackBridge.windowWidth = currentDisplayMetrics.widthPixels;
CallbackBridge.windowHeight = currentDisplayMetrics.heightPixels;
if (CallbackBridge.windowWidth < CallbackBridge.windowHeight) {
CallbackBridge.windowWidth = currentDisplayMetrics.heightPixels;
CallbackBridge.windowHeight = currentDisplayMetrics.widthPixels;
}
}
public static float dpToPx(float dp) {
// 921600 = 1280 * 720, default scale
// TODO better way to scaling
float scaledDp = dp; // / DisplayMetrics.DENSITY_XHIGH * currentDisplayMetrics.densityDpi;
return (scaledDp * currentDisplayMetrics.density);
}
public static void copyAssetFile(Context ctx, String fileName, String output, boolean overwrite) throws IOException {
copyAssetFile(ctx, fileName, output, new File(fileName).getName(), overwrite);
}
public static void copyAssetFile(Context ctx, String fileName, String output, String outputName, boolean overwrite) throws IOException
{
File file = new File(output);
if(!file.exists()) {
file.mkdirs();
}
File file2 = new File(output, outputName);
if(!file2.exists() || overwrite){
write(file2.getAbsolutePath(), loadFromAssetToByte(ctx, fileName));
}
}
/*
public static void extractAssetFolder(Activity ctx, String path, String output) throws Exception {
extractAssetFolder(ctx, path, output, false);
}
public static void extractAssetFolder(Activity ctx, String path, String output, boolean overwrite) throws Exception {
AssetManager assetManager = ctx.getAssets();
String assets[] = null;
try {
assets = assetManager.list(path);
if (assets.length == 0) {
Tools.copyAssetFile(ctx, path, output, overwrite);
} else {
File dir = new File(output, path);
if (!dir.exists())
dir.mkdirs();
for (String sub : assets) {
extractAssetFolder(ctx, path + "/" + sub, output, overwrite);
}
}
} catch (Exception e) {
showError(ctx, e);
}
}
*/
public static void showError(Context ctx, Throwable e) {
showError(ctx, e, false);
}
public static void showError(final Context ctx, final Throwable e, final boolean exitIfOk) {
showError(ctx, R.string.global_error, e, exitIfOk, false);
}
public static void showError(final Context ctx, final int titleId, final Throwable e, final boolean exitIfOk) {
showError(ctx, titleId, e, exitIfOk, false);
}
private static void showError(final Context ctx, final int titleId, final Throwable e, final boolean exitIfOk, final boolean showMore) {
e.printStackTrace();
Runnable runnable = new Runnable(){
@Override
public void run()
{
final String errMsg = showMore ? Log.getStackTraceString(e): e.getMessage();
new AlertDialog.Builder((Context) ctx)
.setTitle(titleId)
.setMessage(errMsg)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2)
{
if(exitIfOk) {
if (ctx instanceof BaseMainActivity) {
BaseMainActivity.fullyExit();
} else if (ctx instanceof Activity) {
((Activity) ctx).finish();
}
}
}
})
.setNegativeButton(showMore ? R.string.error_show_less : R.string.error_show_more, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2)
{
showError(ctx, titleId, e, exitIfOk, !showMore);
}
})
.setNeutralButton(android.R.string.copy, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2)
{
android.content.ClipboardManager mgr = (android.content.ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
mgr.setPrimaryClip(ClipData.newPlainText("error", Log.getStackTraceString(e)));
if(exitIfOk) {
if (ctx instanceof BaseMainActivity) {
BaseMainActivity.fullyExit();
} else {
((Activity) ctx).finish();
}
}
}
})
//.setNegativeButton("Report (not available)", null)
.setCancelable(!exitIfOk)
.show();
}
};
if (ctx instanceof Activity) {
((Activity) ctx).runOnUiThread(runnable);
} else {
runnable.run();
}
}
public static void dialogOnUiThread(final Activity ctx, final CharSequence title, final CharSequence message) {
ctx.runOnUiThread(new Runnable(){
@Override
public void run() {
new AlertDialog.Builder(ctx)
.setTitle(title)
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.show();
}
});
}
public static void moveInside(String from, String to) {
File fromFile = new File(from);
for (File fromInside : fromFile.listFiles()) {
moveRecursive(fromInside.getAbsolutePath(), to);
}
fromFile.delete();
}
public static void moveRecursive(String from, String to) {
moveRecursive(new File(from), new File(to));
}
public static void moveRecursive(File from, File to) {
File toFrom = new File(to, from.getName());
try {
if (from.isDirectory()) {
for (File child : from.listFiles()) {
moveRecursive(child, toFrom);
}
}
} finally {
from.getParentFile().mkdirs();
from.renameTo(toFrom);
}
}
public static void openURL(Activity act, String url) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
act.startActivity(browserIntent);
}
public static String[] generateLibClasspath(JMinecraftVersionList.Version info) {
List<String> libDir = new ArrayList<String>();
for (DependentLibrary libItem: info.libraries) {
String[] libInfos = libItem.name.split(":");
libDir.add(Tools.DIR_HOME_LIBRARY + "/" + Tools.artifactToPath(libInfos[0], libInfos[1], libInfos[2]));
}
return libDir.toArray(new String[0]);
}
public static JMinecraftVersionList.Version getVersionInfo(String versionName) {
try {
JMinecraftVersionList.Version customVer = Tools.GLOBAL_GSON.fromJson(read(DIR_HOME_VERSION + "/" + versionName + "/" + versionName + ".json"), JMinecraftVersionList.Version.class);
for (DependentLibrary lib : customVer.libraries) {
if (lib.name.startsWith(LIBNAME_OPTIFINE)) {
customVer.optifineLib = lib;
}
}
if (customVer.inheritsFrom == null || customVer.inheritsFrom.equals(customVer.id)) {
return customVer;
} else {
JMinecraftVersionList.Version inheritsVer = Tools.GLOBAL_GSON.fromJson(read(DIR_HOME_VERSION + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json"), JMinecraftVersionList.Version.class);
inheritsVer.inheritsFrom = inheritsVer.id;
insertSafety(inheritsVer, customVer,
"assetIndex", "assets", "id",
"mainClass", "minecraftArguments",
"optifineLib", "releaseTime", "time", "type"
);
List<DependentLibrary> libList = new ArrayList<DependentLibrary>(Arrays.asList(inheritsVer.libraries));
try {
loop_1:
for (DependentLibrary lib : customVer.libraries) {
String libName = lib.name.substring(0, lib.name.lastIndexOf(":"));
for (int i = 0; i < libList.size(); i++) {
DependentLibrary libAdded = libList.get(i);
String libAddedName = libAdded.name.substring(0, libAdded.name.lastIndexOf(":"));
if (libAddedName.equals(libName)) {
Log.d(APP_NAME, "Library " + libName + ": Replaced version " +
libName.substring(libName.lastIndexOf(":") + 1) + " with " +
libAddedName.substring(libAddedName.lastIndexOf(":") + 1));
libList.set(i, lib);
continue loop_1;
}
}
libList.add(lib);
}
} finally {
inheritsVer.libraries = libList.toArray(new DependentLibrary[0]);
}
// Inheriting Minecraft 1.13+ with append custom args
if (inheritsVer.arguments != null && customVer.arguments != null) {
List totalArgList = new ArrayList();
totalArgList.addAll(Arrays.asList(inheritsVer.arguments.game));
int nskip = 0;
for (int i = 0; i < customVer.arguments.game.length; i++) {
if (nskip > 0) {
nskip--;
continue;
}
Object perCustomArg = customVer.arguments.game[i];
if (perCustomArg instanceof String) {
String perCustomArgStr = (String) perCustomArg;
// Check if there is a duplicate argument on combine
if (perCustomArgStr.startsWith("--") && totalArgList.contains(perCustomArgStr)) {
perCustomArg = customVer.arguments.game[i + 1];
if (perCustomArg instanceof String) {
perCustomArgStr = (String) perCustomArg;
// If the next is argument value, skip it
if (!perCustomArgStr.startsWith("--")) {
nskip++;
}
}
} else {
totalArgList.add(perCustomArgStr);
}
} else if (!totalArgList.contains(perCustomArg)) {
totalArgList.add(perCustomArg);
}
}
inheritsVer.arguments.game = totalArgList.toArray(new Object[0]);
}
return inheritsVer;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// Prevent NullPointerException
private static void insertSafety(JMinecraftVersionList.Version targetVer, JMinecraftVersionList.Version fromVer, String... keyArr) {
for (String key : keyArr) {
Object value = null;
try {
Field fieldA = fromVer.getClass().getDeclaredField(key);
value = fieldA.get(fromVer);
if (((value instanceof String) && !((String) value).isEmpty()) || value != null) {
Field fieldB = targetVer.getClass().getDeclaredField(key);
fieldB.set(targetVer, value);
}
} catch (Throwable th) {
Log.w(Tools.APP_NAME, "Unable to insert " + key + "=" + value, th);
}
}
}
public static String convertStream(InputStream inputStream) throws IOException {
return convertStream(inputStream, Charset.forName("UTF-8"));
}
public static String convertStream(InputStream inputStream, Charset charset) throws IOException {
String out = "";
int len;
byte[] buf = new byte[512];
while((len = inputStream.read(buf))!=-1) {
out += new String(buf,0,len,charset);
}
return out;
}
public static File lastFileModified(String dir) {
File fl = new File(dir);
File[] files = fl.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isFile();
}
});
long lastMod = Long.MIN_VALUE;
File choice = null;
for (File file : files) {
if (file.lastModified() > lastMod) {
choice = file;
lastMod = file.lastModified();
}
}
return choice;
}
public static String read(InputStream is) throws IOException {
String out = "";
int len;
byte[] buf = new byte[512];
while((len = is.read(buf))!=-1) {
out += new String(buf,0,len);
}
return out;
}
public static String read(String path) throws IOException {
return read(new FileInputStream(path));
}
public static void write(String path, byte[] content) throws IOException
{
File outPath = new File(path);
outPath.getParentFile().mkdirs();
outPath.createNewFile();
BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(path));
fos.write(content, 0, content.length);
fos.close();
}
public static void write(String path, String content) throws IOException {
write(path, content.getBytes());
}
public static byte[] loadFromAssetToByte(Context ctx, String inFile) {
byte[] buffer = null;
try {
InputStream stream = ctx.getAssets().open(inFile);
int size = stream.available();
buffer = new byte[size];
stream.read(buffer);
stream.close();
} catch (IOException e) {
// Handle exceptions here
e.printStackTrace();
}
return buffer;
}
public static void downloadFile(String urlInput, String nameOutput) throws IOException {
File file = new File(nameOutput);
DownloadUtils.downloadFile(urlInput, file);
}
public abstract static class DownloaderFeedback {
public abstract void updateProgress(int curr, int max);
}
public static void downloadFileMonitored(String urlInput,String nameOutput, DownloaderFeedback monitor) throws IOException {
if(!new File(nameOutput).exists()){
new File(nameOutput).getParentFile().mkdirs();
}
HttpURLConnection conn = (HttpURLConnection) new URL(urlInput).openConnection();
InputStream readStr = conn.getInputStream();
FileOutputStream fos = new FileOutputStream(new File(nameOutput));
int cur = 0; int oval=0; int len = conn.getContentLength(); byte[] buf = new byte[65535];
while((cur = readStr.read(buf)) != -1) {
oval += cur;
fos.write(buf,0,cur);
monitor.updateProgress(oval,len);
}
fos.close();
conn.disconnect();
}
public static class ZipTool
{
private ZipTool(){}
public static void zip(List<File> files, File zipFile) throws IOException {
final int BUFFER_SIZE = 2048;
BufferedInputStream origin = null;
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
try {
byte data[] = new byte[BUFFER_SIZE];
for (File file : files) {
FileInputStream fileInputStream = new FileInputStream( file );
origin = new BufferedInputStream(fileInputStream, BUFFER_SIZE);
try {
ZipEntry entry = new ZipEntry(file.getName());
out.putNextEntry(entry);
int count;
while ((count = origin.read(data, 0, BUFFER_SIZE)) != -1) {
out.write(data, 0, count);
}
}
finally {
origin.close();
}
}
} finally {
out.close();
}
}
public static void unzip(File zipFile, File targetDirectory) throws IOException {
final int BUFFER_SIZE = 1024;
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(new FileInputStream(zipFile)));
try {
ZipEntry ze;
int count;
byte[] buffer = new byte[BUFFER_SIZE];
while ((ze = zis.getNextEntry()) != null) {
File file = new File(targetDirectory, ze.getName());
File dir = ze.isDirectory() ? file : file.getParentFile();
if (!dir.isDirectory() && !dir.mkdirs())
throw new FileNotFoundException("Failed to ensure directory: " +
dir.getAbsolutePath());
if (ze.isDirectory())
continue;
FileOutputStream fout = new FileOutputStream(file);
try {
while ((count = zis.read(buffer)) != -1)
fout.write(buffer, 0, count);
} finally {
fout.close();
}
/* if time should be restored as well
long time = ze.getTime();
if (time > 0)
file.setLastModified(time);
*/
}
} finally {
zis.close();
}
}
}
}
@@ -1,45 +0,0 @@
package net.kdt.pojavlaunch.authenticator.microsoft;
import java.io.*;
import java.util.*;
public class HttpClient
{
public static class Builder {
public HttpClient build() {
return new HttpClient(/* this */);
}
}
public static Builder newBuilder() {
return new Builder();
}
// private Builder mBuilder;
protected HttpClient(/* Builder b */) {
// mBuilder = b;
}
// This method is not official java.net.http.HttpClient API.
public <T> HttpResponse<T> sendRequest(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler) throws IOException {
req.mBuilder.getBase().connect();
if (req.mBuilder.mData != null) {
byte[] byteArr = req.mBuilder.mData.getBody().getBytes();
OutputStream os = req.mBuilder.getBase().getOutputStream();
os.write(byteArr, 0, byteArr.length);
os.close();
}
HttpResponse<T> response = new HttpResponse<T>(req);
return response;
}
/*
public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler) throws IOException {
CompletableFuture<HttpResponse<T>> result = new CompletableFuture<HttpResponse<T>>();
result.complete(sendRequest(req, responseBodyHandler));
return result;
}
*/
}
@@ -1,72 +0,0 @@
package net.kdt.pojavlaunch.authenticator.microsoft;
import java.net.*;
import java.io.*;
import java.util.*;
public class HttpRequest
{
public static class Builder {
private URI mURI;
private HttpURLConnection mConn;
protected BodyPublisher mData;
public Builder(URI uri) throws IOException {
mURI = uri;
mConn = (HttpURLConnection) uri.toURL().openConnection();
mConn.setUseCaches(false);
mConn.setDoOutput(true);
}
public HttpURLConnection getBase() {
return mConn;
}
public Builder header(String key, String value) {
mConn.setRequestProperty(key, value);
return this;
}
public Builder GET() throws ProtocolException {
mConn.setRequestMethod("GET");
return this;
}
public Builder POST(BodyPublisher data) throws ProtocolException {
mConn.setDoInput(true);
mConn.setRequestMethod("POST");
mData = data;
return this;
}
public HttpRequest build() throws IOException {
return new HttpRequest(this);
}
}
public static class BodyPublisher {
private String mStr;
private BodyPublisher(String str) {
mStr = str;
}
public String getBody() {
return mStr;
}
}
public static class BodyPublishers {
public static BodyPublisher ofString(String str) {
return new BodyPublisher(str);
}
}
public static Builder newBuilder(URI uri) throws IOException {
return new Builder(uri);
}
protected Builder mBuilder;
protected HttpRequest(Builder b) {
mBuilder = b;
}
}
@@ -1,46 +0,0 @@
package net.kdt.pojavlaunch.authenticator.microsoft;
import java.io.*;
import java.lang.reflect.*;
import net.kdt.pojavlaunch.*;
public class HttpResponse<T>
{
private HttpRequest mRequest;
public HttpResponse(HttpRequest request) {
mRequest = request;
}
public static class BodyHandler<T> {
// public BodySubscriber<T> apply(ResponseInfo responseInfo);
}
public static class BodyHandlers {
public static BodyHandler<String> ofString() {
return new BodyHandler<String>();
}
}
public int statusCode() throws IOException {
return mRequest.mBuilder.getBase().getResponseCode();
}
public T body() throws IOException {
if (statusCode() >= 200 && statusCode() < 300) {
return (T) Tools.read(mRequest.mBuilder.getBase().getInputStream());
} else {
return (T) Tools.read(mRequest.mBuilder.getBase().getErrorStream());
}
/*
if (T instanceof String) {
if (statusCode() >= 200 && statusCode() < 300) {
return (T) Tools.read(mRequest.mBuilder.getBase().getInputStream());
} else {
return (T) Tools.read(mRequest.mBuilder.getBase().getErrorStream());
}
} else {
throw new UnsupportedOperationException();
}
*/
}
}
@@ -1,312 +0,0 @@
package net.kdt.pojavlaunch.authenticator.microsoft;
import android.app.*;
import android.content.*;
import android.os.*;
import android.util.*;
import java.net.*;
import java.text.*;
import java.util.*;
import net.kdt.pojavlaunch.*;
import net.kdt.pojavlaunch.authenticator.mojang.*;
import net.kdt.pojavlaunch.authenticator.microsoft.*;
import org.json.*;
import java.text.ParseException;
import java.io.*;
import net.kdt.pojavlaunch.value.launcherprofiles.*;
import net.kdt.pojavlaunch.value.*;
public class MicrosoftAuthTask extends AsyncTask<String, Void, Object> {
/*
private static final String authTokenUrl = "https://login.live.com/oauth20_token.srf";
private static final String xblAuthUrl = "https://user.auth.xboxlive.com/user/authenticate";
private static final String xstsAuthUrl = "https://xsts.auth.xboxlive.com/xsts/authorize";
private static final String mcLoginUrl = "https://api.minecraftservices.com/authentication/login_with_xbox";
private static final String mcStoreUrl = "https://api.minecraftservices.com/entitlements/mcstore";
private static final String mcProfileUrl = "https://api.minecraftservices.com/minecraft/profile";
*/
//private Gson gson = new Gson();
private RefreshListener listener;
private Context ctx;
private ProgressDialog build;
public MicrosoftAuthTask(Context ctx, RefreshListener listener) {
this.ctx = ctx;
this.listener = listener;
}
@Override
public void onPreExecute() {
build = new ProgressDialog(ctx);
build.setMessage(ctx.getString(R.string.global_waiting));
build.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
build.setCancelable(false);
build.setMax(6);
build.show();
}
@Override
public Object doInBackground(String... args) {
try {
/*
publishProgress();
String msaAccessToken = acquireAccessToken(args[0]);
publishProgress();
String xblToken = acquireXBLToken(msaAccessToken);
publishProgress();
String[] xstsData = acquireXsts(xblToken);
publishProgress();
String mcAccessToken = acquireMinecraftToken(xstsData[0], xstsData[1]);
publishProgress();
*/
Msa msa = new Msa(this, Boolean.parseBoolean(args[0]), args[1]);
MinecraftAccount acc = new MinecraftAccount();
if (msa.doesOwnGame) {
acc.clientToken = "0"; /* FIXME */
acc.accessToken = msa.mcToken;
acc.username = msa.mcName;
acc.profileId = msa.mcUuid;
acc.isMicrosoft = true;
acc.msaRefreshToken = msa.msRefreshToken;
acc.updateSkinFace();
}
acc.save();
return acc;
} catch (Throwable e) {
return e;
}
}
public void publishProgressPublic() {
super.publishProgress();
}
@Override
protected void onProgressUpdate(Void[] p1) {
super.onProgressUpdate(p1);
build.setProgress(build.getProgress() + 1);
}
@Override
public void onPostExecute(Object result) {
build.dismiss();
if (result instanceof MinecraftAccount) {
listener.onSuccess((MinecraftAccount) result);
} else {
listener.onFailed((Throwable) result);
}
}
// Based on https://github.com/MiniDigger/MiniLauncher/blob/master/launcher/src/main/java/me/minidigger/minecraftlauncher/launcher/gui/MsaFragmentController.java
/*
MIT License
Copyright (c) 2018 Ammar Ahmad
Copyright (c) 2018 Martin Benndorf
Copyright (c) 2018 Mark Vainomaa
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
private final class XSTSXUI {
private String uhs;
}
private final class XSTSDisplayClaims {
private XSTSXUI[] xui;
}
private final class GlobalToken {
// MSA AccessToken
private String access_token;
// XBL, XSTS Token
private String Token;
// XSTS
private XSTSDisplayClaims DisplayClaims;
// Minecraft side
private String id;
private String name;
}
private String acquireAccessToken(String authcode) throws IOException, URISyntaxException{
URI uri = new URI(authTokenUrl);
Map<Object, Object> data = new ArrayMap<>();
data.put("client_id", "00000000402b5328");
data.put("code", authcode);
data.put("grant_type", "authorization_code");
data.put("redirect_url", "https://login.live.com/oauth20_desktop.srf");
data.put("scope", "service::user.auth.xboxlive.com::MBI_SSL");
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(ofFormData(data)).build();
HttpResponse resp = HttpClient.newBuilder().build().sendRequest(request, HttpResponse.BodyHandlers.ofString());
if (resp.statusCode() >= 200 && resp.statusCode() < 300) {
return Tools.GLOBAL_GSON.fromJson((String) resp.body(), GlobalToken.class).access_token;
} else {
throw new RuntimeException("Error " + resp.statusCode() + ": " + (String) resp.body());
}
}
private String acquireXBLToken(String accessToken) throws IOException, URISyntaxException {
URI uri = new URI(xblAuthUrl);
Map<Object, Object> dataProp = new ArrayMap<>();
dataProp.put("AuthMethod", "RPS");
dataProp.put("SiteName", "user.auth.xboxlive.com");
dataProp.put("RpsTicket", accessToken);
Map<Object, Object> data = new ArrayMap<>();
data.put("Properties", dataProp);
data.put("RelyingParty", "http://auth.xboxlive.com");
data.put("TokenType", "JWT");
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.POST(ofJSONData(data)).build();
HttpResponse resp = HttpClient.newBuilder().build().sendRequest(request, HttpResponse.BodyHandlers.ofString());
if (resp.statusCode() >= 200 && resp.statusCode() < 300) {
return Tools.GLOBAL_GSON.fromJson((String) resp.body(), GlobalToken.class).Token;
} else {
throw new RuntimeException("Error " + resp.statusCode() + ": " + (String) resp.body());
}
}
private String[] acquireXsts(String xblToken) throws IOException, URISyntaxException {
URI uri = new URI(xstsAuthUrl);
Map<Object, Object> dataProp = new ArrayMap<>();
dataProp.put("SandboxId", "RETAIL");
dataProp.put("UserTokens", Arrays.asList(xblToken));
Map<Object, Object> data = new ArrayMap<>();
data.put("Properties", dataProp);
data.put("RelyingParty", "rp://api.minecraftservices.com/");
data.put("TokenType", "JWT");
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.POST(ofJSONData(data)).build();
HttpResponse resp = HttpClient.newBuilder().build().sendRequest(request, HttpResponse.BodyHandlers.ofString());
if (resp.statusCode() >= 200 && resp.statusCode() < 300) {
String body = (String) resp.body();
GlobalToken token = Tools.GLOBAL_GSON.fromJson(body, GlobalToken.class);
String xblXsts = token.Token;
String uhs = token.DisplayClaims.xui[0].uhs;
return new String[]{uhs, xblXsts};
} else {
throw new RuntimeException("Error " + resp.statusCode() + ": " + (String) resp.body());
}
}
private String acquireMinecraftToken(String xblUhs, String xblXsts) throws IOException, URISyntaxException {
URI uri = new URI(mcLoginUrl);
Map<Object, Object> data = new ArrayMap<>();
data.put("identityToken", "XBL3.0 x=" + xblUhs + ";" + xblXsts);
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.POST(ofJSONData(data)).build();
HttpResponse resp = HttpClient.newBuilder().build().sendRequest(request, HttpResponse.BodyHandlers.ofString());
if (resp.statusCode() >= 200 && resp.statusCode() < 300) {
String body = (String) resp.body();
return Tools.GLOBAL_GSON.fromJson(body, GlobalToken.class).access_token;
} else {
throw new RuntimeException("Error " + resp.statusCode() + ": " + (String) resp.body());
}
}
private MinecraftAccount checkMcProfile(String mcAccessToken) throws IOException, URISyntaxException {
URI uri = new URI(mcProfileUrl);
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Authorization", "Bearer " + mcAccessToken)
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.GET().build();
HttpResponse resp = HttpClient.newBuilder().build().sendRequest(request, HttpResponse.BodyHandlers.ofString());
if (resp.statusCode() >= 200 && resp.statusCode() < 300) {
String body = (String) resp.body();
GlobalToken token = Tools.GLOBAL_GSON.fromJson(body, GlobalToken.class);
String uuid = token.id;
String uuidDashes = uuid.replaceFirst(
"(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5"
);
MinecraftAccount acc = new MinecraftAccount();
acc.isMicrosoft = true;
acc.username = token.name;
acc.accessToken = mcAccessToken;
acc.profileId = uuidDashes;
return acc;
} else {
throw new RuntimeException("Error " + resp.statusCode() + ": " + (String) resp.body());
}
}
public static HttpRequest.BodyPublisher ofJSONData(Map<Object, Object> data) {
return HttpRequest.BodyPublishers.ofString(Tools.GLOBAL_GSON.toJson(data));
}
public static HttpRequest.BodyPublisher ofFormData(Map<Object, Object> data) {
StringBuilder builder = new StringBuilder();
for (Map.Entry<Object, Object> entry : data.entrySet()) {
if (builder.length() > 0) {
builder.append("&");
}
try {
builder.append(URLEncoder.encode(entry.getKey().toString(), "UTF-8"));
builder.append("=");
builder.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
return HttpRequest.BodyPublishers.ofString(builder.toString());
}
*/
}
@@ -1,307 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package net.kdt.pojavlaunch.authenticator.microsoft;
import android.util.*;
import java.io.*;
import java.net.*;
import java.util.*;
import net.kdt.pojavlaunch.*;
import org.json.*;
public class Msa {
/*
private static final String loginUrl = "https://login.live.com/oauth20_authorize.srf" +
"?client_id=00000000402b5328" +
"&response_type=code" +
"&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL" +
"&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf";
private static final String redirectUrlSuffix = "https://login.live.com/oauth20_desktop.srf?code=";
*/
private static final String authTokenUrl = "https://login.live.com/oauth20_token.srf";
private static final String xblAuthUrl = "https://user.auth.xboxlive.com/user/authenticate";
private static final String xstsAuthUrl = "https://xsts.auth.xboxlive.com/xsts/authorize";
private static final String mcLoginUrl = "https://api.minecraftservices.com/authentication/login_with_xbox";
private static final String mcStoreUrl = "https://api.minecraftservices.com/entitlements/mcstore";
private static final String mcProfileUrl = "https://api.minecraftservices.com/minecraft/profile";
private MicrosoftAuthTask task;
public boolean isRefresh;
public String msRefreshToken;
public String mcName;
public String mcToken;
public String mcUuid;
public boolean doesOwnGame;
public Msa(MicrosoftAuthTask task, boolean isRefresh, String authCode) throws IOException, JSONException {
this.task = task;
acquireAccessToken(isRefresh, authCode);
}
public void acquireAccessToken(boolean isRefresh, String authcode) throws IOException, JSONException {
task.publishProgressPublic();
URL url = new URL(authTokenUrl);
Log.i("MicroAuth", "isRefresh=" + isRefresh + ", authCode= "+authcode);
Map<Object, Object> data = new HashMap<>();/*Map.of(
"client_id", "00000000402b5328",
"code", authcode,
"grant_type", "authorization_code",
"redirect_uri", "https://login.live.com/oauth20_desktop.srf",
"scope", "service::user.auth.xboxlive.com::MBI_SSL"
);*/
data.put("client_id", "00000000402b5328");
data.put(isRefresh ? "refresh_token" : "code", authcode);
data.put("grant_type", isRefresh ? "refresh_token" : "authorization_code");
data.put("redirect_url", "https://login.live.com/oauth20_desktop.srf");
data.put("scope", "service::user.auth.xboxlive.com::MBI_SSL");
//да пошла yf[eq1 она ваша джава 11
String req = ofFormData(data);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("charset", "utf-8");
conn.setRequestProperty("Content-Length", Integer.toString(req.getBytes("UTF-8").length));
conn.setRequestMethod("POST");
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
try(OutputStream wr = conn.getOutputStream()) {
wr.write(req.getBytes("UTF-8"));
}
if(conn.getResponseCode() >= 200 && conn.getResponseCode() < 300) {
JSONObject jo = new JSONObject(Tools.read(conn.getInputStream()));
msRefreshToken = jo.getString("refresh_token");
Log.i("MicroAuth","Acess Token = "+jo.getString("access_token"));
acquireXBLToken(jo.getString("access_token"));
}else{
throwResponseError(conn);
}
}
private void acquireXBLToken(String accessToken) throws IOException, JSONException {
task.publishProgressPublic();
URL url = new URL(xblAuthUrl);
Map<Object, Object> data = new HashMap<>();
Map<Object, Object> properties = new HashMap<>();
properties.put("AuthMethod", "RPS");
properties.put("SiteName", "user.auth.xboxlive.com");
properties.put("RpsTicket", accessToken);
data.put("Properties",properties);
data.put("RelyingParty", "http://auth.xboxlive.com");
data.put("TokenType", "JWT");
/*Map.of(
"Properties", Map.of(
"AuthMethod", "RPS",
"SiteName", "user.auth.xboxlive.com",
"RpsTicket", accessToken
),
"RelyingParty", "http://auth.xboxlive.com",
"TokenType", "JWT"
);*/
String req = ofJSONData(data);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("charset", "utf-8");
conn.setRequestProperty("Content-Length", Integer.toString(req.getBytes("UTF-8").length));
conn.setRequestMethod("POST");
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
try(OutputStream wr = conn.getOutputStream()) {
wr.write(req.getBytes("UTF-8"));
}
if(conn.getResponseCode() >= 200 && conn.getResponseCode() < 300) {
JSONObject jo = new JSONObject(Tools.read(conn.getInputStream()));
Log.i("MicroAuth","Xbl Token = "+jo.getString("Token"));
acquireXsts(jo.getString("Token"));
}else{
throwResponseError(conn);
}
}
private void acquireXsts(String xblToken) throws IOException, JSONException {
task.publishProgressPublic();
URL url = new URL(xstsAuthUrl);
Map<Object, Object> data = new HashMap<>();
Map<Object, Object> properties = new HashMap<>();
properties.put("SandboxId", "RETAIL");
properties.put("UserTokens",Collections.singleton(xblToken));
data.put("Properties",properties);
data.put("RelyingParty", "rp://api.minecraftservices.com/");
data.put("TokenType", "JWT");
/*Map<Object, Object> data = Map.of(
"Properties", Map.of(
"SandboxId", "RETAIL",
"UserTokens", List.of(xblToken)
),
"RelyingParty", "rp://api.minecraftservices.com/",
"TokenType", "JWT"
);
*/
String req = ofJSONData(data);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("charset", "utf-8");
conn.setRequestProperty("Content-Length", Integer.toString(req.getBytes("UTF-8").length));
conn.setRequestMethod("POST");
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
try(OutputStream wr = conn.getOutputStream()) {
wr.write(req.getBytes("UTF-8"));
}
if(conn.getResponseCode() >= 200 && conn.getResponseCode() < 300) {
JSONObject jo = new JSONObject(Tools.read(conn.getInputStream()));
String uhs = jo.getJSONObject("DisplayClaims").getJSONArray("xui").getJSONObject(0).getString("uhs");
Log.i("MicroAuth","Xbl Xsts = "+jo.getString("Token")+"; Uhs = " + uhs);
acquireMinecraftToken(uhs,jo.getString("Token"));
}else{
throwResponseError(conn);
}
}
private void acquireMinecraftToken(String xblUhs, String xblXsts) throws IOException, JSONException {
task.publishProgressPublic();
URL url = new URL(mcLoginUrl);
Map<Object, Object> data = new HashMap<>();
data.put("identityToken", "XBL3.0 x=" + xblUhs + ";" + xblXsts);
String req = ofJSONData(data);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("charset", "utf-8");
conn.setRequestProperty("Content-Length", Integer.toString(req.getBytes("UTF-8").length));
conn.setRequestMethod("POST");
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
try(OutputStream wr = conn.getOutputStream()) {
wr.write(req.getBytes("UTF-8"));
}
if(conn.getResponseCode() >= 200 && conn.getResponseCode() < 300) {
JSONObject jo = new JSONObject(Tools.read(conn.getInputStream()));
Log.i("MicroAuth","MC token: "+jo.getString("access_token"));
mcToken = jo.getString("access_token");
checkMcProfile(jo.getString("access_token"));
checkMcStore(jo.getString("access_token"));
}else{
throwResponseError(conn);
}
}
private void checkMcStore(String mcAccessToken) throws IOException, JSONException {
task.publishProgressPublic();
URL url = new URL(mcStoreUrl);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("Authorization", "Bearer " + mcAccessToken);
conn.setRequestMethod("GET");
conn.setUseCaches(false);
conn.connect();
if(conn.getResponseCode() >= 200 && conn.getResponseCode() < 300) {
JSONObject jo = new JSONObject(Tools.read(conn.getInputStream()));
JSONArray ja = jo.getJSONArray("items");
Log.i("MicroAuth","Store Len = " + ja.length());
for(int i = 0; i < ja.length(); i++) {
String prod = ja.getJSONObject(i).getString("name");
Log.i("MicroAuth","Product " + i +": " +prod);
}
}else{
throwResponseError(conn);
}
/*
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Authorization", "Bearer " + mcAccessToken)
.GET().build();
HttpClient.newBuilder().build().sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept(resp -> {
if (resp.statusCode() >= 200 && resp.statusCode() < 300) {
String body = resp.body();
Log.i("MicroAuth","store: " + body);
}
});
*/
}
private void checkMcProfile(String mcAccessToken) throws IOException, JSONException {
task.publishProgressPublic();
URL url = new URL(mcProfileUrl);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("Authorization", "Bearer " + mcAccessToken);
conn.setUseCaches(false);
conn.connect();
if(conn.getResponseCode() >= 200 && conn.getResponseCode() < 300) {
String s= Tools.read(conn.getInputStream());
Log.i("MicroAuth","profile:" + s);
JSONObject jsonObject = new JSONObject(s);
String name = (String) jsonObject.get("name");
String uuid = (String) jsonObject.get("id");
String uuidDashes = uuid .replaceFirst(
"(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5"
);
doesOwnGame = true;
Log.i("MicroAuth","UserName = " + name);
Log.i("MicroAuth","Uuid Minecraft = " + uuidDashes);
mcName=name;
mcUuid=uuidDashes;
}else{
Log.i("MicroAuth","It seems that this Microsoft Account does not own the game.");
doesOwnGame = false;
throwResponseError(conn);
}
}
public static String ofJSONData(Map<Object, Object> data) {
return new JSONObject(data).toString();
}
public static String ofFormData(Map<Object, Object> data) {
StringBuilder builder = new StringBuilder();
for (Map.Entry<Object, Object> entry : data.entrySet()) {
if (builder.length() > 0) {
builder.append("&");
}
try {
builder.append(URLEncoder.encode(entry.getKey().toString(), "UTF-8"));
builder.append("=");
builder.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
//Should not happen
}
}
return builder.toString();
}
private static void throwResponseError(HttpURLConnection conn) throws IOException {
String errStr = Tools.read(conn.getErrorStream());
Log.i("MicroAuth","Error code: " + conn.getResponseCode() + ": " + conn.getResponseMessage() + "\n" + errStr);
throw new RuntimeException("MSA Error: " + conn.getResponseCode() + ": " + conn.getResponseMessage() + ", error stream:\n" + errStr);
}
}
@@ -1,48 +0,0 @@
package net.kdt.pojavlaunch.authenticator.mojang;
import android.content.*;
import android.os.*;
import net.kdt.pojavlaunch.authenticator.mojang.yggdrasil.*;
import java.io.*;
import java.util.*;
import net.kdt.pojavlaunch.*;
import net.kdt.pojavlaunch.value.*;
public class InvalidateTokenTask extends AsyncTask<String, Void, Throwable> {
private YggdrasilAuthenticator authenticator = new YggdrasilAuthenticator();
//private Gson gson = new Gson();
private MinecraftAccount profilePath;
private Context ctx;
private String path;
public InvalidateTokenTask(Context ctx) {
this.ctx = ctx;
}
@Override
public Throwable doInBackground(String... args) {
path = args[0];
try {
if (profilePath.accessToken.equals("0")) {
return null;
}
this.profilePath = MinecraftAccount.load(args[0]);
this.authenticator.invalidate(profilePath.accessToken,
UUID.fromString(profilePath.isMicrosoft ? profilePath.profileId : profilePath.clientToken /* should be? */));
return null;
} catch (Throwable e) {
return e;
}
}
@Override
public void onPostExecute(Throwable result) {
if (result != null) {
Tools.showError(ctx, result);
}
new File(Tools.DIR_ACCOUNT_NEW + "/" + path + ".json").delete();
}
}
@@ -1,7 +0,0 @@
package net.kdt.pojavlaunch.authenticator.mojang;
public interface LoginListener
{
public void onBeforeLogin();
public void onLoginDone(String[] result);
}
@@ -1,71 +0,0 @@
package net.kdt.pojavlaunch.authenticator.mojang;
import android.os.*;
import net.kdt.pojavlaunch.authenticator.mojang.yggdrasil.*;
import java.io.*;
import java.util.*;
import net.kdt.pojavlaunch.*;
public class LoginTask extends AsyncTask<String, Void, Void>
{
private YggdrasilAuthenticator authenticator = new YggdrasilAuthenticator();
//private String TAG = "MojangAuth-login";
private LoginListener listener;
public LoginTask setLoginListener(LoginListener listener) {
this.listener = listener;
return this;
}
private UUID getRandomUUID() {
return UUID.randomUUID();
}
@Override
protected void onPreExecute() {
listener.onBeforeLogin();
super.onPreExecute();
}
@Override
protected Void doInBackground(String[] args) {
ArrayList<String> str = new ArrayList<String>();
str.add("ERROR");
try{
try{
AuthenticateResponse response = authenticator.authenticate(args[0], args[1], getRandomUUID());
if (response.selectedProfile == null) {
str.add("Can't login a demo account!\n");
} else {
if (new File(Tools.DIR_ACCOUNT_NEW + "/" + response.selectedProfile.name + ".json").exists()) {
str.add("This account already exist!\n");
} else {
str.add(response.accessToken); // Access token
str.add(response.clientToken.toString()); // Client token
str.add(response.selectedProfile.id); // Profile ID
str.add(response.selectedProfile.name); // Username
str.set(0, "NORMAL");
}
}
}
//MainActivity.updateStatus(804);
catch(Throwable e){
str.add(e.getMessage());
}
}
catch(Exception e){
str.add(e.getMessage());
}
listener.onLoginDone(str.toArray(new String[0]));
return null;
}
@Override
protected void onPostExecute(Void result) {
// listener.onLoginDone(result);
super.onPostExecute(result);
}
}
@@ -1,10 +0,0 @@
package net.kdt.pojavlaunch.authenticator.mojang;
import net.kdt.pojavlaunch.*;
import net.kdt.pojavlaunch.value.*;
public interface RefreshListener
{
public void onFailed(Throwable e);
public void onSuccess(MinecraftAccount profile);
}
Loaded 100 of 535 files, more files were not shown because too many files have changed in this diff. Show more