├── .gitignore ├── LICENSE ├── README.md ├── ScreenRecorder └── 2020-1-17.gif ├── app ├── .gitignore ├── build.gradle ├── comictools.jks ├── proguard-rules.pro ├── release │ ├── ComicTools-1.0.1.apk │ ├── ComicTools-1.0.2.apk │ ├── README.md │ └── output.json └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xyoye │ │ └── comictools │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xyoye │ │ │ └── comictools │ │ │ ├── IApplication.kt │ │ │ ├── MainActivity.kt │ │ │ ├── ProgressButton.kt │ │ │ ├── bean │ │ │ ├── ComicBean.kt │ │ │ ├── ComicNetworkInfo.kt │ │ │ └── IndexBean.kt │ │ │ ├── file │ │ │ ├── FileManagerBean.kt │ │ │ └── FileManagerDialog.kt │ │ │ └── utils │ │ │ ├── ComicFileUtils.kt │ │ │ ├── ComicInfoUtils.kt │ │ │ ├── IndexUtils.kt │ │ │ ├── NetworkCallback.kt │ │ │ ├── NetworkUtils.kt │ │ │ └── Utils.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── background_button_gray.xml │ │ ├── background_button_theme.xml │ │ ├── background_line.xml │ │ ├── ic_chevron_left_dark.xml │ │ ├── ic_folder_dark.xml │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── dialog_file_manager.xml │ │ └── item_file_manager.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ └── ic_next_act.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── network_security_config.xml │ └── test │ └── java │ └── com │ └── xyoye │ └── comictools │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | /.idea/caches 6 | /.idea/libraries 7 | /.idea/modules.xml 8 | /.idea/workspace.xml 9 | /.idea/navEditor.xml 10 | /.idea/assetWizardSettings.xml 11 | .DS_Store 12 | /build 13 | /captures 14 | .externalNativeBuild 15 | .cxx 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ComicTools # 2 | 将BiliBili漫画缓存文件转换成可直接观看的webp文件 3 | 4 | ## 新版本说明 ## 5 | 6 | 实测3.8.0版本,BiliBili漫画缓存目录已迁移至"/data/data/com.bilibili.comic/files/down",改目录为APP私有目录,无法直接访问文件夹。且图片文件已不再加密(直接更改文件格式即可),因此此项目目前可视为一个BiliBili漫画文件名查询更改工具。 7 | 8 | 3.8.0版本后使用说明,**使用有root权限的手机或模拟器**,将BiliBili漫画缓存目录(/data/data/com.bilibili.comic/files/down)下文件复制到下载目录(/storage/emulated/0/Download),再使用APP进行转换 9 | 10 | 11 | *1. 必须复制到Download目录下,否则无法网络查询漫画名* 12 | 13 | *2. 3.8.0为实测版本,具体在哪个版本修改了缓存路径未知* 14 | 15 | ## 下载 ## 16 | [前往安装包下载页面](https://github.com/xyoye/ComicTools/tree/master/app/release) 17 | 18 | ## 使用 ## 19 | 选择源目录,存在BiliBili漫画缓存目录将自动打开,选中需要转换的目录 20 | 21 | APP将联网自动识别漫画名及其它信息 22 | 23 | 输出路径默认为BiliBili漫画缓存目录,待信息确认完成,可点击“开始转换” 24 | 25 | ## 实现 ## 26 | 漫画名通过漫画ID即文件夹名,联网获取 27 | 28 | 章节名在联网获取到的信息中 29 | 30 | 页顺序根据章节目录下“index.dat”,解密获取 31 | 32 | ## 录屏 ## 33 |
34 | 35 |
36 | -------------------------------------------------------------------------------- /ScreenRecorder/2020-1-17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/ScreenRecorder/2020-1-17.gif -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 28 9 | buildToolsVersion "28.0.3" 10 | defaultConfig { 11 | applicationId "com.xyoye.comictools" 12 | minSdkVersion 21 13 | targetSdkVersion 28 14 | versionCode 2 15 | versionName "1.0.1" 16 | testInstrumentationRunner "androidx.ComicNetworkInfo.runner.AndroidJUnitRunner" 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 29 | implementation 'androidx.appcompat:appcompat:1.1.0' 30 | implementation 'androidx.core:core-ktx:1.1.0' 31 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 32 | implementation 'androidx.cardview:cardview:1.0.0' 33 | implementation 'androidx.recyclerview:recyclerview:1.1.0' 34 | testImplementation 'junit:junit:4.12' 35 | 36 | implementation 'com.google.code.gson:gson:2.8.5' 37 | implementation 'com.blankj:utilcode:1.23.7' 38 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.46' 39 | } 40 | -------------------------------------------------------------------------------- /app/comictools.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/comictools.jks -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/release/ComicTools-1.0.1.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/release/ComicTools-1.0.1.apk -------------------------------------------------------------------------------- /app/release/ComicTools-1.0.2.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/release/ComicTools-1.0.2.apk -------------------------------------------------------------------------------- /app/release/README.md: -------------------------------------------------------------------------------- 1 | ## 版本说明 ## 2 | 3 | 旧版本:3.8.0之前,新版本:3.8.0及之后版本 4 | 5 | *3.8.0是实测版本,具体是在哪个版本变更不确定* 6 | 7 | ### 1.0.1 ### 8 | 适用于旧版本,BiliBili漫画缓存目录为"/storage/emulated/0/data/bilibili/comic/down",可直接访问文件夹,选中文件夹并转换图片 9 | 10 | ### 1.0.2 ### 11 | 适用于新版本,BiliBili漫画缓存目录为"/data/data/com.bilibili.comic/files/down",无法访问文件夹,需通过**root设备**将目录下漫画复制到"/storage/emulated/0/Download"目录后再进行转换 12 | -------------------------------------------------------------------------------- /app/release/output.json: -------------------------------------------------------------------------------- 1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":2,"versionName":"1.0.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xyoye/comictools/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented ComicNetworkInfo, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under ComicNetworkInfo. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.xyoye.comictools", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/IApplication.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools 2 | 3 | import android.app.Application 4 | import com.blankj.utilcode.util.Utils 5 | 6 | /** 7 | * Created by xyoye on 2020/1/14. 8 | */ 9 | 10 | class IApplication : Application() { 11 | 12 | override fun onCreate() { 13 | super.onCreate() 14 | Utils.init(this) 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools 2 | 3 | import android.Manifest 4 | import android.annotation.SuppressLint 5 | import android.content.ClipData 6 | import android.content.ClipboardManager 7 | import android.content.Context 8 | import android.os.Bundle 9 | import android.os.Handler 10 | import android.os.Message 11 | import androidx.appcompat.app.AppCompatActivity 12 | import androidx.core.content.ContextCompat 13 | import com.blankj.utilcode.util.FileUtils 14 | import com.blankj.utilcode.util.PermissionUtils 15 | import com.blankj.utilcode.util.ToastUtils 16 | import com.xyoye.comictools.bean.ComicBean 17 | import com.xyoye.comictools.file.FileManagerDialog 18 | import com.xyoye.comictools.utils.ComicFileUtils 19 | import com.xyoye.comictools.utils.ComicInfoUtils 20 | import kotlinx.android.synthetic.main.activity_main.* 21 | import java.io.File 22 | 23 | class MainActivity : AppCompatActivity() { 24 | companion object { 25 | const val CODE_PREPARED_CONVERT = 1001 26 | const val CODE_ON_CONVERTING = 1002 27 | const val CODE_AFTER_CONVERTED = 1003 28 | } 29 | 30 | private var mComicBean: ComicBean? = null 31 | private var mOutputPath: String? = null 32 | 33 | @SuppressLint("SetTextI18n") 34 | private var handler = Handler { 35 | when (it.what) { 36 | CODE_PREPARED_CONVERT -> { 37 | //show comic name 38 | comic_name_tv.text = mComicBean!!.comicName 39 | //show chapter count 40 | chapter_count_tv.text = "共" + mComicBean!!.chapterList!!.size.toString() + "话" 41 | 42 | //show total page count 43 | var fileCount = 0 44 | for (chapter in mComicBean!!.chapterList!!) { 45 | fileCount += chapter.episodeList!!.size 46 | } 47 | file_count_tv.text = "共" + fileCount.toString() + "页" 48 | 49 | //default output path is BiliBili comic cache path 50 | mOutputPath = FileManagerDialog.COMIC_CACHE_PATH 51 | output_path_tv.text = mOutputPath 52 | 53 | 54 | //must page count > 0 can do convert 55 | if (fileCount > 0) { 56 | convert_bt.progress(1f) 57 | convert_bt.isClickable = true 58 | convert_bt.background = ContextCompat.getDrawable( 59 | this@MainActivity, 60 | R.drawable.background_button_theme 61 | ) 62 | } else { 63 | mComicBean = null 64 | } 65 | } 66 | CODE_ON_CONVERTING -> { 67 | ToastUtils.showShort("转换完成") 68 | convert_bt.setLock(false) 69 | } 70 | CODE_AFTER_CONVERTED -> { 71 | //update convert duration 72 | convert_bt.progress(it.obj as Float) 73 | } 74 | } 75 | false 76 | } 77 | 78 | override fun onCreate(savedInstanceState: Bundle?) { 79 | super.onCreate(savedInstanceState) 80 | setContentView(R.layout.activity_main) 81 | 82 | checkPermission() 83 | 84 | //select input comic folder 85 | select_origin_path_tv.setOnClickListener { 86 | FileManagerDialog(this, object : FileManagerDialog.FileManagerCallback { 87 | override fun onSelected(resultPath: String) { 88 | //can't click button before conversion prepared 89 | origin_path_tv.text = resultPath 90 | convert_bt.isClickable = false 91 | convert_bt.background = ContextCompat.getDrawable( 92 | this@MainActivity, 93 | R.drawable.background_button_gray 94 | ) 95 | 96 | Thread(Runnable { 97 | mComicBean = ComicInfoUtils.getComicData(resultPath) 98 | if (mComicBean != null) { 99 | handler.sendEmptyMessage(CODE_PREPARED_CONVERT) 100 | } 101 | }).start() 102 | } 103 | }).show() 104 | } 105 | 106 | //select output folder 107 | select_output_path_tv.setOnClickListener { 108 | FileManagerDialog(this, object : FileManagerDialog.FileManagerCallback { 109 | override fun onSelected(resultPath: String) { 110 | mOutputPath = resultPath 111 | output_path_tv.text = mOutputPath 112 | } 113 | }).show() 114 | } 115 | 116 | //copy output path 117 | output_path_tv.setOnClickListener { 118 | val outputPath = output_path_tv.text 119 | if (!outputPath.isNullOrBlank()) { 120 | val clipboardManager = 121 | getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager 122 | val clipData = ClipData.newPlainText("OutPut", outputPath) 123 | clipboardManager.primaryClip = clipData 124 | ToastUtils.showShort("输出路径已复制") 125 | } 126 | } 127 | 128 | //do convert 129 | convert_bt.setOnClickListener { 130 | if (convert_bt.isLocked()) { 131 | ToastUtils.showShort("转换进行中,请稍后") 132 | return@setOnClickListener 133 | } 134 | if (mComicBean == null) { 135 | ToastUtils.showShort("任务为空,无法进行转换") 136 | return@setOnClickListener 137 | } 138 | convert_bt.setLock(true) 139 | Thread(Runnable { 140 | val count = doConvert() 141 | val msg = Message() 142 | msg.what = CODE_ON_CONVERTING 143 | msg.obj = count 144 | handler.sendMessage(msg) 145 | }).start() 146 | } 147 | } 148 | 149 | //检查权限 150 | @SuppressLint("WrongConstant") 151 | private fun checkPermission() { 152 | PermissionUtils.permission( 153 | Manifest.permission.READ_EXTERNAL_STORAGE, 154 | Manifest.permission.WRITE_EXTERNAL_STORAGE 155 | ).callback(object : PermissionUtils.SimpleCallback { 156 | override fun onGranted() { 157 | 158 | } 159 | 160 | override fun onDenied() { 161 | ToastUtils.showShort("获取文件管理权限失败,后续操作将无法进行") 162 | } 163 | }).request() 164 | } 165 | 166 | private fun doConvert(): Int { 167 | var convertCount = 0 168 | 169 | //check output folder 170 | val outputFolder = File(mOutputPath) 171 | if (!outputFolder.exists()) { 172 | outputFolder.mkdirs() 173 | } 174 | 175 | //comic folder name 176 | val comicFolderName = when { 177 | mComicBean!!.comicId == null -> "未知漫画" 178 | mComicBean!!.comicId == mComicBean!!.comicName -> mComicBean!!.comicId + "_new" 179 | else -> mComicBean!!.comicName 180 | } 181 | val comicFolder = File(outputFolder, comicFolderName) 182 | if (!comicFolder.exists()) 183 | comicFolder.mkdir() 184 | 185 | //calc total page count 186 | var totalCount = 0 187 | var durationCount = 0 188 | for (chapter in mComicBean!!.chapterList!!) { 189 | totalCount += chapter.episodeList!!.size 190 | } 191 | 192 | //ergodic comic bean 193 | for (chapter in mComicBean!!.chapterList!!) { 194 | //chapter folder 195 | val chapterName = 196 | if (chapter.chapterNum.isNullOrBlank()) chapter.chapterId else "第" + chapter.chapterNum + "话 " + chapter.chapterName 197 | val chapterFolder = File(comicFolder, chapterName) 198 | if (!chapterFolder.exists()) 199 | chapterFolder.mkdir() 200 | 201 | for (index in chapter.episodeList!!.indices) { 202 | //convert page file 203 | val episode = chapter.episodeList!![index] 204 | val outputPath = if (episode.episodeIndex == 0) { 205 | val fileName = FileUtils.getFileNameNoExtension(episode.episodePath) 206 | chapterFolder.absolutePath + "/" + FileUtils.getFileNameNoExtension(fileName) + ".webp" 207 | } else { 208 | chapterFolder.absolutePath + "/" + episode.episodeIndex + ".webp" 209 | } 210 | if (ComicFileUtils.convert(episode.episodePath!!, outputPath)) 211 | convertCount++ 212 | 213 | //update progress button 214 | val msg = Message() 215 | msg.what = CODE_AFTER_CONVERTED 216 | msg.obj = (++durationCount).toFloat() / totalCount.toFloat() 217 | handler.sendMessage(msg) 218 | } 219 | } 220 | 221 | return convertCount 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/ProgressButton.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools 2 | 3 | import android.content.Context 4 | import android.graphics.Canvas 5 | import android.util.AttributeSet 6 | import android.widget.Button 7 | import androidx.core.content.ContextCompat 8 | import com.blankj.utilcode.util.ConvertUtils 9 | 10 | /** 11 | * Created by xyoye on 2020/1/17. 12 | */ 13 | 14 | class ProgressButton : Button { 15 | private var progress: Float = 0f 16 | private var isLocked = false 17 | 18 | constructor(context: Context?) : super(context) 19 | 20 | constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) 21 | 22 | constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super( 23 | context, 24 | attrs, 25 | defStyleAttr 26 | ) 27 | 28 | override fun onDraw(canvas: Canvas?) { 29 | if (canvas != null) { 30 | val leftX2 = when (progress) { 31 | 1f -> measuredWidth 32 | 0f -> 0 33 | else -> (measuredWidth * progress).toInt() 34 | } 35 | 36 | val extraPX = ConvertUtils.dp2px(4f) 37 | val rightX1 = 38 | if (measuredWidth - leftX2 < extraPX) 0 else leftX2 - extraPX 39 | 40 | //right 41 | val drawableRight = 42 | ContextCompat.getDrawable(context, R.drawable.background_button_gray) 43 | drawableRight?.setBounds(rightX1, 0, measuredWidth, measuredHeight) 44 | drawableRight?.draw(canvas) 45 | 46 | //left 47 | val drawableLeft = background 48 | drawableLeft?.setBounds(0, 0, leftX2, measuredHeight) 49 | drawableLeft?.draw(canvas) 50 | } 51 | super.onDraw(canvas) 52 | } 53 | 54 | public fun progress(progress: Float) { 55 | this@ProgressButton.progress = progress 56 | postInvalidate() 57 | } 58 | 59 | public fun isLocked(): Boolean{ 60 | synchronized(isLocked){ 61 | return isLocked 62 | } 63 | } 64 | 65 | public fun setLock(lock: Boolean){ 66 | synchronized(isLocked){ 67 | isLocked = lock 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/bean/ComicBean.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.bean 2 | 3 | /** 4 | * Created by xyoye on 2020/1/16. 5 | */ 6 | 7 | class ComicBean { 8 | var comicId: String? = null 9 | var comicName: String? = null 10 | var chapterList: List? = null 11 | 12 | class ChapterBean { 13 | var chapterId: String? = null 14 | var chapterName: String? = null 15 | var chapterNum: String? = null 16 | var chapterIndexPath: String? = null 17 | var episodeList: List? = null 18 | 19 | class EpisodeBean { 20 | var episodePath: String? = null 21 | var episodeIndex: Int = 0 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/bean/ComicNetworkInfo.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.bean 2 | 3 | /** 4 | * Created by xyoye on 2020/1/16. 5 | */ 6 | 7 | class ComicNetworkInfo { 8 | /** 9 | * code : 0 10 | * data : {"id":25756,"title":"五等分的新娘","ep_list":[{"id":354234,"short_title":"福利","title":"《五等分的新娘》应援福利"}]} 11 | */ 12 | 13 | var code: Int = 0 14 | var data: DataBean? = null 15 | 16 | class DataBean { 17 | /** 18 | * id : 25756 19 | * title : 五等分的新娘 20 | * ep_list : [{"id":354234,"short_title":"福利","title":"《五等分的新娘》应援福利"}] 21 | */ 22 | 23 | var id: Int = 0 24 | var title: String? = null 25 | var ep_list: ArrayList? = null 26 | 27 | class EpListBean { 28 | /** 29 | * id : 354234 30 | * short_title : 福利 31 | * title : 《五等分的新娘》应援福利 32 | */ 33 | 34 | var id: Int = 0 35 | var short_title: String? = null 36 | var title: String? = null 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/bean/IndexBean.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.bean 2 | 3 | import com.blankj.utilcode.util.FileUtils 4 | 5 | /** 6 | * Created by xyoye on 2020/1/15. 7 | */ 8 | 9 | class IndexBean { 10 | var pics: List? = null 11 | var indexList: ArrayList = ArrayList() 12 | 13 | public fun indexOf(episodeId: String): Int { 14 | if (pics == null || pics!!.isEmpty()) 15 | return 0 16 | if (indexList.size < 1){ 17 | indexList = ArrayList() 18 | for (pic in pics!!) { 19 | indexList.add(FileUtils.getFileNameNoExtension(pic)) 20 | } 21 | } 22 | return indexList.indexOf(episodeId) + 1 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/file/FileManagerBean.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.file 2 | 3 | import java.io.File 4 | import java.io.Serializable 5 | 6 | /** 7 | * Created by xyoye on 2018/7/2. 8 | */ 9 | 10 | class FileManagerBean(var file: File, var name: String, var isParent: Boolean) : Serializable 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/file/FileManagerDialog.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.file 2 | 3 | import android.app.Dialog 4 | import android.content.Context 5 | import android.os.Bundle 6 | import android.os.Environment 7 | import androidx.annotation.LayoutRes 8 | import androidx.annotation.Nullable 9 | import androidx.core.content.ContextCompat 10 | import androidx.recyclerview.widget.LinearLayoutManager 11 | import com.chad.library.adapter.base.BaseQuickAdapter 12 | import com.chad.library.adapter.base.BaseViewHolder 13 | import com.xyoye.comictools.R 14 | import kotlinx.android.synthetic.main.dialog_file_manager.* 15 | import java.io.File 16 | import java.text.Collator 17 | import java.util.* 18 | import kotlin.collections.ArrayList 19 | 20 | /** 21 | * Created by xyoye on 2020/1/14. 22 | */ 23 | 24 | class FileManagerDialog( 25 | mContext: Context, 26 | private val callback: FileManagerCallback 27 | ) : Dialog(mContext, R.style.Dialog) { 28 | companion object { 29 | public var COMIC_CACHE_PATH = 30 | Environment.getExternalStorageDirectory().absolutePath + "/Download" 31 | } 32 | 33 | private val fileList = ArrayList() 34 | private var fileAdapter: FileAdapter? = null 35 | private var rootPath = Environment.getExternalStorageDirectory().absolutePath 36 | 37 | override fun onCreate(savedInstanceState: Bundle?) { 38 | super.onCreate(savedInstanceState) 39 | setContentView(R.layout.dialog_file_manager) 40 | 41 | title_tv.text = "请选择文件夹" 42 | 43 | val comicCacheFile = File(COMIC_CACHE_PATH) 44 | val comicCachePath = if (comicCacheFile.exists() && comicCacheFile.isDirectory) 45 | comicCacheFile.absolutePath 46 | else 47 | rootPath 48 | 49 | default_tv.setOnClickListener { listFolder(File(comicCachePath)) } 50 | 51 | cancel_tv.setOnClickListener { cancel() } 52 | 53 | confirm_tv.setOnClickListener { 54 | callback.onSelected(path_tv.text.toString()) 55 | dismiss() 56 | } 57 | 58 | fileAdapter = FileAdapter(R.layout.item_file_manager, fileList) 59 | fileAdapter?.setOnItemChildClickListener { _, _, position -> 60 | if (fileList[position].isParent) { 61 | val parentFile = fileList[position].file.parentFile 62 | if (parentFile != null && parentFile.exists()) 63 | listFolder(parentFile) 64 | } else { 65 | listFolder(fileList[position].file) 66 | } 67 | } 68 | 69 | file_rv.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) 70 | file_rv.adapter = fileAdapter 71 | 72 | listFolder(File(comicCachePath)) 73 | } 74 | 75 | private fun listFolder(parentFile: File) { 76 | path_tv.text = parentFile.absolutePath 77 | default_tv.setTextColor( 78 | ContextCompat.getColor( 79 | context, 80 | if (parentFile.absolutePath == COMIC_CACHE_PATH) R.color.text_gray else R.color.text_black 81 | ) 82 | ) 83 | 84 | val childFileList = ArrayList() 85 | val childFiles = parentFile.listFiles() 86 | if (childFiles != null){ 87 | for (file: File in parentFile.listFiles()!!) { 88 | if (file.isDirectory && !file.name.startsWith(".")) { 89 | childFileList.add( 90 | FileManagerBean( 91 | file, 92 | file.name, 93 | false 94 | ) 95 | ) 96 | } 97 | } 98 | } 99 | 100 | childFileList.sortWith(Comparator { o1, o2 -> 101 | Collator.getInstance(Locale.CHINESE).compare(o1.name, o2.name) 102 | }) 103 | 104 | if (rootPath != parentFile.absolutePath) 105 | childFileList.add( 106 | 0, 107 | FileManagerBean(parentFile, "..", true) 108 | ) 109 | 110 | fileList.clear() 111 | fileList.addAll(childFileList) 112 | fileAdapter?.notifyDataSetChanged() 113 | } 114 | 115 | class FileAdapter(@LayoutRes layoutResId: Int, @Nullable data: List) : 116 | BaseQuickAdapter(layoutResId, data) { 117 | 118 | override fun convert(helper: BaseViewHolder?, item: FileManagerBean?) { 119 | helper!!.addOnClickListener(R.id.item_layout) 120 | .setText(R.id.file_name_tv, item!!.name) 121 | .setImageResource( 122 | R.id.file_type_iv, 123 | if (item.isParent) 124 | R.drawable.ic_chevron_left_dark 125 | else 126 | R.drawable.ic_folder_dark 127 | ) 128 | } 129 | 130 | } 131 | 132 | interface FileManagerCallback { 133 | fun onSelected(resultPath: String) 134 | } 135 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/utils/ComicFileUtils.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.utils 2 | 3 | import java.io.File 4 | import java.io.FileInputStream 5 | import java.io.FileOutputStream 6 | import java.io.IOException 7 | 8 | /** 9 | * Created by xyoye on 2020/1/17. 10 | */ 11 | 12 | object ComicFileUtils { 13 | 14 | /** 15 | * convert encrypt file to normal webp file 16 | */ 17 | fun convert(inputPath: String, outputPath: String): Boolean { 18 | var fileInputStream: FileInputStream? = null 19 | var fileOutputStream: FileOutputStream? = null 20 | 21 | try { 22 | val outputFile = File(outputPath) 23 | val inputFile = File(inputPath) 24 | 25 | if (outputFile.exists()) 26 | outputFile.delete() 27 | outputFile.createNewFile() 28 | 29 | fileInputStream = FileInputStream(inputFile) 30 | val byteArray = ByteArray(fileInputStream.available()) 31 | fileInputStream.read(byteArray) 32 | 33 | fileOutputStream = FileOutputStream(outputFile) 34 | fileOutputStream.write(byteArray) 35 | fileOutputStream.flush() 36 | 37 | return true 38 | } catch (e: IOException) { 39 | e.printStackTrace() 40 | } finally { 41 | fileInputStream?.let { 42 | try { 43 | fileInputStream.close() 44 | } catch (ignore: IOException) { 45 | 46 | } 47 | } 48 | fileOutputStream?.let { 49 | try { 50 | fileOutputStream.close() 51 | } catch (ignore: IOException) { 52 | 53 | } 54 | } 55 | } 56 | return false 57 | } 58 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/utils/ComicInfoUtils.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.utils 2 | 3 | import com.blankj.utilcode.util.FileUtils 4 | import com.blankj.utilcode.util.ToastUtils 5 | import com.xyoye.comictools.bean.ComicBean 6 | import com.xyoye.comictools.bean.ComicNetworkInfo 7 | import com.xyoye.comictools.file.FileManagerDialog 8 | import java.io.File 9 | 10 | /** 11 | * Created by xyoye on 2020/1/17. 12 | */ 13 | 14 | object ComicInfoUtils { 15 | 16 | /** 17 | * get comic info by BiliBili cache folder or other cache folder 18 | */ 19 | fun getComicData(folderPath: String): ComicBean? { 20 | val folderFile = File(folderPath) 21 | if (!folderFile.exists() || !folderFile.isDirectory) { 22 | ToastUtils.showLong("文件夹路径错误") 23 | return null 24 | } 25 | 26 | if (folderFile.listFiles().isNullOrEmpty()) { 27 | ToastUtils.showLong("文件夹为空") 28 | return null 29 | } 30 | 31 | return if (checkComicFolder(folderPath)) 32 | getBiliBiliComicInfo(folderPath) 33 | else 34 | getOtherComicInfo(folderPath) 35 | } 36 | 37 | /** 38 | * is BiliBili cache folder 39 | * 40 | * the right rule : BiliBili_Cache_Folder/123(the comic id, must be a number) 41 | */ 42 | private fun checkComicFolder(folderPath: String): Boolean { 43 | if (!folderPath.startsWith(FileManagerDialog.COMIC_CACHE_PATH)) 44 | return false 45 | var comicId = folderPath.substring(FileManagerDialog.COMIC_CACHE_PATH.length) 46 | if (comicId.startsWith("/")) 47 | comicId = comicId.substring(1, comicId.length) 48 | return Utils.isNum(comicId) 49 | } 50 | 51 | private fun getBiliBiliComicInfo(folderPath: String): ComicBean { 52 | //ergodic comic folder 53 | val comicFile = File(folderPath) 54 | val comicBean = ComicBean() 55 | comicBean.comicId = comicFile.name 56 | val chapterList = ArrayList() 57 | for (chapterFile in comicFile.listFiles()) { 58 | if (chapterFile.isDirectory && Utils.isNum(chapterFile.name)) { 59 | val chapterBean = ComicBean.ChapterBean() 60 | chapterBean.chapterId = chapterFile.name 61 | val episodeList = ArrayList() 62 | for (episodeFile in chapterFile.listFiles()) { 63 | if (episodeFile.absolutePath.endsWith(".jpg.view") 64 | || episodeFile.absolutePath.endsWith(".png.view")) { 65 | val episodeBean = ComicBean.ChapterBean.EpisodeBean() 66 | episodeBean.episodePath = episodeFile.absolutePath 67 | episodeList.add(episodeBean) 68 | } else if (episodeFile.name == "index.dat") { 69 | chapterBean.chapterIndexPath = episodeFile.absolutePath 70 | } 71 | } 72 | chapterBean.episodeList = episodeList 73 | chapterList.add(chapterBean) 74 | } 75 | } 76 | comicBean.chapterList = chapterList 77 | 78 | //get more info by network 79 | fillInfoByNetWork(comicBean) 80 | 81 | //get more info by index.dat file 82 | fillInfoByIndexFile(comicBean) 83 | 84 | return comicBean 85 | } 86 | 87 | private fun fillInfoByNetWork(comicBean: ComicBean) { 88 | //get comic info by comic id 89 | NetworkUtils.getComicInfo(comicBean.comicId!!, object : NetworkCallback { 90 | override fun onSuccess(comicInfo: ComicNetworkInfo) { 91 | comicBean.comicName = comicInfo.data?.title 92 | for (chapter in comicBean.chapterList!!) { 93 | val infoIterator = comicInfo.data?.ep_list!!.iterator() 94 | BreakTag@ while (infoIterator.hasNext()) { 95 | val epBean = infoIterator.next() 96 | if (epBean.id.toString() == chapter.chapterId) { 97 | chapter.chapterName = epBean.title 98 | chapter.chapterNum = epBean.short_title 99 | infoIterator.remove() 100 | break@BreakTag 101 | } 102 | } 103 | } 104 | } 105 | 106 | override fun onFailed() { 107 | comicBean.comicName = comicBean.comicId 108 | for (chapter in comicBean.chapterList!!) { 109 | chapter.chapterNum = chapter.chapterId 110 | } 111 | } 112 | }) 113 | } 114 | 115 | private fun fillInfoByIndexFile(comicBean: ComicBean) { 116 | for (chapter in comicBean.chapterList!!) { 117 | if (!chapter.chapterIndexPath.isNullOrBlank()) { 118 | val indexBean = IndexUtils.getIndexInfo( 119 | chapter.chapterIndexPath!!, 120 | comicBean.comicId!!, 121 | chapter.chapterId!! 122 | ) 123 | for (episode in chapter.episodeList!!) { 124 | val jpgPath = FileUtils.getFileNameNoExtension(episode.episodePath) 125 | episode.episodeIndex = 126 | indexBean!!.indexOf(FileUtils.getFileNameNoExtension(jpgPath)) 127 | } 128 | } 129 | } 130 | } 131 | 132 | /** 133 | * not BiliBili cache folder 134 | * 135 | * the right rule : xxx/xxx(the folder must contains .jpg.view file) 136 | */ 137 | private fun getOtherComicInfo(folderPath: String): ComicBean { 138 | val chapterFile = File(folderPath) 139 | val comicBean = ComicBean() 140 | val chapterBean = ComicBean.ChapterBean() 141 | val episodeList = ArrayList() 142 | 143 | for (episodeFile in chapterFile.listFiles()) { 144 | if (episodeFile.absolutePath.endsWith(".jpg.view") 145 | || episodeFile.absolutePath.endsWith(".png.view")) { 146 | val episodeBean = ComicBean.ChapterBean.EpisodeBean() 147 | episodeBean.episodePath = episodeFile.absolutePath 148 | episodeList.add(episodeBean) 149 | } 150 | } 151 | chapterBean.chapterId = chapterFile.name 152 | chapterBean.episodeList = episodeList 153 | val chapterList = ArrayList() 154 | chapterList.add(chapterBean) 155 | comicBean.chapterList = chapterList 156 | 157 | return comicBean 158 | } 159 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/utils/IndexUtils.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.utils 2 | 3 | import com.xyoye.comictools.bean.IndexBean 4 | import java.io.* 5 | import java.util.zip.ZipInputStream 6 | import kotlin.experimental.xor 7 | 8 | /** 9 | * Created by xyoye on 2020/1/15. 10 | */ 11 | 12 | object IndexUtils { 13 | 14 | /** 15 | * get page index info by index.dat file 16 | */ 17 | fun getIndexInfo( 18 | indexFilePath: String, 19 | comicId: String, 20 | chapterId: String 21 | ): IndexBean? { 22 | var fileInputStream: FileInputStream? = null 23 | var byteArrayInputStream: ByteArrayInputStream? = null 24 | var bufferedInputStream: BufferedInputStream? = null 25 | var zipInputStream: ZipInputStream? = null 26 | try { 27 | //获取index数据 28 | fileInputStream = FileInputStream(File(indexFilePath)) 29 | val indexData = ByteArray(fileInputStream.available() - 9) 30 | fileInputStream.skip(9) 31 | fileInputStream.read(indexData) 32 | 33 | //获取解密后数据 34 | val contentData = decryptData(getKeyData(comicId, chapterId), indexData) 35 | 36 | //提取json信息 37 | byteArrayInputStream = ByteArrayInputStream(contentData) 38 | bufferedInputStream = BufferedInputStream(byteArrayInputStream) 39 | zipInputStream = ZipInputStream(bufferedInputStream) 40 | var zipEntry = zipInputStream.nextEntry 41 | while (zipEntry != null) { 42 | if ("index.dat" == zipEntry.name) { 43 | val indexJson = getJsonData(zipInputStream) 44 | return Utils.fromJson(indexJson, IndexBean::class.java) 45 | } else { 46 | zipEntry = zipInputStream.nextEntry 47 | } 48 | } 49 | } catch (e: IOException) { 50 | e.printStackTrace() 51 | } finally { 52 | fileInputStream?.close() 53 | byteArrayInputStream?.close() 54 | bufferedInputStream?.close() 55 | zipInputStream?.close() 56 | } 57 | return null 58 | } 59 | 60 | private fun decryptData(keyData: ByteArray, indexData: ByteArray): ByteArray { 61 | val decryptData = ByteArray(indexData.size) 62 | for (i in indexData.indices) { 63 | decryptData[i] = indexData[i] xor keyData[i % 8] 64 | } 65 | return decryptData 66 | } 67 | 68 | private fun getKeyData(comicId: String, chapterId: String): ByteArray { 69 | val keyData = ByteArray(8) 70 | val comicIdInt = comicId.toInt() 71 | val chapterIdInt = chapterId.toInt() 72 | 73 | keyData[0] = chapterIdInt.toByte() 74 | keyData[1] = chapterIdInt.shr(8).toByte() 75 | keyData[2] = chapterIdInt.shr(16).toByte() 76 | keyData[3] = chapterIdInt.shr(24).toByte() 77 | keyData[4] = comicIdInt.toByte() 78 | keyData[5] = comicIdInt.shr(8).toByte() 79 | keyData[6] = comicIdInt.shr(16).toByte() 80 | keyData[7] = comicIdInt.shr(24).toByte() 81 | 82 | for (i in keyData.indices) { 83 | keyData[i] = (keyData[i] % 256).toByte() 84 | } 85 | 86 | return keyData 87 | } 88 | 89 | private fun getJsonData(zipInputStream: ZipInputStream): String? { 90 | val byteArrayOutputStream = ByteArrayOutputStream() 91 | val dataArray = ByteArray(1024) 92 | 93 | while (true) { 94 | try { 95 | val read = zipInputStream.read(dataArray) 96 | if (read != -1) { 97 | byteArrayOutputStream.write(dataArray, 0, read) 98 | } else { 99 | val jsonData = byteArrayOutputStream.toByteArray() 100 | try { 101 | byteArrayOutputStream.close() 102 | } catch (ignore: IOException) { 103 | } 104 | return String(jsonData) 105 | } 106 | } catch (e: IOException) { 107 | e.printStackTrace() 108 | return null 109 | } 110 | 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/utils/NetworkCallback.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.utils 2 | 3 | import com.xyoye.comictools.bean.ComicNetworkInfo 4 | 5 | /** 6 | * Created by xyoye on 2020/1/16. 7 | */ 8 | 9 | interface NetworkCallback { 10 | fun onSuccess(comicInfo: ComicNetworkInfo) 11 | 12 | fun onFailed() 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/utils/NetworkUtils.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.utils 2 | 3 | import com.xyoye.comictools.bean.ComicNetworkInfo 4 | import java.io.BufferedReader 5 | import java.io.DataOutputStream 6 | import java.io.InputStreamReader 7 | import java.lang.Exception 8 | import java.lang.StringBuilder 9 | import java.net.HttpURLConnection 10 | import java.net.URL 11 | import java.net.URLEncoder 12 | 13 | /** 14 | * Created by xyoye on 2020/1/16. 15 | */ 16 | 17 | object NetworkUtils { 18 | 19 | fun getComicInfo(comicId: String, callback: NetworkCallback) { 20 | var connection: HttpURLConnection? = null 21 | var reader: BufferedReader? = null 22 | 23 | try { 24 | val url = URL("https://manga.bilibili.com/twirp/comic.v2.Comic/ComicDetail") 25 | connection = url.openConnection() as HttpURLConnection 26 | connection.requestMethod = "POST" 27 | connection.connectTimeout = 3000 28 | connection.readTimeout = 3000 29 | 30 | connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded") 31 | connection.setRequestProperty("user-agent", "Mozilla/5.0 BiliComic/1.9.0") 32 | connection.setRequestProperty("Host", "manga.bilibili.com") 33 | connection.setRequestProperty("cache-control", "no-cache") 34 | 35 | connection.connect() 36 | val dataOutputStream = DataOutputStream(connection.outputStream) 37 | 38 | val params = "device=" + URLEncoder.encode( 39 | "android", "utf-8" 40 | ) + "&comic_id=" + URLEncoder.encode(comicId,"utf-8").toString() 41 | 42 | dataOutputStream.writeBytes(params) 43 | dataOutputStream.flush() 44 | dataOutputStream.close() 45 | 46 | if (connection.responseCode == 200) { 47 | val inputStream = connection.inputStream 48 | reader = BufferedReader(InputStreamReader(inputStream)) 49 | val responseText = reader.use(BufferedReader::readText) 50 | val response = StringBuilder(responseText) 51 | println(response.toString()) 52 | val comicInfo = 53 | Utils.fromJson(response.toString(), ComicNetworkInfo::class.java) 54 | if (comicInfo?.code == 0) { 55 | callback.onSuccess(comicInfo) 56 | } else { 57 | callback.onFailed() 58 | } 59 | } else { 60 | callback.onFailed() 61 | } 62 | } catch (e: Exception) { 63 | e.printStackTrace() 64 | callback.onFailed() 65 | } finally { 66 | reader?.let { 67 | try { 68 | it.close() 69 | } catch (ignore: Exception) { 70 | 71 | } 72 | } 73 | 74 | connection?.disconnect() 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/xyoye/comictools/utils/Utils.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools.utils 2 | 3 | import com.google.gson.Gson 4 | import java.util.regex.Pattern 5 | 6 | /** 7 | * Created by xyoye on 2020/1/15. 8 | */ 9 | 10 | object Utils { 11 | //字符串是否为数字 12 | fun isNum(str: String): Boolean { 13 | val pattern = Pattern.compile("^[\\d]*$") 14 | return pattern.matcher(str).matches() 15 | } 16 | 17 | fun fromJson(jsonStr: String?, clazz: Class): T? { 18 | if (jsonStr == null || jsonStr.isEmpty()) { 19 | return null 20 | } 21 | try { 22 | return Gson().fromJson(jsonStr, clazz) 23 | } catch (e: Exception) { 24 | e.printStackTrace() 25 | } 26 | 27 | return null 28 | } 29 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_button_gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_button_theme.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_chevron_left_dark.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_folder_dark.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 25 | 26 | 29 | 30 | 35 | 36 | 45 | 46 | 58 | 59 | 60 | 66 | 67 | 73 | 74 | 82 | 83 | 95 | 96 | 97 | 98 | 104 | 105 | 113 | 114 | 125 | 126 | 127 | 128 | 134 | 135 | 143 | 144 | 155 | 156 | 157 | 158 | 164 | 165 | 173 | 174 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 199 | 200 | 206 | 207 | 210 | 211 | 216 | 217 | 226 | 227 | 239 | 240 | 241 | 247 | 248 | 254 | 255 | 263 | 264 | 276 | 277 | 278 | 279 | 280 | 281 | 294 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_file_manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 29 | 30 | 36 | 37 | 46 | 47 | 48 | 54 | 55 | 60 | 61 | 62 | 63 | 68 | 69 | 79 | 80 | 86 | 87 | 95 | 96 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_file_manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_next_act.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-xhdpi/ic_next_act.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #2095f4 4 | #2095f4 5 | #2095f4 6 | 7 | #353535 8 | #ffffff 9 | #9b9b9b 10 | #2095f4 11 | 12 | #f3f3f3 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ComicTools 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 22 | 23 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/test/java/com/xyoye/comictools/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.xyoye.comictools 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit ComicNetworkInfo, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.3.50' 5 | repositories { 6 | google() 7 | jcenter() 8 | 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.5.1' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | maven { url 'https://jitpack.io' } 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyoye/ComicTools/873f2329b50a36dde216a0f4cd20e57d2058a5e7/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jan 14 09:19:11 CST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /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 | rootProject.name='ComicTools' 3 | --------------------------------------------------------------------------------