Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5436c65b76 | |||
| c590813a1a | |||
| 1cf36e1b41 | |||
| 5895a20af1 | |||
| fd5fd43b72 |
@@ -13,7 +13,6 @@ disabled_rules = no-wildcard-imports, no-unused-imports
|
|||||||
|
|
||||||
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
|
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
|
||||||
ij_continuation_indent_size = 4
|
ij_continuation_indent_size = 4
|
||||||
ij_xml_attribute_wrap = on_every_item
|
|
||||||
|
|
||||||
[{*.kt,*.kts}]
|
[{*.kt,*.kts}]
|
||||||
ij_kotlin_allow_trailing_comma_on_call_site = true
|
ij_kotlin_allow_trailing_comma_on_call_site = true
|
||||||
|
|||||||
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ko_fi: xtimms
|
||||||
|
custom: ["https://yoomoney.ru/to/410012543938752"]
|
||||||
4
.github/ISSUE_TEMPLATE/report_bug.yml
vendored
@@ -61,6 +61,4 @@ body:
|
|||||||
label: Acknowledgements
|
label: Acknowledgements
|
||||||
options:
|
options:
|
||||||
- label: I have searched the existing issues and this is a new ticket, **NOT** a duplicate or related to another open issue.
|
- label: I have searched the existing issues and this is a new ticket, **NOT** a duplicate or related to another open issue.
|
||||||
required: true
|
required: true
|
||||||
- label: If this is an issue with a parser, I should be opening an issue in the [parsers repository](https://github.com/KotatsuApp/kotatsu-parsers/issues/new/choose).
|
|
||||||
required: true
|
|
||||||
2
.gitignore
vendored
@@ -10,13 +10,11 @@
|
|||||||
/.idea/compiler.xml
|
/.idea/compiler.xml
|
||||||
/.idea/workspace.xml
|
/.idea/workspace.xml
|
||||||
/.idea/navEditor.xml
|
/.idea/navEditor.xml
|
||||||
/.idea/ktlint-plugin.xml
|
|
||||||
/.idea/assetWizardSettings.xml
|
/.idea/assetWizardSettings.xml
|
||||||
/.idea/kotlinScripting.xml
|
/.idea/kotlinScripting.xml
|
||||||
/.idea/kotlinc.xml
|
/.idea/kotlinc.xml
|
||||||
/.idea/deploymentTargetDropDown.xml
|
/.idea/deploymentTargetDropDown.xml
|
||||||
/.idea/androidTestResultsUserPreferences.xml
|
/.idea/androidTestResultsUserPreferences.xml
|
||||||
/.idea/deploymentTargetSelector.xml
|
|
||||||
/.idea/render.experimental.xml
|
/.idea/render.experimental.xml
|
||||||
/.idea/inspectionProfiles/
|
/.idea/inspectionProfiles/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
1
.idea/.gitignore
generated
vendored
@@ -1,4 +1,3 @@
|
|||||||
# Default ignored files
|
# Default ignored files
|
||||||
/shelf/
|
/shelf/
|
||||||
/workspace.xml
|
/workspace.xml
|
||||||
/migrations.xml
|
|
||||||
|
|||||||
2
.idea/gradle.xml
generated
@@ -5,6 +5,7 @@
|
|||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveExternalAnnotations" value="false" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
3
.weblate
@@ -1,3 +0,0 @@
|
|||||||
[weblate]
|
|
||||||
url = https://hosted.weblate.org/api/
|
|
||||||
translation = kotatsu/strings
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
## Kotatsu contribution guidelines
|
|
||||||
|
|
||||||
- If you want to fix bug or implement a new feature, that already mention in the [issues](https://github.com/KotatsuApp/Kotatsu/issues), please, assign this issue to you and/or comment about it.
|
|
||||||
- Whether you have to implement new feature, please, open an issue or discussion regarding it to ensure it will be accepted.
|
|
||||||
- Translations have to be managed using the [Weblate](https://hosted.weblate.org/engage/kotatsu/) platform.
|
|
||||||
- In case you want to add a new manga source, refer to the [parsers repository](https://github.com/KotatsuApp/kotatsu-parsers).
|
|
||||||
|
|
||||||
Refactoring or some dev-faces improvements are also might be accepted, however please stick to the following principles:
|
|
||||||
- Performance matters. In the case of choosing between source code beauty and performance, performance should be a priority.
|
|
||||||
- Please, do not modify readme and other information files (except for typos).
|
|
||||||
- Avoid adding new dependencies unless required. APK size is important.
|
|
||||||
15
README.md
@@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
Kotatsu is a free and open source manga reader for Android.
|
Kotatsu is a free and open source manga reader for Android.
|
||||||
|
|
||||||
   [](https://hosted.weblate.org/engage/kotatsu/) [](https://t.me/kotatsuapp) [](https://discord.gg/NNJ5RgVBC5)
|
   [](https://hosted.weblate.org/engage/kotatsu/) [](http://4pda.ru/forum/index.php?showtopic=697669) [](https://discord.gg/NNJ5RgVBC5)
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
|
|
||||||
- **Recommended:** Download and install APK from **[GitHub Releases](https://github.com/KotatsuApp/Kotatsu/releases/latest)**. Application has a built-in self-updating feature.
|
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
|
||||||
- Get it on **[F-Droid](https://f-droid.org/packages/org.koitharu.kotatsu)**. The F-Droid build may be a bit outdated and some fixes might be missing.
|
alt="Get it on F-Droid"
|
||||||
|
height="80">](https://f-droid.org/packages/org.koitharu.kotatsu)
|
||||||
|
|
||||||
|
Download APK directly from GitHub:
|
||||||
|
|
||||||
|
- **[Latest release](https://github.com/KotatsuApp/Kotatsu/releases/latest)**
|
||||||
|
|
||||||
### Main Features
|
### Main Features
|
||||||
|
|
||||||
@@ -39,10 +44,6 @@ Kotatsu is a free and open source manga reader for Android.
|
|||||||
Kotatsu is localized in a number of different languages, if you would like to help improve these or add new languages,
|
Kotatsu is localized in a number of different languages, if you would like to help improve these or add new languages,
|
||||||
please head over to the [Weblate project page](https://hosted.weblate.org/engage/kotatsu/)
|
please head over to the [Weblate project page](https://hosted.weblate.org/engage/kotatsu/)
|
||||||
|
|
||||||
### Contributing
|
|
||||||
|
|
||||||
See [CONTRIBUTING.md](./CONTRIBUTING.md) for the guidelines.
|
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
[](http://www.gnu.org/licenses/gpl-3.0.en.html)
|
[](http://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
|||||||
119
app/build.gradle
@@ -2,30 +2,28 @@ plugins {
|
|||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
id 'kotlin-android'
|
id 'kotlin-android'
|
||||||
id 'kotlin-kapt'
|
id 'kotlin-kapt'
|
||||||
id 'com.google.devtools.ksp'
|
|
||||||
id 'kotlin-parcelize'
|
id 'kotlin-parcelize'
|
||||||
id 'dagger.hilt.android.plugin'
|
id 'dagger.hilt.android.plugin'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk = 34
|
compileSdk = 33
|
||||||
buildToolsVersion = '34.0.0'
|
buildToolsVersion = '33.0.2'
|
||||||
namespace = 'org.koitharu.kotatsu'
|
namespace = 'org.koitharu.kotatsu'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'org.koitharu.kotatsu'
|
applicationId 'org.koitharu.kotatsu'
|
||||||
minSdk = 21
|
minSdkVersion 21
|
||||||
targetSdk = 34
|
targetSdkVersion 33
|
||||||
versionCode = 610
|
versionCode 525
|
||||||
versionName = '6.5.4'
|
versionName '4.4.9'
|
||||||
generatedDensities = []
|
generatedDensities = []
|
||||||
testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner'
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
ksp {
|
|
||||||
arg('room.generateKotlin', 'true')
|
kapt {
|
||||||
arg('room.schemaLocation', "$projectDir/schemas")
|
arguments {
|
||||||
}
|
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
||||||
androidResources {
|
}
|
||||||
generateLocaleConfig true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -33,6 +31,7 @@ android {
|
|||||||
applicationIdSuffix = '.debug'
|
applicationIdSuffix = '.debug'
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
|
multiDexEnabled false
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
shrinkResources true
|
shrinkResources true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
@@ -40,14 +39,11 @@ android {
|
|||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
buildConfig true
|
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
|
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
|
||||||
main.java.srcDirs += 'src/main/kotlin/'
|
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
coreLibraryDesugaringEnabled true
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
@@ -59,11 +55,12 @@ android {
|
|||||||
'-opt-in=kotlinx.coroutines.FlowPreview',
|
'-opt-in=kotlinx.coroutines.FlowPreview',
|
||||||
'-opt-in=kotlin.contracts.ExperimentalContracts',
|
'-opt-in=kotlin.contracts.ExperimentalContracts',
|
||||||
'-opt-in=coil.annotation.ExperimentalCoilApi',
|
'-opt-in=coil.annotation.ExperimentalCoilApi',
|
||||||
|
'-opt-in=com.google.android.material.badge.ExperimentalBadgeUtils',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
lint {
|
lint {
|
||||||
abortOnError true
|
abortOnError true
|
||||||
disable 'MissingTranslation', 'PrivateResource', 'NotifyDataSetChanged', 'SetJavaScriptEnabled'
|
disable 'MissingTranslation', 'PrivateResource', 'NotifyDataSetChanged'
|
||||||
}
|
}
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests.includeAndroidResources true
|
unitTests.includeAndroidResources true
|
||||||
@@ -82,79 +79,73 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
//noinspection GradleDependency
|
//noinspection GradleDependency
|
||||||
implementation('com.github.KotatsuApp:kotatsu-parsers:ea095084cc') {
|
implementation('com.github.KotatsuApp:kotatsu-parsers:1b6d1456f3') {
|
||||||
exclude group: 'org.json', module: 'json'
|
exclude group: 'org.json', module: 'json'
|
||||||
}
|
}
|
||||||
|
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.10'
|
||||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.22'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
|
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'androidx.core:core-ktx:1.12.0'
|
implementation 'androidx.core:core-ktx:1.9.0'
|
||||||
implementation 'androidx.activity:activity-ktx:1.8.2'
|
implementation 'androidx.activity:activity-ktx:1.6.1'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.6.2'
|
implementation 'androidx.fragment:fragment-ktx:1.5.5'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-service:2.6.2'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-process:2.6.2'
|
implementation 'androidx.lifecycle:lifecycle-service:2.5.1'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-process:2.5.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||||
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta02'
|
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
|
||||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||||
|
implementation 'androidx.work:work-runtime-ktx:2.8.0'
|
||||||
implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05'
|
implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05'
|
||||||
implementation 'com.google.android.material:material:1.11.0'
|
implementation 'com.google.android.material:material:1.8.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.2'
|
//noinspection LifecycleAnnotationProcessorWithJava8
|
||||||
|
kapt 'androidx.lifecycle:lifecycle-compiler:2.5.1'
|
||||||
|
|
||||||
implementation 'androidx.work:work-runtime:2.9.0'
|
implementation 'androidx.room:room-runtime:2.5.0'
|
||||||
//noinspection GradleDependency
|
implementation 'androidx.room:room-ktx:2.5.0'
|
||||||
implementation('com.google.guava:guava:32.0.1-android') {
|
kapt 'androidx.room:room-compiler:2.5.0'
|
||||||
exclude group: 'com.google.guava', module: 'failureaccess'
|
|
||||||
exclude group: 'org.checkerframework', module: 'checker-qual'
|
|
||||||
exclude group: 'com.google.j2objc', module: 'j2objc-annotations'
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation 'androidx.room:room-runtime:2.6.1'
|
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||||
implementation 'androidx.room:room-ktx:2.6.1'
|
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.3'
|
||||||
ksp 'androidx.room:room-compiler:2.6.1'
|
implementation 'com.squareup.okio:okio:3.3.0'
|
||||||
|
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
|
||||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
|
|
||||||
implementation 'com.squareup.okio:okio:3.7.0'
|
|
||||||
|
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.2'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.2'
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.2'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.2'
|
||||||
|
|
||||||
implementation 'com.google.dagger:hilt-android:2.50'
|
implementation 'com.google.dagger:hilt-android:2.45'
|
||||||
kapt 'com.google.dagger:hilt-compiler:2.50'
|
kapt 'com.google.dagger:hilt-compiler:2.45'
|
||||||
implementation 'androidx.hilt:hilt-work:1.1.0'
|
implementation 'androidx.hilt:hilt-work:1.0.0'
|
||||||
kapt 'androidx.hilt:hilt-compiler:1.1.0'
|
kapt 'androidx.hilt:hilt-compiler:1.0.0'
|
||||||
|
|
||||||
implementation 'io.coil-kt:coil-base:2.5.0'
|
implementation 'io.coil-kt:coil-base:2.2.2'
|
||||||
implementation 'io.coil-kt:coil-svg:2.5.0'
|
implementation 'io.coil-kt:coil-svg:2.2.2'
|
||||||
implementation 'com.github.KotatsuApp:subsampling-scale-image-view:02e6d6cfe9'
|
implementation 'com.github.KotatsuApp:subsampling-scale-image-view:1b19231b2f'
|
||||||
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
||||||
implementation 'io.noties.markwon:core:4.6.2'
|
implementation 'io.noties.markwon:core:4.6.2'
|
||||||
|
|
||||||
implementation 'ch.acra:acra-http:5.11.3'
|
implementation 'ch.acra:acra-http:5.9.7'
|
||||||
implementation 'ch.acra:acra-dialog:5.11.3'
|
implementation 'ch.acra:acra-dialog:5.9.7'
|
||||||
|
|
||||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.json:json:20231013'
|
testImplementation 'org.json:json:20230227'
|
||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'
|
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
||||||
|
|
||||||
androidTestImplementation 'androidx.test:runner:1.5.2'
|
androidTestImplementation 'androidx.test:runner:1.5.2'
|
||||||
androidTestImplementation 'androidx.test:rules:1.5.0'
|
androidTestImplementation 'androidx.test:rules:1.5.0'
|
||||||
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
|
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
|
||||||
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
|
||||||
|
|
||||||
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'
|
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
||||||
|
|
||||||
androidTestImplementation 'androidx.room:room-testing:2.6.1'
|
androidTestImplementation 'androidx.room:room-testing:2.5.0'
|
||||||
androidTestImplementation 'com.squareup.moshi:moshi-kotlin:1.15.0'
|
androidTestImplementation 'com.squareup.moshi:moshi-kotlin:1.14.0'
|
||||||
|
|
||||||
androidTestImplementation 'com.google.dagger:hilt-android-testing:2.50'
|
androidTestImplementation 'com.google.dagger:hilt-android-testing:2.45'
|
||||||
kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.50'
|
kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.45'
|
||||||
}
|
}
|
||||||
|
|||||||
10
app/proguard-rules.pro
vendored
@@ -8,16 +8,10 @@
|
|||||||
public static void checkParameterIsNotNull(...);
|
public static void checkParameterIsNotNull(...);
|
||||||
public static void checkNotNullParameter(...);
|
public static void checkNotNullParameter(...);
|
||||||
}
|
}
|
||||||
-keep public class ** extends org.koitharu.kotatsu.core.ui.BaseFragment
|
-keep public class ** extends org.koitharu.kotatsu.base.ui.BaseFragment
|
||||||
-keep class org.koitharu.kotatsu.core.db.entity.* { *; }
|
-keep class org.koitharu.kotatsu.core.db.entity.* { *; }
|
||||||
-dontwarn okhttp3.internal.platform.**
|
-dontwarn okhttp3.internal.platform.ConscryptPlatform
|
||||||
-dontwarn org.conscrypt.**
|
|
||||||
-dontwarn org.bouncycastle.**
|
|
||||||
-dontwarn org.openjsse.**
|
|
||||||
|
|
||||||
-keep class org.koitharu.kotatsu.core.exceptions.* { *; }
|
-keep class org.koitharu.kotatsu.core.exceptions.* { *; }
|
||||||
-keep class org.koitharu.kotatsu.settings.NotificationSettingsLegacyFragment
|
-keep class org.koitharu.kotatsu.settings.NotificationSettingsLegacyFragment
|
||||||
-keep class org.koitharu.kotatsu.core.prefs.ScreenshotsPolicy { *; }
|
-keep class org.koitharu.kotatsu.core.prefs.ScreenshotsPolicy { *; }
|
||||||
-keep class org.koitharu.kotatsu.settings.backup.PeriodicalBackupSettingsFragment { *; }
|
|
||||||
-keep class org.jsoup.parser.Tag
|
|
||||||
-keep class org.jsoup.internal.StringUtil
|
|
||||||
|
|||||||
BIN
app/sampledata/covers/Forget-me-not Volume 1.jpg
Normal file
|
After Width: | Height: | Size: 213 KiB |
BIN
app/sampledata/covers/Forget-me-not Volume 2.jpg
Normal file
|
After Width: | Height: | Size: 131 KiB |
BIN
app/sampledata/covers/La Pomme Prisoinniere.jpg
Normal file
|
After Width: | Height: | Size: 439 KiB |
BIN
app/sampledata/covers/Momo Kanchou no Himitsu Kichi.jpg
Normal file
|
After Width: | Height: | Size: 495 KiB |
BIN
app/sampledata/covers/Omoide Emanon.jpg
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
app/sampledata/covers/Sasurai Emanon Volume 1.jpg
Normal file
|
After Width: | Height: | Size: 791 KiB |
BIN
app/sampledata/covers/Sasurai Emanon Volume 2.jpg
Normal file
|
After Width: | Height: | Size: 844 KiB |
BIN
app/sampledata/covers/Sasurai Emanon Volume 3.jpg
Normal file
|
After Width: | Height: | Size: 386 KiB |
BIN
app/sampledata/covers/Wandering Island Volume 1.jpg
Normal file
|
After Width: | Height: | Size: 375 KiB |
BIN
app/sampledata/covers/Wandering Island Volume 2.jpg
Normal file
|
After Width: | Height: | Size: 398 KiB |
10
app/sampledata/genres
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Slice of Life, Mystery
|
||||||
|
Slice of Life, Mystery
|
||||||
|
Psychological, Romance, Comedy, Slice of Life, Supernatural
|
||||||
|
Sci-Fi, Comedy
|
||||||
|
Reincarnation, Sci-Fi, Historical, Psychological, Drama, Slice of Life, Supernatural, Mystery
|
||||||
|
Reincarnation, Sci-Fi, Historical, Psychological, Drama, Slice of Life, Supernatural, Mystery
|
||||||
|
Reincarnation, Sci-Fi, Historical, Psychological, Drama, Slice of Life, Supernatural, Mystery
|
||||||
|
Reincarnation, Sci-Fi, Historical, Psychological, Drama, Slice of Life, Supernatural, Mystery
|
||||||
|
Adventure, Slice of Life, Mystery
|
||||||
|
Adventure, Slice of Life, Mystery
|
||||||
10
app/sampledata/titles
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Forget-me-not Vol. 1
|
||||||
|
Forget-me-not Vol. 2
|
||||||
|
La Pomme Prisoinniere
|
||||||
|
Momo Kanchou no Himitsu Kichi
|
||||||
|
Omoide Emanon
|
||||||
|
Sasurai Emanon Vol. 1
|
||||||
|
Sasurai Emanon Vol. 2
|
||||||
|
Sasurai Emanon Vol. 3
|
||||||
|
Wandering Island Vol. 1
|
||||||
|
Wandering Island Vol. 2
|
||||||
@@ -17,7 +17,7 @@ class MangaDatabaseTest {
|
|||||||
MangaDatabase::class.java,
|
MangaDatabase::class.java,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val migrations = getDatabaseMigrations(InstrumentationRegistry.getInstrumentation().targetContext)
|
private val migrations = databaseMigrations
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun versions() {
|
fun versions() {
|
||||||
@@ -8,6 +8,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
|||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import dagger.hilt.android.testing.HiltAndroidRule
|
import dagger.hilt.android.testing.HiltAndroidRule
|
||||||
import dagger.hilt.android.testing.HiltAndroidTest
|
import dagger.hilt.android.testing.HiltAndroidTest
|
||||||
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
@@ -18,12 +19,11 @@ import org.junit.runner.RunWith
|
|||||||
import org.koitharu.kotatsu.SampleData
|
import org.koitharu.kotatsu.SampleData
|
||||||
import org.koitharu.kotatsu.awaitForIdle
|
import org.koitharu.kotatsu.awaitForIdle
|
||||||
import org.koitharu.kotatsu.core.db.MangaDatabase
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
import org.koitharu.kotatsu.history.data.HistoryRepository
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltAndroidTest
|
@HiltAndroidTest
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class AppShortcutManagerTest {
|
class ShortcutsUpdaterTest {
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
var hiltRule = HiltAndroidRule(this)
|
var hiltRule = HiltAndroidRule(this)
|
||||||
@@ -32,7 +32,7 @@ class AppShortcutManagerTest {
|
|||||||
lateinit var historyRepository: HistoryRepository
|
lateinit var historyRepository: HistoryRepository
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var appShortcutManager: AppShortcutManager
|
lateinit var shortcutsUpdater: ShortcutsUpdater
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var database: MangaDatabase
|
lateinit var database: MangaDatabase
|
||||||
@@ -48,7 +48,6 @@ class AppShortcutManagerTest {
|
|||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
|
||||||
return@runTest
|
return@runTest
|
||||||
}
|
}
|
||||||
database.invalidationTracker.addObserver(appShortcutManager)
|
|
||||||
awaitUpdate()
|
awaitUpdate()
|
||||||
assertTrue(getShortcuts().isEmpty())
|
assertTrue(getShortcuts().isEmpty())
|
||||||
historyRepository.addOrUpdate(
|
historyRepository.addOrUpdate(
|
||||||
@@ -73,6 +72,6 @@ class AppShortcutManagerTest {
|
|||||||
private suspend fun awaitUpdate() {
|
private suspend fun awaitUpdate() {
|
||||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||||
instrumentation.awaitForIdle()
|
instrumentation.awaitForIdle()
|
||||||
appShortcutManager.await()
|
shortcutsUpdater.await()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
|||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import dagger.hilt.android.testing.HiltAndroidRule
|
import dagger.hilt.android.testing.HiltAndroidRule
|
||||||
import dagger.hilt.android.testing.HiltAndroidTest
|
import dagger.hilt.android.testing.HiltAndroidTest
|
||||||
|
import java.io.File
|
||||||
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
@@ -17,9 +19,7 @@ import org.koitharu.kotatsu.core.backup.BackupRepository
|
|||||||
import org.koitharu.kotatsu.core.db.MangaDatabase
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
import org.koitharu.kotatsu.core.db.entity.toMangaTags
|
import org.koitharu.kotatsu.core.db.entity.toMangaTags
|
||||||
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||||
import org.koitharu.kotatsu.history.data.HistoryRepository
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
import java.io.File
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltAndroidTest
|
@HiltAndroidTest
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@@ -52,7 +52,6 @@ class AppBackupAgentTest {
|
|||||||
title = SampleData.favouriteCategory.title,
|
title = SampleData.favouriteCategory.title,
|
||||||
sortOrder = SampleData.favouriteCategory.order,
|
sortOrder = SampleData.favouriteCategory.order,
|
||||||
isTrackerEnabled = SampleData.favouriteCategory.isTrackingEnabled,
|
isTrackerEnabled = SampleData.favouriteCategory.isTrackingEnabled,
|
||||||
isVisibleOnShelf = SampleData.favouriteCategory.isVisibleInLibrary,
|
|
||||||
)
|
)
|
||||||
favouritesRepository.addToCategory(categoryId = category.id, mangas = listOf(SampleData.manga))
|
favouritesRepository.addToCategory(categoryId = category.id, mangas = listOf(SampleData.manga))
|
||||||
historyRepository.addOrUpdate(
|
historyRepository.addOrUpdate(
|
||||||
@@ -82,7 +81,7 @@ class AppBackupAgentTest {
|
|||||||
assertEquals(history, historyRepository.getOne(SampleData.manga))
|
assertEquals(history, historyRepository.getOne(SampleData.manga))
|
||||||
assertEquals(listOf(SampleData.manga), favouritesRepository.getManga(category.id))
|
assertEquals(listOf(SampleData.manga), favouritesRepository.getManga(category.id))
|
||||||
|
|
||||||
val allTags = database.getTagsDao().findTags(SampleData.tag.source.name).toMangaTags()
|
val allTags = database.tagsDao.findTags(SampleData.tag.source.name).toMangaTags()
|
||||||
assertTrue(SampleData.tag in allTags)
|
assertTrue(SampleData.tag in allTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3,6 +3,7 @@ package org.koitharu.kotatsu.tracker.domain
|
|||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import dagger.hilt.android.testing.HiltAndroidRule
|
import dagger.hilt.android.testing.HiltAndroidRule
|
||||||
import dagger.hilt.android.testing.HiltAndroidTest
|
import dagger.hilt.android.testing.HiltAndroidTest
|
||||||
|
import javax.inject.Inject
|
||||||
import junit.framework.TestCase.*
|
import junit.framework.TestCase.*
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@@ -10,9 +11,8 @@ import org.junit.Rule
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.koitharu.kotatsu.SampleData
|
import org.koitharu.kotatsu.SampleData
|
||||||
import org.koitharu.kotatsu.core.parser.MangaDataRepository
|
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltAndroidTest
|
@HiltAndroidTest
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.koitharu.kotatsu
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.test.runner.AndroidJUnitRunner
|
|
||||||
import dagger.hilt.android.testing.HiltTestApplication
|
|
||||||
|
|
||||||
class HiltTestRunner : AndroidJUnitRunner() {
|
|
||||||
|
|
||||||
override fun newApplication(cl: ClassLoader?, name: String?, context: Context?): Application {
|
|
||||||
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import org.koitharu.kotatsu.parsers.MangaParser
|
|||||||
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaListFilter
|
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
@@ -18,16 +17,21 @@ import java.util.EnumSet
|
|||||||
class DummyParser(context: MangaLoaderContext) : MangaParser(context, MangaSource.DUMMY) {
|
class DummyParser(context: MangaLoaderContext) : MangaParser(context, MangaSource.DUMMY) {
|
||||||
|
|
||||||
override val configKeyDomain: ConfigKey.Domain
|
override val configKeyDomain: ConfigKey.Domain
|
||||||
get() = ConfigKey.Domain("")
|
get() = ConfigKey.Domain("", null)
|
||||||
|
|
||||||
override val availableSortOrders: Set<SortOrder>
|
override val sortOrders: Set<SortOrder>
|
||||||
get() = EnumSet.allOf(SortOrder::class.java)
|
get() = EnumSet.allOf(SortOrder::class.java)
|
||||||
|
|
||||||
override suspend fun getDetails(manga: Manga): Manga {
|
override suspend fun getDetails(manga: Manga): Manga {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getList(offset: Int, filter: MangaListFilter?): List<Manga> {
|
override suspend fun getList(
|
||||||
|
offset: Int,
|
||||||
|
query: String?,
|
||||||
|
tags: Set<MangaTag>?,
|
||||||
|
sortOrder: SortOrder,
|
||||||
|
): List<Manga> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +39,7 @@ class DummyParser(context: MangaLoaderContext) : MangaParser(context, MangaSourc
|
|||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getAvailableTags(): Set<MangaTag> {
|
override suspend fun getTags(): Set<MangaTag> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package org.koitharu.kotatsu.utils.ext
|
||||||
|
|
||||||
|
fun Throwable.printStackTraceDebug() = printStackTrace()
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package org.koitharu.kotatsu
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.StrictMode
|
|
||||||
import androidx.fragment.app.strictmode.FragmentStrictMode
|
|
||||||
import org.koitharu.kotatsu.core.BaseApp
|
|
||||||
import org.koitharu.kotatsu.local.data.LocalMangaRepository
|
|
||||||
import org.koitharu.kotatsu.local.data.PagesCache
|
|
||||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
||||||
import org.koitharu.kotatsu.reader.domain.PageLoader
|
|
||||||
|
|
||||||
class KotatsuApp : BaseApp() {
|
|
||||||
|
|
||||||
override fun attachBaseContext(base: Context?) {
|
|
||||||
super.attachBaseContext(base)
|
|
||||||
enableStrictMode()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun enableStrictMode() {
|
|
||||||
StrictMode.setThreadPolicy(
|
|
||||||
StrictMode.ThreadPolicy.Builder()
|
|
||||||
.detectAll()
|
|
||||||
.penaltyLog()
|
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
StrictMode.setVmPolicy(
|
|
||||||
StrictMode.VmPolicy.Builder()
|
|
||||||
.detectAll()
|
|
||||||
.setClassInstanceLimit(LocalMangaRepository::class.java, 1)
|
|
||||||
.setClassInstanceLimit(PagesCache::class.java, 1)
|
|
||||||
.setClassInstanceLimit(MangaLoaderContext::class.java, 1)
|
|
||||||
.setClassInstanceLimit(PageLoader::class.java, 1)
|
|
||||||
.penaltyLog()
|
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
FragmentStrictMode.defaultPolicy = FragmentStrictMode.Policy.Builder()
|
|
||||||
.penaltyDeath()
|
|
||||||
.detectFragmentReuse()
|
|
||||||
// .detectWrongFragmentContainer() FIXME: migrate to ViewPager2
|
|
||||||
.detectRetainInstanceUsage()
|
|
||||||
.detectSetUserVisibleHint()
|
|
||||||
.detectFragmentTagUsage()
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.core.util.ext
|
|
||||||
|
|
||||||
fun Throwable.printStackTraceDebug() = printStackTrace()
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<bool name="leak_canary_add_launcher_icon" tools:node="replace">false</bool>
|
<bool name="leak_canary_add_launcher_icon" tools:node="replace">false</bool>
|
||||||
|
<bool name="is_sync_enabled">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<string name="account_type_sync" translatable="false">org.kotatsu.debug.sync</string>
|
|
||||||
<string name="sync_authority_history" translatable="false">org.koitharu.kotatsu.debug.history</string>
|
|
||||||
<string name="sync_authority_favourites" translatable="false">org.koitharu.kotatsu.debug.favourites</string>
|
|
||||||
</resources>
|
|
||||||
@@ -18,24 +18,6 @@
|
|||||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
|
||||||
android:maxSdkVersion="29" />
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
|
||||||
tools:ignore="ScopedStorage" />
|
|
||||||
|
|
||||||
<queries>
|
|
||||||
<intent>
|
|
||||||
<action android:name="android.intent.action.PROCESS_TEXT" />
|
|
||||||
<data android:mimeType="text/plain" />
|
|
||||||
</intent>
|
|
||||||
<intent>
|
|
||||||
<action android:name="android.speech.action.RECOGNIZE_SPEECH" />
|
|
||||||
</intent>
|
|
||||||
</queries>
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="org.koitharu.kotatsu.KotatsuApp"
|
android:name="org.koitharu.kotatsu.KotatsuApp"
|
||||||
@@ -48,8 +30,8 @@
|
|||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:largeHeap="true"
|
android:largeHeap="true"
|
||||||
|
android:localeConfig="@xml/locales"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:requestLegacyExternalStorage="true"
|
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Kotatsu"
|
android:theme="@style/Theme.Kotatsu"
|
||||||
@@ -72,27 +54,6 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="${applicationId}.action.VIEW_MANGA" />
|
<action android:name="${applicationId}.action.VIEW_MANGA" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter android:autoVerify="true">
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data android:scheme="http" />
|
|
||||||
<data android:scheme="https" />
|
|
||||||
<data android:host="kotatsu.app" />
|
|
||||||
<data android:path="/manga" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data android:scheme="kotatsu" />
|
|
||||||
<data android:host="manga" />
|
|
||||||
<data android:host="kotatsu.app" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.reader.ui.ReaderActivity"
|
android:name="org.koitharu.kotatsu.reader.ui.ReaderActivity"
|
||||||
@@ -106,12 +67,7 @@
|
|||||||
android:label="@string/search" />
|
android:label="@string/search" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.search.ui.MangaListActivity"
|
android:name="org.koitharu.kotatsu.search.ui.MangaListActivity"
|
||||||
android:exported="true"
|
android:label="@string/search_manga" />
|
||||||
android:label="@string/manga_list">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="${applicationId}.action.EXPLORE_MANGA" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.history.ui.HistoryActivity"
|
android:name="org.koitharu.kotatsu.history.ui.HistoryActivity"
|
||||||
android:label="@string/history" />
|
android:label="@string/history" />
|
||||||
@@ -127,59 +83,30 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.suggestions.ui.SuggestionsActivity"
|
android:name="org.koitharu.kotatsu.suggestions.ui.SuggestionsActivity"
|
||||||
android:label="@string/suggestions" />
|
android:label="@string/suggestions" />
|
||||||
<activity
|
|
||||||
android:name="org.koitharu.kotatsu.details.ui.related.RelatedMangaActivity"
|
|
||||||
android:label="@string/related_manga" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.settings.SettingsActivity"
|
android:name="org.koitharu.kotatsu.settings.SettingsActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/settings">
|
android:label="@string/settings" />
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data android:scheme="kotatsu" />
|
|
||||||
<data android:host="about" />
|
|
||||||
<data android:host="sync-settings" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name="org.koitharu.kotatsu.settings.storage.directories.MangaDirectoriesActivity"
|
|
||||||
android:label="@string/local_manga_directories" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.browser.BrowserActivity"
|
android:name="org.koitharu.kotatsu.browser.BrowserActivity"
|
||||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
|
||||||
android:name="org.koitharu.kotatsu.browser.cloudflare.CloudFlareActivity"
|
|
||||||
android:autoRemoveFromRecents="true"
|
|
||||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
|
||||||
android:windowSoftInputMode="adjustResize" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity"
|
android:name="org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity"
|
||||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.favourites.ui.categories.FavouriteCategoriesActivity"
|
android:name="org.koitharu.kotatsu.favourites.ui.categories.FavouriteCategoriesActivity"
|
||||||
android:label="@string/manage_categories" />
|
android:label="@string/favourites"
|
||||||
|
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.widget.shelf.ShelfWidgetConfigActivity"
|
android:name="org.koitharu.kotatsu.widget.shelf.ShelfConfigActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/manga_shelf">
|
android:label="@string/manga_shelf">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name="org.koitharu.kotatsu.widget.recent.RecentWidgetConfigActivity"
|
|
||||||
android:exported="true"
|
|
||||||
android:label="@string/recent_manga">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.search.ui.multi.MultiSearchActivity"
|
android:name="org.koitharu.kotatsu.search.ui.multi.MultiSearchActivity"
|
||||||
android:label="@string/search" />
|
android:label="@string/search" />
|
||||||
@@ -191,7 +118,7 @@
|
|||||||
android:name="org.koitharu.kotatsu.settings.protect.ProtectSetupActivity"
|
android:name="org.koitharu.kotatsu.settings.protect.ProtectSetupActivity"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.download.ui.list.DownloadsActivity"
|
android:name="org.koitharu.kotatsu.download.ui.DownloadsActivity"
|
||||||
android:label="@string/downloads"
|
android:label="@string/downloads"
|
||||||
android:launchMode="singleTop" />
|
android:launchMode="singleTop" />
|
||||||
<activity android:name="org.koitharu.kotatsu.image.ui.ImageActivity" />
|
<activity android:name="org.koitharu.kotatsu.image.ui.ImageActivity" />
|
||||||
@@ -202,6 +129,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.reader.ui.colorfilter.ColorFilterConfigActivity"
|
android:name="org.koitharu.kotatsu.reader.ui.colorfilter.ColorFilterConfigActivity"
|
||||||
android:label="@string/color_correction" />
|
android:label="@string/color_correction" />
|
||||||
|
<activity
|
||||||
|
android:name="org.koitharu.kotatsu.shelf.ui.config.ShelfSettingsActivity"
|
||||||
|
android:label="@string/settings" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.scrobbling.common.ui.config.ScrobblerConfigActivity"
|
android:name="org.koitharu.kotatsu.scrobbling.common.ui.config.ScrobblerConfigActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -215,23 +145,16 @@
|
|||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data android:scheme="kotatsu" />
|
<data android:scheme="kotatsu" />
|
||||||
<data android:host="shikimori-auth" />
|
|
||||||
<data android:host="anilist-auth" />
|
|
||||||
<data android:host="mal-auth" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name="org.koitharu.kotatsu.settings.sources.catalog.SourcesCatalogActivity"
|
|
||||||
android:label="@string/sources_catalog" />
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="androidx.work.impl.foreground.SystemForegroundService"
|
android:name="org.koitharu.kotatsu.download.ui.service.DownloadService"
|
||||||
android:foregroundServiceType="dataSync"
|
android:foregroundServiceType="dataSync"
|
||||||
tools:node="merge" />
|
android:stopWithTask="false" />
|
||||||
<service
|
<service android:name="org.koitharu.kotatsu.local.ui.LocalChaptersRemoveService" />
|
||||||
android:name="org.koitharu.kotatsu.local.ui.LocalChaptersRemoveService"
|
<service android:name="org.koitharu.kotatsu.local.ui.ImportService" />
|
||||||
android:foregroundServiceType="dataSync" />
|
|
||||||
<service
|
<service
|
||||||
android:name="org.koitharu.kotatsu.widget.shelf.ShelfWidgetService"
|
android:name="org.koitharu.kotatsu.widget.shelf.ShelfWidgetService"
|
||||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||||
@@ -252,7 +175,8 @@
|
|||||||
<service
|
<service
|
||||||
android:name="org.koitharu.kotatsu.sync.ui.favourites.FavouritesSyncService"
|
android:name="org.koitharu.kotatsu.sync.ui.favourites.FavouritesSyncService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/favourites">
|
android:label="@string/favourites"
|
||||||
|
android:process=":sync">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.content.SyncAdapter" />
|
<action android:name="android.content.SyncAdapter" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -263,7 +187,8 @@
|
|||||||
<service
|
<service
|
||||||
android:name="org.koitharu.kotatsu.sync.ui.history.HistorySyncService"
|
android:name="org.koitharu.kotatsu.sync.ui.history.HistorySyncService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/history">
|
android:label="@string/history"
|
||||||
|
android:process=":sync">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.content.SyncAdapter" />
|
<action android:name="android.content.SyncAdapter" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -290,26 +215,20 @@
|
|||||||
</provider>
|
</provider>
|
||||||
<provider
|
<provider
|
||||||
android:name="org.koitharu.kotatsu.sync.ui.favourites.FavouritesSyncProvider"
|
android:name="org.koitharu.kotatsu.sync.ui.favourites.FavouritesSyncProvider"
|
||||||
android:authorities="@string/sync_authority_favourites"
|
android:authorities="org.koitharu.kotatsu.favourites"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/favourites"
|
android:label="@string/favourites"
|
||||||
android:syncable="true" />
|
android:syncable="true" />
|
||||||
<provider
|
<provider
|
||||||
android:name="org.koitharu.kotatsu.sync.ui.history.HistorySyncProvider"
|
android:name="org.koitharu.kotatsu.sync.ui.history.HistorySyncProvider"
|
||||||
android:authorities="@string/sync_authority_history"
|
android:authorities="org.koitharu.kotatsu.history"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/history"
|
android:label="@string/history"
|
||||||
android:syncable="true" />
|
android:syncable="true" />
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.startup.InitializationProvider"
|
android:name="androidx.startup.InitializationProvider"
|
||||||
android:authorities="${applicationId}.androidx-startup"
|
android:authorities="${applicationId}.androidx-startup"
|
||||||
android:exported="false"
|
tools:node="remove" />
|
||||||
tools:node="remove">
|
|
||||||
<meta-data
|
|
||||||
android:name="androidx.work.WorkManagerInitializer"
|
|
||||||
android:value="androidx.startup"
|
|
||||||
tools:node="remove" />
|
|
||||||
</provider>
|
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="org.koitharu.kotatsu.widget.shelf.ShelfWidgetProvider"
|
android:name="org.koitharu.kotatsu.widget.shelf.ShelfWidgetProvider"
|
||||||
@@ -333,20 +252,6 @@
|
|||||||
android:name="android.appwidget.provider"
|
android:name="android.appwidget.provider"
|
||||||
android:resource="@xml/widget_recent" />
|
android:resource="@xml/widget_recent" />
|
||||||
</receiver>
|
</receiver>
|
||||||
<receiver
|
|
||||||
android:name="org.koitharu.kotatsu.settings.about.UpdateDownloadReceiver"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
<receiver
|
|
||||||
android:name="org.koitharu.kotatsu.core.ErrorReporterReceiver"
|
|
||||||
android:exported="false">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="${applicationId}.action.REPORT_ERROR" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.webkit.WebView.EnableSafeBrowsing"
|
android:name="android.webkit.WebView.EnableSafeBrowsing"
|
||||||
@@ -358,660 +263,6 @@
|
|||||||
android:name="com.samsung.android.icon_container.has_icon_container"
|
android:name="com.samsung.android.icon_container.has_icon_container"
|
||||||
android:value="@bool/com_samsung_android_icon_container_has_icon_container" />
|
android:value="@bool/com_samsung_android_icon_container_has_icon_container" />
|
||||||
|
|
||||||
<activity-alias
|
|
||||||
android:name="org.koitharu.kotatsu.details.ui.DetailsBYLinkActivity"
|
|
||||||
android:exported="true"
|
|
||||||
android:targetActivity="org.koitharu.kotatsu.details.ui.DetailsActivity">
|
|
||||||
|
|
||||||
<intent-filter android:autoVerify="false">
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data android:scheme="http" />
|
|
||||||
<data android:scheme="https" />
|
|
||||||
<data android:host="1stkissmanga.me" />
|
|
||||||
<data android:host="3asq.org" />
|
|
||||||
<data android:host="18porncomic.com" />
|
|
||||||
<data android:host="212.32.226.234" />
|
|
||||||
<data android:host="247manga.com" />
|
|
||||||
<data android:host="365manga.com" />
|
|
||||||
<data android:host="2023.allhen.online" />
|
|
||||||
<data android:host="adultwebtoon.com" />
|
|
||||||
<data android:host="afroditscans.com" />
|
|
||||||
<data android:host="ainzscans.site" />
|
|
||||||
<data android:host="aiyumanga.com" />
|
|
||||||
<data android:host="alceascan.my.id" />
|
|
||||||
<data android:host="allporncomic.com" />
|
|
||||||
<data android:host="anibel.net" />
|
|
||||||
<data android:host="anigliscans.com" />
|
|
||||||
<data android:host="anikiga.com" />
|
|
||||||
<data android:host="animaregia.net" />
|
|
||||||
<data android:host="anisamanga.com" />
|
|
||||||
<data android:host="anshscans.org" />
|
|
||||||
<data android:host="apenasmaisumyaoi.com" />
|
|
||||||
<data android:host="apollcomics.com" />
|
|
||||||
<data android:host="aquamanga.com" />
|
|
||||||
<data android:host="arabtoons.net" />
|
|
||||||
<data android:host="araznovel.com" />
|
|
||||||
<data android:host="arcanescans.com" />
|
|
||||||
<data android:host="arenascans.net" />
|
|
||||||
<data android:host="arthurscan.xyz" />
|
|
||||||
<data android:host="astral-manga.fr" />
|
|
||||||
<data android:host="astrallibrary.net" />
|
|
||||||
<data android:host="astrumscans.xyz" />
|
|
||||||
<data android:host="asura.nacm.xyz" />
|
|
||||||
<data android:host="asurascanstr.com" />
|
|
||||||
<data android:host="athenafansub.com" />
|
|
||||||
<data android:host="ayatoon.com" />
|
|
||||||
<data android:host="azoranov.com" />
|
|
||||||
<data android:host="azuremanga.com" />
|
|
||||||
<data android:host="babeltoon.com" />
|
|
||||||
<data android:host="bakai.org" />
|
|
||||||
<data android:host="bakaman.net" />
|
|
||||||
<data android:host="bakamh.com" />
|
|
||||||
<data android:host="banana-scan.com" />
|
|
||||||
<data android:host="bato.to" />
|
|
||||||
<data android:host="batocomic.com" />
|
|
||||||
<data android:host="batocomic.net" />
|
|
||||||
<data android:host="batocomic.org" />
|
|
||||||
<data android:host="batotoo.com" />
|
|
||||||
<data android:host="batotwo.com" />
|
|
||||||
<data android:host="battwo.com" />
|
|
||||||
<data android:host="beast-scans.com" />
|
|
||||||
<data android:host="beehentai.com" />
|
|
||||||
<data android:host="bentomanga.com" />
|
|
||||||
<data android:host="bestmanga.club" />
|
|
||||||
<data android:host="bestmanhua.com" />
|
|
||||||
<data android:host="bibimanga.com" />
|
|
||||||
<data android:host="birdmanga.com" />
|
|
||||||
<data android:host="birdtoon.net" />
|
|
||||||
<data android:host="blogmanga.net" />
|
|
||||||
<data android:host="blogtruyenmoi.com" />
|
|
||||||
<data android:host="bokugents.com" />
|
|
||||||
<data android:host="boosei.net" />
|
|
||||||
<data android:host="boyslove.me" />
|
|
||||||
<data android:host="br.atlantisscan.com" />
|
|
||||||
<data android:host="br.ninemanga.com" />
|
|
||||||
<data android:host="cabaredowatame.site" />
|
|
||||||
<data android:host="cafecomyaoi.com.br" />
|
|
||||||
<data android:host="carteldemanhwas.com" />
|
|
||||||
<data android:host="cat300.com" />
|
|
||||||
<data android:host="cerisescans.com" />
|
|
||||||
<data android:host="chap.mangairo.com" />
|
|
||||||
<data android:host="chapmanganato.com" />
|
|
||||||
<data android:host="chapmanganato.com" />
|
|
||||||
<data android:host="cizgiromanarsivi.com" />
|
|
||||||
<data android:host="cmreader.info" />
|
|
||||||
<data android:host="cocorip.net" />
|
|
||||||
<data android:host="coffeemanga.io" />
|
|
||||||
<data android:host="coloredmanga.com" />
|
|
||||||
<data android:host="comick.app" />
|
|
||||||
<data android:host="comiko.net" />
|
|
||||||
<data android:host="comiko.org" />
|
|
||||||
<data android:host="copypastescan.xyz" />
|
|
||||||
<data android:host="cosmicscans.com" />
|
|
||||||
<data android:host="daprob.com" />
|
|
||||||
<data android:host="darkscans.com" />
|
|
||||||
<data android:host="de.ninemanga.com" />
|
|
||||||
<data android:host="desu.me" />
|
|
||||||
<data android:host="diamondfansub.com" />
|
|
||||||
<data android:host="dojing.net" />
|
|
||||||
<data android:host="dokkomanga.com" />
|
|
||||||
<data android:host="dokkomanga.com" />
|
|
||||||
<data android:host="doujin69.com" />
|
|
||||||
<data android:host="doujindesu.rip" />
|
|
||||||
<data android:host="doujinhentai.net" />
|
|
||||||
<data android:host="dragontea.ink" />
|
|
||||||
<data android:host="dragontranslation.net" />
|
|
||||||
<data android:host="drakescans.com" />
|
|
||||||
<data android:host="dto.to" />
|
|
||||||
<data android:host="duckmanga.com" />
|
|
||||||
<data android:host="duniakomik.id" />
|
|
||||||
<data android:host="dynasty-scans.com" />
|
|
||||||
<data android:host="e-hentai.org" />
|
|
||||||
<data android:host="elarcpage.com" />
|
|
||||||
<data android:host="en.leviatanscans.com" />
|
|
||||||
<data android:host="epsilonscan.fr" />
|
|
||||||
<data android:host="es.ninemanga.com" />
|
|
||||||
<data android:host="esomanga.com" />
|
|
||||||
<data android:host="exhentai.org" />
|
|
||||||
<data android:host="falconmanga.com" />
|
|
||||||
<data android:host="fbsquads.com" />
|
|
||||||
<data android:host="finalscans.com" />
|
|
||||||
<data android:host="flamescans.org" />
|
|
||||||
<data android:host="foxwhite.com.br" />
|
|
||||||
<data android:host="fr-scan.cc" />
|
|
||||||
<data android:host="fr.ninemanga.com" />
|
|
||||||
<data android:host="franxxmangas.net" />
|
|
||||||
<data android:host="freakscans.com" />
|
|
||||||
<data android:host="freemanga.me" />
|
|
||||||
<data android:host="freemangatop.com" />
|
|
||||||
<data android:host="freewebtooncoins.com" />
|
|
||||||
<data android:host="frscans.com" />
|
|
||||||
<data android:host="furyosociety.com" />
|
|
||||||
<data android:host="galaxymanga.org" />
|
|
||||||
<data android:host="gatemanga.com" />
|
|
||||||
<data android:host="gdscans.com" />
|
|
||||||
<data android:host="gekkou.com.br" />
|
|
||||||
<data android:host="glorymanga.com" />
|
|
||||||
<data android:host="goldenmanga.top" />
|
|
||||||
<data android:host="golgebahcesi.com" />
|
|
||||||
<data android:host="gooffansub.com" />
|
|
||||||
<data android:host="gourmetscans.net" />
|
|
||||||
<data android:host="grabber.zone" />
|
|
||||||
<data android:host="gremorymangas.com" />
|
|
||||||
<data android:host="guimah.com" />
|
|
||||||
<data android:host="guncelmanga.net" />
|
|
||||||
<data android:host="h.mangabat.com" />
|
|
||||||
<data android:host="hachiraw.com" />
|
|
||||||
<data android:host="harimanga.com" />
|
|
||||||
<data android:host="hayalistic.com" />
|
|
||||||
<data android:host="hensekai.com" />
|
|
||||||
<data android:host="hentai3z.cc" />
|
|
||||||
<data android:host="hentai3z.xyz" />
|
|
||||||
<data android:host="hentai4free.net" />
|
|
||||||
<data android:host="hentai20.io" />
|
|
||||||
<data android:host="hentai.gekkouscans.com.br" />
|
|
||||||
<data android:host="hentai.scantrad-vf.cc" />
|
|
||||||
<data android:host="hentaichan.live" />
|
|
||||||
<data android:host="hentaichan.pro" />
|
|
||||||
<data android:host="hentaicube.net" />
|
|
||||||
<data android:host="hentailib.me" />
|
|
||||||
<data android:host="hentaimanga.me" />
|
|
||||||
<data android:host="hentaiteca.net" />
|
|
||||||
<data android:host="hentaivn.autos" />
|
|
||||||
<data android:host="hentaivn.tv" />
|
|
||||||
<data android:host="hentaiwebtoon.com" />
|
|
||||||
<data android:host="hentaixcomic.com" />
|
|
||||||
<data android:host="hentaixdickgirl.com" />
|
|
||||||
<data android:host="hentaixyuri.com" />
|
|
||||||
<data android:host="hentaizone.xyz" />
|
|
||||||
<data android:host="herenscan.com" />
|
|
||||||
<data android:host="hhentai.fr" />
|
|
||||||
<data android:host="hikariscan.com.br" />
|
|
||||||
<data android:host="hipercool.xyz" />
|
|
||||||
<data android:host="hmanhwa.com" />
|
|
||||||
<data android:host="hni-scantrad.com" />
|
|
||||||
<data android:host="honey-manga.com.ua" />
|
|
||||||
<data android:host="hscans.com" />
|
|
||||||
<data android:host="hto.to" />
|
|
||||||
<data android:host="id.gourmetscans.net" />
|
|
||||||
<data android:host="illusionscan.com" />
|
|
||||||
<data android:host="immortalupdates.com" />
|
|
||||||
<data android:host="immortalupdates.id" />
|
|
||||||
<data android:host="imperiodabritannia.com" />
|
|
||||||
<data android:host="imperioscans.com.br" />
|
|
||||||
<data android:host="indo18h.com" />
|
|
||||||
<data android:host="infrafandub.xyz" />
|
|
||||||
<data android:host="isekaiscan.top" />
|
|
||||||
<data android:host="it.ninemanga.com" />
|
|
||||||
<data android:host="itsyourightmanhua.com" />
|
|
||||||
<data android:host="jaiminisbox.net" />
|
|
||||||
<data android:host="japscan.ws" />
|
|
||||||
<data android:host="jiangzaitoon.co" />
|
|
||||||
<data android:host="jimanga.com" />
|
|
||||||
<data android:host="jpmangas.xyz" />
|
|
||||||
<data android:host="kanzenin.xyz" />
|
|
||||||
<data android:host="karatcam-scans.fr" />
|
|
||||||
<data android:host="katakomik.online" />
|
|
||||||
<data android:host="kiryuu.id" />
|
|
||||||
<data android:host="kissmanga.in" />
|
|
||||||
<data android:host="klikmanga.id" />
|
|
||||||
<data android:host="klz9.com" />
|
|
||||||
<data android:host="koinoboriscan.com" />
|
|
||||||
<data android:host="kolmanga.com" />
|
|
||||||
<data android:host="komikav.com" />
|
|
||||||
<data android:host="komikcast.io" />
|
|
||||||
<data android:host="komikdewasa.cfd" />
|
|
||||||
<data android:host="komikgo.org" />
|
|
||||||
<data android:host="komikhentai.co" />
|
|
||||||
<data android:host="komikid.com" />
|
|
||||||
<data android:host="komikindo.co" />
|
|
||||||
<data android:host="komikindo.info" />
|
|
||||||
<data android:host="komiklab.com" />
|
|
||||||
<data android:host="komiklokal.cfd" />
|
|
||||||
<data android:host="komikmama.co" />
|
|
||||||
<data android:host="komikmanhwa.me" />
|
|
||||||
<data android:host="komikmirror.art" />
|
|
||||||
<data android:host="komiksan.link" />
|
|
||||||
<data android:host="komiksay.site" />
|
|
||||||
<data android:host="komikstation.co" />
|
|
||||||
<data android:host="komiktap.in" />
|
|
||||||
<data android:host="komiku.com" />
|
|
||||||
<data android:host="komikzoid.xyz" />
|
|
||||||
<data android:host="ksgroupscans.com" />
|
|
||||||
<data android:host="kumascans.com" />
|
|
||||||
<data android:host="kunmanga.com" />
|
|
||||||
<data android:host="ladymanga.com" />
|
|
||||||
<data android:host="lectortmo.com" />
|
|
||||||
<data android:host="lectorunitoon.com" />
|
|
||||||
<data android:host="legacy-scans.com" />
|
|
||||||
<data android:host="legionscans.com" />
|
|
||||||
<data android:host="leitor.kamisama.com.br" />
|
|
||||||
<data android:host="leitorizakaya.net" />
|
|
||||||
<data android:host="lelscanvf.cc" />
|
|
||||||
<data android:host="leryaoi.com" />
|
|
||||||
<data android:host="lilymanga.net" />
|
|
||||||
<data android:host="limascans.xyz/v2" />
|
|
||||||
<data android:host="lkscanlation.com" />
|
|
||||||
<data android:host="lolicon.mobi" />
|
|
||||||
<data android:host="lugnica-scans.com" />
|
|
||||||
<data android:host="lunarscan.org" />
|
|
||||||
<data android:host="luxmanga.net" />
|
|
||||||
<data android:host="lxmanga.net" />
|
|
||||||
<data android:host="lynxscans.com" />
|
|
||||||
<data android:host="m.isekaiscan.to" />
|
|
||||||
<data android:host="mafia-manga.com" />
|
|
||||||
<data android:host="maidscan.com.br" />
|
|
||||||
<data android:host="manga1st.online" />
|
|
||||||
<data android:host="manga3s.com" />
|
|
||||||
<data android:host="manga18.club" />
|
|
||||||
<data android:host="manga68.com" />
|
|
||||||
<data android:host="manga689.com" />
|
|
||||||
<data android:host="manga-chan.me" />
|
|
||||||
<data android:host="manga-crab.com" />
|
|
||||||
<data android:host="manga-diyari.com" />
|
|
||||||
<data android:host="manga-fast.com" />
|
|
||||||
<data android:host="manga-fr.me" />
|
|
||||||
<data android:host="manga-mate.org" />
|
|
||||||
<data android:host="manga-moons.net" />
|
|
||||||
<data android:host="manga-scan.co" />
|
|
||||||
<data android:host="manga-scantrad.io" />
|
|
||||||
<data android:host="manga-tx.com" />
|
|
||||||
<data android:host="manga-uptocats.com" />
|
|
||||||
<data android:host="manga.clone-army.org" />
|
|
||||||
<data android:host="manga.in.ua" />
|
|
||||||
<data android:host="manga.mundodrama.site" />
|
|
||||||
<data android:host="mangaaction.com" />
|
|
||||||
<data android:host="mangaatrend.net" />
|
|
||||||
<data android:host="mangabaz.net" />
|
|
||||||
<data android:host="mangabob.com" />
|
|
||||||
<data android:host="mangabuddy.com" />
|
|
||||||
<data android:host="mangacim.com" />
|
|
||||||
<data android:host="mangaclash.com" />
|
|
||||||
<data android:host="mangacultivator.com" />
|
|
||||||
<data android:host="mangacute.com" />
|
|
||||||
<data android:host="mangacv.com" />
|
|
||||||
<data android:host="mangadass.com" />
|
|
||||||
<data android:host="mangadeemak.com" />
|
|
||||||
<data android:host="mangadex.org" />
|
|
||||||
<data android:host="mangadistrict.com" />
|
|
||||||
<data android:host="mangadna.com" />
|
|
||||||
<data android:host="mangadoor.com" />
|
|
||||||
<data android:host="mangaeffect.com" />
|
|
||||||
<data android:host="mangaforest.me" />
|
|
||||||
<data android:host="mangaforfree.com" />
|
|
||||||
<data android:host="mangafoxfull.com" />
|
|
||||||
<data android:host="mangafreak.online" />
|
|
||||||
<data android:host="mangagalaxy.me" />
|
|
||||||
<data android:host="mangagg.com" />
|
|
||||||
<data android:host="mangagoyaoi.com" />
|
|
||||||
<data android:host="mangagreat.com" />
|
|
||||||
<data android:host="mangahentai.me" />
|
|
||||||
<data android:host="mangahub.fr" />
|
|
||||||
<data android:host="mangaid.click" />
|
|
||||||
<data android:host="mangaindo.me" />
|
|
||||||
<data android:host="mangak2.com" />
|
|
||||||
<data android:host="mangakakalot.com" />
|
|
||||||
<data android:host="mangakeyfi.net" />
|
|
||||||
<data android:host="mangaking.net" />
|
|
||||||
<data android:host="mangakio.me" />
|
|
||||||
<data android:host="mangakiss.org" />
|
|
||||||
<data android:host="mangakita.net" />
|
|
||||||
<data android:host="mangakomi.io" />
|
|
||||||
<data android:host="mangakyo.org" />
|
|
||||||
<data android:host="mangalek.com" />
|
|
||||||
<data android:host="mangaleks.com" />
|
|
||||||
<data android:host="mangaleveling.com" />
|
|
||||||
<data android:host="mangalib.me" />
|
|
||||||
<data android:host="mangalike.me" />
|
|
||||||
<data android:host="mangalink.online" />
|
|
||||||
<data android:host="mangalionz.com" />
|
|
||||||
<data android:host="mangamammy.ru" />
|
|
||||||
<data android:host="mangamanhua.online" />
|
|
||||||
<data android:host="mangamaniacs.org" />
|
|
||||||
<data android:host="manganato.com" />
|
|
||||||
<data android:host="mangaokutr.com" />
|
|
||||||
<data android:host="mangaonelove.site" />
|
|
||||||
<data android:host="mangaonlineteam.com" />
|
|
||||||
<data android:host="mangaowl.to" />
|
|
||||||
<data android:host="mangaprotm.com" />
|
|
||||||
<data android:host="mangapt.com" />
|
|
||||||
<data android:host="mangapuma.com" />
|
|
||||||
<data android:host="mangaread.co" />
|
|
||||||
<data android:host="mangareaderpro.com" />
|
|
||||||
<data android:host="mangareading.org" />
|
|
||||||
<data android:host="mangarockteam.com" />
|
|
||||||
<data android:host="mangarocky.com" />
|
|
||||||
<data android:host="mangarolls.net" />
|
|
||||||
<data android:host="mangarosie.in" />
|
|
||||||
<data android:host="mangas-origines.fr" />
|
|
||||||
<data android:host="mangas-origines.xyz" />
|
|
||||||
<data android:host="mangaschan.com" />
|
|
||||||
<data android:host="mangasehri.com" />
|
|
||||||
<data android:host="mangaspark.com" />
|
|
||||||
<data android:host="mangastarz.com" />
|
|
||||||
<data android:host="mangastic.cc" />
|
|
||||||
<data android:host="mangastic.cc" />
|
|
||||||
<data android:host="mangasushi.org" />
|
|
||||||
<data android:host="mangasusuku.xyz" />
|
|
||||||
<data android:host="mangatale.co" />
|
|
||||||
<data android:host="mangatone.com" />
|
|
||||||
<data android:host="mangatoto.com" />
|
|
||||||
<data android:host="mangatoto.net" />
|
|
||||||
<data android:host="mangatoto.org" />
|
|
||||||
<data android:host="mangatx.com" />
|
|
||||||
<data android:host="mangaus.xyz" />
|
|
||||||
<data android:host="mangavisa.com" />
|
|
||||||
<data android:host="mangaweebs.in" />
|
|
||||||
<data android:host="mangawt.com" />
|
|
||||||
<data android:host="mangax1.com" />
|
|
||||||
<data android:host="mangaxyz.com" />
|
|
||||||
<data android:host="mangayaro.net" />
|
|
||||||
<data android:host="mangazavr.ru" />
|
|
||||||
<data android:host="mangazodiac.com" />
|
|
||||||
<data android:host="manhatic.com" />
|
|
||||||
<data android:host="manhuaes.com" />
|
|
||||||
<data android:host="manhuafast.com" />
|
|
||||||
<data android:host="manhuafast.net" />
|
|
||||||
<data android:host="manhuaga.com" />
|
|
||||||
<data android:host="manhuahot.com" />
|
|
||||||
<data android:host="manhuamix.com" />
|
|
||||||
<data android:host="manhuaplus.com" />
|
|
||||||
<data android:host="manhuascan.us" />
|
|
||||||
<data android:host="manhuaus.com" />
|
|
||||||
<data android:host="manhuazone.net" />
|
|
||||||
<data android:host="manhwa18.app" />
|
|
||||||
<data android:host="manhwa18.com" />
|
|
||||||
<data android:host="manhwa18.net" />
|
|
||||||
<data android:host="manhwa18.org" />
|
|
||||||
<data android:host="manhwa68.com" />
|
|
||||||
<data android:host="manhwa-latino.com" />
|
|
||||||
<data android:host="manhwaclan.com" />
|
|
||||||
<data android:host="manhwadesu.top" />
|
|
||||||
<data android:host="manhwafull.com" />
|
|
||||||
<data android:host="manhwahentai.me" />
|
|
||||||
<data android:host="manhwaindo.icu" />
|
|
||||||
<data android:host="manhwaindo.id" />
|
|
||||||
<data android:host="manhwakool.com" />
|
|
||||||
<data android:host="manhwalist.xyz" />
|
|
||||||
<data android:host="manhwalover.com" />
|
|
||||||
<data android:host="manhwaplus.pro" />
|
|
||||||
<data android:host="manhwasco.net" />
|
|
||||||
<data android:host="manhwatop.com" />
|
|
||||||
<data android:host="manhwaworld.com" />
|
|
||||||
<data android:host="manhwax.org" />
|
|
||||||
<data android:host="manhwaz.com" />
|
|
||||||
<data android:host="mantrazscan.com" />
|
|
||||||
<data android:host="manwe.pro" />
|
|
||||||
<data android:host="manycomic.com" />
|
|
||||||
<data android:host="manytoon.com" />
|
|
||||||
<data android:host="manytoon.me" />
|
|
||||||
<data android:host="masterkomik.com" />
|
|
||||||
<data android:host="melokomik.xyz" />
|
|
||||||
<data android:host="mgkomik.com" />
|
|
||||||
<data android:host="miauscans.com" />
|
|
||||||
<data android:host="milftoon.xxx" />
|
|
||||||
<data android:host="mintmanga.com" />
|
|
||||||
<data android:host="mintmanga.live" />
|
|
||||||
<data android:host="mirrordesu.ink" />
|
|
||||||
<data android:host="mm-scans.org" />
|
|
||||||
<data android:host="momonohanascan.com" />
|
|
||||||
<data android:host="monarcamanga.com" />
|
|
||||||
<data android:host="moonloversscan.com.br" />
|
|
||||||
<data android:host="moonwitchinlovescan.com" />
|
|
||||||
<data android:host="mortalsgroove.com" />
|
|
||||||
<data android:host="mto.to" />
|
|
||||||
<data android:host="mundomangakun.com.br" />
|
|
||||||
<data android:host="mundomanhwa.com" />
|
|
||||||
<data android:host="murimscan.run" />
|
|
||||||
<data android:host="neatmangas.com" />
|
|
||||||
<data android:host="neoxscans.net" />
|
|
||||||
<data android:host="nettruyenin.com" />
|
|
||||||
<data android:host="nettruyento.com" />
|
|
||||||
<data android:host="neumanga.net" />
|
|
||||||
<data android:host="neumanga.xyz" />
|
|
||||||
<data android:host="nhattruyenmin.com" />
|
|
||||||
<data android:host="nhentai.net" />
|
|
||||||
<data android:host="nicovideo.jp" />
|
|
||||||
<data android:host="nightscans.org" />
|
|
||||||
<data android:host="niji-translations.com" />
|
|
||||||
<data android:host="ninjascan.site" />
|
|
||||||
<data android:host="niverafansub.com" />
|
|
||||||
<data android:host="nocsummer.com.br" />
|
|
||||||
<data android:host="noindexscan.com" />
|
|
||||||
<data android:host="nonbiri.space" />
|
|
||||||
<data android:host="novelcrow.com" />
|
|
||||||
<data android:host="novelmic.com" />
|
|
||||||
<data android:host="novelstown.cyou" />
|
|
||||||
<data android:host="nude-moon.net" />
|
|
||||||
<data android:host="nude-moon.org" />
|
|
||||||
<data android:host="nyxmanga.com" />
|
|
||||||
<data android:host="origami-orpheans.com.br" />
|
|
||||||
<data android:host="otsugami.id" />
|
|
||||||
<data android:host="oxapk.com" />
|
|
||||||
<data android:host="ozulmanga.com" />
|
|
||||||
<data android:host="painfulnightz.com" />
|
|
||||||
<data android:host="pantheon-scan.com" />
|
|
||||||
<data android:host="papscan.com" />
|
|
||||||
<data android:host="paragonscans.com" />
|
|
||||||
<data android:host="peacescans.com" />
|
|
||||||
<data android:host="phantomscans.com" />
|
|
||||||
<data android:host="phenixscans.fr" />
|
|
||||||
<data android:host="pianmanga.me" />
|
|
||||||
<data android:host="pirulitorosa.site" />
|
|
||||||
<data android:host="piscans.in" />
|
|
||||||
<data android:host="platinumscans.com" />
|
|
||||||
<data android:host="pojokmanga.net" />
|
|
||||||
<data android:host="popsmanga.com" />
|
|
||||||
<data android:host="portalyaoi.com" />
|
|
||||||
<data android:host="prismahentai.com" />
|
|
||||||
<data android:host="prismascans.net" />
|
|
||||||
<data android:host="projetoscanlator.com" />
|
|
||||||
<data android:host="psunicorn.com" />
|
|
||||||
<data android:host="queenscans.com" />
|
|
||||||
<data android:host="ragnarokscan.com" />
|
|
||||||
<data android:host="ragnarokscanlation.com" />
|
|
||||||
<data android:host="raijinscans.fr" />
|
|
||||||
<data android:host="raikiscan.com" />
|
|
||||||
<data android:host="rainbowfairyscan.com" />
|
|
||||||
<data android:host="randomscans.com" />
|
|
||||||
<data android:host="ravenscans.com" />
|
|
||||||
<data android:host="rawdex.net" />
|
|
||||||
<data android:host="rawkuma.com" />
|
|
||||||
<data android:host="read-nifteam.info" />
|
|
||||||
<data android:host="read.babelwuxia.com" />
|
|
||||||
<data android:host="readcomicsonline.ru" />
|
|
||||||
<data android:host="reader.deathtollscans.net" />
|
|
||||||
<data android:host="reader.decadencescans.com" />
|
|
||||||
<data android:host="reader.evilflowers.com" />
|
|
||||||
<data android:host="reader.mangatellers.gr" />
|
|
||||||
<data android:host="reader.onepiecenakama.pl" />
|
|
||||||
<data android:host="reader.powermanga.org" />
|
|
||||||
<data android:host="reader.silentsky-scans.net" />
|
|
||||||
<data android:host="readfreecomics.com" />
|
|
||||||
<data android:host="readkomik.com" />
|
|
||||||
<data android:host="readmanga.io" />
|
|
||||||
<data android:host="readmanga.live" />
|
|
||||||
<data android:host="readmanga.me" />
|
|
||||||
<data android:host="readmangabat.com" />
|
|
||||||
<data android:host="readmanhua.net" />
|
|
||||||
<data android:host="readtoto.com" />
|
|
||||||
<data android:host="readtoto.net" />
|
|
||||||
<data android:host="readtoto.org" />
|
|
||||||
<data android:host="realmscans.xyz" />
|
|
||||||
<data android:host="reaperscans.fr" />
|
|
||||||
<data android:host="remanga.org" />
|
|
||||||
<data android:host="rightdark-scan.com" />
|
|
||||||
<data android:host="rio2manga.com" />
|
|
||||||
<data android:host="rio2manga.net" />
|
|
||||||
<data android:host="rogmangas.com" />
|
|
||||||
<data android:host="romantikmanga.com" />
|
|
||||||
<data android:host="ru.ninemanga.com" />
|
|
||||||
<data android:host="s2manga.com" />
|
|
||||||
<data android:host="samuraiscan.com" />
|
|
||||||
<data android:host="sawamics.com" />
|
|
||||||
<data android:host="saytruyenhay.com" />
|
|
||||||
<data android:host="scambertraslator.com" />
|
|
||||||
<data android:host="scan.hentai.menu" />
|
|
||||||
<data android:host="scanmanga-vf.ws" />
|
|
||||||
<data android:host="scansmangas.me" />
|
|
||||||
<data android:host="scansraw.com" />
|
|
||||||
<data android:host="scantrad-union.com" />
|
|
||||||
<data android:host="scantrad-vf.co" />
|
|
||||||
<data android:host="sekaikomik.pro" />
|
|
||||||
<data android:host="sektedoujin.cc" />
|
|
||||||
<data android:host="sektekomik.xyz" />
|
|
||||||
<data android:host="selfmanga.live" />
|
|
||||||
<data android:host="senpaiediciones.com" />
|
|
||||||
<data android:host="shadowmangas.com" />
|
|
||||||
<data android:host="shadowtrad.net" />
|
|
||||||
<data android:host="sheakomik.com" />
|
|
||||||
<data android:host="shibamanga.com" />
|
|
||||||
<data android:host="shinigami.id" />
|
|
||||||
<data android:host="shirodoujin.com" />
|
|
||||||
<data android:host="shootingstarscans.com" />
|
|
||||||
<data android:host="silencescan.com.br" />
|
|
||||||
<data android:host="sinensisscans.com" />
|
|
||||||
<data android:host="skanlacje-feniksy.pl" />
|
|
||||||
<data android:host="skymanga.work" />
|
|
||||||
<data android:host="skymangas.com" />
|
|
||||||
<data android:host="sleepytranslations.com" />
|
|
||||||
<data android:host="soulscans.my.id" />
|
|
||||||
<data android:host="spartanmanga.com.tr" />
|
|
||||||
<data android:host="sssscanlator.com" />
|
|
||||||
<data android:host="summanga.com" />
|
|
||||||
<data android:host="suryascans.com" />
|
|
||||||
<data android:host="sushiscan.fr" />
|
|
||||||
<data android:host="sushiscan.net" />
|
|
||||||
<data android:host="swatop.club" />
|
|
||||||
<data android:host="tankouhentai.com" />
|
|
||||||
<data android:host="tatakaescan.com" />
|
|
||||||
<data android:host="tecnoscann.com" />
|
|
||||||
<data android:host="teenmanhua.com" />
|
|
||||||
<data android:host="tempestfansub.com" />
|
|
||||||
<data android:host="templescan.net" />
|
|
||||||
<data android:host="templescanesp.com" />
|
|
||||||
<data android:host="tenkaiscan.net" />
|
|
||||||
<data android:host="theguildscans.com" />
|
|
||||||
<data android:host="thesugarscan.com" />
|
|
||||||
<data android:host="timenaight.com" />
|
|
||||||
<data android:host="todaymic.com" />
|
|
||||||
<data android:host="tonizutoon.com" />
|
|
||||||
<data android:host="toonchill.com" />
|
|
||||||
<data android:host="toonfr.com" />
|
|
||||||
<data android:host="toonhunter.com" />
|
|
||||||
<data android:host="toonily.com" />
|
|
||||||
<data android:host="toonily.me" />
|
|
||||||
<data android:host="toonily.net" />
|
|
||||||
<data android:host="toonitube.com" />
|
|
||||||
<data android:host="tortuga-ceviri.com" />
|
|
||||||
<data android:host="traduccionesmoonlight.com" />
|
|
||||||
<data android:host="treemanga.com" />
|
|
||||||
<data android:host="tritinia.org" />
|
|
||||||
<data android:host="truemanga.com" />
|
|
||||||
<data android:host="truyentranhlh.net" />
|
|
||||||
<data android:host="tsundoku.com.br" />
|
|
||||||
<data android:host="tukangkomik.id" />
|
|
||||||
<data android:host="tumanhwas.club" />
|
|
||||||
<data android:host="turktoon.com" />
|
|
||||||
<data android:host="v2.comiz.net" />
|
|
||||||
<data android:host="valkyriescan.com" />
|
|
||||||
<data android:host="vercomicsporno.com" />
|
|
||||||
<data android:host="vermangasporno.com" />
|
|
||||||
<data android:host="vermanhwa.es" />
|
|
||||||
<data android:host="viyafansub.com" />
|
|
||||||
<data android:host="void-scans.com" />
|
|
||||||
<data android:host="w.mangairo.com" />
|
|
||||||
<data android:host="wakamics.net" />
|
|
||||||
<data android:host="webcomic.me" />
|
|
||||||
<data android:host="webtoon-tr.com" />
|
|
||||||
<data android:host="webtoon.uk" />
|
|
||||||
<data android:host="webtoonempire.org" />
|
|
||||||
<data android:host="webtoonhatti.com" />
|
|
||||||
<data android:host="webtoons.top" />
|
|
||||||
<data android:host="webtoonscan.com" />
|
|
||||||
<data android:host="weloma.art" />
|
|
||||||
<data android:host="welovemanga.one" />
|
|
||||||
<data android:host="westmanga.info" />
|
|
||||||
<data android:host="wickedwitchscan.com" />
|
|
||||||
<data android:host="winterscan.com" />
|
|
||||||
<data android:host="wonderlandscan.com" />
|
|
||||||
<data android:host="woopread.com" />
|
|
||||||
<data android:host="worldmanhwas.bar" />
|
|
||||||
<data android:host="wto.to" />
|
|
||||||
<data android:host="www1.bluesolo.org" />
|
|
||||||
<data android:host="www.areascans.net" />
|
|
||||||
<data android:host="www.bentomanga.com" />
|
|
||||||
<data android:host="www.eromiau.com" />
|
|
||||||
<data android:host="www.inu-manga.com" />
|
|
||||||
<data android:host="www.japscan.lol" />
|
|
||||||
<data android:host="www.kuroimanga.com" />
|
|
||||||
<data android:host="www.lami-manga.com" />
|
|
||||||
<data android:host="www.lelmanga.com" />
|
|
||||||
<data android:host="www.lianscans.my.id" />
|
|
||||||
<data android:host="www.maid.my.id" />
|
|
||||||
<data android:host="www.majorscans.com" />
|
|
||||||
<data android:host="www.mangadods.com" />
|
|
||||||
<data android:host="www.mangaread.org" />
|
|
||||||
<data android:host="www.mangascantrad.fr" />
|
|
||||||
<data android:host="www.mangatown.com" />
|
|
||||||
<data android:host="www.manhuabug.com" />
|
|
||||||
<data android:host="www.manhuakey.com" />
|
|
||||||
<data android:host="www.manhuasy.com" />
|
|
||||||
<data android:host="www.menudo-fansub.com" />
|
|
||||||
<data android:host="www.nettruyenmax.com" />
|
|
||||||
<data android:host="www.nettruyento.com" />
|
|
||||||
<data android:host="www.nightcomic.com" />
|
|
||||||
<data android:host="www.ninemanga.com" />
|
|
||||||
<data android:host="www.noblessetranslations.com" />
|
|
||||||
<data android:host="www.pantheon-scan.fr" />
|
|
||||||
<data android:host="www.paritehaber.com" />
|
|
||||||
<data android:host="www.peachscan.com" />
|
|
||||||
<data android:host="www.petrotechsociety.org" />
|
|
||||||
<data android:host="www.petrotechsociety.org" />
|
|
||||||
<data android:host="www.ramareader.it" />
|
|
||||||
<data android:host="www.rh2plusmanga.com" />
|
|
||||||
<data android:host="www.ruyamanga.com" />
|
|
||||||
<data android:host="www.scan-fr.org" />
|
|
||||||
<data android:host="www.scan-vf.net" />
|
|
||||||
<data android:host="www.thaimanga.net" />
|
|
||||||
<data android:host="www.topmanhua.com" />
|
|
||||||
<data android:host="www.vfscan.com" />
|
|
||||||
<data android:host="www.walpurgiscan.it" />
|
|
||||||
<data android:host="www.webtoon.xyz" />
|
|
||||||
<data android:host="www.witcomics.net" />
|
|
||||||
<data android:host="www.xn--l3c0azab5a2gta.com" />
|
|
||||||
<data android:host="www.yaoitoshokan.net" />
|
|
||||||
<data android:host="xbato.com" />
|
|
||||||
<data android:host="xbato.net" />
|
|
||||||
<data android:host="xbato.org" />
|
|
||||||
<data android:host="xoxocomics.net" />
|
|
||||||
<data android:host="xx.hentaichan.live" />
|
|
||||||
<data android:host="xxx.hentaichan.live" />
|
|
||||||
<data android:host="y.hentaichan.live" />
|
|
||||||
<data android:host="yaoi-chan.me" />
|
|
||||||
<data android:host="yaoi.mobi" />
|
|
||||||
<data android:host="yaoilib.me" />
|
|
||||||
<data android:host="yaoiscan.com" />
|
|
||||||
<data android:host="ycscan.com" />
|
|
||||||
<data android:host="yugenmangas.com.br" />
|
|
||||||
<data android:host="yuri.live" />
|
|
||||||
<data android:host="zahard.xyz" />
|
|
||||||
<data android:host="zandynofansub.aishiteru.org" />
|
|
||||||
<data android:host="zbato.com" />
|
|
||||||
<data android:host="zbato.net" />
|
|
||||||
<data android:host="zbato.org" />
|
|
||||||
<data android:host="zeroscan.com.br" />
|
|
||||||
<data android:host="zinmanga.com" />
|
|
||||||
<data android:host="zinmanhwa.com" />
|
|
||||||
<data android:host="zuttomanga.com" />
|
|
||||||
<data android:host="реманга.орг" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity-alias>
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -1,37 +1,33 @@
|
|||||||
package org.koitharu.kotatsu.core
|
package org.koitharu.kotatsu
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.StrictMode
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.fragment.app.strictmode.FragmentStrictMode
|
||||||
import androidx.hilt.work.HiltWorkerFactory
|
import androidx.hilt.work.HiltWorkerFactory
|
||||||
import androidx.room.InvalidationTracker
|
import androidx.room.InvalidationTracker
|
||||||
import androidx.work.Configuration
|
import androidx.work.Configuration
|
||||||
import androidx.work.WorkManager
|
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import org.acra.ACRA
|
|
||||||
import org.acra.ReportField
|
import org.acra.ReportField
|
||||||
import org.acra.config.dialog
|
import org.acra.config.dialog
|
||||||
import org.acra.config.httpSender
|
import org.acra.config.httpSender
|
||||||
import org.acra.data.StringFormat
|
import org.acra.data.StringFormat
|
||||||
import org.acra.ktx.initAcra
|
import org.acra.ktx.initAcra
|
||||||
import org.acra.sender.HttpSender
|
import org.acra.sender.HttpSender
|
||||||
import org.koitharu.kotatsu.BuildConfig
|
|
||||||
import org.koitharu.kotatsu.R
|
|
||||||
import org.koitharu.kotatsu.core.db.MangaDatabase
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
import org.koitharu.kotatsu.core.os.AppValidator
|
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.core.util.WorkServiceStopHelper
|
import org.koitharu.kotatsu.local.data.PagesCache
|
||||||
import org.koitharu.kotatsu.core.util.ext.processLifecycleScope
|
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
||||||
import org.koitharu.kotatsu.settings.work.WorkScheduleManager
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||||
|
import org.koitharu.kotatsu.utils.ext.processLifecycleScope
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Provider
|
|
||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
open class BaseApp : Application(), Configuration.Provider {
|
class KotatsuApp : Application(), Configuration.Provider {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var databaseObservers: Set<@JvmSuppressWildcards InvalidationTracker.Observer>
|
lateinit var databaseObservers: Set<@JvmSuppressWildcards InvalidationTracker.Observer>
|
||||||
@@ -40,7 +36,7 @@ open class BaseApp : Application(), Configuration.Provider {
|
|||||||
lateinit var activityLifecycleCallbacks: Set<@JvmSuppressWildcards ActivityLifecycleCallbacks>
|
lateinit var activityLifecycleCallbacks: Set<@JvmSuppressWildcards ActivityLifecycleCallbacks>
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var database: Provider<MangaDatabase>
|
lateinit var database: MangaDatabase
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var settings: AppSettings
|
lateinit var settings: AppSettings
|
||||||
@@ -48,36 +44,17 @@ open class BaseApp : Application(), Configuration.Provider {
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var workerFactory: HiltWorkerFactory
|
lateinit var workerFactory: HiltWorkerFactory
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var appValidator: AppValidator
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var workScheduleManager: Provider<WorkScheduleManager>
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var workManagerProvider: Provider<WorkManager>
|
|
||||||
|
|
||||||
override val workManagerConfiguration: Configuration
|
|
||||||
get() = Configuration.Builder()
|
|
||||||
.setWorkerFactory(workerFactory)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
enableStrictMode()
|
||||||
|
}
|
||||||
AppCompatDelegate.setDefaultNightMode(settings.theme)
|
AppCompatDelegate.setDefaultNightMode(settings.theme)
|
||||||
AppCompatDelegate.setApplicationLocales(settings.appLocales)
|
AppCompatDelegate.setApplicationLocales(settings.appLocales)
|
||||||
setupActivityLifecycleCallbacks()
|
setupActivityLifecycleCallbacks()
|
||||||
processLifecycleScope.launch {
|
|
||||||
val isOriginalApp = withContext(Dispatchers.Default) {
|
|
||||||
appValidator.isOriginalApp
|
|
||||||
}
|
|
||||||
ACRA.errorReporter.putCustomData("isOriginalApp", isOriginalApp.toString())
|
|
||||||
}
|
|
||||||
processLifecycleScope.launch(Dispatchers.Default) {
|
processLifecycleScope.launch(Dispatchers.Default) {
|
||||||
setupDatabaseObservers()
|
setupDatabaseObservers()
|
||||||
}
|
}
|
||||||
workScheduleManager.get().init()
|
|
||||||
WorkServiceStopHelper(workManagerProvider).setup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attachBaseContext(base: Context?) {
|
override fun attachBaseContext(base: Context?) {
|
||||||
@@ -85,6 +62,9 @@ open class BaseApp : Application(), Configuration.Provider {
|
|||||||
initAcra {
|
initAcra {
|
||||||
buildConfigClass = BuildConfig::class.java
|
buildConfigClass = BuildConfig::class.java
|
||||||
reportFormat = StringFormat.JSON
|
reportFormat = StringFormat.JSON
|
||||||
|
excludeMatchingSharedPreferencesKeys = listOf(
|
||||||
|
"sources_\\w+",
|
||||||
|
)
|
||||||
httpSender {
|
httpSender {
|
||||||
uri = getString(R.string.url_error_report)
|
uri = getString(R.string.url_error_report)
|
||||||
basicAuthLogin = getString(R.string.acra_login)
|
basicAuthLogin = getString(R.string.acra_login)
|
||||||
@@ -100,9 +80,8 @@ open class BaseApp : Application(), Configuration.Provider {
|
|||||||
ReportField.PHONE_MODEL,
|
ReportField.PHONE_MODEL,
|
||||||
ReportField.STACK_TRACE,
|
ReportField.STACK_TRACE,
|
||||||
ReportField.CRASH_CONFIGURATION,
|
ReportField.CRASH_CONFIGURATION,
|
||||||
ReportField.CUSTOM_DATA,
|
ReportField.SHARED_PREFERENCES,
|
||||||
)
|
)
|
||||||
|
|
||||||
dialog {
|
dialog {
|
||||||
text = getString(R.string.crash_text)
|
text = getString(R.string.crash_text)
|
||||||
title = getString(R.string.error_occurred)
|
title = getString(R.string.error_occurred)
|
||||||
@@ -113,9 +92,15 @@ open class BaseApp : Application(), Configuration.Provider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getWorkManagerConfiguration(): Configuration {
|
||||||
|
return Configuration.Builder()
|
||||||
|
.setWorkerFactory(workerFactory)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private fun setupDatabaseObservers() {
|
private fun setupDatabaseObservers() {
|
||||||
val tracker = database.get().invalidationTracker
|
val tracker = database.invalidationTracker
|
||||||
databaseObservers.forEach {
|
databaseObservers.forEach {
|
||||||
tracker.addObserver(it)
|
tracker.addObserver(it)
|
||||||
}
|
}
|
||||||
@@ -126,4 +111,30 @@ open class BaseApp : Application(), Configuration.Provider {
|
|||||||
registerActivityLifecycleCallbacks(it)
|
registerActivityLifecycleCallbacks(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun enableStrictMode() {
|
||||||
|
StrictMode.setThreadPolicy(
|
||||||
|
StrictMode.ThreadPolicy.Builder()
|
||||||
|
.detectAll()
|
||||||
|
.penaltyLog()
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
|
StrictMode.setVmPolicy(
|
||||||
|
StrictMode.VmPolicy.Builder()
|
||||||
|
.detectAll()
|
||||||
|
.setClassInstanceLimit(LocalMangaRepository::class.java, 1)
|
||||||
|
.setClassInstanceLimit(PagesCache::class.java, 1)
|
||||||
|
.setClassInstanceLimit(MangaLoaderContext::class.java, 1)
|
||||||
|
.penaltyLog()
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
|
FragmentStrictMode.defaultPolicy = FragmentStrictMode.Policy.Builder()
|
||||||
|
.penaltyDeath()
|
||||||
|
.detectFragmentReuse()
|
||||||
|
.detectWrongFragmentContainer()
|
||||||
|
.detectRetainInstanceUsage()
|
||||||
|
.detectSetUserVisibleHint()
|
||||||
|
.detectFragmentTagUsage()
|
||||||
|
.build()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
package org.koitharu.kotatsu.base.domain
|
||||||
|
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
import android.net.Uri
|
||||||
|
import android.util.Size
|
||||||
|
import androidx.room.withTransaction
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlinx.coroutines.runInterruptible
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaPrefsEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toEntities
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toManga
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.toMangaTags
|
||||||
|
import org.koitharu.kotatsu.core.network.CommonHeaders
|
||||||
|
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||||
|
import org.koitharu.kotatsu.core.prefs.ReaderMode
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
|
import org.koitharu.kotatsu.parsers.util.await
|
||||||
|
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
|
||||||
|
import java.io.File
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
private const val MIN_WEBTOON_RATIO = 2
|
||||||
|
|
||||||
|
class MangaDataRepository @Inject constructor(
|
||||||
|
private val okHttpClient: OkHttpClient,
|
||||||
|
private val db: MangaDatabase,
|
||||||
|
) {
|
||||||
|
|
||||||
|
suspend fun saveReaderMode(manga: Manga, mode: ReaderMode) {
|
||||||
|
db.withTransaction {
|
||||||
|
storeManga(manga)
|
||||||
|
val entity = db.preferencesDao.find(manga.id) ?: newEntity(manga.id)
|
||||||
|
db.preferencesDao.upsert(entity.copy(mode = mode.id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun saveColorFilter(manga: Manga, colorFilter: ReaderColorFilter?) {
|
||||||
|
db.withTransaction {
|
||||||
|
storeManga(manga)
|
||||||
|
val entity = db.preferencesDao.find(manga.id) ?: newEntity(manga.id)
|
||||||
|
db.preferencesDao.upsert(
|
||||||
|
entity.copy(
|
||||||
|
cfBrightness = colorFilter?.brightness ?: 0f,
|
||||||
|
cfContrast = colorFilter?.contrast ?: 0f,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getReaderMode(mangaId: Long): ReaderMode? {
|
||||||
|
return db.preferencesDao.find(mangaId)?.let { ReaderMode.valueOf(it.mode) }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getColorFilter(mangaId: Long): ReaderColorFilter? {
|
||||||
|
return db.preferencesDao.find(mangaId)?.getColorFilterOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun observeColorFilter(mangaId: Long): Flow<ReaderColorFilter?> {
|
||||||
|
return db.preferencesDao.observe(mangaId)
|
||||||
|
.map { it?.getColorFilterOrNull() }
|
||||||
|
.distinctUntilChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun findMangaById(mangaId: Long): Manga? {
|
||||||
|
return db.mangaDao.find(mangaId)?.toManga()
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun resolveIntent(intent: MangaIntent): Manga? = when {
|
||||||
|
intent.manga != null -> intent.manga
|
||||||
|
intent.mangaId != 0L -> findMangaById(intent.mangaId)
|
||||||
|
else -> null // TODO resolve uri
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun storeManga(manga: Manga) {
|
||||||
|
val tags = manga.tags.toEntities()
|
||||||
|
db.withTransaction {
|
||||||
|
db.tagsDao.upsert(tags)
|
||||||
|
db.mangaDao.upsert(manga.toEntity(), tags)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun findTags(source: MangaSource): Set<MangaTag> {
|
||||||
|
return db.tagsDao.findTags(source.name).toMangaTags()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun MangaPrefsEntity.getColorFilterOrNull(): ReaderColorFilter? {
|
||||||
|
return if (cfBrightness != 0f || cfContrast != 0f) {
|
||||||
|
ReaderColorFilter(cfBrightness, cfContrast)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatic determine type of manga by page size
|
||||||
|
* @return ReaderMode.WEBTOON if page is wide
|
||||||
|
*/
|
||||||
|
suspend fun determineMangaIsWebtoon(repository: MangaRepository, pages: List<MangaPage>): Boolean {
|
||||||
|
val pageIndex = (pages.size * 0.3).roundToInt()
|
||||||
|
val page = requireNotNull(pages.getOrNull(pageIndex)) { "No pages" }
|
||||||
|
val url = repository.getPageUrl(page)
|
||||||
|
val uri = Uri.parse(url)
|
||||||
|
val size = if (uri.scheme == "cbz") {
|
||||||
|
runInterruptible(Dispatchers.IO) {
|
||||||
|
val zip = ZipFile(uri.schemeSpecificPart)
|
||||||
|
val entry = zip.getEntry(uri.fragment)
|
||||||
|
zip.getInputStream(entry).use {
|
||||||
|
getBitmapSize(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.get()
|
||||||
|
.tag(MangaSource::class.java, page.source)
|
||||||
|
.cacheControl(CommonHeaders.CACHE_CONTROL_DISABLED)
|
||||||
|
.build()
|
||||||
|
okHttpClient.newCall(request).await().use {
|
||||||
|
runInterruptible(Dispatchers.IO) {
|
||||||
|
getBitmapSize(it.body?.byteStream())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return size.width * MIN_WEBTOON_RATIO < size.height
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun newEntity(mangaId: Long) = MangaPrefsEntity(
|
||||||
|
mangaId = mangaId,
|
||||||
|
mode = -1,
|
||||||
|
cfBrightness = 0f,
|
||||||
|
cfContrast = 0f,
|
||||||
|
)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
suspend fun getImageMimeType(file: File): String? = runInterruptible(Dispatchers.IO) {
|
||||||
|
val options = BitmapFactory.Options().apply {
|
||||||
|
inJustDecodeBounds = true
|
||||||
|
}
|
||||||
|
BitmapFactory.decodeFile(file.path, options)?.recycle()
|
||||||
|
options.outMimeType
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getBitmapSize(input: InputStream?): Size {
|
||||||
|
val options = BitmapFactory.Options().apply {
|
||||||
|
inJustDecodeBounds = true
|
||||||
|
}
|
||||||
|
BitmapFactory.decodeStream(input, null, options)?.recycle()
|
||||||
|
val imageHeight: Int = options.outHeight
|
||||||
|
val imageWidth: Int = options.outWidth
|
||||||
|
check(imageHeight > 0 && imageWidth > 0)
|
||||||
|
return Size(imageWidth, imageHeight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.koitharu.kotatsu.base.domain
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getParcelableCompat
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getParcelableExtraCompat
|
||||||
|
|
||||||
|
class MangaIntent private constructor(
|
||||||
|
val manga: Manga?,
|
||||||
|
val mangaId: Long,
|
||||||
|
val uri: Uri?,
|
||||||
|
) {
|
||||||
|
|
||||||
|
constructor(intent: Intent?) : this(
|
||||||
|
manga = intent?.getParcelableExtraCompat<ParcelableManga>(KEY_MANGA)?.manga,
|
||||||
|
mangaId = intent?.getLongExtra(KEY_ID, ID_NONE) ?: ID_NONE,
|
||||||
|
uri = intent?.data,
|
||||||
|
)
|
||||||
|
|
||||||
|
constructor(args: Bundle?) : this(
|
||||||
|
manga = args?.getParcelableCompat<ParcelableManga>(KEY_MANGA)?.manga,
|
||||||
|
mangaId = args?.getLong(KEY_ID, ID_NONE) ?: ID_NONE,
|
||||||
|
uri = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
const val ID_NONE = 0L
|
||||||
|
|
||||||
|
const val KEY_MANGA = "manga"
|
||||||
|
const val KEY_ID = "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.domain
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineStart
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.NonCancellable
|
import kotlinx.coroutines.NonCancellable
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.koitharu.kotatsu.core.util.ext.processLifecycleScope
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
|
import org.koitharu.kotatsu.utils.ext.processLifecycleScope
|
||||||
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
import org.koitharu.kotatsu.utils.ext.runCatchingCancellable
|
||||||
|
|
||||||
fun interface ReversibleHandle {
|
fun interface ReversibleHandle {
|
||||||
|
|
||||||
suspend fun reverse()
|
suspend fun reverse()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ReversibleHandle.reverseAsync() = processLifecycleScope.launch(Dispatchers.Default, CoroutineStart.ATOMIC) {
|
fun ReversibleHandle.reverseAsync() = processLifecycleScope.launch(Dispatchers.Default) {
|
||||||
runCatchingCancellable {
|
runCatchingCancellable {
|
||||||
withContext(NonCancellable) {
|
withContext(NonCancellable) {
|
||||||
reverse()
|
reverse()
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
@@ -13,21 +12,18 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||||||
|
|
||||||
abstract class AlertDialogFragment<B : ViewBinding> : DialogFragment() {
|
abstract class AlertDialogFragment<B : ViewBinding> : DialogFragment() {
|
||||||
|
|
||||||
var viewBinding: B? = null
|
private var viewBinding: B? = null
|
||||||
private set
|
|
||||||
|
|
||||||
@Deprecated("", ReplaceWith("requireViewBinding()"))
|
|
||||||
protected val binding: B
|
protected val binding: B
|
||||||
get() = requireViewBinding()
|
get() = checkNotNull(viewBinding)
|
||||||
|
|
||||||
final override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
final override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val binding = onCreateViewBinding(layoutInflater, null)
|
val binding = onInflateView(layoutInflater, null)
|
||||||
viewBinding = binding
|
viewBinding = binding
|
||||||
return MaterialAlertDialogBuilder(requireContext(), theme)
|
return MaterialAlertDialogBuilder(requireContext(), theme)
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.run(::onBuildDialog)
|
.run(::onBuildDialog)
|
||||||
.create()
|
.create()
|
||||||
.also(::onDialogCreated)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun onCreateView(
|
final override fun onCreateView(
|
||||||
@@ -36,11 +32,6 @@ abstract class AlertDialogFragment<B : ViewBinding> : DialogFragment() {
|
|||||||
savedInstanceState: Bundle?,
|
savedInstanceState: Bundle?,
|
||||||
) = viewBinding?.root
|
) = viewBinding?.root
|
||||||
|
|
||||||
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
onViewBindingCreated(requireViewBinding(), savedInstanceState)
|
|
||||||
}
|
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
viewBinding = null
|
viewBinding = null
|
||||||
@@ -51,14 +42,7 @@ abstract class AlertDialogFragment<B : ViewBinding> : DialogFragment() {
|
|||||||
|
|
||||||
open fun onDialogCreated(dialog: AlertDialog) = Unit
|
open fun onDialogCreated(dialog: AlertDialog) = Unit
|
||||||
|
|
||||||
@Deprecated("", ReplaceWith("viewBinding"))
|
protected fun bindingOrNull(): B? = viewBinding
|
||||||
protected fun bindingOrNull() = viewBinding
|
|
||||||
|
|
||||||
fun requireViewBinding(): B = checkNotNull(viewBinding) {
|
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
||||||
"Fragment $this did not return a ViewBinding from onCreateView() or this was called before onCreateView()."
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract fun onCreateViewBinding(inflater: LayoutInflater, container: ViewGroup?): B
|
|
||||||
|
|
||||||
protected open fun onViewBindingCreated(binding: B, savedInstanceState: Bundle?) = Unit
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
@@ -24,55 +23,42 @@ import androidx.viewbinding.ViewBinding
|
|||||||
import dagger.hilt.android.EntryPointAccessors
|
import dagger.hilt.android.EntryPointAccessors
|
||||||
import org.koitharu.kotatsu.BuildConfig
|
import org.koitharu.kotatsu.BuildConfig
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.ActionModeDelegate
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.BaseActivityEntryPoint
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.inject
|
||||||
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||||
import org.koitharu.kotatsu.core.ui.util.ActionModeDelegate
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.core.ui.util.BaseActivityEntryPoint
|
import org.koitharu.kotatsu.utils.ext.getThemeColor
|
||||||
import org.koitharu.kotatsu.core.ui.util.WindowInsetsDelegate
|
import javax.inject.Inject
|
||||||
import org.koitharu.kotatsu.core.util.ext.getThemeColor
|
|
||||||
|
|
||||||
@Suppress("LeakingThis")
|
|
||||||
abstract class BaseActivity<B : ViewBinding> :
|
abstract class BaseActivity<B : ViewBinding> :
|
||||||
AppCompatActivity(),
|
AppCompatActivity(),
|
||||||
WindowInsetsDelegate.WindowInsetsListener {
|
WindowInsetsDelegate.WindowInsetsListener {
|
||||||
|
|
||||||
private var isAmoledTheme = false
|
@Inject
|
||||||
|
lateinit var settings: AppSettings
|
||||||
|
|
||||||
lateinit var viewBinding: B
|
protected lateinit var binding: B
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@JvmField
|
@Suppress("LeakingThis")
|
||||||
protected val exceptionResolver = ExceptionResolver(this)
|
protected val exceptionResolver = ExceptionResolver(this)
|
||||||
|
|
||||||
@JvmField
|
@Suppress("LeakingThis")
|
||||||
protected val insetsDelegate = WindowInsetsDelegate()
|
protected val insetsDelegate = WindowInsetsDelegate(this)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val actionModeDelegate = ActionModeDelegate()
|
val actionModeDelegate = ActionModeDelegate()
|
||||||
|
|
||||||
private var defaultStatusBarColor = Color.TRANSPARENT
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
val settings = EntryPointAccessors.fromApplication(this, BaseActivityEntryPoint::class.java).settings
|
EntryPointAccessors.fromApplication(this, BaseActivityEntryPoint::class.java).inject(this)
|
||||||
isAmoledTheme = settings.isAmoledTheme
|
|
||||||
setTheme(settings.colorScheme.styleResId)
|
setTheme(settings.colorScheme.styleResId)
|
||||||
if (isAmoledTheme) {
|
if (settings.isAmoledTheme) {
|
||||||
setTheme(R.style.ThemeOverlay_Kotatsu_Amoled)
|
setTheme(R.style.ThemeOverlay_Kotatsu_Amoled)
|
||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
insetsDelegate.handleImeInsets = true
|
insetsDelegate.handleImeInsets = true
|
||||||
insetsDelegate.addInsetsListener(this)
|
|
||||||
putDataToExtras(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onPostCreate(savedInstanceState)
|
|
||||||
onBackPressedDispatcher.addCallback(actionModeDelegate)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
|
||||||
putDataToExtras(intent)
|
|
||||||
super.onNewIntent(intent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use ViewBinding", level = DeprecationLevel.ERROR)
|
@Deprecated("Use ViewBinding", level = DeprecationLevel.ERROR)
|
||||||
@@ -88,17 +74,18 @@ abstract class BaseActivity<B : ViewBinding> :
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected fun setContentView(binding: B) {
|
protected fun setContentView(binding: B) {
|
||||||
this.viewBinding = binding
|
this.binding = binding
|
||||||
super.setContentView(binding.root)
|
super.setContentView(binding.root)
|
||||||
val toolbar = (binding.root.findViewById<View>(R.id.toolbar) as? Toolbar)
|
val toolbar = (binding.root.findViewById<View>(R.id.toolbar) as? Toolbar)
|
||||||
toolbar?.let(this::setSupportActionBar)
|
toolbar?.let(this::setSupportActionBar)
|
||||||
insetsDelegate.onViewCreated(binding.root)
|
insetsDelegate.onViewCreated(binding.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSupportNavigateUp(): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem) = if (item.itemId == android.R.id.home) {
|
||||||
dispatchNavigateUp()
|
@Suppress("DEPRECATION")
|
||||||
return true
|
onBackPressed()
|
||||||
}
|
true
|
||||||
|
} else super.onOptionsItemSelected(item)
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||||
if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||||
@@ -115,22 +102,18 @@ abstract class BaseActivity<B : ViewBinding> :
|
|||||||
protected fun isDarkAmoledTheme(): Boolean {
|
protected fun isDarkAmoledTheme(): Boolean {
|
||||||
val uiMode = resources.configuration.uiMode
|
val uiMode = resources.configuration.uiMode
|
||||||
val isNight = uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
val isNight = uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||||
return isNight && isAmoledTheme
|
return isNight && settings.isAmoledTheme
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
override fun onSupportActionModeStarted(mode: ActionMode) {
|
override fun onSupportActionModeStarted(mode: ActionMode) {
|
||||||
super.onSupportActionModeStarted(mode)
|
super.onSupportActionModeStarted(mode)
|
||||||
actionModeDelegate.onSupportActionModeStarted(mode)
|
actionModeDelegate.onSupportActionModeStarted(mode)
|
||||||
val actionModeColor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
val actionModeColor = ColorUtils.compositeColors(
|
||||||
ColorUtils.compositeColors(
|
ContextCompat.getColor(this, com.google.android.material.R.color.m3_appbar_overlay_color),
|
||||||
ContextCompat.getColor(this, com.google.android.material.R.color.m3_appbar_overlay_color),
|
getThemeColor(com.google.android.material.R.attr.colorSurface),
|
||||||
getThemeColor(R.attr.m3ColorBackground),
|
)
|
||||||
)
|
val insets = ViewCompat.getRootWindowInsets(binding.root)
|
||||||
} else {
|
|
||||||
ContextCompat.getColor(this, R.color.kotatsu_m3_background)
|
|
||||||
}
|
|
||||||
val insets = ViewCompat.getRootWindowInsets(viewBinding.root)
|
|
||||||
?.getInsets(WindowInsetsCompat.Type.systemBars()) ?: return
|
?.getInsets(WindowInsetsCompat.Type.systemBars()) ?: return
|
||||||
findViewById<ActionBarContextView?>(androidx.appcompat.R.id.action_mode_bar).apply {
|
findViewById<ActionBarContextView?>(androidx.appcompat.R.id.action_mode_bar).apply {
|
||||||
setBackgroundColor(actionModeColor)
|
setBackgroundColor(actionModeColor)
|
||||||
@@ -138,7 +121,6 @@ abstract class BaseActivity<B : ViewBinding> :
|
|||||||
topMargin = insets.top
|
topMargin = insets.top
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaultStatusBarColor = window.statusBarColor
|
|
||||||
window.statusBarColor = actionModeColor
|
window.statusBarColor = actionModeColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,26 +128,20 @@ abstract class BaseActivity<B : ViewBinding> :
|
|||||||
override fun onSupportActionModeFinished(mode: ActionMode) {
|
override fun onSupportActionModeFinished(mode: ActionMode) {
|
||||||
super.onSupportActionModeFinished(mode)
|
super.onSupportActionModeFinished(mode)
|
||||||
actionModeDelegate.onSupportActionModeFinished(mode)
|
actionModeDelegate.onSupportActionModeFinished(mode)
|
||||||
window.statusBarColor = defaultStatusBarColor
|
window.statusBarColor = getThemeColor(android.R.attr.statusBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun dispatchNavigateUp() {
|
@Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
|
||||||
val upIntent = parentActivityIntent
|
@Deprecated("Should not be used")
|
||||||
if (upIntent != null) {
|
override fun onBackPressed() {
|
||||||
if (!navigateUpTo(upIntent)) {
|
if ( // https://issuetracker.google.com/issues/139738913
|
||||||
startActivity(upIntent)
|
Build.VERSION.SDK_INT == Build.VERSION_CODES.Q &&
|
||||||
}
|
isTaskRoot &&
|
||||||
} else {
|
supportFragmentManager.backStackEntryCount == 0
|
||||||
|
) {
|
||||||
finishAfterTransition()
|
finishAfterTransition()
|
||||||
|
} else {
|
||||||
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun putDataToExtras(intent: Intent?) {
|
|
||||||
intent?.putExtra(EXTRA_DATA, intent.data)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
const val EXTRA_DATA = "data"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewGroup.LayoutParams
|
||||||
|
import androidx.activity.OnBackPressedDispatcher
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.base.ui.dialog.AppBottomSheetDialog
|
||||||
|
import org.koitharu.kotatsu.utils.ext.displayCompat
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
|
abstract class BaseBottomSheet<B : ViewBinding> : BottomSheetDialogFragment() {
|
||||||
|
|
||||||
|
private var viewBinding: B? = null
|
||||||
|
|
||||||
|
protected val binding: B
|
||||||
|
get() = checkNotNull(viewBinding)
|
||||||
|
|
||||||
|
protected val behavior: BottomSheetBehavior<*>?
|
||||||
|
get() = (dialog as? BottomSheetDialog)?.behavior
|
||||||
|
|
||||||
|
val isExpanded: Boolean
|
||||||
|
get() = behavior?.state == BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
|
||||||
|
val onBackPressedDispatcher: OnBackPressedDispatcher
|
||||||
|
get() = (requireDialog() as AppBottomSheetDialog).onBackPressedDispatcher
|
||||||
|
|
||||||
|
final override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?,
|
||||||
|
): View {
|
||||||
|
val binding = onInflateView(inflater, container)
|
||||||
|
viewBinding = binding
|
||||||
|
|
||||||
|
// Enforce max width for tablets
|
||||||
|
val width = resources.getDimensionPixelSize(R.dimen.bottom_sheet_width)
|
||||||
|
if (width > 0) {
|
||||||
|
behavior?.maxWidth = width
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set peek height to 50% display height
|
||||||
|
requireContext().displayCompat?.let {
|
||||||
|
val metrics = DisplayMetrics()
|
||||||
|
it.getRealMetrics(metrics)
|
||||||
|
behavior?.peekHeight = (metrics.heightPixels * 0.4).toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
viewBinding = null
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
return AppBottomSheetDialog(requireContext(), theme)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addBottomSheetCallback(callback: BottomSheetBehavior.BottomSheetCallback) {
|
||||||
|
val b = behavior ?: return
|
||||||
|
b.addBottomSheetCallback(callback)
|
||||||
|
val rootView = dialog?.findViewById<View>(materialR.id.design_bottom_sheet)
|
||||||
|
if (rootView != null) {
|
||||||
|
callback.onStateChanged(rootView, b.state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
||||||
|
|
||||||
|
protected fun setExpanded(isExpanded: Boolean, isLocked: Boolean) {
|
||||||
|
val b = behavior ?: return
|
||||||
|
if (isExpanded) {
|
||||||
|
b.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
}
|
||||||
|
b.isFitToContents = !isExpanded
|
||||||
|
val rootView = dialog?.findViewById<View>(materialR.id.design_bottom_sheet)
|
||||||
|
rootView?.updateLayoutParams {
|
||||||
|
height = if (isExpanded) LayoutParams.MATCH_PARENT else LayoutParams.WRAP_CONTENT
|
||||||
|
}
|
||||||
|
b.isDraggable = !isLocked
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.ActionModeDelegate
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
||||||
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||||
|
|
||||||
|
abstract class BaseFragment<B : ViewBinding> :
|
||||||
|
Fragment(),
|
||||||
|
WindowInsetsDelegate.WindowInsetsListener {
|
||||||
|
|
||||||
|
private var viewBinding: B? = null
|
||||||
|
|
||||||
|
protected val binding: B
|
||||||
|
get() = checkNotNull(viewBinding)
|
||||||
|
|
||||||
|
@Suppress("LeakingThis")
|
||||||
|
protected val exceptionResolver = ExceptionResolver(this)
|
||||||
|
|
||||||
|
@Suppress("LeakingThis")
|
||||||
|
protected val insetsDelegate = WindowInsetsDelegate(this)
|
||||||
|
|
||||||
|
protected val actionModeDelegate: ActionModeDelegate
|
||||||
|
get() = (requireActivity() as BaseActivity<*>).actionModeDelegate
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
val binding = onInflateView(inflater, container)
|
||||||
|
viewBinding = binding
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
insetsDelegate.onViewCreated(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
viewBinding = null
|
||||||
|
insetsDelegate.onDestroyView()
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun bindingOrNull() = viewBinding
|
||||||
|
|
||||||
|
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.WindowManager
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
private const val SYSTEM_UI_FLAGS_SHOWN = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
private const val SYSTEM_UI_FLAGS_HIDDEN = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||||
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
||||||
|
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
||||||
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||||
|
|
||||||
|
abstract class BaseFullscreenActivity<B : ViewBinding> :
|
||||||
|
BaseActivity<B>(),
|
||||||
|
View.OnSystemUiVisibilityChangeListener {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
with(window) {
|
||||||
|
statusBarColor = Color.TRANSPARENT
|
||||||
|
navigationBarColor = Color.TRANSPARENT
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
attributes.layoutInDisplayCutoutMode =
|
||||||
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||||
|
}
|
||||||
|
decorView.setOnSystemUiVisibilityChangeListener(this@BaseFullscreenActivity)
|
||||||
|
}
|
||||||
|
showSystemUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
|
||||||
|
@Deprecated("Deprecated in Java")
|
||||||
|
final override fun onSystemUiVisibilityChange(visibility: Int) {
|
||||||
|
onSystemUiVisibilityChanged(visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO WindowInsetsControllerCompat works incorrect
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
protected fun hideSystemUI() {
|
||||||
|
window.decorView.systemUiVisibility = SYSTEM_UI_FLAGS_HIDDEN
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
protected fun showSystemUI() {
|
||||||
|
window.decorView.systemUiVisibility = SYSTEM_UI_FLAGS_SHOWN
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun onSystemUiVisibilityChanged(isVisible: Boolean) = Unit
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
import android.content.ActivityNotFoundException
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
@@ -10,16 +8,12 @@ import androidx.core.graphics.Insets
|
|||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.snackbar.Snackbar
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.koitharu.kotatsu.R
|
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
|
||||||
import org.koitharu.kotatsu.core.ui.util.RecyclerViewOwner
|
|
||||||
import org.koitharu.kotatsu.core.ui.util.WindowInsetsDelegate
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.getThemeColor
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.parentView
|
|
||||||
import org.koitharu.kotatsu.settings.SettingsActivity
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.RecyclerViewOwner
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
||||||
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
|
import org.koitharu.kotatsu.settings.SettingsHeadersFragment
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
||||||
@@ -30,30 +24,28 @@ abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var settings: AppSettings
|
lateinit var settings: AppSettings
|
||||||
|
|
||||||
@JvmField
|
@Suppress("LeakingThis")
|
||||||
protected val insetsDelegate = WindowInsetsDelegate()
|
protected val insetsDelegate = WindowInsetsDelegate(this)
|
||||||
|
|
||||||
override val recyclerView: RecyclerView
|
override val recyclerView: RecyclerView
|
||||||
get() = listView
|
get() = listView
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
val themedContext = (view.parentView ?: view).context
|
|
||||||
view.setBackgroundColor(themedContext.getThemeColor(android.R.attr.colorBackground))
|
|
||||||
listView.clipToPadding = false
|
listView.clipToPadding = false
|
||||||
insetsDelegate.onViewCreated(view)
|
insetsDelegate.onViewCreated(view)
|
||||||
insetsDelegate.addInsetsListener(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
insetsDelegate.removeInsetsListener(this)
|
|
||||||
insetsDelegate.onDestroyView()
|
insetsDelegate.onDestroyView()
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setTitle(if (titleId != 0) getString(titleId) else null)
|
if (titleId != 0) {
|
||||||
|
setTitle(getString(titleId))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
@@ -63,15 +55,9 @@ abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun setTitle(title: CharSequence?) {
|
@Suppress("UsePropertyAccessSyntax")
|
||||||
(activity as? SettingsActivity)?.setSectionTitle(title)
|
protected fun setTitle(title: CharSequence) {
|
||||||
}
|
(parentFragment as? SettingsHeadersFragment)?.setTitle(title)
|
||||||
|
?: activity?.setTitle(title)
|
||||||
protected fun startActivitySafe(intent: Intent) {
|
|
||||||
try {
|
|
||||||
startActivity(intent)
|
|
||||||
} catch (_: ActivityNotFoundException) {
|
|
||||||
Snackbar.make(listView, R.string.operation_not_supported, Snackbar.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleService
|
||||||
|
|
||||||
|
abstract class BaseService : LifecycleService()
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import org.koitharu.kotatsu.base.ui.util.CountedBooleanLiveData
|
||||||
|
import org.koitharu.kotatsu.utils.SingleLiveEvent
|
||||||
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
|
|
||||||
|
abstract class BaseViewModel : ViewModel() {
|
||||||
|
|
||||||
|
protected val loadingCounter = CountedBooleanLiveData()
|
||||||
|
protected val errorEvent = SingleLiveEvent<Throwable>()
|
||||||
|
|
||||||
|
val onError: LiveData<Throwable>
|
||||||
|
get() = errorEvent
|
||||||
|
|
||||||
|
val isLoading: LiveData<Boolean>
|
||||||
|
get() = loadingCounter
|
||||||
|
|
||||||
|
protected fun launchJob(
|
||||||
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
|
block: suspend CoroutineScope.() -> Unit
|
||||||
|
): Job = viewModelScope.launch(context + createErrorHandler(), start, block)
|
||||||
|
|
||||||
|
protected fun launchLoadingJob(
|
||||||
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
|
block: suspend CoroutineScope.() -> Unit
|
||||||
|
): Job = viewModelScope.launch(context + createErrorHandler(), start) {
|
||||||
|
loadingCounter.increment()
|
||||||
|
try {
|
||||||
|
block()
|
||||||
|
} finally {
|
||||||
|
loadingCounter.decrement()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createErrorHandler() = CoroutineExceptionHandler { _, throwable ->
|
||||||
|
throwable.printStackTraceDebug()
|
||||||
|
if (throwable !is CancellationException) {
|
||||||
|
errorEvent.postCall(throwable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
|
import android.app.Service
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import kotlinx.coroutines.CoroutineDispatcher
|
import kotlinx.coroutines.CoroutineDispatcher
|
||||||
@@ -9,7 +10,7 @@ import kotlinx.coroutines.launch
|
|||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
|
|
||||||
abstract class CoroutineIntentService : BaseService() {
|
abstract class CoroutineIntentService : BaseService() {
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ abstract class CoroutineIntentService : BaseService() {
|
|||||||
final override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
final override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
super.onStartCommand(intent, flags, startId)
|
super.onStartCommand(intent, flags, startId)
|
||||||
launchCoroutine(intent, startId)
|
launchCoroutine(intent, startId)
|
||||||
return START_REDELIVER_INTENT
|
return Service.START_REDELIVER_INTENT
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchCoroutine(intent: Intent?, startId: Int) = lifecycleScope.launch(errorHandler(startId)) {
|
private fun launchCoroutine(intent: Intent?, startId: Int) = lifecycleScope.launch(errorHandler(startId)) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
package org.koitharu.kotatsu.base.ui
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.Application.ActivityLifecycleCallbacks
|
import android.app.Application.ActivityLifecycleCallbacks
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.dialog
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.view.View
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
|
|
||||||
|
class AppBottomSheetDialog(context: Context, theme: Int) : BottomSheetDialog(context, theme) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/material-components/material-components-android/issues/2582
|
||||||
|
*/
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
override fun onAttachedToWindow() {
|
||||||
|
val window = window
|
||||||
|
val initialSystemUiVisibility = window?.decorView?.systemUiVisibility ?: 0
|
||||||
|
super.onAttachedToWindow()
|
||||||
|
if (window != null) {
|
||||||
|
// If the navigation bar is translucent at all, the BottomSheet should be edge to edge
|
||||||
|
val drawEdgeToEdge = edgeToEdgeEnabled && Color.alpha(window.navigationBarColor) < 0xFF
|
||||||
|
if (drawEdgeToEdge) {
|
||||||
|
// Copied from super.onAttachedToWindow:
|
||||||
|
val edgeToEdgeFlags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
// Fix super-class's window flag bug by respecting the initial system UI visibility:
|
||||||
|
window.decorView.systemUiVisibility = edgeToEdgeFlags or initialSystemUiVisibility
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.dialog
|
package org.koitharu.kotatsu.base.ui.dialog
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
@@ -77,4 +77,4 @@ class CheckBoxAlertDialog private constructor(private val delegate: AlertDialog)
|
|||||||
fun create() = CheckBoxAlertDialog(delegate.create())
|
fun create() = CheckBoxAlertDialog(delegate.create())
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.dialog
|
package org.koitharu.kotatsu.base.ui.dialog
|
||||||
|
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
|
||||||
@@ -10,4 +10,4 @@ class RememberSelectionDialogListener(initialValue: Int) : DialogInterface.OnCli
|
|||||||
override fun onClick(dialog: DialogInterface?, which: Int) {
|
override fun onClick(dialog: DialogInterface?, which: Int) {
|
||||||
selection = which
|
selection = which
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.dialog
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.BaseAdapter
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.databinding.ItemStorageBinding
|
||||||
|
import org.koitharu.kotatsu.local.data.LocalStorageManager
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class StorageSelectDialog private constructor(private val delegate: AlertDialog) :
|
||||||
|
DialogInterface by delegate {
|
||||||
|
|
||||||
|
fun show() = delegate.show()
|
||||||
|
|
||||||
|
class Builder(context: Context, storageManager: LocalStorageManager, listener: OnStorageSelectListener) {
|
||||||
|
|
||||||
|
private val adapter = VolumesAdapter(storageManager)
|
||||||
|
private val delegate = MaterialAlertDialogBuilder(context)
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (adapter.isEmpty) {
|
||||||
|
delegate.setMessage(R.string.cannot_find_available_storage)
|
||||||
|
} else {
|
||||||
|
val defaultValue = runBlocking {
|
||||||
|
storageManager.getDefaultWriteableDir()
|
||||||
|
}
|
||||||
|
adapter.selectedItemPosition = adapter.volumes.indexOfFirst {
|
||||||
|
it.first.canonicalPath == defaultValue?.canonicalPath
|
||||||
|
}
|
||||||
|
delegate.setAdapter(adapter) { d, i ->
|
||||||
|
listener.onStorageSelected(adapter.getItem(i).first)
|
||||||
|
d.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTitle(@StringRes titleResId: Int): Builder {
|
||||||
|
delegate.setTitle(titleResId)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTitle(title: CharSequence): Builder {
|
||||||
|
delegate.setTitle(title)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setNegativeButton(@StringRes textId: Int): Builder {
|
||||||
|
delegate.setNegativeButton(textId, null)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun create() = StorageSelectDialog(delegate.create())
|
||||||
|
}
|
||||||
|
|
||||||
|
private class VolumesAdapter(storageManager: LocalStorageManager) : BaseAdapter() {
|
||||||
|
|
||||||
|
var selectedItemPosition: Int = -1
|
||||||
|
val volumes = getAvailableVolumes(storageManager)
|
||||||
|
|
||||||
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
|
val view = convertView ?: LayoutInflater.from(parent.context).inflate(R.layout.item_storage, parent, false)
|
||||||
|
val binding = (view.tag as? ItemStorageBinding) ?: ItemStorageBinding.bind(view).also {
|
||||||
|
view.tag = it
|
||||||
|
}
|
||||||
|
val item = volumes[position]
|
||||||
|
binding.imageViewIndicator.isChecked = selectedItemPosition == position
|
||||||
|
binding.textViewTitle.text = item.second
|
||||||
|
binding.textViewSubtitle.text = item.first.path
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItem(position: Int): Pair<File, String> = volumes[position]
|
||||||
|
|
||||||
|
override fun getItemId(position: Int) = position.toLong()
|
||||||
|
|
||||||
|
override fun getCount() = volumes.size
|
||||||
|
|
||||||
|
override fun hasStableIds() = true
|
||||||
|
|
||||||
|
private fun getAvailableVolumes(storageManager: LocalStorageManager): List<Pair<File, String>> {
|
||||||
|
return runBlocking {
|
||||||
|
storageManager.getWriteableDirs().map {
|
||||||
|
it to storageManager.getStorageDisplayName(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interface OnStorageSelectListener {
|
||||||
|
|
||||||
|
fun onStorageSelected(file: File)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
@@ -1,41 +1,31 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
abstract class BoundsScrollListener(
|
abstract class BoundsScrollListener(private val offsetTop: Int, private val offsetBottom: Int) :
|
||||||
@JvmField protected val offsetTop: Int,
|
RecyclerView.OnScrollListener() {
|
||||||
@JvmField protected val offsetBottom: Int
|
|
||||||
) : RecyclerView.OnScrollListener() {
|
constructor(offset: Int = 0) : this(offset, offset)
|
||||||
|
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
if (recyclerView.hasPendingAdapterUpdates()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val layoutManager = (recyclerView.layoutManager as? LinearLayoutManager) ?: return
|
val layoutManager = (recyclerView.layoutManager as? LinearLayoutManager) ?: return
|
||||||
val firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition()
|
val firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition()
|
||||||
if (firstVisibleItemPosition == RecyclerView.NO_POSITION) {
|
if (firstVisibleItemPosition == RecyclerView.NO_POSITION) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (firstVisibleItemPosition <= offsetTop) {
|
||||||
|
onScrolledToStart(recyclerView)
|
||||||
|
}
|
||||||
val visibleItemCount = layoutManager.childCount
|
val visibleItemCount = layoutManager.childCount
|
||||||
val totalItemCount = layoutManager.itemCount
|
val totalItemCount = layoutManager.itemCount
|
||||||
if (visibleItemCount + firstVisibleItemPosition >= totalItemCount - offsetBottom) {
|
if (visibleItemCount + firstVisibleItemPosition >= totalItemCount - offsetBottom) {
|
||||||
onScrolledToEnd(recyclerView)
|
onScrolledToEnd(recyclerView)
|
||||||
}
|
}
|
||||||
if (firstVisibleItemPosition <= offsetTop) {
|
|
||||||
onScrolledToStart(recyclerView)
|
|
||||||
}
|
|
||||||
onPostScrolled(recyclerView, firstVisibleItemPosition, visibleItemCount)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun onScrolledToStart(recyclerView: RecyclerView)
|
abstract fun onScrolledToStart(recyclerView: RecyclerView)
|
||||||
|
|
||||||
abstract fun onScrolledToEnd(recyclerView: RecyclerView)
|
abstract fun onScrolledToEnd(recyclerView: RecyclerView)
|
||||||
|
}
|
||||||
protected open fun onPostScrolled(
|
|
||||||
recyclerView: RecyclerView,
|
|
||||||
firstVisibleItemPosition: Int,
|
|
||||||
visibleItemCount: Int
|
|
||||||
) = Unit
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
@@ -34,4 +34,4 @@ class FitHeightGridLayoutManager : GridLayoutManager {
|
|||||||
super.layoutDecoratedWithMargins(child, left, top, right, bottom)
|
super.layoutDecoratedWithMargins(child, left, top, right, bottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
@@ -34,4 +34,4 @@ class FitHeightLinearLayoutManager : LinearLayoutManager {
|
|||||||
super.layoutDecoratedWithMargins(child, left, top, right, bottom)
|
super.layoutDecoratedWithMargins(child, left, top, right, bottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -12,9 +12,9 @@ import androidx.lifecycle.LifecycleOwner
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.savedstate.SavedStateRegistry
|
import androidx.savedstate.SavedStateRegistry
|
||||||
import androidx.savedstate.SavedStateRegistryOwner
|
import androidx.savedstate.SavedStateRegistryOwner
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import org.koitharu.kotatsu.core.ui.list.decor.AbstractSelectionItemDecoration
|
|
||||||
import kotlin.coroutines.EmptyCoroutineContext
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.decor.AbstractSelectionItemDecoration
|
||||||
|
|
||||||
private const val KEY_SELECTION = "selection"
|
private const val KEY_SELECTION = "selection"
|
||||||
private const val PROVIDER_NAME = "selection_decoration"
|
private const val PROVIDER_NAME = "selection_decoration"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
||||||
fun interface OnListItemClickListener<I> {
|
interface OnListItemClickListener<I> {
|
||||||
|
|
||||||
fun onItemClick(item: I, view: View)
|
fun onItemClick(item: I, view: View)
|
||||||
|
|
||||||
fun onItemLongClick(item: I, view: View) = false
|
fun onItemLongClick(item: I, view: View) = false
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
@@ -15,4 +15,4 @@ class PaginationScrollListener(offset: Int, private val callback: Callback) :
|
|||||||
|
|
||||||
fun onScrolledToEnd()
|
fun onScrolledToEnd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,237 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.appcompat.view.ActionMode
|
||||||
|
import androidx.collection.ArrayMap
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.savedstate.SavedStateRegistry
|
||||||
|
import androidx.savedstate.SavedStateRegistryOwner
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.decor.AbstractSelectionItemDecoration
|
||||||
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
|
private const val PROVIDER_NAME = "selection_decoration_sectioned"
|
||||||
|
|
||||||
|
class SectionedSelectionController<T : Any>(
|
||||||
|
private val activity: Activity,
|
||||||
|
private val owner: SavedStateRegistryOwner,
|
||||||
|
private val callback: Callback<T>,
|
||||||
|
) : ActionMode.Callback, SavedStateRegistry.SavedStateProvider {
|
||||||
|
|
||||||
|
private var actionMode: ActionMode? = null
|
||||||
|
|
||||||
|
private var pendingData: MutableMap<String, Collection<Long>>? = null
|
||||||
|
private val decorations = ArrayMap<T, AbstractSelectionItemDecoration>()
|
||||||
|
|
||||||
|
val count: Int
|
||||||
|
get() = decorations.values.sumOf { it.checkedItemsCount }
|
||||||
|
|
||||||
|
init {
|
||||||
|
owner.lifecycle.addObserver(StateEventObserver())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun snapshot(): Map<T, Set<Long>> {
|
||||||
|
return decorations.mapValues { it.value.checkedItemsIds.toSet() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun peekCheckedIds(): Map<T, Set<Long>> {
|
||||||
|
return decorations.mapValues { it.value.checkedItemsIds }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clear() {
|
||||||
|
decorations.values.forEach {
|
||||||
|
it.clearSelection()
|
||||||
|
}
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun attachToRecyclerView(section: T, recyclerView: RecyclerView) {
|
||||||
|
val decoration = getDecoration(section)
|
||||||
|
val pendingIds = pendingData?.remove(section.toString())
|
||||||
|
if (!pendingIds.isNullOrEmpty()) {
|
||||||
|
decoration.checkAll(pendingIds)
|
||||||
|
startActionMode()
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
var shouldAddDecoration = true
|
||||||
|
for (i in (0 until recyclerView.itemDecorationCount).reversed()) {
|
||||||
|
val decor = recyclerView.getItemDecorationAt(i)
|
||||||
|
if (decor === decoration) {
|
||||||
|
shouldAddDecoration = false
|
||||||
|
break
|
||||||
|
} else if (decor.javaClass == decoration.javaClass) {
|
||||||
|
recyclerView.removeItemDecorationAt(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (shouldAddDecoration) {
|
||||||
|
recyclerView.addItemDecoration(decoration)
|
||||||
|
}
|
||||||
|
if (pendingData?.isEmpty() == true) {
|
||||||
|
pendingData = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun saveState(): Bundle {
|
||||||
|
val bundle = Bundle(decorations.size)
|
||||||
|
for ((k, v) in decorations) {
|
||||||
|
bundle.putLongArray(k.toString(), v.checkedItemsIds.toLongArray())
|
||||||
|
}
|
||||||
|
return bundle
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onItemClick(section: T, id: Long): Boolean {
|
||||||
|
val decoration = getDecoration(section)
|
||||||
|
if (isInSelectionMode()) {
|
||||||
|
decoration.toggleItemChecked(id)
|
||||||
|
if (isInSelectionMode()) {
|
||||||
|
actionMode?.invalidate()
|
||||||
|
} else {
|
||||||
|
actionMode?.finish()
|
||||||
|
}
|
||||||
|
notifySelectionChanged()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onItemLongClick(section: T, id: Long): Boolean {
|
||||||
|
val decoration = getDecoration(section)
|
||||||
|
startActionMode()
|
||||||
|
return actionMode?.also {
|
||||||
|
decoration.setItemIsChecked(id, true)
|
||||||
|
notifySelectionChanged()
|
||||||
|
} != null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSectionCount(section: T): Int {
|
||||||
|
return decorations[section]?.checkedItemsCount ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addToSelection(section: T, ids: Collection<Long>): Boolean {
|
||||||
|
val decoration = getDecoration(section)
|
||||||
|
startActionMode()
|
||||||
|
return actionMode?.also {
|
||||||
|
decoration.checkAll(ids)
|
||||||
|
notifySelectionChanged()
|
||||||
|
} != null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearSelection(section: T) {
|
||||||
|
decorations[section]?.clearSelection() ?: return
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
|
return callback.onCreateActionMode(this, mode, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
|
return callback.onPrepareActionMode(this, mode, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
|
return callback.onActionItemClicked(this, mode, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyActionMode(mode: ActionMode) {
|
||||||
|
callback.onDestroyActionMode(this, mode)
|
||||||
|
clear()
|
||||||
|
actionMode = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startActionMode() {
|
||||||
|
if (actionMode == null) {
|
||||||
|
actionMode = (activity as? AppCompatActivity)?.startSupportActionMode(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isInSelectionMode(): Boolean {
|
||||||
|
return decorations.values.any { x -> x.checkedItemsCount > 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifySelectionChanged() {
|
||||||
|
val count = this.count
|
||||||
|
callback.onSelectionChanged(this, count)
|
||||||
|
if (count == 0) {
|
||||||
|
actionMode?.finish()
|
||||||
|
} else {
|
||||||
|
actionMode?.invalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreState(ids: MutableMap<String, Collection<Long>>) {
|
||||||
|
if (ids.isEmpty() || isInSelectionMode()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for ((k, v) in decorations) {
|
||||||
|
val items = ids.remove(k.toString())
|
||||||
|
if (!items.isNullOrEmpty()) {
|
||||||
|
v.checkAll(items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pendingData = ids
|
||||||
|
if (isInSelectionMode()) {
|
||||||
|
startActionMode()
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDecoration(section: T): AbstractSelectionItemDecoration {
|
||||||
|
return decorations.getOrPut(section) {
|
||||||
|
callback.onCreateItemDecoration(this, section)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Callback<T : Any> {
|
||||||
|
|
||||||
|
fun onSelectionChanged(controller: SectionedSelectionController<T>, count: Int)
|
||||||
|
|
||||||
|
fun onCreateActionMode(controller: SectionedSelectionController<T>, mode: ActionMode, menu: Menu): Boolean
|
||||||
|
|
||||||
|
fun onPrepareActionMode(controller: SectionedSelectionController<T>, mode: ActionMode, menu: Menu): Boolean {
|
||||||
|
mode.title = controller.count.toString()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onDestroyActionMode(controller: SectionedSelectionController<T>, mode: ActionMode) = Unit
|
||||||
|
|
||||||
|
fun onActionItemClicked(
|
||||||
|
controller: SectionedSelectionController<T>,
|
||||||
|
mode: ActionMode,
|
||||||
|
item: MenuItem,
|
||||||
|
): Boolean
|
||||||
|
|
||||||
|
fun onCreateItemDecoration(
|
||||||
|
controller: SectionedSelectionController<T>,
|
||||||
|
section: T,
|
||||||
|
): AbstractSelectionItemDecoration
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class StateEventObserver : LifecycleEventObserver {
|
||||||
|
|
||||||
|
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||||
|
if (event == Lifecycle.Event.ON_CREATE) {
|
||||||
|
val registry = owner.savedStateRegistry
|
||||||
|
registry.registerSavedStateProvider(PROVIDER_NAME, this@SectionedSelectionController)
|
||||||
|
val state = registry.consumeRestoredStateForKey(PROVIDER_NAME)
|
||||||
|
if (state != null) {
|
||||||
|
Dispatchers.Main.dispatch(EmptyCoroutineContext) { // == Handler.post
|
||||||
|
if (source.lifecycle.currentState.isAtLeast(Lifecycle.State.CREATED)) {
|
||||||
|
restoreState(
|
||||||
|
state.keySet()
|
||||||
|
.associateWithTo(HashMap()) { state.getLongArray(it)?.toList().orEmpty() },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list.decor
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.content.res.getColorOrThrow
|
||||||
|
import androidx.core.view.children
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
|
@SuppressLint("PrivateResource")
|
||||||
|
abstract class AbstractDividerItemDecoration(context: Context) : RecyclerView.ItemDecoration() {
|
||||||
|
|
||||||
|
private val bounds = Rect()
|
||||||
|
private val thickness: Int
|
||||||
|
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
|
||||||
|
init {
|
||||||
|
paint.style = Paint.Style.FILL
|
||||||
|
val ta = context.obtainStyledAttributes(
|
||||||
|
null,
|
||||||
|
materialR.styleable.MaterialDivider,
|
||||||
|
materialR.attr.materialDividerStyle,
|
||||||
|
materialR.style.Widget_Material3_MaterialDivider,
|
||||||
|
)
|
||||||
|
paint.color = ta.getColorOrThrow(materialR.styleable.MaterialDivider_dividerColor)
|
||||||
|
thickness = ta.getDimensionPixelSize(
|
||||||
|
materialR.styleable.MaterialDivider_dividerThickness,
|
||||||
|
context.resources.getDimensionPixelSize(materialR.dimen.material_divider_thickness),
|
||||||
|
)
|
||||||
|
ta.recycle()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun getItemOffsets(
|
||||||
|
outRect: Rect,
|
||||||
|
view: View,
|
||||||
|
parent: RecyclerView,
|
||||||
|
state: RecyclerView.State,
|
||||||
|
) {
|
||||||
|
outRect.set(0, thickness, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO implement for horizontal lists on demand
|
||||||
|
override fun onDraw(canvas: Canvas, parent: RecyclerView, s: RecyclerView.State) {
|
||||||
|
if (parent.layoutManager == null || thickness == 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
canvas.save()
|
||||||
|
val left: Float
|
||||||
|
val right: Float
|
||||||
|
if (parent.clipToPadding) {
|
||||||
|
left = parent.paddingLeft.toFloat()
|
||||||
|
right = (parent.width - parent.paddingRight).toFloat()
|
||||||
|
canvas.clipRect(
|
||||||
|
left,
|
||||||
|
parent.paddingTop.toFloat(),
|
||||||
|
right,
|
||||||
|
(parent.height - parent.paddingBottom).toFloat()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
left = 0f
|
||||||
|
right = parent.width.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
var previous: RecyclerView.ViewHolder? = null
|
||||||
|
for (child in parent.children) {
|
||||||
|
val holder = parent.getChildViewHolder(child)
|
||||||
|
if (previous != null && shouldDrawDivider(previous, holder)) {
|
||||||
|
parent.getDecoratedBoundsWithMargins(child, bounds)
|
||||||
|
val top: Float = bounds.top + child.translationY
|
||||||
|
val bottom: Float = top + thickness
|
||||||
|
canvas.drawRect(left, top, right, bottom, paint)
|
||||||
|
}
|
||||||
|
previous = holder
|
||||||
|
}
|
||||||
|
canvas.restore()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract fun shouldDrawDivider(
|
||||||
|
above: RecyclerView.ViewHolder,
|
||||||
|
below: RecyclerView.ViewHolder,
|
||||||
|
): Boolean
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list.decor
|
package org.koitharu.kotatsu.base.ui.list.decor
|
||||||
|
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
@@ -67,7 +67,7 @@ abstract class AbstractSelectionItemDecoration : RecyclerView.ItemDecoration() {
|
|||||||
if (parent.clipToPadding) {
|
if (parent.clipToPadding) {
|
||||||
canvas.clipRect(
|
canvas.clipRect(
|
||||||
parent.paddingLeft, parent.paddingTop, parent.width - parent.paddingRight,
|
parent.paddingLeft, parent.paddingTop, parent.width - parent.paddingRight,
|
||||||
parent.height - parent.paddingBottom,
|
parent.height - parent.paddingBottom
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,4 +108,4 @@ abstract class AbstractSelectionItemDecoration : RecyclerView.ItemDecoration() {
|
|||||||
bounds: RectF,
|
bounds: RectF,
|
||||||
state: RecyclerView.State,
|
state: RecyclerView.State,
|
||||||
) = Unit
|
) = Unit
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list.decor
|
package org.koitharu.kotatsu.base.ui.list.decor
|
||||||
|
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list.decor
|
||||||
|
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.util.SparseIntArray
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.util.getOrDefault
|
||||||
|
import androidx.core.util.set
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
|
class TypedSpacingItemDecoration(
|
||||||
|
vararg spacingMapping: Pair<Int, Int>,
|
||||||
|
private val fallbackSpacing: Int = 0,
|
||||||
|
) : RecyclerView.ItemDecoration() {
|
||||||
|
|
||||||
|
private val mapping = SparseIntArray(spacingMapping.size)
|
||||||
|
|
||||||
|
init {
|
||||||
|
spacingMapping.forEach { (k, v) -> mapping[k] = v }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemOffsets(
|
||||||
|
outRect: Rect,
|
||||||
|
view: View,
|
||||||
|
parent: RecyclerView,
|
||||||
|
state: RecyclerView.State
|
||||||
|
) {
|
||||||
|
val itemType = parent.getChildViewHolder(view)?.itemViewType
|
||||||
|
val spacing = if (itemType == null) {
|
||||||
|
fallbackSpacing
|
||||||
|
} else {
|
||||||
|
mapping.getOrDefault(itemType, fallbackSpacing)
|
||||||
|
}
|
||||||
|
outRect.set(spacing, spacing, spacing, spacing)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list.fastscroll
|
package org.koitharu.kotatsu.base.ui.list.fastscroll
|
||||||
|
|
||||||
import android.animation.Animator
|
import android.animation.Animator
|
||||||
import android.animation.AnimatorListenerAdapter
|
import android.animation.AnimatorListenerAdapter
|
||||||
@@ -8,9 +8,9 @@ import android.view.animation.AccelerateInterpolator
|
|||||||
import android.view.animation.DecelerateInterpolator
|
import android.view.animation.DecelerateInterpolator
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import org.koitharu.kotatsu.core.util.ext.animatorDurationScale
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.measureWidth
|
|
||||||
import kotlin.math.hypot
|
import kotlin.math.hypot
|
||||||
|
import org.koitharu.kotatsu.utils.ext.animatorDurationScale
|
||||||
|
import org.koitharu.kotatsu.utils.ext.measureWidth
|
||||||
|
|
||||||
class BubbleAnimator(
|
class BubbleAnimator(
|
||||||
private val bubble: View,
|
private val bubble: View,
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list.fastscroll
|
package org.koitharu.kotatsu.base.ui.list.fastscroll
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
|
|
||||||
@@ -16,12 +15,6 @@ class FastScrollRecyclerView @JvmOverloads constructor(
|
|||||||
|
|
||||||
val fastScroller = FastScroller(context, attrs)
|
val fastScroller = FastScroller(context, attrs)
|
||||||
|
|
||||||
var isFastScrollerEnabled: Boolean = true
|
|
||||||
set(value) {
|
|
||||||
field = value
|
|
||||||
fastScroller.isVisible = value && isVisible
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
fastScroller.id = R.id.fast_scroller
|
fastScroller.id = R.id.fast_scroller
|
||||||
fastScroller.layoutParams = ViewGroup.LayoutParams(
|
fastScroller.layoutParams = ViewGroup.LayoutParams(
|
||||||
@@ -37,7 +30,7 @@ class FastScrollRecyclerView @JvmOverloads constructor(
|
|||||||
|
|
||||||
override fun setVisibility(visibility: Int) {
|
override fun setVisibility(visibility: Int) {
|
||||||
super.setVisibility(visibility)
|
super.setVisibility(visibility)
|
||||||
fastScroller.visibility = if (isFastScrollerEnabled) visibility else GONE
|
fastScroller.visibility = visibility
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttachedToWindow() {
|
override fun onAttachedToWindow() {
|
||||||
@@ -49,4 +42,4 @@ class FastScrollRecyclerView @JvmOverloads constructor(
|
|||||||
fastScroller.detachRecyclerView()
|
fastScroller.detachRecyclerView()
|
||||||
super.onDetachedFromWindow()
|
super.onDetachedFromWindow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list.fastscroll
|
package org.koitharu.kotatsu.base.ui.list.fastscroll
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -9,29 +9,22 @@ import android.util.AttributeSet
|
|||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.*
|
||||||
import androidx.annotation.ColorInt
|
|
||||||
import androidx.annotation.DimenRes
|
|
||||||
import androidx.annotation.DrawableRes
|
|
||||||
import androidx.annotation.Px
|
|
||||||
import androidx.annotation.StyleableRes
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.constraintlayout.widget.ConstraintSet
|
import androidx.constraintlayout.widget.ConstraintSet
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.withStyledAttributes
|
import androidx.core.content.withStyledAttributes
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import androidx.core.view.ancestors
|
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.util.ext.getThemeColor
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.isLayoutReversed
|
|
||||||
import org.koitharu.kotatsu.databinding.FastScrollerBinding
|
import org.koitharu.kotatsu.databinding.FastScrollerBinding
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getThemeColor
|
||||||
|
import org.koitharu.kotatsu.utils.ext.isLayoutReversed
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
import com.google.android.material.R as materialR
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
@@ -63,7 +56,6 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
private var bubbleHeight = 0
|
private var bubbleHeight = 0
|
||||||
private var handleHeight = 0
|
private var handleHeight = 0
|
||||||
private var viewHeight = 0
|
private var viewHeight = 0
|
||||||
private var offset = 0
|
|
||||||
private var hideScrollbar = true
|
private var hideScrollbar = true
|
||||||
private var showBubble = true
|
private var showBubble = true
|
||||||
private var showBubbleAlways = false
|
private var showBubbleAlways = false
|
||||||
@@ -106,7 +98,6 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
showScrollbar()
|
showScrollbar()
|
||||||
if (showBubbleAlways && sectionIndexer != null) showBubble()
|
if (showBubbleAlways && sectionIndexer != null) showBubble()
|
||||||
}
|
}
|
||||||
|
|
||||||
RecyclerView.SCROLL_STATE_IDLE -> if (hideScrollbar && !binding.thumb.isSelected) {
|
RecyclerView.SCROLL_STATE_IDLE -> if (hideScrollbar && !binding.thumb.isSelected) {
|
||||||
handler.postDelayed(scrollbarHider, SCROLLBAR_HIDE_DELAY)
|
handler.postDelayed(scrollbarHider, SCROLLBAR_HIDE_DELAY)
|
||||||
}
|
}
|
||||||
@@ -122,9 +113,6 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
return viewHeight * proportion
|
return viewHeight * proportion
|
||||||
}
|
}
|
||||||
|
|
||||||
val isScrollbarVisible: Boolean
|
|
||||||
get() = binding.scrollbar.isVisible
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
clipChildren = false
|
clipChildren = false
|
||||||
orientation = HORIZONTAL
|
orientation = HORIZONTAL
|
||||||
@@ -136,19 +124,18 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
|
|
||||||
var showTrack = false
|
var showTrack = false
|
||||||
|
|
||||||
context.withStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, defStyleAttr) {
|
context.withStyledAttributes(attrs, R.styleable.FastScroller, defStyleAttr) {
|
||||||
bubbleColor = getColor(R.styleable.FastScrollRecyclerView_bubbleColor, bubbleColor)
|
bubbleColor = getColor(R.styleable.FastScroller_bubbleColor, bubbleColor)
|
||||||
handleColor = getColor(R.styleable.FastScrollRecyclerView_thumbColor, handleColor)
|
handleColor = getColor(R.styleable.FastScroller_thumbColor, handleColor)
|
||||||
trackColor = getColor(R.styleable.FastScrollRecyclerView_trackColor, trackColor)
|
trackColor = getColor(R.styleable.FastScroller_trackColor, trackColor)
|
||||||
textColor = getColor(R.styleable.FastScrollRecyclerView_bubbleTextColor, textColor)
|
textColor = getColor(R.styleable.FastScroller_bubbleTextColor, textColor)
|
||||||
hideScrollbar = getBoolean(R.styleable.FastScrollRecyclerView_hideScrollbar, hideScrollbar)
|
hideScrollbar = getBoolean(R.styleable.FastScroller_hideScrollbar, hideScrollbar)
|
||||||
showBubble = getBoolean(R.styleable.FastScrollRecyclerView_showBubble, showBubble)
|
showBubble = getBoolean(R.styleable.FastScroller_showBubble, showBubble)
|
||||||
showBubbleAlways = getBoolean(R.styleable.FastScrollRecyclerView_showBubbleAlways, showBubbleAlways)
|
showBubbleAlways = getBoolean(R.styleable.FastScroller_showBubbleAlways, showBubbleAlways)
|
||||||
showTrack = getBoolean(R.styleable.FastScrollRecyclerView_showTrack, showTrack)
|
showTrack = getBoolean(R.styleable.FastScroller_showTrack, showTrack)
|
||||||
bubbleSize = getBubbleSize(R.styleable.FastScrollRecyclerView_bubbleSize, BubbleSize.NORMAL)
|
bubbleSize = getBubbleSize(R.styleable.FastScroller_bubbleSize, BubbleSize.NORMAL)
|
||||||
val textSize = getDimension(R.styleable.FastScrollRecyclerView_bubbleTextSize, bubbleSize.textSize)
|
val textSize = getDimension(R.styleable.FastScroller_bubbleTextSize, bubbleSize.textSize)
|
||||||
binding.bubble.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
binding.bubble.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||||
offset = getDimensionPixelOffset(R.styleable.FastScrollRecyclerView_scrollerOffset, offset)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTrackColor(trackColor)
|
setTrackColor(trackColor)
|
||||||
@@ -175,9 +162,7 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
|
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
if (!isScrollbarVisible || event.x.toInt() !in binding.scrollbar.left..binding.scrollbar.right) {
|
if (event.x.toInt() !in binding.scrollbar.left..binding.scrollbar.right) return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
requestDisallowInterceptTouchEvent(true)
|
requestDisallowInterceptTouchEvent(true)
|
||||||
setHandleSelected(true)
|
setHandleSelected(true)
|
||||||
@@ -191,12 +176,10 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
setYPositions()
|
setYPositions()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
setYPositions()
|
setYPositions()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
requestDisallowInterceptTouchEvent(false)
|
requestDisallowInterceptTouchEvent(false)
|
||||||
setHandleSelected(false)
|
setHandleSelected(false)
|
||||||
@@ -262,31 +245,27 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
|
|
||||||
layoutParams = (layoutParams as ConstraintLayout.LayoutParams).apply {
|
layoutParams = (layoutParams as ConstraintLayout.LayoutParams).apply {
|
||||||
height = 0
|
height = 0
|
||||||
setMargins(offset, marginTop, offset, marginBottom)
|
setMargins(0, marginTop, 0, marginBottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is CoordinatorLayout -> layoutParams = (layoutParams as CoordinatorLayout.LayoutParams).apply {
|
is CoordinatorLayout -> layoutParams = (layoutParams as CoordinatorLayout.LayoutParams).apply {
|
||||||
height = LayoutParams.MATCH_PARENT
|
height = LayoutParams.MATCH_PARENT
|
||||||
anchorGravity = GravityCompat.END
|
anchorGravity = GravityCompat.END
|
||||||
anchorId = recyclerViewId
|
anchorId = recyclerViewId
|
||||||
setMargins(offset, marginTop, offset, marginBottom)
|
setMargins(0, marginTop, 0, marginBottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
is FrameLayout -> layoutParams = (layoutParams as FrameLayout.LayoutParams).apply {
|
is FrameLayout -> layoutParams = (layoutParams as FrameLayout.LayoutParams).apply {
|
||||||
height = LayoutParams.MATCH_PARENT
|
height = LayoutParams.MATCH_PARENT
|
||||||
gravity = GravityCompat.END
|
gravity = GravityCompat.END
|
||||||
setMargins(offset, marginTop, offset, marginBottom)
|
setMargins(0, marginTop, 0, marginBottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
is RelativeLayout -> layoutParams = (layoutParams as RelativeLayout.LayoutParams).apply {
|
is RelativeLayout -> layoutParams = (layoutParams as RelativeLayout.LayoutParams).apply {
|
||||||
height = 0
|
height = 0
|
||||||
addRule(RelativeLayout.ALIGN_TOP, recyclerViewId)
|
addRule(RelativeLayout.ALIGN_TOP, recyclerViewId)
|
||||||
addRule(RelativeLayout.ALIGN_BOTTOM, recyclerViewId)
|
addRule(RelativeLayout.ALIGN_BOTTOM, recyclerViewId)
|
||||||
addRule(RelativeLayout.ALIGN_END, recyclerViewId)
|
addRule(RelativeLayout.ALIGN_END, recyclerViewId)
|
||||||
setMargins(offset, marginTop, offset, marginBottom)
|
setMargins(0, marginTop, 0, marginBottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("Parent ViewGroup must be a ConstraintLayout, CoordinatorLayout, FrameLayout, or RelativeLayout")
|
else -> throw IllegalArgumentException("Parent ViewGroup must be a ConstraintLayout, CoordinatorLayout, FrameLayout, or RelativeLayout")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,12 +287,10 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
|
|
||||||
if (parent is ViewGroup) {
|
if (parent is ViewGroup) {
|
||||||
setLayoutParams(parent as ViewGroup)
|
setLayoutParams(parent as ViewGroup)
|
||||||
} else {
|
} else if (recyclerView.parent is ViewGroup) {
|
||||||
val viewGroup = findValidParent(recyclerView)
|
val viewGroup = recyclerView.parent as ViewGroup
|
||||||
if (viewGroup != null) {
|
viewGroup.addView(this)
|
||||||
viewGroup.addView(this)
|
setLayoutParams(viewGroup)
|
||||||
setLayoutParams(viewGroup)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recyclerView.addOnScrollListener(scrollListener)
|
recyclerView.addOnScrollListener(scrollListener)
|
||||||
@@ -524,15 +501,7 @@ class FastScroller @JvmOverloads constructor(
|
|||||||
|
|
||||||
private fun TypedArray.getBubbleSize(@StyleableRes index: Int, defaultValue: BubbleSize): BubbleSize {
|
private fun TypedArray.getBubbleSize(@StyleableRes index: Int, defaultValue: BubbleSize): BubbleSize {
|
||||||
val ordinal = getInt(index, -1)
|
val ordinal = getInt(index, -1)
|
||||||
return BubbleSize.entries.getOrNull(ordinal) ?: defaultValue
|
return BubbleSize.values().getOrNull(ordinal) ?: defaultValue
|
||||||
}
|
|
||||||
|
|
||||||
private fun findValidParent(view: View): ViewGroup? = view.ancestors.firstNotNullOfOrNull { p ->
|
|
||||||
if (p is FrameLayout || p is ConstraintLayout || p is CoordinatorLayout || p is RelativeLayout) {
|
|
||||||
p as ViewGroup
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val BubbleSize.textSize
|
private val BubbleSize.textSize
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.list.fastscroll
|
package org.koitharu.kotatsu.base.ui.list.fastscroll
|
||||||
|
|
||||||
import android.animation.Animator
|
import android.animation.Animator
|
||||||
import android.animation.AnimatorListenerAdapter
|
import android.animation.AnimatorListenerAdapter
|
||||||
@@ -7,7 +7,7 @@ import android.view.ViewPropertyAnimator
|
|||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.util.ext.animatorDurationScale
|
import org.koitharu.kotatsu.utils.ext.animatorDurationScale
|
||||||
|
|
||||||
class ScrollbarAnimator(
|
class ScrollbarAnimator(
|
||||||
private val scrollbar: View,
|
private val scrollbar: View,
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import androidx.activity.OnBackPressedCallback
|
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.lifecycle.DefaultLifecycleObserver
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
|
||||||
class ActionModeDelegate : OnBackPressedCallback(false) {
|
class ActionModeDelegate {
|
||||||
|
|
||||||
private var activeActionMode: ActionMode? = null
|
private var activeActionMode: ActionMode? = null
|
||||||
private var listeners: MutableList<ActionModeListener>? = null
|
private var listeners: MutableList<ActionModeListener>? = null
|
||||||
@@ -13,19 +12,13 @@ class ActionModeDelegate : OnBackPressedCallback(false) {
|
|||||||
val isActionModeStarted: Boolean
|
val isActionModeStarted: Boolean
|
||||||
get() = activeActionMode != null
|
get() = activeActionMode != null
|
||||||
|
|
||||||
override fun handleOnBackPressed() {
|
|
||||||
finishActionMode()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onSupportActionModeStarted(mode: ActionMode) {
|
fun onSupportActionModeStarted(mode: ActionMode) {
|
||||||
activeActionMode = mode
|
activeActionMode = mode
|
||||||
isEnabled = true
|
|
||||||
listeners?.forEach { it.onActionModeStarted(mode) }
|
listeners?.forEach { it.onActionModeStarted(mode) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSupportActionModeFinished(mode: ActionMode) {
|
fun onSupportActionModeFinished(mode: ActionMode) {
|
||||||
activeActionMode = null
|
activeActionMode = null
|
||||||
isEnabled = false
|
|
||||||
listeners?.forEach { it.onActionModeFinished(mode) }
|
listeners?.forEach { it.onActionModeFinished(mode) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,10 +38,6 @@ class ActionModeDelegate : OnBackPressedCallback(false) {
|
|||||||
owner.lifecycle.addObserver(ListenerLifecycleObserver(listener))
|
owner.lifecycle.addObserver(ListenerLifecycleObserver(listener))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun finishActionMode() {
|
|
||||||
activeActionMode?.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class ListenerLifecycleObserver(
|
private inner class ListenerLifecycleObserver(
|
||||||
private val listener: ActionModeListener,
|
private val listener: ActionModeListener,
|
||||||
) : DefaultLifecycleObserver {
|
) : DefaultLifecycleObserver {
|
||||||
@@ -58,4 +47,4 @@ class ActionModeDelegate : OnBackPressedCallback(false) {
|
|||||||
removeListener(listener)
|
removeListener(listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
|
|
||||||
@@ -7,4 +7,4 @@ interface ActionModeListener {
|
|||||||
fun onActionModeStarted(mode: ActionMode)
|
fun onActionModeStarted(mode: ActionMode)
|
||||||
|
|
||||||
fun onActionModeFinished(mode: ActionMode)
|
fun onActionModeFinished(mode: ActionMode)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.app.ActivityCompat
|
import org.koitharu.kotatsu.base.ui.DefaultActivityLifecycleCallbacks
|
||||||
import org.koitharu.kotatsu.core.ui.DefaultActivityLifecycleCallbacks
|
|
||||||
import java.util.WeakHashMap
|
import java.util.WeakHashMap
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@@ -23,11 +22,6 @@ class ActivityRecreationHandle @Inject constructor() : DefaultActivityLifecycleC
|
|||||||
|
|
||||||
fun recreateAll() {
|
fun recreateAll() {
|
||||||
val snapshot = activities.keys.toList()
|
val snapshot = activities.keys.toList()
|
||||||
snapshot.forEach { ActivityCompat.recreate(it) }
|
snapshot.forEach { it.recreate() }
|
||||||
}
|
|
||||||
|
|
||||||
fun recreate(cls: Class<out Activity>) {
|
|
||||||
val activity = activities.keys.find { x -> x.javaClass == cls } ?: return
|
|
||||||
ActivityCompat.recreate(activity)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import dagger.hilt.EntryPoint
|
import dagger.hilt.EntryPoint
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import org.koitharu.kotatsu.base.ui.BaseActivity
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
|
|
||||||
@EntryPoint
|
@EntryPoint
|
||||||
@@ -10,3 +11,8 @@ import org.koitharu.kotatsu.core.prefs.AppSettings
|
|||||||
interface BaseActivityEntryPoint {
|
interface BaseActivityEntryPoint {
|
||||||
val settings: AppSettings
|
val settings: AppSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hilt cannot inject into parametrized classes
|
||||||
|
fun BaseActivityEntryPoint.inject(activity: BaseActivity<*>) {
|
||||||
|
activity.settings = settings
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.MenuItem.OnActionExpandListener
|
import android.view.MenuItem.OnActionExpandListener
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
|
import androidx.annotation.AnyThread
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
|
class CountedBooleanLiveData : LiveData<Boolean>(false) {
|
||||||
|
|
||||||
|
private val counter = AtomicInteger(0)
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
fun increment() {
|
||||||
|
if (counter.getAndIncrement() == 0) {
|
||||||
|
postValue(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
fun decrement() {
|
||||||
|
if (counter.decrementAndGet() == 0) {
|
||||||
|
postValue(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
fun reset() {
|
||||||
|
if (counter.getAndSet(0) != 0) {
|
||||||
|
postValue(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
interface RecyclerViewOwner {
|
interface RecyclerViewOwner {
|
||||||
|
|
||||||
val recyclerView: RecyclerView
|
val recyclerView: RecyclerView
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import org.koitharu.kotatsu.base.domain.ReversibleHandle
|
||||||
|
|
||||||
class ReversibleAction(
|
class ReversibleAction(
|
||||||
@StringRes val stringResId: Int,
|
@StringRes val stringResId: Int,
|
||||||
val handle: ReversibleHandle?,
|
val handle: ReversibleHandle?,
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
@@ -10,7 +10,9 @@ import com.google.android.material.floatingactionbutton.ExtendedFloatingActionBu
|
|||||||
|
|
||||||
open class ShrinkOnScrollBehavior : Behavior<ExtendedFloatingActionButton> {
|
open class ShrinkOnScrollBehavior : Behavior<ExtendedFloatingActionButton> {
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
constructor() : super()
|
constructor() : super()
|
||||||
|
@Suppress("unused")
|
||||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
||||||
|
|
||||||
override fun onStartNestedScroll(
|
override fun onStartNestedScroll(
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.Px
|
import androidx.annotation.Px
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.view.animation.AccelerateDecelerateInterpolator
|
import android.view.animation.AccelerateDecelerateInterpolator
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import org.koitharu.kotatsu.core.util.ext.getAnimationDuration
|
import org.koitharu.kotatsu.utils.ext.getAnimationDuration
|
||||||
import com.google.android.material.R as materialR
|
|
||||||
|
|
||||||
class StatusBarDimHelper : AppBarLayout.OnOffsetChangedListener {
|
class StatusBarDimHelper : AppBarLayout.OnOffsetChangedListener {
|
||||||
|
|
||||||
@@ -1,21 +1,19 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.base.ui.util
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
import androidx.core.view.OnApplyWindowInsetsListener
|
import androidx.core.view.OnApplyWindowInsetsListener
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import java.util.LinkedList
|
|
||||||
|
|
||||||
class WindowInsetsDelegate : OnApplyWindowInsetsListener, View.OnLayoutChangeListener {
|
class WindowInsetsDelegate(
|
||||||
|
private val listener: WindowInsetsListener,
|
||||||
|
) : OnApplyWindowInsetsListener, View.OnLayoutChangeListener {
|
||||||
|
|
||||||
@JvmField
|
|
||||||
var handleImeInsets: Boolean = false
|
var handleImeInsets: Boolean = false
|
||||||
|
|
||||||
@JvmField
|
|
||||||
var interceptingWindowInsetsListener: OnApplyWindowInsetsListener? = null
|
var interceptingWindowInsetsListener: OnApplyWindowInsetsListener? = null
|
||||||
|
|
||||||
private val listeners = LinkedList<WindowInsetsListener>()
|
|
||||||
private var lastInsets: Insets? = null
|
private var lastInsets: Insets? = null
|
||||||
|
|
||||||
override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
|
override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
|
||||||
@@ -29,7 +27,7 @@ class WindowInsetsDelegate : OnApplyWindowInsetsListener, View.OnLayoutChangeLis
|
|||||||
handledInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
handledInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
}
|
}
|
||||||
if (newInsets != lastInsets) {
|
if (newInsets != lastInsets) {
|
||||||
listeners.forEach { it.onWindowInsetsChanged(newInsets) }
|
listener.onWindowInsetsChanged(newInsets)
|
||||||
lastInsets = newInsets
|
lastInsets = newInsets
|
||||||
}
|
}
|
||||||
return handledInsets
|
return handledInsets
|
||||||
@@ -52,15 +50,6 @@ class WindowInsetsDelegate : OnApplyWindowInsetsListener, View.OnLayoutChangeLis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addInsetsListener(listener: WindowInsetsListener) {
|
|
||||||
listeners.add(listener)
|
|
||||||
lastInsets?.let { listener.onWindowInsetsChanged(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun removeInsetsListener(listener: WindowInsetsListener) {
|
|
||||||
listeners.remove(listener)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onViewCreated(view: View) {
|
fun onViewCreated(view: View) {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(view, this)
|
ViewCompat.setOnApplyWindowInsetsListener(view, this)
|
||||||
view.addOnLayoutChangeListener(this)
|
view.addOnLayoutChangeListener(this)
|
||||||
@@ -70,8 +59,8 @@ class WindowInsetsDelegate : OnApplyWindowInsetsListener, View.OnLayoutChangeLis
|
|||||||
lastInsets = null
|
lastInsets = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun interface WindowInsetsListener {
|
interface WindowInsetsListener {
|
||||||
|
|
||||||
fun onWindowInsetsChanged(insets: Insets)
|
fun onWindowInsetsChanged(insets: Insets)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,312 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.animation.LayoutTransition
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.WindowInsets
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.MenuRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
|
import androidx.core.view.*
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.databinding.LayoutSheetHeaderBinding
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getAnimationDuration
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getThemeDrawable
|
||||||
|
import org.koitharu.kotatsu.utils.ext.parents
|
||||||
|
import java.util.*
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
|
private const val THROTTLE_DELAY = 200L
|
||||||
|
|
||||||
|
class BottomSheetHeaderBar @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = materialR.attr.appBarLayoutStyle,
|
||||||
|
) : AppBarLayout(context, attrs, defStyleAttr), MenuHost {
|
||||||
|
|
||||||
|
private val binding = LayoutSheetHeaderBinding.inflate(LayoutInflater.from(context), this)
|
||||||
|
private val closeDrawable = context.getThemeDrawable(materialR.attr.actionModeCloseDrawable)
|
||||||
|
private val bottomSheetCallback = Callback()
|
||||||
|
private val adjustStateRunnable = Runnable { adjustState() }
|
||||||
|
private var bottomSheetBehavior: BottomSheetBehavior<*>? = null
|
||||||
|
private val locationBuffer = IntArray(2)
|
||||||
|
private val expansionListeners = LinkedList<OnExpansionChangeListener>()
|
||||||
|
private var fitStatusBar = false
|
||||||
|
private val minHandleHeight = context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_size_min)
|
||||||
|
private val maxHandleHeight = context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_size_max)
|
||||||
|
private var isLayoutSuppressedCompat = false
|
||||||
|
private var isLayoutCalledWhileSuppressed = false
|
||||||
|
private var isBsExpanded = false
|
||||||
|
private var stateAdjustedAt = 0L
|
||||||
|
|
||||||
|
@Deprecated("")
|
||||||
|
val toolbar: MaterialToolbar
|
||||||
|
get() = binding.toolbar
|
||||||
|
|
||||||
|
val menu: Menu
|
||||||
|
get() = binding.toolbar.menu
|
||||||
|
|
||||||
|
var title: CharSequence?
|
||||||
|
get() = binding.toolbar.title
|
||||||
|
set(value) {
|
||||||
|
binding.toolbar.title = value
|
||||||
|
}
|
||||||
|
|
||||||
|
var subtitle: CharSequence?
|
||||||
|
get() = binding.toolbar.subtitle
|
||||||
|
set(value) {
|
||||||
|
binding.toolbar.subtitle = value
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
setBackgroundResource(R.drawable.sheet_toolbar_background)
|
||||||
|
layoutTransition = LayoutTransition().apply {
|
||||||
|
setDuration(context.getAnimationDuration(R.integer.config_tinyAnimTime))
|
||||||
|
}
|
||||||
|
context.withStyledAttributes(attrs, R.styleable.BottomSheetHeaderBar, defStyleAttr) {
|
||||||
|
binding.toolbar.title = getString(R.styleable.BottomSheetHeaderBar_title)
|
||||||
|
fitStatusBar = getBoolean(R.styleable.BottomSheetHeaderBar_fitStatusBar, fitStatusBar)
|
||||||
|
val menuResId = getResourceId(R.styleable.BottomSheetHeaderBar_menu, 0)
|
||||||
|
if (menuResId != 0) {
|
||||||
|
binding.toolbar.inflateMenu(menuResId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.toolbar.setNavigationOnClickListener(bottomSheetCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow()
|
||||||
|
setBottomSheetBehavior(findParentBottomSheetBehavior())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromWindow() {
|
||||||
|
setBottomSheetBehavior(null)
|
||||||
|
super.onDetachedFromWindow()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addView(child: View?, index: Int) {
|
||||||
|
if (shouldAddView(child)) {
|
||||||
|
super.addView(child, index)
|
||||||
|
} else {
|
||||||
|
binding.toolbar.addView(child, index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addView(child: View?, width: Int, height: Int) {
|
||||||
|
if (shouldAddView(child)) {
|
||||||
|
super.addView(child, width, height)
|
||||||
|
} else {
|
||||||
|
binding.toolbar.addView(child, width, height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addView(child: View?, index: Int, params: ViewGroup.LayoutParams?) {
|
||||||
|
if (shouldAddView(child)) {
|
||||||
|
super.addView(child, index, params)
|
||||||
|
} else {
|
||||||
|
binding.toolbar.addView(child, index, convertLayoutParams(params))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onApplyWindowInsets(insets: WindowInsets?): WindowInsets {
|
||||||
|
dispatchInsets(if (insets != null) WindowInsetsCompat.toWindowInsetsCompat(insets) else null)
|
||||||
|
return super.onApplyWindowInsets(insets)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addMenuProvider(provider: MenuProvider) {
|
||||||
|
binding.toolbar.addMenuProvider(provider)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addMenuProvider(provider: MenuProvider, owner: LifecycleOwner) {
|
||||||
|
binding.toolbar.addMenuProvider(provider, owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addMenuProvider(provider: MenuProvider, owner: LifecycleOwner, state: Lifecycle.State) {
|
||||||
|
binding.toolbar.addMenuProvider(provider, owner, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeMenuProvider(provider: MenuProvider) {
|
||||||
|
binding.toolbar.removeMenuProvider(provider)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun invalidateMenu() {
|
||||||
|
binding.toolbar.invalidateMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun inflateMenu(@MenuRes resId: Int) {
|
||||||
|
binding.toolbar.inflateMenu(resId)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setNavigationOnClickListener(onClickListener: OnClickListener) {
|
||||||
|
binding.toolbar.setNavigationOnClickListener(onClickListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addOnExpansionChangeListener(listener: OnExpansionChangeListener) {
|
||||||
|
expansionListeners.add(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeOnExpansionChangeListener(listener: OnExpansionChangeListener) {
|
||||||
|
expansionListeners.remove(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTitle(@StringRes resId: Int) {
|
||||||
|
binding.toolbar.setTitle(resId)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setSubtitle(@StringRes resId: Int) {
|
||||||
|
binding.toolbar.setSubtitle(resId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
||||||
|
if (isLayoutSuppressedCompat) {
|
||||||
|
isLayoutCalledWhileSuppressed = true
|
||||||
|
} else {
|
||||||
|
super.onLayout(changed, l, t, r, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setBottomSheetBehavior(behavior: BottomSheetBehavior<*>?) {
|
||||||
|
bottomSheetBehavior?.removeBottomSheetCallback(bottomSheetCallback)
|
||||||
|
bottomSheetBehavior = behavior
|
||||||
|
if (behavior != null) {
|
||||||
|
onBottomSheetStateChanged(behavior.state)
|
||||||
|
behavior.addBottomSheetCallback(bottomSheetCallback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onBottomSheetStateChanged(newState: Int) {
|
||||||
|
val expanded = newState == BottomSheetBehavior.STATE_EXPANDED && isOnTopOfScreen()
|
||||||
|
if (isBsExpanded != expanded) {
|
||||||
|
isBsExpanded = expanded
|
||||||
|
postAdjustState()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun suppressLayoutCompat(suppress: Boolean) {
|
||||||
|
if (suppress == isLayoutSuppressedCompat) return
|
||||||
|
isLayoutSuppressedCompat = suppress
|
||||||
|
if (!suppress && isLayoutCalledWhileSuppressed) {
|
||||||
|
requestLayout()
|
||||||
|
}
|
||||||
|
isLayoutCalledWhileSuppressed = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun dispatchInsets(insets: WindowInsetsCompat?) {
|
||||||
|
if (!fitStatusBar) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val isExpanded = binding.dragHandle.isGone
|
||||||
|
val topInset = insets?.getInsets(WindowInsetsCompat.Type.systemBars())?.top ?: 0
|
||||||
|
if (isExpanded) {
|
||||||
|
updatePadding(top = topInset)
|
||||||
|
} else {
|
||||||
|
updatePadding(top = 0)
|
||||||
|
binding.dragHandle.updateLayoutParams {
|
||||||
|
height = topInset.coerceIn(minHandleHeight, maxHandleHeight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findParentBottomSheetBehavior(): BottomSheetBehavior<*>? {
|
||||||
|
for (p in parents) {
|
||||||
|
val layoutParams = (p as? View)?.layoutParams
|
||||||
|
if (layoutParams is CoordinatorLayout.LayoutParams) {
|
||||||
|
val behavior = layoutParams.behavior
|
||||||
|
if (behavior is BottomSheetBehavior<*>) {
|
||||||
|
return behavior
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isOnTopOfScreen(): Boolean {
|
||||||
|
getLocationInWindow(locationBuffer)
|
||||||
|
val topInset = ViewCompat.getRootWindowInsets(this)
|
||||||
|
?.getInsets(WindowInsetsCompat.Type.systemBars())?.top ?: 0
|
||||||
|
val zeroTop = (layoutParams as? MarginLayoutParams)?.topMargin ?: 0
|
||||||
|
return (locationBuffer[1] - topInset) <= zeroTop
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun dismissBottomSheet() {
|
||||||
|
val behavior = bottomSheetBehavior ?: return
|
||||||
|
if (behavior.isHideable) {
|
||||||
|
behavior.state = BottomSheetBehavior.STATE_HIDDEN
|
||||||
|
} else {
|
||||||
|
behavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun shouldAddView(child: View?): Boolean {
|
||||||
|
if (child == null) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val viewId = child.id
|
||||||
|
return viewId == R.id.dragHandle || viewId == R.id.toolbar
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun convertLayoutParams(params: ViewGroup.LayoutParams?): Toolbar.LayoutParams? {
|
||||||
|
return when (params) {
|
||||||
|
null -> null
|
||||||
|
is MarginLayoutParams -> {
|
||||||
|
val lp = Toolbar.LayoutParams(params)
|
||||||
|
if (params is LayoutParams) {
|
||||||
|
lp.gravity = params.gravity
|
||||||
|
}
|
||||||
|
lp
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> Toolbar.LayoutParams(params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun postAdjustState() {
|
||||||
|
removeCallbacks(adjustStateRunnable)
|
||||||
|
val now = System.currentTimeMillis()
|
||||||
|
if (stateAdjustedAt + THROTTLE_DELAY < now) {
|
||||||
|
adjustState()
|
||||||
|
} else {
|
||||||
|
postDelayed(adjustStateRunnable, THROTTLE_DELAY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun adjustState() {
|
||||||
|
suppressLayoutCompat(true)
|
||||||
|
binding.toolbar.navigationIcon = (if (isBsExpanded) closeDrawable else null)
|
||||||
|
binding.dragHandle.isGone = isBsExpanded
|
||||||
|
expansionListeners.forEach { it.onExpansionStateChanged(this, isBsExpanded) }
|
||||||
|
dispatchInsets(ViewCompat.getRootWindowInsets(this))
|
||||||
|
stateAdjustedAt = System.currentTimeMillis()
|
||||||
|
suppressLayoutCompat(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class Callback : BottomSheetBehavior.BottomSheetCallback(), OnClickListener {
|
||||||
|
|
||||||
|
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||||
|
onBottomSheetStateChanged(newState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSlide(bottomSheet: View, slideOffset: Float) = Unit
|
||||||
|
|
||||||
|
override fun onClick(v: View?) {
|
||||||
|
dismissBottomSheet()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interface OnExpansionChangeListener {
|
||||||
|
|
||||||
|
fun onExpansionStateChanged(headerBar: BottomSheetHeaderBar, isExpanded: Boolean)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
@@ -101,4 +101,4 @@ class CheckableImageView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import androidx.annotation.ColorRes
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import com.google.android.material.chip.ChipDrawable
|
import com.google.android.material.chip.ChipDrawable
|
||||||
import com.google.android.material.chip.ChipGroup
|
import com.google.android.material.chip.ChipGroup
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.util.ext.castOrNull
|
import org.koitharu.kotatsu.utils.ext.castOrNull
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getThemeColorStateList
|
||||||
|
|
||||||
class ChipsView @JvmOverloads constructor(
|
class ChipsView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
@@ -26,7 +27,6 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
private val chipOnCloseListener = OnClickListener {
|
private val chipOnCloseListener = OnClickListener {
|
||||||
onChipCloseClickListener?.onChipCloseClick(it as Chip, it.tag)
|
onChipCloseClickListener?.onChipCloseClick(it as Chip, it.tag)
|
||||||
}
|
}
|
||||||
private val chipStyle: Int
|
|
||||||
var onChipClickListener: OnChipClickListener? = null
|
var onChipClickListener: OnChipClickListener? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
@@ -40,20 +40,6 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
children.forEach { (it as? Chip)?.isCloseIconVisible = isCloseIconVisible }
|
children.forEach { (it as? Chip)?.isCloseIconVisible = isCloseIconVisible }
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
val ta = context.obtainStyledAttributes(attrs, R.styleable.ChipsView, defStyleAttr, 0)
|
|
||||||
chipStyle = ta.getResourceId(R.styleable.ChipsView_chipStyle, R.style.Widget_Kotatsu_Chip)
|
|
||||||
ta.recycle()
|
|
||||||
|
|
||||||
if (isInEditMode) {
|
|
||||||
setChips(
|
|
||||||
List(5) {
|
|
||||||
ChipModel(0, "Chip $it", 0, isCheckable = false, isChecked = false)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun requestLayout() {
|
override fun requestLayout() {
|
||||||
if (isLayoutSuppressedCompat) {
|
if (isLayoutSuppressedCompat) {
|
||||||
isLayoutCalledOnSuppressed = true
|
isLayoutCalledOnSuppressed = true
|
||||||
@@ -89,26 +75,25 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
|
|
||||||
private fun bindChip(chip: Chip, model: ChipModel) {
|
private fun bindChip(chip: Chip, model: ChipModel) {
|
||||||
chip.text = model.title
|
chip.text = model.title
|
||||||
chip.isClickable = onChipClickListener != null || model.isCheckable
|
|
||||||
chip.isCheckable = model.isCheckable
|
|
||||||
if (model.icon == 0) {
|
if (model.icon == 0) {
|
||||||
chip.chipIcon = null
|
|
||||||
chip.isChipIconVisible = false
|
chip.isChipIconVisible = false
|
||||||
} else {
|
} else {
|
||||||
chip.setChipIconResource(model.icon)
|
|
||||||
chip.isChipIconVisible = true
|
chip.isChipIconVisible = true
|
||||||
|
chip.setChipIconResource(model.icon)
|
||||||
}
|
}
|
||||||
|
chip.isClickable = onChipClickListener != null || model.isCheckable
|
||||||
|
chip.isCheckable = model.isCheckable
|
||||||
chip.isChecked = model.isChecked
|
chip.isChecked = model.isChecked
|
||||||
chip.tag = model.data
|
chip.tag = model.data
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addChip(): Chip {
|
private fun addChip(): Chip {
|
||||||
val chip = Chip(context)
|
val chip = Chip(context)
|
||||||
val drawable = ChipDrawable.createFromAttributes(context, null, 0, chipStyle)
|
val drawable = ChipDrawable.createFromAttributes(context, null, 0, R.style.Widget_Kotatsu_Chip)
|
||||||
chip.setChipDrawable(drawable)
|
chip.setChipDrawable(drawable)
|
||||||
chip.isCheckedIconVisible = true
|
chip.isCheckedIconVisible = true
|
||||||
chip.isChipIconVisible = false
|
|
||||||
chip.setCheckedIconResource(R.drawable.ic_check)
|
chip.setCheckedIconResource(R.drawable.ic_check)
|
||||||
|
chip.checkedIconTint = context.getThemeColorStateList(materialR.attr.colorControlNormal)
|
||||||
chip.isCloseIconVisible = onChipCloseClickListener != null
|
chip.isCloseIconVisible = onChipCloseClickListener != null
|
||||||
chip.setOnCloseIconClickListener(chipOnCloseListener)
|
chip.setOnCloseIconClickListener(chipOnCloseListener)
|
||||||
chip.setEnsureMinTouchTargetSize(false)
|
chip.setEnsureMinTouchTargetSize(false)
|
||||||
@@ -127,14 +112,38 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ChipModel(
|
class ChipModel(
|
||||||
@ColorRes val tint: Int,
|
|
||||||
val title: CharSequence,
|
|
||||||
@DrawableRes val icon: Int,
|
@DrawableRes val icon: Int,
|
||||||
|
val title: CharSequence,
|
||||||
val isCheckable: Boolean,
|
val isCheckable: Boolean,
|
||||||
val isChecked: Boolean,
|
val isChecked: Boolean,
|
||||||
val data: Any? = null,
|
val data: Any? = null,
|
||||||
)
|
) {
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as ChipModel
|
||||||
|
|
||||||
|
if (icon != other.icon) return false
|
||||||
|
if (title != other.title) return false
|
||||||
|
if (isCheckable != other.isCheckable) return false
|
||||||
|
if (isChecked != other.isChecked) return false
|
||||||
|
if (data != other.data) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = icon
|
||||||
|
result = 31 * result + title.hashCode()
|
||||||
|
result = 31 * result + isCheckable.hashCode()
|
||||||
|
result = 31 * result + isChecked.hashCode()
|
||||||
|
result = 31 * result + (data?.hashCode() ?: 0)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun interface OnChipClickListener {
|
fun interface OnChipClickListener {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
@@ -40,4 +40,4 @@ class CoverImageView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
setMeasuredDimension(desiredWidth, desiredHeight)
|
setMeasuredDimension(desiredWidth, desiredHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -10,8 +10,8 @@ import androidx.core.view.ViewCompat
|
|||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.util.ext.getAnimationDuration
|
import org.koitharu.kotatsu.utils.ext.getAnimationDuration
|
||||||
import org.koitharu.kotatsu.core.util.ext.measureHeight
|
import org.koitharu.kotatsu.utils.ext.measureHeight
|
||||||
|
|
||||||
class HideBottomNavigationOnScrollBehavior @JvmOverloads constructor(
|
class HideBottomNavigationOnScrollBehavior @JvmOverloads constructor(
|
||||||
context: Context? = null,
|
context: Context? = null,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -19,7 +19,7 @@ import com.google.android.material.ripple.RippleUtils
|
|||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.util.ext.resolveDp
|
import org.koitharu.kotatsu.utils.ext.resolveDp
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
class ListItemTextView @JvmOverloads constructor(
|
class ListItemTextView @JvmOverloads constructor(
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.animation.Animator
|
|
||||||
import android.animation.ValueAnimator
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Outline
|
import android.graphics.Outline
|
||||||
@@ -11,29 +9,46 @@ import android.view.View
|
|||||||
import android.view.ViewOutlineProvider
|
import android.view.ViewOutlineProvider
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.FloatRange
|
import androidx.annotation.FloatRange
|
||||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
import androidx.core.graphics.ColorUtils
|
||||||
import org.koitharu.kotatsu.core.util.ext.getAnimationDuration
|
import com.google.android.material.R as materialR
|
||||||
import org.koitharu.kotatsu.core.util.ext.isAnimationsEnabled
|
import kotlin.random.Random
|
||||||
import org.koitharu.kotatsu.core.util.ext.resolveDp
|
|
||||||
import org.koitharu.kotatsu.parsers.util.replaceWith
|
import org.koitharu.kotatsu.parsers.util.replaceWith
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getThemeColor
|
||||||
|
import org.koitharu.kotatsu.utils.ext.resolveDp
|
||||||
|
|
||||||
class SegmentedBarView @JvmOverloads constructor(
|
class SegmentedBarView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = 0,
|
defStyleAttr: Int = 0,
|
||||||
) : View(context, attrs, defStyleAttr), ValueAnimator.AnimatorUpdateListener, Animator.AnimatorListener {
|
) : View(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
private val segmentsData = ArrayList<Segment>()
|
private val segmentsData = ArrayList<Segment>()
|
||||||
private val segmentsSizes = ArrayList<Float>()
|
private val segmentsSizes = ArrayList<Float>()
|
||||||
|
private val outlineColor = context.getThemeColor(materialR.attr.colorOutline)
|
||||||
private var cornerSize = 0f
|
private var cornerSize = 0f
|
||||||
private var scaleFactor = 1f
|
|
||||||
private var scaleAnimator: ValueAnimator? = null
|
var segments: List<Segment>
|
||||||
|
get() = segmentsData
|
||||||
|
set(value) {
|
||||||
|
segmentsData.replaceWith(value)
|
||||||
|
updateSizes()
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
paint.strokeWidth = context.resources.resolveDp(0f)
|
paint.strokeWidth = context.resources.resolveDp(1f)
|
||||||
outlineProvider = OutlineProvider()
|
outlineProvider = OutlineProvider()
|
||||||
clipToOutline = true
|
clipToOutline = true
|
||||||
|
|
||||||
|
if (isInEditMode) {
|
||||||
|
segments = List(Random.nextInt(3, 5)) {
|
||||||
|
Segment(
|
||||||
|
percent = Random.nextFloat(),
|
||||||
|
color = ColorUtils.HSLToColor(floatArrayOf(Random.nextInt(0, 360).toFloat(), 0.5f, 0.5f)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||||
@@ -54,74 +69,51 @@ class SegmentedBarView @JvmOverloads constructor(
|
|||||||
paint.style = Paint.Style.FILL
|
paint.style = Paint.Style.FILL
|
||||||
val segmentWidth = segmentsSizes[i]
|
val segmentWidth = segmentsSizes[i]
|
||||||
canvas.drawRoundRect(0f, 0f, x + cornerSize, height.toFloat(), cornerSize, cornerSize, paint)
|
canvas.drawRoundRect(0f, 0f, x + cornerSize, height.toFloat(), cornerSize, cornerSize, paint)
|
||||||
|
paint.color = outlineColor
|
||||||
paint.style = Paint.Style.STROKE
|
paint.style = Paint.Style.STROKE
|
||||||
canvas.drawRoundRect(0f, 0f, x + cornerSize, height.toFloat(), cornerSize, cornerSize, paint)
|
canvas.drawRoundRect(0f, 0f, x + cornerSize, height.toFloat(), cornerSize, cornerSize, paint)
|
||||||
x -= segmentWidth
|
x -= segmentWidth
|
||||||
}
|
}
|
||||||
|
paint.color = outlineColor
|
||||||
paint.style = Paint.Style.STROKE
|
paint.style = Paint.Style.STROKE
|
||||||
canvas.drawRoundRect(0f, 0f, w, height.toFloat(), cornerSize, cornerSize, paint)
|
canvas.drawRoundRect(0f, 0f, w, height.toFloat(), cornerSize, cornerSize, paint)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAnimationStart(animation: Animator) = Unit
|
|
||||||
|
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
|
||||||
if (scaleAnimator === animation) {
|
|
||||||
scaleAnimator = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAnimationUpdate(animation: ValueAnimator) {
|
|
||||||
scaleFactor = animation.animatedValue as Float
|
|
||||||
updateSizes()
|
|
||||||
invalidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAnimationCancel(animation: Animator) = Unit
|
|
||||||
|
|
||||||
override fun onAnimationRepeat(animation: Animator) = Unit
|
|
||||||
|
|
||||||
fun animateSegments(value: List<Segment>) {
|
|
||||||
scaleAnimator?.cancel()
|
|
||||||
segmentsData.replaceWith(value)
|
|
||||||
if (!context.isAnimationsEnabled) {
|
|
||||||
scaleAnimator = null
|
|
||||||
scaleFactor = 1f
|
|
||||||
updateSizes()
|
|
||||||
invalidate()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
scaleFactor = 0f
|
|
||||||
updateSizes()
|
|
||||||
invalidate()
|
|
||||||
val animator = ValueAnimator.ofFloat(0f, 1f)
|
|
||||||
animator.duration = context.getAnimationDuration(android.R.integer.config_longAnimTime)
|
|
||||||
animator.interpolator = FastOutSlowInInterpolator()
|
|
||||||
animator.addUpdateListener(this@SegmentedBarView)
|
|
||||||
animator.addListener(this@SegmentedBarView)
|
|
||||||
scaleAnimator = animator
|
|
||||||
animator.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateSizes() {
|
private fun updateSizes() {
|
||||||
segmentsSizes.clear()
|
segmentsSizes.clear()
|
||||||
segmentsSizes.ensureCapacity(segmentsData.size + 1)
|
segmentsSizes.ensureCapacity(segmentsData.size + 1)
|
||||||
var w = width.toFloat()
|
var w = width.toFloat()
|
||||||
val maxScale = (scaleFactor * (segmentsData.size - 1)).coerceAtLeast(1f)
|
for (segment in segmentsData) {
|
||||||
for ((index, segment) in segmentsData.withIndex()) {
|
val segmentWidth = (w * segment.percent).coerceAtLeast(cornerSize)
|
||||||
val scale = (scaleFactor * (index + 1) / maxScale).coerceAtMost(1f)
|
|
||||||
val segmentWidth = (w * segment.percent).coerceAtLeast(
|
|
||||||
if (index == 0) height.toFloat() else cornerSize,
|
|
||||||
) * scale
|
|
||||||
segmentsSizes.add(segmentWidth)
|
segmentsSizes.add(segmentWidth)
|
||||||
w -= segmentWidth
|
w -= segmentWidth
|
||||||
}
|
}
|
||||||
segmentsSizes.add(w)
|
segmentsSizes.add(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Segment(
|
class Segment(
|
||||||
@FloatRange(from = 0.0, to = 1.0) val percent: Float,
|
@FloatRange(from = 0.0, to = 1.0) val percent: Float,
|
||||||
@ColorInt val color: Int,
|
@ColorInt val color: Int,
|
||||||
)
|
) {
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as Segment
|
||||||
|
|
||||||
|
if (percent != other.percent) return false
|
||||||
|
if (color != other.color) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = percent.hashCode()
|
||||||
|
result = 31 * result + color
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class OutlineProvider : ViewOutlineProvider() {
|
private class OutlineProvider : ViewOutlineProvider() {
|
||||||
override fun getOutline(view: View, outline: Outline) {
|
override fun getOutline(view: View, outline: Outline) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.Selection
|
import android.text.Selection
|
||||||
@@ -26,8 +26,4 @@ class SelectableTextView @JvmOverloads constructor(
|
|||||||
Selection.setSelection(spannableText, text.length)
|
Selection.setSelection(spannableText, text.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
override fun scrollTo(x: Int, y: Int) {
|
|
||||||
super.scrollTo(0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.animation.Animator
|
import android.animation.Animator
|
||||||
import android.animation.AnimatorListenerAdapter
|
import android.animation.AnimatorListenerAdapter
|
||||||
@@ -14,10 +14,10 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|||||||
import androidx.customview.view.AbsSavedState
|
import androidx.customview.view.AbsSavedState
|
||||||
import androidx.interpolator.view.animation.FastOutLinearInInterpolator
|
import androidx.interpolator.view.animation.FastOutLinearInInterpolator
|
||||||
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator
|
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.applySystemAnimatorScale
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.measureHeight
|
|
||||||
import com.google.android.material.R as materialR
|
import com.google.android.material.R as materialR
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
import org.koitharu.kotatsu.utils.ext.applySystemAnimatorScale
|
||||||
|
import org.koitharu.kotatsu.utils.ext.measureHeight
|
||||||
|
|
||||||
private const val STATE_DOWN = 1
|
private const val STATE_DOWN = 1
|
||||||
private const val STATE_UP = 2
|
private const val STATE_UP = 2
|
||||||
@@ -65,9 +65,6 @@ class SlidingBottomNavigationView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun show() {
|
fun show() {
|
||||||
if (currentState == STATE_UP) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
currentAnimator?.cancel()
|
currentAnimator?.cancel()
|
||||||
clearAnimation()
|
clearAnimation()
|
||||||
|
|
||||||
@@ -80,9 +77,6 @@ class SlidingBottomNavigationView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun hide() {
|
fun hide() {
|
||||||
if (currentState == STATE_DOWN) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
currentAnimator?.cancel()
|
currentAnimator?.cancel()
|
||||||
clearAnimation()
|
clearAnimation()
|
||||||
|
|
||||||
@@ -98,14 +92,6 @@ class SlidingBottomNavigationView @JvmOverloads constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showOrHide(show: Boolean) {
|
|
||||||
if (show) {
|
|
||||||
show()
|
|
||||||
} else {
|
|
||||||
hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun animateTranslation(targetY: Float, duration: Long, interpolator: TimeInterpolator) {
|
private fun animateTranslation(targetY: Float, duration: Long, interpolator: TimeInterpolator) {
|
||||||
currentAnimator = animate()
|
currentAnimator = animate()
|
||||||
.translationY(targetY)
|
.translationY(targetY)
|
||||||
@@ -123,7 +109,6 @@ class SlidingBottomNavigationView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal class SavedState : AbsSavedState {
|
internal class SavedState : AbsSavedState {
|
||||||
|
|
||||||
var currentState = STATE_UP
|
var currentState = STATE_UP
|
||||||
var translationY = 0F
|
var translationY = 0F
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.data
|
||||||
|
|
||||||
|
import androidx.room.*
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaWithTags
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
abstract class BookmarksDao {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM bookmarks WHERE manga_id = :mangaId AND page_id = :pageId")
|
||||||
|
abstract suspend fun find(mangaId: Long, pageId: Long): BookmarkEntity?
|
||||||
|
|
||||||
|
@Query("SELECT * FROM bookmarks WHERE manga_id = :mangaId AND chapter_id = :chapterId AND page = :page")
|
||||||
|
abstract fun observe(mangaId: Long, chapterId: Long, page: Int): Flow<BookmarkEntity?>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM bookmarks WHERE manga_id = :mangaId ORDER BY created_at DESC")
|
||||||
|
abstract fun observe(mangaId: Long): Flow<List<BookmarkEntity>>
|
||||||
|
|
||||||
|
@Transaction
|
||||||
|
@Query(
|
||||||
|
"SELECT * FROM manga JOIN bookmarks ON bookmarks.manga_id = manga.manga_id ORDER BY bookmarks.created_at"
|
||||||
|
)
|
||||||
|
abstract fun observe(): Flow<Map<MangaWithTags, List<BookmarkEntity>>>
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
abstract suspend fun insert(entity: BookmarkEntity)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
abstract suspend fun delete(entity: BookmarkEntity)
|
||||||
|
|
||||||
|
@Query("DELETE FROM bookmarks WHERE manga_id = :mangaId AND page_id = :pageId")
|
||||||
|
abstract suspend fun delete(mangaId: Long, pageId: Long)
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package org.koitharu.kotatsu.bookmarks.data
|
|||||||
|
|
||||||
import org.koitharu.kotatsu.bookmarks.domain.Bookmark
|
import org.koitharu.kotatsu.bookmarks.domain.Bookmark
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import java.util.Date
|
import java.util.*
|
||||||
|
|
||||||
fun BookmarkEntity.toBookmark(manga: Manga) = Bookmark(
|
fun BookmarkEntity.toBookmark(manga: Manga) = Bookmark(
|
||||||
manga = manga,
|
manga = manga,
|
||||||
@@ -30,5 +30,4 @@ fun Collection<BookmarkEntity>.toBookmarks(manga: Manga) = map {
|
|||||||
it.toBookmark(manga)
|
it.toBookmark(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmName("bookmarksIds")
|
fun Collection<Bookmark>.ids() = map { it.pageId }
|
||||||
fun Collection<Bookmark>.ids() = map { it.pageId }
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.koitharu.kotatsu.bookmarks.domain
|
||||||
|
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class Bookmark(
|
||||||
|
val manga: Manga,
|
||||||
|
val pageId: Long,
|
||||||
|
val chapterId: Long,
|
||||||
|
val page: Int,
|
||||||
|
val scroll: Int,
|
||||||
|
val imageUrl: String,
|
||||||
|
val createdAt: Date,
|
||||||
|
val percent: Float,
|
||||||
|
) {
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as Bookmark
|
||||||
|
|
||||||
|
if (manga != other.manga) return false
|
||||||
|
if (pageId != other.pageId) return false
|
||||||
|
if (chapterId != other.chapterId) return false
|
||||||
|
if (page != other.page) return false
|
||||||
|
if (scroll != other.scroll) return false
|
||||||
|
if (imageUrl != other.imageUrl) return false
|
||||||
|
if (createdAt != other.createdAt) return false
|
||||||
|
if (percent != other.percent) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = manga.hashCode()
|
||||||
|
result = 31 * result + pageId.hashCode()
|
||||||
|
result = 31 * result + chapterId.hashCode()
|
||||||
|
result = 31 * result + page
|
||||||
|
result = 31 * result + scroll
|
||||||
|
result = 31 * result + imageUrl.hashCode()
|
||||||
|
result = 31 * result + createdAt.hashCode()
|
||||||
|
result = 31 * result + percent.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,10 @@ package org.koitharu.kotatsu.bookmarks.domain
|
|||||||
|
|
||||||
import android.database.SQLException
|
import android.database.SQLException
|
||||||
import androidx.room.withTransaction
|
import androidx.room.withTransaction
|
||||||
import dagger.Reusable
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
import org.koitharu.kotatsu.base.domain.ReversibleHandle
|
||||||
import org.koitharu.kotatsu.bookmarks.data.BookmarkEntity
|
import org.koitharu.kotatsu.bookmarks.data.BookmarkEntity
|
||||||
import org.koitharu.kotatsu.bookmarks.data.toBookmark
|
import org.koitharu.kotatsu.bookmarks.data.toBookmark
|
||||||
import org.koitharu.kotatsu.bookmarks.data.toBookmarks
|
import org.koitharu.kotatsu.bookmarks.data.toBookmarks
|
||||||
@@ -13,27 +14,24 @@ import org.koitharu.kotatsu.core.db.MangaDatabase
|
|||||||
import org.koitharu.kotatsu.core.db.entity.toEntities
|
import org.koitharu.kotatsu.core.db.entity.toEntities
|
||||||
import org.koitharu.kotatsu.core.db.entity.toEntity
|
import org.koitharu.kotatsu.core.db.entity.toEntity
|
||||||
import org.koitharu.kotatsu.core.db.entity.toManga
|
import org.koitharu.kotatsu.core.db.entity.toManga
|
||||||
import org.koitharu.kotatsu.core.ui.util.ReversibleHandle
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.mapItems
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import javax.inject.Inject
|
import org.koitharu.kotatsu.utils.ext.mapItems
|
||||||
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
|
|
||||||
@Reusable
|
|
||||||
class BookmarksRepository @Inject constructor(
|
class BookmarksRepository @Inject constructor(
|
||||||
private val db: MangaDatabase,
|
private val db: MangaDatabase,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun observeBookmark(manga: Manga, chapterId: Long, page: Int): Flow<Bookmark?> {
|
fun observeBookmark(manga: Manga, chapterId: Long, page: Int): Flow<Bookmark?> {
|
||||||
return db.getBookmarksDao().observe(manga.id, chapterId, page).map { it?.toBookmark(manga) }
|
return db.bookmarksDao.observe(manga.id, chapterId, page).map { it?.toBookmark(manga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun observeBookmarks(manga: Manga): Flow<List<Bookmark>> {
|
fun observeBookmarks(manga: Manga): Flow<List<Bookmark>> {
|
||||||
return db.getBookmarksDao().observe(manga.id).mapItems { it.toBookmark(manga) }
|
return db.bookmarksDao.observe(manga.id).mapItems { it.toBookmark(manga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun observeBookmarks(): Flow<Map<Manga, List<Bookmark>>> {
|
fun observeBookmarks(): Flow<Map<Manga, List<Bookmark>>> {
|
||||||
return db.getBookmarksDao().observe().map { map ->
|
return db.bookmarksDao.observe().map { map ->
|
||||||
val res = LinkedHashMap<Manga, List<Bookmark>>(map.size)
|
val res = LinkedHashMap<Manga, List<Bookmark>>(map.size)
|
||||||
for ((k, v) in map) {
|
for ((k, v) in map) {
|
||||||
val manga = k.toManga()
|
val manga = k.toManga()
|
||||||
@@ -46,39 +44,28 @@ class BookmarksRepository @Inject constructor(
|
|||||||
suspend fun addBookmark(bookmark: Bookmark) {
|
suspend fun addBookmark(bookmark: Bookmark) {
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
val tags = bookmark.manga.tags.toEntities()
|
val tags = bookmark.manga.tags.toEntities()
|
||||||
db.getTagsDao().upsert(tags)
|
db.tagsDao.upsert(tags)
|
||||||
db.getMangaDao().upsert(bookmark.manga.toEntity(), tags)
|
db.mangaDao.upsert(bookmark.manga.toEntity(), tags)
|
||||||
db.getBookmarksDao().insert(bookmark.toEntity())
|
db.bookmarksDao.insert(bookmark.toEntity())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun updateBookmark(bookmark: Bookmark, imageUrl: String) {
|
suspend fun removeBookmark(mangaId: Long, pageId: Long) {
|
||||||
val entity = bookmark.toEntity().copy(
|
db.bookmarksDao.delete(mangaId, pageId)
|
||||||
imageUrl = imageUrl,
|
|
||||||
)
|
|
||||||
db.getBookmarksDao().upsert(listOf(entity))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun removeBookmark(mangaId: Long, chapterId: Long, page: Int) {
|
suspend fun removeBookmarks(ids: Map<Manga, Set<Long>>): ReversibleHandle {
|
||||||
check(db.getBookmarksDao().delete(mangaId, chapterId, page) != 0) {
|
|
||||||
"Bookmark not found"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun removeBookmark(bookmark: Bookmark) {
|
|
||||||
removeBookmark(bookmark.manga.id, bookmark.chapterId, bookmark.page)
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun removeBookmarks(ids: Set<Long>): ReversibleHandle {
|
|
||||||
val entities = ArrayList<BookmarkEntity>(ids.size)
|
val entities = ArrayList<BookmarkEntity>(ids.size)
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
val dao = db.getBookmarksDao()
|
val dao = db.bookmarksDao
|
||||||
for (pageId in ids) {
|
for ((manga, idSet) in ids) {
|
||||||
val e = dao.find(pageId)
|
for (pageId in idSet) {
|
||||||
if (e != null) {
|
val e = dao.find(manga.id, pageId)
|
||||||
entities.add(e)
|
if (e != null) {
|
||||||
|
entities.add(e)
|
||||||
|
}
|
||||||
|
dao.delete(manga.id, pageId)
|
||||||
}
|
}
|
||||||
dao.delete(pageId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BookmarksRestorer(entities)
|
return BookmarksRestorer(entities)
|
||||||
@@ -92,7 +79,7 @@ class BookmarksRepository @Inject constructor(
|
|||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
for (e in entities) {
|
for (e in entities) {
|
||||||
try {
|
try {
|
||||||
db.getBookmarksDao().insert(e)
|
db.bookmarksDao.insert(e)
|
||||||
} catch (e: SQLException) {
|
} catch (e: SQLException) {
|
||||||
e.printStackTraceDebug()
|
e.printStackTraceDebug()
|
||||||
}
|
}
|
||||||