Skip to content

Commit

Permalink
fix: various small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed May 22, 2024
1 parent 4ccf6fa commit e5ec6a6
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/java/ani/dantotsu/others/calc/CalcActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/ani/dantotsu/parsers/BaseParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -147,18 +148,19 @@ 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)
.build()
responseTime = measureTimeMillis {
client.newCall(request).execute().use { response ->
statusCode = response.code
responseMessage = response.message
responseMessage = response.message.ifEmpty { "None" }
}
}.toInt()
} catch (e: Exception) {
Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class ExtensionTestSettingsBottomDialog : BottomSheetDialogFragment() {
testType = "full"
}
}
binding.extensionTypeTextView.setOnLongClickListener {
binding.searchTextView.visibility = View.VISIBLE
binding.searchView.visibility = View.VISIBLE
true
}
setupAdapter()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/layout/activity_calc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
android:id="@+id/mainContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="32dp"
android:layout_marginTop="64dp"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/bg"
android:orientation="vertical"
tools:context=".MainActivity">

<LinearLayout
android:id="@+id/displayContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
Expand Down Expand Up @@ -72,8 +73,10 @@
android:layout_weight="1" />

<LinearLayout
android:id="@+id/buttonContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:layout_gravity="center_horizontal|bottom"
android:orientation="vertical">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
android:orientation="vertical">

<TextView
android:id="@+id/extensionTypeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
Expand Down Expand Up @@ -49,6 +50,7 @@
</RadioGroup>

<TextView
android:id="@+id/testTypeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
Expand Down Expand Up @@ -91,13 +93,15 @@
</RadioGroup>

<TextView
android:id="@+id/searchTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginTop="16dp"
android:fontFamily="@font/poppins_bold"
android:text="@string/test_search"
android:textAlignment="center"
android:visibility="gone"
android:textSize="16sp" />

<com.google.android.material.textfield.TextInputLayout
Expand All @@ -116,6 +120,7 @@
app:boxCornerRadiusTopEnd="28dp"
app:boxCornerRadiusTopStart="28dp"
app:endIconDrawable="@drawable/ic_round_search_24"
android:visibility="gone"
app:hintAnimationEnabled="true">

<AutoCompleteTextView
Expand Down

0 comments on commit e5ec6a6

Please sign in to comment.