fix: various small fixes

This commit is contained in:
rebelonion 2024-05-22 11:26:48 -05:00
parent 4ccf6fa1c8
commit e5ec6a6526
8 changed files with 44 additions and 21 deletions

View file

@ -240,6 +240,9 @@ class SubscriptionNotificationTask : Task {
if (newStore.size >= 100) {
newStore.remove(newStore.minByOrNull { it.time })
}
if (newStore.any { it.title == notification.title && it.content == notification.content}) {
return
}
newStore.add(notification)
PrefManager.setVal(PrefName.SubscriptionNotificationStore, newStore)

View file

@ -8,6 +8,7 @@ import android.text.style.ForegroundColorSpan
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.doOnAttach
import androidx.core.view.updateLayoutParams
import ani.dantotsu.MainActivity
import ani.dantotsu.R
@ -27,13 +28,17 @@ class CalcActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ThemeManager(this).applyTheme()
initActivity(this)
binding = ActivityCalcBinding.inflate(layoutInflater)
binding.mainContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin += statusBarHeight
bottomMargin = navBarHeight
}
setContentView(binding.root)
binding.root.doOnAttach {
initActivity(this)
binding.displayContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin += statusBarHeight
}
binding.buttonContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin += navBarHeight
}
}
code = intent.getStringExtra("code") ?: "0"
binding.apply {

View file

@ -11,6 +11,7 @@ import ani.dantotsu.util.Logger
import eu.kanade.tachiyomi.animesource.model.SAnime
import eu.kanade.tachiyomi.source.model.SManga
import me.xdrop.fuzzywuzzy.FuzzySearch
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.Serializable
import java.net.URLDecoder
@ -147,10 +148,11 @@ abstract class BaseParser {
* @return Triple<Int, Int?, String> : First Int is the status code, Second Int is the response time in milliseconds, Third String is the response message.
*/
fun ping(): Triple<Int, Int?, String> {
val client = okHttpClient
val client = OkHttpClient()
var statusCode = 0
var responseTime: Int? = null
var responseMessage = ""
println("Pinging $name at $hostUrl")
try {
val request = Request.Builder()
.url(hostUrl)
@ -158,7 +160,7 @@ abstract class BaseParser {
responseTime = measureTimeMillis {
client.newCall(request).execute().use { response ->
statusCode = response.code
responseMessage = response.message
responseMessage = response.message.ifEmpty { "None" }
}
}.toInt()
} catch (e: Exception) {

View file

@ -95,11 +95,11 @@ class ExtensionTestItem(
}
private suspend fun runAnimeTest(extension: AnimeParser) {
pingResult = extension.ping()
withContext(Dispatchers.Main) {
pingResult()
}
if (testType == "ping") {
pingResult = extension.ping()
withContext(Dispatchers.Main) {
pingResult()
}
done()
return
}
@ -137,11 +137,11 @@ class ExtensionTestItem(
}
private suspend fun runMangaTest(extension: MangaParser) {
pingResult = extension.ping()
withContext(Dispatchers.Main) {
pingResult()
}
if (testType == "ping") {
pingResult = extension.ping()
withContext(Dispatchers.Main) {
pingResult()
}
done()
return
}
@ -179,10 +179,10 @@ class ExtensionTestItem(
}
private suspend fun runNovelTest(extension: NovelParser) {
withContext(Dispatchers.Main) {
pingResult()
}
if (testType == "ping") {
withContext(Dispatchers.Main) {
pingResult()
}
done()
return
}
@ -219,7 +219,7 @@ class ExtensionTestItem(
private fun pingResult() {
if (::binding.isInitialized.not()) return
if (extensionType == "novel") {
if (extensionType == "novel" && testType != "basic") {
binding.pingResultText.isVisible = true
binding.pingResultText.text = context.getString(R.string.test_not_supported)
binding.pingResultText.setCompoundDrawablesWithIntrinsicBounds(

View file

@ -96,6 +96,11 @@ class ExtensionTestSettingsBottomDialog : BottomSheetDialogFragment() {
testType = "full"
}
}
binding.extensionTypeTextView.setOnLongClickListener {
binding.searchTextView.visibility = View.VISIBLE
binding.searchView.visibility = View.VISIBLE
true
}
setupAdapter()
}

View file

@ -176,7 +176,7 @@ class SettingsCommonActivity : AppCompatActivity() {
icon = R.drawable.ic_round_lock_open_24,
onClick = {
val passwordDialog = AlertDialog.Builder(context, R.style.MyPopup)
.setTitle(R.string.download_manager)
.setTitle(R.string.app_lock)
.setView(R.layout.dialog_set_password)
.setPositiveButton(R.string.ok) { dialog, _ ->
val passwordInput =