├── .gitignore
├── .project
├── .settings
└── org.eclipse.buildship.core.prefs
├── LICENSE.md
├── app
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.buildship.core.prefs
├── build.gradle
├── lib
│ └── XposedBridgeApi-54.jar
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── xposed_init
│ ├── java
│ └── net
│ │ └── manhong2112
│ │ └── downloadredirect
│ │ ├── CheckableListAdapter.kt
│ │ ├── ConfigDAO.kt
│ │ ├── Const.kt
│ │ ├── DLApi
│ │ ├── DLApi.kt
│ │ └── DownloadConfig.kt
│ │ ├── Main.kt
│ │ └── XposedHook.kt
│ └── res
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-pt-rBR
│ └── strings.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-zh-rCN
│ └── strings.xml
│ └── values
│ ├── colors.xml
│ └── strings.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | local.properties
4 | .DS_Store
5 | build
6 | .idea
7 |
8 | *.apk
9 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | DownloadRedirect
4 | Project DownloadRedirect created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.arguments=
2 | connection.java.home=null
3 | connection.jvm.arguments=
4 | connection.project.dir=
5 | derived.resources=.gradle,build
6 | eclipse.preferences.version=1
7 | project.path=\:
8 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/app/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | app
4 | Project app created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.buildship.core.gradleprojectnature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | build.commands=org.eclipse.jdt.core.javabuilder
2 | connection.arguments=
3 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
4 | connection.java.home=null
5 | connection.jvm.arguments=
6 | connection.project.dir=..
7 | derived.resources=.gradle,build
8 | eclipse.preferences.version=1
9 | natures=org.eclipse.jdt.core.javanature
10 | project.path=\:app
11 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 27
7 | buildToolsVersion '27.0.3'
8 | lintOptions{
9 | disable 'MissingTranslation'
10 | abortOnError false
11 | }
12 | signingConfigs {
13 | config {
14 | Properties properties = new Properties()
15 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
16 | keyAlias properties.getProperty('keyAlias')
17 | keyPassword properties.getProperty('keyPassword')
18 | storeFile file(properties.getProperty('storeFile'))
19 | storePassword properties.getProperty('storePassword')
20 | }
21 | }
22 | buildTypes {
23 | release {
24 | minifyEnabled true
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | signingConfig signingConfigs.config
27 | zipAlignEnabled true
28 | }
29 | debug {
30 | minifyEnabled true
31 | zipAlignEnabled true
32 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
33 | signingConfig signingConfigs.config
34 | }
35 | }
36 | defaultConfig {
37 | applicationId "net.manhong2112.downloadredirect"
38 | minSdkVersion 14
39 | targetSdkVersion 23
40 | versionCode 67
41 | versionName "1.3.0.2(ゝ∀・)"
42 | }
43 |
44 | packagingOptions {
45 | exclude 'META-INF/DEPENDENCIES.txt'
46 | exclude 'META-INF/LICENSE.txt'
47 | exclude 'META-INF/NOTICE.txt'
48 | exclude 'META-INF/NOTICE'
49 | exclude 'META-INF/LICENSE'
50 | exclude 'META-INF/DEPENDENCIES'
51 | exclude 'META-INF/notice.txt'
52 | exclude 'META-INF/license.txt'
53 | exclude 'META-INF/dependencies.txt'
54 | exclude 'META-INF/LGPL2.1'
55 | }
56 | }
57 |
58 | buildscript {
59 | repositories {
60 | google()
61 | jcenter()
62 | mavenCentral()
63 | }
64 | dependencies {
65 | classpath 'com.android.tools.build:gradle:3.1.2'
66 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
67 | }
68 | }
69 |
70 | dependencies {
71 | compile fileTree(include: ['*.jar'], dir: 'libs')
72 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
73 | compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
74 | compile "org.jetbrains.anko:anko-sdk23:$anko_version"
75 | // compile "org.jetbrains.anko:anko-common:$anko_version"
76 | // compile "com.android.support:support-v4:23.0.+"
77 | compile 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.4.1'
78 | testCompile 'junit:junit:4.12'
79 | provided files('lib/XposedBridgeApi-54.jar')
80 | }
81 |
82 |
83 |
--------------------------------------------------------------------------------
/app/lib/XposedBridgeApi-54.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paletteOvO/DownloadRedirect/322ddc1486f0d2f6a6dd6a29f9fe710c4884af0d/app/lib/XposedBridgeApi-54.jar
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\manhong\WorkSpace\Android\SDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 | -verbose
19 | -dontnote **
20 | -dontwarn **
21 | -keepattributes SourceFile,LineNumberTable
22 |
23 | -renamesourcefileattribute ''
24 | -repackageclasses ''
25 | -allowaccessmodification
26 |
27 | -optimizationpasses 99
28 |
29 | -dontskipnonpubliclibraryclasses
30 | -dontskipnonpubliclibraryclassmembers
31 |
32 | -dontwarn android.support.**
33 |
34 | -keep class ** implements de.robv.android.xposed.IXposedHookLoadPackage {
35 | public void handleLoadPackage(de.robv.android.xposed.callbacks.XC_LoadPackage$LoadPackageParam);
36 | }
37 |
38 | -keep class net.manhong2112.downloadredirect.DLApi.DownloadConfig { *; }
39 | -keep class kotlin.reflect.** { *; }
40 | -keep class kotlin.internal.** { *; }
41 | -keep class kotlin.* { *; }
42 | -optimizationpasses 99
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
27 |
28 |
29 |
30 |
31 |
32 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | net.manhong2112.downloadredirect.XposedHook
2 |
--------------------------------------------------------------------------------
/app/src/main/java/net/manhong2112/downloadredirect/CheckableListAdapter.kt:
--------------------------------------------------------------------------------
1 | package net.manhong2112.downloadredirect
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import android.widget.ArrayAdapter
7 | import android.widget.CheckBox
8 | import org.jetbrains.anko.dip
9 | import org.jetbrains.anko.padding
10 |
11 |
12 | /**
13 | * Created by manhong2112 on 31/12/2016.
14 | *
15 | */
16 | class CheckableListAdapter(list: List,
17 | private val ctx: Context,
18 | private val callback: (CheckableListAdapter, CheckBox, Int, Boolean) -> Unit)
19 | : ArrayAdapter(ctx, android.R.layout.simple_list_item_1, list) {
20 | val isSelected = BooleanArray(list.size)
21 | override fun getView(pos: Int, convertView: View?, parent: ViewGroup?): View {
22 | val cv = (convertView ?: CheckBox(ctx)) as CheckBox
23 | cv.isChecked = isSelected[pos]
24 | cv.text = getItem(pos)
25 | cv.minHeight = ctx.dip(52)
26 | cv.padding = ctx.dip(8)
27 | cv.setOnClickListener {
28 | it as CheckBox
29 | callback(this, it, pos, it.isChecked)
30 | }
31 | return cv
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/net/manhong2112/downloadredirect/ConfigDAO.kt:
--------------------------------------------------------------------------------
1 | package net.manhong2112.downloadredirect
2 |
3 | import android.content.SharedPreferences
4 | import com.fasterxml.jackson.databind.ObjectMapper
5 | import com.fasterxml.jackson.module.kotlin.KotlinModule
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import de.robv.android.xposed.XSharedPreferences
8 | import net.manhong2112.downloadredirect.DLApi.DownloadConfig
9 | import java.util.*
10 | import android.content.Context
11 | import android.content.Context.MODE_WORLD_READABLE
12 | import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
13 |
14 | /**
15 | * Created by manhong2112 on 18/7/2016.
16 | * config manager
17 | */
18 |
19 | class ConfigDAO(private val pref: SharedPreferences) {
20 | companion object {
21 | fun getXPref(): ConfigDAO {
22 | val pref = XSharedPreferences(Const.PACKAGE_NAME, "pref")
23 | pref.makeWorldReadable()
24 | pref.reload()
25 | return ConfigDAO(pref)
26 | }
27 |
28 | fun getPref(ctx: Context, prefName: String = "pref"): ConfigDAO {
29 | return ConfigDAO(ctx.getSharedPreferences(prefName, MODE_WORLD_READABLE))
30 | }
31 | }
32 |
33 | val DownloadConfigs: HashMap by lazy {
34 | val mapper = jacksonObjectMapper()
35 | val k = pref.getStringSet("DownloadConfigs", null) ?: return@lazy Const.defaultDownloadConfig
36 | val map = HashMap()
37 | k.forEach {
38 | i ->
39 | val v: DownloadConfig = mapper.readValue(i)
40 | map[v.name] = v
41 | }
42 | return@lazy map
43 | }
44 |
45 | fun updateDownloadConfigs() {
46 | val mapper = ObjectMapper().registerModule(KotlinModule())
47 | val set: Set = DownloadConfigs.values.map {
48 | i: DownloadConfig ->
49 | mapper.writerWithDefaultPrettyPrinter().writeValueAsString(i)
50 | }.toSet()
51 | pref.edit().putStringSet("DownloadConfigs", set).apply()
52 | }
53 |
54 | val LinkFilter by lazy {
55 | pref.getStringSet("LinkFilter", setOf()).toSortedSet()
56 | }
57 |
58 | val AppFilter by lazy {
59 | pref.getStringSet("AppFilter", setOf()).toSortedSet()
60 | }
61 |
62 | var Experiment = pref.getBoolean("Experiment", false)
63 | set(b) {
64 | field = b
65 | pref.edit().putBoolean("Experiment", b).apply()
66 | }
67 |
68 | var NotSpecifyDownloader = pref.getBoolean("NotSpecifyDownloader", false)
69 | set(b) {
70 | field = b
71 | pref.edit().putBoolean("NotSpecifyDownloader", b).apply()
72 | }
73 |
74 | var Debug = pref.getBoolean("Debug", false)
75 | set(b) {
76 | field = b
77 | pref.edit().putBoolean("Debug", b).apply()
78 | }
79 |
80 | var HideIcon = pref.getBoolean("HideIcon", false)
81 | set(b) {
82 | field = b
83 | pref.edit().putBoolean("HideIcon", b).apply()
84 | }
85 |
86 | var SelectedDownloader: DownloadConfig = DownloadConfigs[pref.getString("SelectedDownloader", "ADM")]!!
87 | set(s) {
88 | field = s
89 | pref.edit().putString("SelectedDownloader", s.name).apply()
90 | }
91 |
92 | var UsingWhiteList_Link = pref.getBoolean("UsingWhiteList_Link", false)
93 | set(b) {
94 | field = b
95 | pref.edit().putBoolean("UsingWhiteList_Link", b).apply()
96 | }
97 |
98 | var UsingWhiteList_App = pref.getBoolean("UsingWhiteList_App", false)
99 | set(b) {
100 | field = b
101 | pref.edit().putBoolean("UsingWhiteList_App", b).apply()
102 | }
103 |
104 | var IgnoreSystemApp = pref.getBoolean("IgnoreSystemApp", false)
105 | set(b) {
106 | field = b
107 | pref.edit().putBoolean("IgnoreSystemApp", b).apply()
108 | }
109 |
110 | var FirstRun = pref.getBoolean("FirstRun", true)
111 | set(b) {
112 | field = b
113 | pref.edit().putBoolean("FirstRun", b).apply()
114 | }
115 |
116 | fun updateLinkFilter() {
117 | pref.edit().putStringSet("LinkFilter", LinkFilter.toSet()).apply()
118 | }
119 |
120 | fun updateAppFilter() {
121 | pref.edit().putStringSet("AppFilter", AppFilter.toSet()).apply()
122 | }
123 |
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/java/net/manhong2112/downloadredirect/Const.kt:
--------------------------------------------------------------------------------
1 | package net.manhong2112.downloadredirect
2 |
3 | import android.os.Build
4 | import net.manhong2112.downloadredirect.DLApi.*
5 | import java.util.*
6 |
7 | /**
8 | * Created by manhong2112 on 11/4/2016.
9 | * Const Data
10 | */
11 | object Const {
12 | const val ACTION_DOWNLOAD_REDIRECT = "net.manhong2112.intent.DOWNLOAD_REDIRECTION"
13 | const val PACKAGE_NAME = "net.manhong2112.downloadredirect"
14 | // version greater or equal than xxx
15 | val VER_GE_LOLLIPOP = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
16 | val VER_GE_MARSHMALLOW = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
17 | val VER_GE_N = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
18 |
19 | const val PACKAGE_NAME_ADM = "com.dv.adm"
20 | const val PACKAGE_NAME_ADMPro = "com.dv.adm.pay"
21 | val defaultDownloadConfig: HashMap by lazy {
22 | hashMapOf(
23 | "ADM" to DownloadConfig("ADM", "com.dv.adm", ACTION_DOWNLOAD_REDIRECT, listOf(Pair("Cookie", "Cookies"))),
24 | "ADMPro" to DownloadConfig("ADMPro", "com.dv.adm.pay", ACTION_DOWNLOAD_REDIRECT, listOf(Pair("Cookie", "Cookies"))),
25 | "LoaderDroid" to DownloadConfig("LoaderDroid", "org.zloy.android.downloader", "org.zloy.android.downloader.action.ADD_LOADING", listOf(Pair("Cookie", "cookies"), Pair("Referer", "referer"))),
26 | "QKADM" to DownloadConfig("QKADM", "com.vanda_adm.vanda", "com.vanda.adm.friends", listOf(Pair("Cookie", "cookie")))
27 | )
28 | }
29 |
30 |
31 | object id {
32 | const val Pref_Page = 0
33 | const val Debug_Label = 1
34 | const val Debug_List = 2
35 | const val Debug_Logging_Switch = 3
36 | const val Pref_Label = 4
37 | const val Pref_List = 5
38 | const val Pref_HideIcon_Switch = 6
39 | const val Filter_Label = 7
40 | const val Filter_List = 8
41 | const val Link_Filter = 9
42 | const val Link_Filter_Add = 10
43 | const val App_Filter = 11
44 | const val App_Filter_Add = 12
45 | const val About_Label = 13
46 | const val About_Version = 14
47 | const val Pref_Downloader_Selector = 15
48 | const val Pref_Ignore_System_App = 16
49 | const val Pref_Use_White_List = 17
50 | const val Pref_Using_Downloader = 18
51 | const val About_Github = 19
52 | const val About_Email = 20
53 | const val About_Author = 21
54 | const val About_ListView = 22
55 | const val Debug_Experiment_Switch = 23
56 | const val Debug_Redirection_Test = 24
57 | const val Pref_NotSpecifyDownloader_Switch = 25
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/net/manhong2112/downloadredirect/DLApi/DLApi.kt:
--------------------------------------------------------------------------------
1 | package net.manhong2112.downloadredirect.DLApi
2 |
3 | import android.content.ActivityNotFoundException
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.net.Uri
7 | import net.manhong2112.downloadredirect.Main
8 | import net.manhong2112.downloadredirect.ConfigDAO
9 |
10 | /**
11 | * Created by manhong2112 on 12/9/2017.
12 | */
13 |
14 | typealias Name = String
15 | typealias Value = String
16 | typealias Header = List>
17 | object DLApi {
18 | fun addDownload(ctx: Context, url: Uri, mRequestHeaders: List>): Boolean {
19 | val Pref = ConfigDAO.getXPref()
20 | val DEBUG = Pref.Debug
21 | Main.log("addDownload(Context, Uri, List)", DEBUG)
22 | val intent = Intent(Intent.ACTION_VIEW, url)
23 | mRequestHeaders.forEach {
24 | (name, value) ->
25 | when (name.toLowerCase()) {
26 | "cookies", "cookie" -> {
27 | intent.putExtra("Cookies", value)
28 | intent.putExtra("cookies", value)
29 | intent.putExtra("Cookie", value)
30 | intent.putExtra("cookie", value)
31 | Main.log("Put 'Cookie' -> ${value}", DEBUG)
32 | }
33 | "referer" -> {
34 | intent.putExtra("referer", value)
35 | intent.putExtra("Referer", value)
36 | Main.log("Put 'Referer' -> ${value}", DEBUG)
37 | }
38 | else -> {
39 | intent.putExtra(name, value)
40 | Main.log("Put ${name} -> ${value}", DEBUG)
41 | }
42 | }
43 | }
44 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
45 | intent.addCategory(Intent.CATEGORY_DEFAULT)
46 |
47 | return try {
48 | ctx.startActivity(intent)
49 | true
50 | } catch (e: ActivityNotFoundException) {
51 | false
52 | }
53 | }
54 |
55 | fun addDownload(ctx: Context, url: Uri, mRequestHeaders: List>, downloadConfig: DownloadConfig): Boolean {
56 | val Pref = ConfigDAO.getXPref()
57 | val DEBUG = Pref.Debug
58 | Main.log("addDownload(Context, Uri, List, DownloadConfig)", DEBUG)
59 | val intent = Intent(downloadConfig.intent, url)
60 | intent.`package` = downloadConfig.packageName
61 | mRequestHeaders.forEach {
62 | (name, value) ->
63 | when (name.toLowerCase()) {
64 | "cookies", "cookie" -> {
65 | val k = downloadConfig.headers.firstOrNull { (name, _) -> name == "Cookie" }?.second ?: ""
66 | intent.putExtra(k, value)
67 | Main.log("Put ${k} -> ${value}", DEBUG)
68 | }
69 | "referer" -> {
70 | val k = downloadConfig.headers.firstOrNull { (name, _) -> name == "Referer" }?.second ?: ""
71 | intent.putExtra(k, value)
72 | Main.log("Put ${k} -> ${value}", DEBUG)
73 | }
74 | else -> {
75 | intent.putExtra(name, value)
76 | Main.log("Put ${name} -> ${value}", DEBUG)
77 | }
78 | }
79 | }
80 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
81 | intent.addCategory(Intent.CATEGORY_DEFAULT)
82 |
83 | return try {
84 | ctx.startActivity(intent)
85 | true
86 | } catch (e: ActivityNotFoundException) {
87 | false
88 | }
89 | }
90 |
91 | }
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/java/net/manhong2112/downloadredirect/DLApi/DownloadConfig.kt:
--------------------------------------------------------------------------------
1 | package net.manhong2112.downloadredirect.DLApi
2 |
3 | /**
4 | * Created by manhong2112 on 12/9/2017.
5 | */
6 | data class DownloadConfig(val name: String, val packageName: String, val intent: String, val headers: Header)
--------------------------------------------------------------------------------
/app/src/main/java/net/manhong2112/downloadredirect/Main.kt:
--------------------------------------------------------------------------------
1 | package net.manhong2112.downloadredirect
2 |
3 | import android.annotation.SuppressLint
4 | import android.app.Activity
5 | import android.app.AlertDialog
6 | import android.content.ComponentName
7 | import android.content.Context
8 | import android.content.DialogInterface
9 | import android.content.pm.ApplicationInfo
10 | import android.content.pm.PackageManager
11 | import android.os.Bundle
12 | import android.text.Editable
13 | import android.text.SpannableStringBuilder
14 | import android.text.TextWatcher
15 | import android.util.Base64
16 | import android.util.Log
17 | import android.view.Gravity
18 | import android.view.Menu
19 | import android.view.ViewManager
20 | import android.view.WindowManager
21 | import android.widget.ArrayAdapter
22 | import android.widget.Switch
23 | import android.widget.TextView
24 | import net.manhong2112.downloadredirect.DLApi.DownloadConfig
25 | import org.jetbrains.anko.*
26 |
27 |
28 | /**
29 | * Created by manhong2112 on 10/4/2016.
30 | * Setting Page
31 | */
32 |
33 | class Main : Activity() {
34 | override fun onCreate(bundle: Bundle?) {
35 | super.onCreate(bundle)
36 | MainUi().setContentView(this)
37 | }
38 |
39 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
40 | return super.onCreateOptionsMenu(menu)
41 | }
42 |
43 | companion object {
44 | fun log(str: String, debug: Boolean = true) {
45 | if (debug) {
46 | Log.i("Xposed", "DownloadRedirect -> $str")
47 | }
48 | }
49 |
50 | fun isPackageInstalled(packageName: String, packageManager: PackageManager): Boolean {
51 | return try {
52 | packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES)
53 | true
54 | } catch (e: PackageManager.NameNotFoundException) {
55 | false
56 | }
57 | }
58 |
59 | fun hideIcon(ctx: Context) {
60 | ctx.packageManager.setComponentEnabledSetting(
61 | ComponentName(ctx, "net.manhong2112.downloadredirect.MainIcon"),
62 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
63 | PackageManager.DONT_KILL_APP)
64 | }
65 |
66 | fun displayIcon(ctx: Context) {
67 | ctx.packageManager.setComponentEnabledSetting(
68 | ComponentName(ctx, "net.manhong2112.downloadredirect.MainIcon"),
69 | PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
70 | PackageManager.DONT_KILL_APP)
71 | }
72 | }
73 | }
74 |
75 | class MainUi : AnkoComponent {
76 | //TODO Undo Bar
77 |
78 | @SuppressLint("NewApi")
79 | fun getColor(ctx: Context, id: Int): Int {
80 | if (Const.VER_GE_MARSHMALLOW) {
81 | return ctx.getColor(id)
82 | } else {
83 | @Suppress("deprecation")
84 | return ctx.resources.getColor(id)
85 | }
86 | }
87 |
88 | fun _RelativeLayout.label(ctx: Context, viewId: Int, _text: String, init: TextView.() -> Unit = {}) = textView {
89 | id = viewId
90 | text = _text
91 | setPadding(dip(16), 0, dip(16), 0)
92 | gravity = Gravity.CENTER_VERTICAL
93 | textColor = getColor(ctx, R.color.label_text)
94 | init()
95 | }
96 |
97 | fun _RelativeLayout.label(ctx: Context, viewId: Int, textResId: Int, init: TextView.() -> Unit = {}) =
98 | label(ctx, viewId, resources.getString(textResId), init)
99 |
100 | @SuppressLint("NewApi")
101 | fun _RelativeLayout.subtitle(ctx: Context, viewId: Int, _text: String, init: TextView.() -> Unit = {}) = textView {
102 | if (Const.VER_GE_LOLLIPOP) {
103 | elevation = dip(2).toFloat()
104 | }
105 | gravity = Gravity.CENTER_VERTICAL
106 | id = viewId
107 | text = _text
108 | textColor = getColor(ctx, R.color.subtitle_text)
109 | backgroundColor = getColor(ctx, R.color.subtitle_bg)
110 | setPadding(dip(12), 0, 0, 0)
111 | init()
112 | }
113 |
114 | fun _RelativeLayout.subtitle(ctx: Context, viewId: Int, textResId: Int, init: TextView.() -> Unit = {}) =
115 | subtitle(ctx, viewId, resources.getString(textResId), init)
116 |
117 | fun _RelativeLayout.prefSwitch(viewId: Int, _text: String, init: Switch.() -> Unit = {}) = switch {
118 | id = viewId
119 | text = _text
120 | setPadding(dip(16), 0, dip(16), 0)
121 | init()
122 | }
123 |
124 | fun _RelativeLayout.prefSwitch(viewId: Int, textResId: Int, init: Switch.() -> Unit = {}) = prefSwitch(viewId, resources.getString(textResId), init)
125 |
126 | fun AnkoContext<*>.showAlert(message: Int, title: Int?, dsl: AlertBuilder.() -> Unit = {}) =
127 | alert(message, title) {
128 | dsl()
129 | }.show()
130 |
131 | inline fun AnkoContext<*>.showAlert(crossinline dsl: AlertBuilder.() -> Unit) =
132 | alert {
133 | dsl()
134 | }.show()
135 |
136 |
137 | inline fun AnkoContext<*>.showCustomAlert(crossinline dsl: AlertBuilder.() -> ViewManager.() -> Unit) =
138 | alert {
139 | customView {
140 | dsl()()
141 | }
142 | }.show()
143 |
144 |
145 | fun AnkoContext<*>.downloaderConfigEditDialog(init: DownloadConfig? = null, callback: (DownloadConfig) -> Unit): DialogInterface {
146 | var g: (DialogInterface.() -> Unit)? = null
147 | val k = showCustomAlert {{
148 | verticalLayout {
149 | padding = dip(16)
150 | val name = editText {
151 | text = SpannableStringBuilder(init?.name ?: "")
152 | hint = "name"
153 | }
154 | val packageName = editText {
155 | text = SpannableStringBuilder(init?.packageName ?: "")
156 | hint = "package name"
157 | }
158 | val intent = editText {
159 | hint = "intent"
160 | text = SpannableStringBuilder(init?.intent ?: "")
161 | }
162 | val cookies = editText {
163 | hint = "Cookies (optional)"
164 | text = SpannableStringBuilder(init?.headers?.firstOrNull { (name, _) -> name == "Cookie" }?.second ?: "")
165 | }
166 | val referer = editText {
167 | hint = "Referer (optional)"
168 | text = SpannableStringBuilder(init?.headers?.firstOrNull { (name, _) -> name == "Referer" }?.second ?: "")
169 | }
170 | positiveButton(android.R.string.ok, {})
171 | g = {
172 | if (name.text.isEmpty() or packageName.text.isEmpty() or intent.text.isEmpty()) {
173 | toast("Please fill in name, package name and intent ")
174 | } else {
175 | toast("${name.text}, ${packageName.text}, ${intent.text}, ${cookies.text}, ${referer.text}")
176 | callback(DownloadConfig(
177 | name.text.toString(),
178 | packageName.text.toString(),
179 | intent.text.toString(),
180 | listOf(Pair("Cookie", cookies.text.toString()),
181 | Pair("Referer", referer.text.toString()))
182 | ))
183 | dismiss()
184 | }
185 | }
186 | }
187 | }
188 | }
189 | (k as AlertDialog).run {
190 | window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
191 | getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
192 | g!!(k)
193 | }
194 | }
195 | return k
196 | }
197 |
198 | override fun createView(ui: AnkoContext) = with(ui) {
199 | val Pref = ConfigDAO.getPref(ctx)
200 | val DEBUG = Pref.Debug
201 | val af = Pref.AppFilter
202 | val lf = Pref.LinkFilter
203 | val ColumnHeight = dip(48)
204 | val SubTitleHeight = dip(36)
205 |
206 | if (Pref.FirstRun) {
207 | Pref.FirstRun = false
208 | showAlert(R.string.first_run_message, R.string.first_run) {
209 | positiveButton(android.R.string.ok) {}
210 | }
211 | }
212 |
213 |
214 | scrollView {
215 | relativeLayout {
216 | lparams {
217 | width = matchParent
218 | }
219 | id = Const.id.Pref_Page
220 | // Debug
221 | subtitle(ctx, Const.id.Debug_Label, R.string.label_debug)
222 | .lparams {
223 | width = matchParent
224 | height = SubTitleHeight
225 | }
226 |
227 | prefSwitch(Const.id.Debug_Logging_Switch, R.string.switch_debug_logging) {
228 | isChecked = Pref.Debug
229 | lparams {
230 | width = matchParent
231 | height = ColumnHeight
232 | below(Const.id.Debug_Label)
233 | }
234 | setOnClickListener {
235 | Pref.Debug = (it as Switch).isChecked
236 | }
237 | }
238 |
239 | prefSwitch(Const.id.Debug_Experiment_Switch, R.string.switch_debug_experiment) {
240 | isChecked = Pref.Experiment
241 | lparams {
242 | width = matchParent
243 | height = ColumnHeight
244 | below(Const.id.Debug_Logging_Switch)
245 | }
246 | setOnClickListener {
247 | Pref.Experiment = (it as Switch).isChecked
248 | }
249 | }
250 |
251 | // Pref
252 | subtitle(ctx, Const.id.Pref_Label, R.string.label_preferences).lparams {
253 | below(Const.id.Debug_Experiment_Switch)
254 | width = matchParent
255 | height = SubTitleHeight
256 | }
257 |
258 | prefSwitch(Const.id.Pref_HideIcon_Switch, R.string.switch_hide_app_icon) {
259 | isChecked = Pref.HideIcon
260 | setOnClickListener {
261 | it as Switch
262 | Pref.HideIcon = it.isChecked
263 | if (it.isChecked) {
264 | Main.hideIcon(ctx)
265 | } else {
266 | Main.displayIcon(ctx)
267 | }
268 | }
269 | lparams {
270 | below(Const.id.Pref_Label)
271 | width = matchParent
272 | height = ColumnHeight
273 | }
274 | }
275 |
276 |
277 | prefSwitch(Const.id.Pref_Ignore_System_App, R.string.switch_ignore_system_app) {
278 | isChecked = Pref.IgnoreSystemApp
279 | setOnClickListener {
280 | Pref.IgnoreSystemApp = (it as Switch).isChecked
281 | }
282 | lparams {
283 | width = matchParent
284 | height = ColumnHeight
285 | below(Const.id.Pref_HideIcon_Switch)
286 | }
287 | }
288 |
289 |
290 | prefSwitch(Const.id.Pref_NotSpecifyDownloader_Switch, R.string.switch_not_specify_downloader) {
291 | isChecked = Pref.NotSpecifyDownloader
292 | setOnClickListener {
293 | Pref.NotSpecifyDownloader = (it as Switch).isChecked
294 | }
295 | lparams {
296 | width = matchParent
297 | height = ColumnHeight
298 | below(Const.id.Pref_Ignore_System_App)
299 | }
300 | }
301 |
302 | val selectedDownloader = Pref.SelectedDownloader
303 | val b = with(label(ctx, Const.id.Pref_Using_Downloader, selectedDownloader.name)) {
304 | lparams {
305 | rightMargin = dip(16)
306 | height = ColumnHeight
307 | below(Const.id.Pref_NotSpecifyDownloader_Switch)
308 | alignParentRight()
309 | }
310 | }
311 |
312 | with(label(ctx, Const.id.Pref_Downloader_Selector, R.string.list_change_downloader)) {
313 | lparams {
314 | width = matchParent
315 | height = ColumnHeight
316 | alignParentLeft()
317 | below(Const.id.Pref_NotSpecifyDownloader_Switch)
318 | }
319 | setOnClickListener {
320 | lateinit var dialog: DialogInterface
321 | dialog = showCustomAlert {
322 | {
323 | verticalLayout {
324 | lparams {
325 | height = matchParent
326 | verticalPadding = dip(16)
327 | }
328 | titleResource = R.string.selector_downloader
329 | val j = listView {
330 | divider = null
331 | isVerticalScrollBarEnabled = false
332 |
333 | adapter = ArrayAdapter(ctx, android.R.layout.simple_list_item_1, Pref.DownloadConfigs.keys.sorted())
334 | setOnItemClickListener { adapterView, view, i, id ->
335 | adapterView!!
336 | val downloader = Pref.DownloadConfigs[adapterView.getItemAtPosition(i) as String]!!
337 | toast("Selected ${downloader.name}")
338 | b.text = downloader.name
339 | Pref.SelectedDownloader = downloader
340 | dialog.dismiss()
341 | }
342 |
343 | setOnItemLongClickListener { adapterView, view, i, id ->
344 | adapterView!!
345 | selector("", listOf("Edit", "Delete")) { _, index ->
346 | val name = adapterView.getItemAtPosition(i) as String
347 | when (index) {
348 | 0 ->
349 | downloaderConfigEditDialog(Pref.DownloadConfigs[name]) { config ->
350 | Pref.DownloadConfigs.remove(name)
351 | Pref.DownloadConfigs[config.name] = config
352 | }
353 | 1 ->
354 | Pref.DownloadConfigs.remove(name)
355 | }
356 | Pref.updateDownloadConfigs()
357 | adapter = ArrayAdapter(ctx, android.R.layout.simple_list_item_1, Pref.DownloadConfigs.keys.sorted())
358 | (adapter as ArrayAdapter<*>).notifyDataSetChanged()
359 | }
360 | true
361 | }
362 | }.lparams {
363 | height = 0
364 | weight = 1f
365 | width = matchParent
366 | }
367 | button {
368 | text = "Add"
369 | setOnClickListener {
370 | downloaderConfigEditDialog { config ->
371 | Pref.DownloadConfigs[config.name] = config
372 | Pref.updateDownloadConfigs()
373 | j.adapter = ArrayAdapter(ctx, android.R.layout.simple_list_item_1, Pref.DownloadConfigs.keys.sorted())
374 | (j.adapter as ArrayAdapter<*>).notifyDataSetChanged()
375 | }
376 | }
377 | }
378 | }
379 | }
380 | }
381 | }
382 | }
383 |
384 | // Filter
385 | subtitle(ctx, Const.id.Filter_Label, R.string.label_filter).lparams {
386 | width = matchParent
387 | height = SubTitleHeight
388 | below(Const.id.Pref_Using_Downloader)
389 | }
390 |
391 | label(ctx, Const.id.Pref_Use_White_List, R.string.switch_white_list) {
392 | lparams {
393 | width = matchParent
394 | height = ColumnHeight
395 | below(Const.id.Filter_Label)
396 | }
397 | setOnClickListener {
398 | showCustomAlert {{
399 | verticalLayout {
400 | titleResource = R.string.selector_whitelist
401 | val choiceList = arrayListOf(
402 | ctx.getString(R.string.filter_link),
403 | ctx.getString(R.string.filter_app))
404 | val aa = CheckableListAdapter(choiceList, ctx) { adapter, view, pos, isChecked ->
405 | when (pos) {
406 | 0 -> Pref.UsingWhiteList_Link = isChecked
407 | 1 -> Pref.UsingWhiteList_App = isChecked
408 | }
409 | }
410 | aa.isSelected[0] = Pref.UsingWhiteList_Link
411 | aa.isSelected[1] = Pref.UsingWhiteList_App
412 | listView {
413 | divider = null
414 | isVerticalScrollBarEnabled = false
415 | adapter = aa
416 | }.lparams {
417 | padding = dip(4)
418 | height = 0
419 | weight = 1f
420 | width = matchParent
421 | }
422 | }
423 | }
424 | }
425 | }
426 | }
427 |
428 | label(ctx, Const.id.Link_Filter, R.string.filter_link) {
429 | lparams {
430 | width = matchParent
431 | height = ColumnHeight
432 | alignParentLeft()
433 | below(Const.id.Pref_Use_White_List)
434 | }
435 | setOnClickListener {
436 | val dialog = showCustomAlert {
437 | {
438 | verticalLayout {
439 | lparams {
440 | height = matchParent
441 | verticalPadding = dip(16)
442 | }
443 | val x = ArrayList(lf)
444 | val aa = ArrayAdapter(ctx, android.R.layout.simple_list_item_1, x)
445 | titleResource = R.string.list_filter_link
446 | listView {
447 | divider = null
448 | isVerticalScrollBarEnabled = false
449 |
450 | adapter = aa
451 | setOnItemClickListener { parent, view, position, id ->
452 | alert("Are you sure to remove") {
453 | positiveButton(android.R.string.yes) {
454 | val item = aa.getItem(position)
455 | toast(ctx.getString(R.string.toast_removed, item[0]))
456 | lf.remove(item)
457 | Pref.updateLinkFilter()
458 | x.remove(item)
459 | aa.notifyDataSetChanged()
460 | }
461 | negativeButton(android.R.string.no, {it.dismiss()})
462 | }.show()
463 | }
464 | }.lparams {
465 | height = 0
466 | weight = 1f
467 | width = matchParent
468 | }
469 | linearLayout {
470 | lparams {
471 | width = matchParent
472 | horizontalMargin = dip(4)
473 | gravity = Gravity.CENTER
474 | }
475 | val link = editText {
476 | maxLines = 1
477 | inputType = android.text.InputType.TYPE_CLASS_TEXT
478 | hint = ctx.getString(R.string.label_regex)
479 | }.lparams {
480 | weight = 1f
481 | }
482 | button {
483 | text = ctx.getString(R.string.button_add)
484 | setOnClickListener {
485 | val d = link.text.trim().toString()
486 | when (true) {
487 | d.isEmpty() ->
488 | toast(R.string.toast_empty_input)
489 | lf.contains(d) ->
490 | toast(R.string.toast_rule_already_exist)
491 | else -> {
492 | toast(ctx.getString(R.string.toast_added, d))
493 | Main.log("Added \"$d\" to filter", DEBUG)
494 | lf.add(d)
495 | Pref.updateLinkFilter()
496 | x.add(d)
497 | x.sort()
498 | aa.notifyDataSetChanged()
499 | }
500 | }
501 | }
502 | }
503 | }
504 | }
505 | }
506 | }
507 | (dialog as AlertDialog).window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
508 | }
509 | }
510 |
511 | label(ctx, Const.id.App_Filter, R.string.filter_app) {
512 | lparams {
513 | width = matchParent
514 | height = ColumnHeight
515 | alignParentLeft()
516 | below(Const.id.Link_Filter)
517 | }
518 | setOnClickListener {
519 | val dialog = showCustomAlert {{
520 | verticalLayout {
521 | lparams {
522 | height = matchParent
523 | verticalPadding = dip(16)
524 | }
525 | val appList = arrayListOf()
526 |
527 | val toBeRemove = mutableSetOf()
528 | af.forEach {
529 | if (Main.isPackageInstalled(it, ctx.packageManager)) {
530 | val appInfo = ctx.packageManager.getApplicationInfo(it, 0)
531 | appList.add(ctx.packageManager.getApplicationLabel(appInfo).toString() + "\n " + it)
532 | } else {
533 | toBeRemove.add(it)
534 | }
535 | }
536 | toBeRemove.forEach {
537 | af.remove(it)
538 | }
539 | Pref.updateAppFilter()
540 |
541 | loop@ for (l in ctx.packageManager.getInstalledPackages(0)) {
542 | when (true) {
543 | Pref.IgnoreSystemApp &&
544 | ((l.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 1) ->
545 | continue@loop
546 | af.contains(l.packageName) ->
547 | continue@loop
548 | else ->
549 | appList.add(
550 | ctx.packageManager.getApplicationLabel(l.applicationInfo).toString() + "\n " + l.packageName)
551 | }
552 | }
553 |
554 | val cla = CheckableListAdapter(appList, ctx) { adapter, view, pos, isChecked ->
555 | val item = adapter.getItem(pos)!!.split("\n ")
556 | if (item[1] in af) {
557 | Main.log("Removed '${item[0]} | ${item[1]}' from filter", DEBUG)
558 | toast(ctx.getString(R.string.toast_removed, item[0]))
559 | af.remove(item[1])
560 | } else {
561 | Main.log("Added '${item[0]} | ${item[1]}' to filter", DEBUG)
562 | toast(ctx.getString(R.string.toast_added, item[0]))
563 | af.add(item[1])
564 | }
565 | Pref.updateAppFilter()
566 | }
567 | for (i in 0 until af.size) {
568 | cla.isSelected[i] = true
569 | }
570 | titleResource = R.string.list_filter_app
571 | listView {
572 | divider = null
573 | isVerticalScrollBarEnabled = false
574 | adapter = cla
575 | }.lparams {
576 | height = 0
577 | weight = 1f
578 | width = matchParent
579 | }
580 | editText {
581 | maxLines = 1
582 | inputType = android.text.InputType.TYPE_CLASS_TEXT
583 |
584 | hint = ctx.getString(R.string.label_search)
585 | addTextChangedListener(object : TextWatcher {
586 | override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
587 | }
588 |
589 | override fun afterTextChanged(p0: Editable?) {
590 | }
591 |
592 | override fun onTextChanged(cs: CharSequence, arg1: Int, arg2: Int, arg3: Int) {
593 | cla.filter.filter(cs)
594 | }
595 | })
596 | }.lparams {
597 | width = matchParent
598 | horizontalMargin = dip(4)
599 | }
600 | }
601 | }
602 | }
603 | (dialog as AlertDialog).window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
604 | }
605 | }
606 |
607 | // About
608 | subtitle(ctx, Const.id.About_Label, R.string.label_about).lparams {
609 | width = matchParent
610 | height = SubTitleHeight
611 | below(Const.id.App_Filter)
612 | }
613 |
614 | val ver = label(ctx, Const.id.About_Version, "${ctx.getString(R.string.app_name)} ${BuildConfig.VERSION_NAME}")
615 | .lparams {
616 | height = ColumnHeight
617 | width = matchParent
618 | below(Const.id.About_Label)
619 | }
620 | ver.textColor = getColor(ctx, R.color.label_about_text)
621 | val s = String(android.util.Base64.decode(ctx.getString(R.string.Info), 0)).split("|")
622 | var i = 1
623 | label(ctx, Const.id.About_Author, String(Base64.decode(s[--i], 0)))
624 | .lparams {
625 | height = ColumnHeight
626 | width = matchParent
627 | below(Const.id.About_Version)
628 | }.textColor = getColor(ctx, R.color.label_about_text)
629 | label(ctx, Const.id.About_Email, String(Base64.decode(s[(i++).plus(++i)], 0)))
630 | .lparams {
631 | height = ColumnHeight
632 | width = matchParent
633 | below(Const.id.About_Author)
634 | }.textColor = getColor(ctx, R.color.label_about_text)
635 | label(ctx, Const.id.About_Github, String(Base64.decode(s[--i], 0)))
636 | .lparams {
637 | height = ColumnHeight
638 | width = matchParent
639 | below(Const.id.About_Email)
640 | }.textColor = getColor(ctx, R.color.label_about_text)
641 |
642 | }
643 | }
644 |
645 |
646 | }
647 |
648 | }
--------------------------------------------------------------------------------
/app/src/main/java/net/manhong2112/downloadredirect/XposedHook.kt:
--------------------------------------------------------------------------------
1 | package net.manhong2112.downloadredirect
2 |
3 | import android.app.AndroidAppHelper
4 | import android.app.DownloadManager
5 | import android.content.Intent
6 | import android.content.IntentFilter
7 | import android.content.pm.ActivityInfo
8 | import android.content.pm.ApplicationInfo
9 | import android.net.Uri
10 | import de.robv.android.xposed.*
11 | import de.robv.android.xposed.XposedHelpers.*
12 | import de.robv.android.xposed.callbacks.XC_LoadPackage
13 | import net.manhong2112.downloadredirect.DLApi.DLApi
14 | import java.util.*
15 | import android.util.Log
16 |
17 |
18 | /**
19 | * Created by manhong2112 on 23/3/2016.
20 | * Main activity of xposed hook
21 | */
22 | @Suppress("UNCHECKED_CAST")
23 | class XposedHook : IXposedHookZygoteInit, IXposedHookLoadPackage {
24 | fun log(str: String, debug: Boolean = true) {
25 | if(debug) {
26 | Log.i("Xposed", "DownloadRedirect -> $str")
27 | }
28 | }
29 | override fun handleLoadPackage(params: XC_LoadPackage.LoadPackageParam?) {
30 | val Pref = ConfigDAO.getXPref()
31 | val DEBUG = Pref.Debug
32 | if (Pref.Experiment &&
33 | params != null &&
34 | params.packageName == "android") {
35 | val clsPMS = XposedHelpers.findClass("android.content.pm.PackageParser", params.classLoader)
36 | if (Const.VER_GE_LOLLIPOP) {
37 | log("enabled experiment function, hooking android.content.pm.PackageParser.parseBaseApk()", DEBUG)
38 | XposedBridge.hookAllMethods(clsPMS,
39 | "parseBaseApk",
40 | injectFilter)
41 | log("Hooked parseBaseApk()", DEBUG)
42 | } else {
43 | log("enabled experiment function, hooking android.content.pm.PackageParser.parsePackage()", DEBUG)
44 | XposedBridge.hookAllMethods(clsPMS,
45 | "parsePackage",
46 | injectFilter)
47 | log("Hooked parsePackage()", DEBUG)
48 | }
49 |
50 | }
51 | }
52 |
53 | @Throws(Throwable::class)
54 | override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam) {
55 | val Pref = ConfigDAO.getXPref()
56 | val DEBUG = Pref.Debug
57 | log("module initing", DEBUG)
58 | log("hooking android.app.DownloadManager.enqueue()", DEBUG)
59 |
60 | XposedBridge.hookAllMethods(DownloadManager::class.java, "enqueue", enqueueHook)
61 |
62 | try {
63 | val EXPERIMENT = Pref.Experiment
64 | if (!EXPERIMENT) {
65 | log("hooking android.content.pm.PackageParser.parsePackage()", DEBUG)
66 | val PackageParser = findClass("android.content.pm.PackageParser", null)
67 | XposedBridge.hookAllMethods(PackageParser, "parsePackage", injectFilter)
68 | }
69 | } catch (e: NoSuchMethodError) {
70 | log("Failed to Hook parsePackage()", DEBUG)
71 | }
72 | log("init ended", DEBUG)
73 |
74 | }
75 |
76 | private val enqueueHook = object : XC_MethodHook() {
77 | @Throws(Throwable::class)
78 | override fun beforeHookedMethod(param: MethodHookParam) {
79 | val ctx = AndroidAppHelper.currentApplication()
80 | val Pref = ConfigDAO.getXPref()
81 | val appFilter = Pref.AppFilter
82 | val linkFilter = Pref.LinkFilter
83 | val DEBUG = Pref.Debug
84 | log("received download request", DEBUG)
85 | val mUri = getObjectField(param.args[0], "mUri") as Uri
86 | val mRequestHeaders = getObjectField(param.args[0], "mRequestHeaders") as List>
87 |
88 | when(true) {
89 | (Pref.IgnoreSystemApp &&
90 | ((ctx.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 1)) -> {
91 | log("enabled ignore system & detected system app, aborted", DEBUG)
92 | return
93 | }
94 | }
95 |
96 | if (Pref.UsingWhiteList_App) {
97 | log("filtering app with whitelist rule", DEBUG)
98 | if (!appFilter.contains(AndroidAppHelper.currentApplication().packageName)) {
99 | log("app is not in the list, aborted", DEBUG)
100 | return
101 | }
102 | } else {
103 | log("filtering app with blacklist rule", DEBUG)
104 | if (appFilter.contains(AndroidAppHelper.currentApplication().packageName)) {
105 | log("app is in the list, aborted", DEBUG)
106 | return
107 | }
108 | }
109 |
110 | if (Pref.UsingWhiteList_Link) {
111 | log("Matching link with whitelist rule", DEBUG)
112 | var not_match = true
113 | linkFilter.forEach {
114 | Main.log("Matching -> $it", DEBUG)
115 | if (mUri.toString().matches(it.toRegex())) {
116 | not_match = false
117 | return@forEach
118 | }
119 | }
120 | if (not_match) {
121 | log("doesn't matched any regex, aborted", DEBUG)
122 | return
123 | }
124 | } else {
125 | log("Matching link with blacklist rule", DEBUG)
126 | linkFilter.forEach {
127 | log("Matching -> $it", DEBUG)
128 | if (mUri.toString().matches(it.toRegex())) {
129 | log("matched $it, aborted", DEBUG)
130 | return
131 | }
132 | }
133 | }
134 |
135 | log("Url to be redirected -> $mUri", DEBUG)
136 | val selectedDownloader = Pref.SelectedDownloader
137 | log("Selected Downloader -> name -> ${selectedDownloader.name}", DEBUG)
138 | log("Selected Downloader -> intent -> ${selectedDownloader.intent}", DEBUG)
139 | log("NotSpecifyDownloader -> ${Pref.NotSpecifyDownloader}", DEBUG)
140 |
141 | val v = if(Pref.NotSpecifyDownloader)
142 | DLApi.addDownload(ctx, mUri, mRequestHeaders)
143 | else (DLApi.addDownload(ctx, mUri, mRequestHeaders, selectedDownloader) || DLApi.addDownload(ctx, mUri, mRequestHeaders))
144 | log("Redirection: ${if (v) "Success" else "Failed"}", DEBUG)
145 | if (v) {
146 | param.result = 0
147 | }
148 | }
149 | }
150 |
151 | private val injectFilter = object : XC_MethodHook() {
152 | @Throws(Throwable::class)
153 | override fun afterHookedMethod(param: MethodHookParam) {
154 | val Pref = ConfigDAO.getXPref()
155 | val DEBUG = Pref.Debug
156 | val ActivityIntentInfo = findClass("android.content.pm.PackageParser\$ActivityIntentInfo", null)
157 | if(param.result == null) {
158 | log("param.result is null", DEBUG)
159 | log("${param.args[0]}", DEBUG)
160 | return
161 | }
162 | val packageName = getObjectField(param.result, "packageName")
163 | if (packageName != Const.PACKAGE_NAME_ADM &&
164 | packageName != Const.PACKAGE_NAME_ADMPro) {
165 | return
166 | }
167 | log("found ADM package", DEBUG)
168 | val activities = getObjectField(param.result, "activities") as ArrayList<*>
169 | if (activities.isEmpty()) return
170 | // List of Activity
171 | log("searching com.dv.adm{|.pay}.AEditor at ${param.args[0]}", DEBUG)
172 | for (activity in activities) {
173 | // obj.activity
174 | val info = getObjectField(activity, "info") as ActivityInfo
175 | when (info.name) {
176 | "com.dv.adm.pay.AEditor", "com.dv.adm.AEditor" -> {
177 | log("Injecting Redirect Intent", DEBUG)
178 | val intent = newInstance(ActivityIntentInfo, activity) as IntentFilter
179 | intent.addDataScheme("http")
180 | intent.addDataScheme("https")
181 | intent.addAction(Const.ACTION_DOWNLOAD_REDIRECT)
182 | intent.addCategory(Intent.CATEGORY_DEFAULT)
183 |
184 | callMethod(getObjectField(activity, "intents"), "add", intent)
185 | log("Injected Redirect Intent", DEBUG)
186 | return
187 | }
188 | }
189 | }
190 | }
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paletteOvO/DownloadRedirect/322ddc1486f0d2f6a6dd6a29f9fe710c4884af0d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-pt-rBR/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Redirecionador de Download
3 |
4 | Debug
5 | Logging
6 |
7 | Configurações de preferência
8 | Esconder aplicativo do lançador
9 | Usar Lista Branca
10 | Ignorar Apps do Sistema
11 | Alterar App Downloader
12 | Selecionar App Downloader
13 |
14 | Filtro
15 | Link
16 | App
17 |
18 | Link Adicionado
19 | App Adicionado
20 |
21 | Adicionar Link
22 | Adicionar App
23 | Usar Lista Branca
24 |
25 | App Downloader alterado para %s
26 | %s Removido
27 | A Lista de filtros está vazio
28 | Cancelado, o campo está vazio
29 | %s Adicionado
30 | Já existe no filtro
31 | Nenhum App Downloader Suportado foi encontrado
32 |
33 |
34 | Adicionar
35 |
36 | Expressão regular
37 | Sobre
38 | Pesquisar
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 下载重定向
4 |
5 |
6 | 调试
7 |
8 | 生成日志
9 |
10 | 设置
11 |
12 | 隐藏图标
13 |
14 | 仅跳转
15 |
16 | 忽略系统应用
17 |
18 | 下载器
19 |
20 | 选择下载器
21 |
22 |
23 | 过滤
24 |
25 | 链接
26 |
27 | 应用
28 |
29 | 你确定要从名单中移除 \"%s"?
30 |
31 | 加入链结
32 |
33 | 加入应用
34 |
35 | 已切换下载器为 %s
36 |
37 | 已移除 %s
38 |
39 | 过滤清单为空
40 |
41 | 输入为空, 已取消操作
42 |
43 | 已加入 %s
44 |
45 | 已存在于清单中
46 |
47 | 未侦测到任何支援的下载器
48 |
49 | 新增
50 |
51 | 正則表示式
52 | 关于
53 | 仅跳转
54 | 搜索
55 | 链接
56 | 应用
57 |
58 | 首次運行
59 |
60 | 这是你第一次打开这个应用程序,这个应用程序是用来重定向系统下载管理器的下载到ADM或LoaderDroid。可以在Xposed Repo获得帮助/解释。
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 | #F26522
3 | #1a1a1a
4 | #222
5 | #333
6 | #EEE
7 | #555
8 | #FFF
9 | #9E9E9E
10 | #80cbc4
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Download Redirection
3 |
4 | Debug
5 | Logging
6 | Experiment
7 |
8 | Preferences
9 | Hide app from launcher
10 | Enable WhiteList
11 | Ignore System App
12 | Not Specify Downloader
13 | Change Downloader
14 | Select Downloader
15 |
16 |
17 | Are you sure you want to remove \"%s\" from the list?
18 |
19 | Filter
20 | Link
21 | App
22 |
23 | Added Link
24 | Added App
25 |
26 | Add Link
27 | Add App
28 | Enable WhiteList
29 |
30 | Changed Downloader to %s
31 | Removed %s
32 | Filter list is empty
33 | Field is empty, Cancelled
34 | Added %s
35 | Already existed in filter
36 | Does Not Detected Any Supported Downloader
37 |
38 | Add
39 |
40 | Regular Expression
41 | About
42 | Search
43 |
44 | First Run
45 | It is the first time you use this application, which is use for redirect the download of system download manager to ADM or LoaderDroid. Check discription on Xposed Repo for help/explain.
46 |
47 | UVhWMGFHOXlPaUJ0WVc1b2IyNW5NakV4TWc9PXxSMmwwYUhWaU9pQm9kSFJ3Y3pvdkwyZHBkR2gxWWk1amIyMHZiV0Z1YUc5dVp6SXhNVEk9fFJXMWhhV3c2SUcxaGJtaHZibWN5TVRFeVFHZHRZV2xzTG1OdmJRPT0=
48 |
49 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.1.2'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | ext.kotlin_version = '1.2.31'
18 | ext.anko_version = '0.10.4'
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8
2 | # org.gradle.parallel=true
3 | org.gradle.daemon=true
4 | kotlin.incremental=true
5 | android.injected.build.model.only.versioned=3
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paletteOvO/DownloadRedirect/322ddc1486f0d2f6a6dd6a29f9fe710c4884af0d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------