Compare commits

...

8 Commits

Author SHA1 Message Date
Koitharu
8c2bff78f7 Fix chapters duplication 2024-03-09 14:27:12 +02:00
Koitharu
4f2c38d4ee Update parsers 2024-03-09 13:05:02 +02:00
Koitharu
3c54fe4217 Fix crash on text selection
(cherry picked from commit 65abfc3a49)
2024-03-09 12:34:52 +02:00
Koitharu
750bf11fdc Update app/src/main/res/color-v23/selector_overlay.xml
(cherry picked from commit ba88ca8234)
2024-03-09 12:34:47 +02:00
Kaorun
b2c5ec5082 Fixed hover color
(cherry picked from commit 63470db6f5)
2024-03-09 12:34:39 +02:00
Koitharu
f97d4d452f Fix null url crash
(cherry picked from commit 1e39ae48ec)
2024-03-09 12:34:33 +02:00
Koitharu
640fe272c8 Fix passing intent data to ViewModels
(cherry picked from commit 094b0f694c)
2024-03-09 12:34:21 +02:00
Koitharu
f730e80bb7 Use numeric keyboard if app password is numeric
(cherry picked from commit f98bb87d6e)
2024-03-09 12:33:53 +02:00
13 changed files with 53 additions and 20 deletions

View File

@@ -16,8 +16,8 @@ android {
applicationId 'org.koitharu.kotatsu'
minSdk = 21
targetSdk = 34
versionCode = 626
versionName = '6.7.4'
versionCode = 627
versionName = '6.7.5'
generatedDensities = []
testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner'
ksp {
@@ -82,7 +82,7 @@ afterEvaluate {
}
dependencies {
//noinspection GradleDependency
implementation('com.github.KotatsuApp:kotatsu-parsers:103f578c61') {
implementation('com.github.KotatsuApp:kotatsu-parsers:b7613606c0') {
exclude group: 'org.json', module: 'json'
}

View File

@@ -14,6 +14,7 @@ import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.ui.BaseActivity
import org.koitharu.kotatsu.core.util.ext.toUriOrNull
import org.koitharu.kotatsu.databinding.ActivityBrowserBinding
import org.koitharu.kotatsu.parsers.network.UserAgents
import com.google.android.material.R as materialR
@@ -80,11 +81,14 @@ class BrowserActivity : BaseActivity<ActivityBrowserBinding>(), BrowserCallback
}
R.id.action_browser -> {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(viewBinding.webView.url)
try {
startActivity(Intent.createChooser(intent, item.title))
} catch (_: ActivityNotFoundException) {
val url = viewBinding.webView.url?.toUriOrNull()
if (url != null) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = url
try {
startActivity(Intent.createChooser(intent, item.title))
} catch (_: ActivityNotFoundException) {
}
}
true
}

View File

@@ -27,6 +27,7 @@ import org.koitharu.kotatsu.explore.data.SourcesSortOrder
import org.koitharu.kotatsu.list.domain.ListSortOrder
import org.koitharu.kotatsu.parsers.model.SortOrder
import org.koitharu.kotatsu.parsers.util.find
import org.koitharu.kotatsu.parsers.util.isNumeric
import org.koitharu.kotatsu.parsers.util.mapNotNullToSet
import org.koitharu.kotatsu.parsers.util.mapToSet
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
@@ -191,11 +192,13 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
var appPassword: String?
get() = prefs.getString(KEY_APP_PASSWORD, null)
set(value) = prefs.edit {
if (value != null) putString(KEY_APP_PASSWORD, value) else remove(
KEY_APP_PASSWORD,
)
if (value != null) putString(KEY_APP_PASSWORD, value) else remove(KEY_APP_PASSWORD)
}
var isAppPasswordNumeric: Boolean
get() = prefs.getBoolean(KEY_APP_PASSWORD_NUMERIC, false)
set(value) = prefs.edit { putBoolean(KEY_APP_PASSWORD_NUMERIC, value) }
val isLoggingEnabled: Boolean
get() = prefs.getBoolean(KEY_LOGGING_ENABLED, false)
@@ -528,6 +531,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
const val KEY_READER_MODE = "reader_mode"
const val KEY_READER_MODE_DETECT = "reader_mode_detect"
const val KEY_APP_PASSWORD = "app_password"
const val KEY_APP_PASSWORD_NUMERIC = "app_password_num"
const val KEY_PROTECT_APP = "protect_app"
const val KEY_PROTECT_APP_BIOMETRIC = "protect_app_bio"
const val KEY_APP_VERSION = "app_version"

View File

@@ -60,11 +60,11 @@ abstract class BaseActivity<B : ViewBinding> :
if (isAmoledTheme) {
setTheme(R.style.ThemeOverlay_Kotatsu_Amoled)
}
putDataToExtras(intent)
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
insetsDelegate.handleImeInsets = true
insetsDelegate.addInsetsListener(this)
putDataToExtras(intent)
}
override fun onPostCreate(savedInstanceState: Bundle?) {

View File

@@ -44,6 +44,12 @@ class ProtectActivity :
viewBinding.buttonNext.setOnClickListener(this)
viewBinding.buttonCancel.setOnClickListener(this)
viewBinding.editPassword.inputType = if (viewModel.isNumericPassword) {
EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_VARIATION_PASSWORD
} else {
EditorInfo.TYPE_CLASS_TEXT or EditorInfo.TYPE_TEXT_VARIATION_PASSWORD
}
viewModel.onError.observeEvent(this, this::onError)
viewModel.isLoading.observe(this, this::onLoadingStateChanged)
viewModel.onUnlockSuccess.observeEvent(this) {

View File

@@ -8,6 +8,7 @@ import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.core.ui.BaseViewModel
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
import org.koitharu.kotatsu.core.util.ext.call
import org.koitharu.kotatsu.parsers.util.isNumeric
import org.koitharu.kotatsu.parsers.util.md5
import javax.inject.Inject
@@ -26,6 +27,9 @@ class ProtectViewModel @Inject constructor(
val isBiometricEnabled
get() = settings.isBiometricProtectionEnabled
val isNumericPassword
get() = settings.isAppPasswordNumeric
fun tryUnlock(password: String) {
if (job?.isActive == true) {
return

View File

@@ -14,6 +14,7 @@ class ChapterPages private constructor(private val pages: ArrayDeque<ReaderPage>
val chaptersSize: Int
get() = indices.size()
@Synchronized
fun removeFirst() {
val chapterId = pages.first().chapterId
indices.remove(chapterId)
@@ -25,6 +26,7 @@ class ChapterPages private constructor(private val pages: ArrayDeque<ReaderPage>
shiftIndices(delta)
}
@Synchronized
fun removeLast() {
val chapterId = pages.last().chapterId
indices.remove(chapterId)
@@ -33,17 +35,28 @@ class ChapterPages private constructor(private val pages: ArrayDeque<ReaderPage>
}
}
fun addLast(id: Long, newPages: List<ReaderPage>) {
@Synchronized
fun addLast(id: Long, newPages: List<ReaderPage>): Boolean {
if (id in indices) {
return false
}
indices.put(id, pages.size until (pages.size + newPages.size))
pages.addAll(newPages)
return true
}
fun addFirst(id: Long, newPages: List<ReaderPage>) {
@Synchronized
fun addFirst(id: Long, newPages: List<ReaderPage>): Boolean {
if (id in indices) {
return false
}
shiftIndices(newPages.size)
indices.put(id, newPages.indices)
pages.addAll(0, newPages)
return true
}
@Synchronized
fun clear() {
indices.clear()
pages.clear()
@@ -58,7 +71,7 @@ class ChapterPages private constructor(private val pages: ArrayDeque<ReaderPage>
return pages.subList(range.first, range.last + 1)
}
operator fun contains(chapterId: Long) = indices.contains(chapterId)
operator fun contains(chapterId: Long) = chapterId in indices
private fun shiftIndices(delta: Int) {
for (i in 0 until indices.size()) {

View File

@@ -12,6 +12,7 @@ import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.core.ui.BaseViewModel
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
import org.koitharu.kotatsu.core.util.ext.call
import org.koitharu.kotatsu.parsers.util.isNumeric
import org.koitharu.kotatsu.parsers.util.md5
import javax.inject.Inject
@@ -39,6 +40,7 @@ class ProtectSetupViewModel @Inject constructor(
} else {
if (firstPassword.value == password) {
settings.appPassword = password.md5()
settings.isAppPasswordNumeric = password.isNumeric()
onPasswordSet.call(Unit)
} else {
onPasswordMismatch.call(Unit)

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="0.2" android:color="?attr/colorPrimaryInverse" />
<item android:alpha="0.27" android:color="?attr/colorOnSurface" />
</selector>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- https://stackoverflow.com/questions/54685474/theme-attributes-in-color-selector-for-api-22 -->
<item android:alpha="0.2" android:color="@color/kotatsu_inversePrimary" />
<item android:alpha="0.27" android:color="@color/kotatsu_onSurface" />
</selector>

View File

@@ -112,7 +112,7 @@
app:barrierMargin="8dp"
app:constraint_referenced_ids="imageView_cover,spinner_status" />
<TextView
<org.koitharu.kotatsu.core.ui.widgets.SelectableTextView
android:id="@+id/textView_description"
android:layout_width="0dp"
android:layout_height="wrap_content"

View File

@@ -4,7 +4,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.2'
classpath 'com.android.tools.build:gradle:8.3.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.51'
classpath 'com.google.devtools.ksp:symbol-processing-gradle-plugin:1.9.22-1.0.17'

View File

@@ -2,6 +2,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists