From b3471234ad74152bca46237e89a54e84a9912fe7 Mon Sep 17 00:00:00 2001 From: Taco Date: Thu, 8 Apr 2021 17:56:01 -0400 Subject: [PATCH] Update NDK, more KTX usage (#4792) * Update NDK * Utilize more KTX extensions --- .../ui/browse/source/filter/TextItem.kt | 10 ++++------ .../tachiyomi/ui/reader/ReaderActivity.kt | 2 +- .../kanade/tachiyomi/util/system/ImageUtil.kt | 5 +++-- .../widget/DialogCustomDownloadView.kt | 17 ++++++++--------- .../tachiyomi/widget/SimpleTextWatcher.kt | 15 --------------- buildSrc/src/main/kotlin/AndroidConfig.kt | 2 +- 6 files changed, 17 insertions(+), 34 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/SimpleTextWatcher.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TextItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TextItem.kt index f55ca009b6..b0f5010aff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TextItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TextItem.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.source.filter import android.view.View import android.widget.EditText +import androidx.core.widget.doOnTextChanged import androidx.recyclerview.widget.RecyclerView import com.google.android.material.textfield.TextInputLayout import eu.davidea.flexibleadapter.FlexibleAdapter @@ -10,7 +11,6 @@ import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.viewholders.FlexibleViewHolder import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.model.Filter -import eu.kanade.tachiyomi.widget.SimpleTextWatcher open class TextItem(val filter: Filter.Text) : AbstractFlexibleItem() { @@ -25,11 +25,9 @@ open class TextItem(val filter: Filter.Text) : AbstractFlexibleItem>, holder: Holder, position: Int, payloads: List?) { holder.wrapper.hint = filter.name holder.edit.setText(filter.state) - holder.edit.addTextChangedListener(object : SimpleTextWatcher() { - override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) { - filter.state = text.toString() - } - }) + holder.edit.doOnTextChanged { text, _, _, _ -> + filter.state = text.toString() + } } override fun equals(other: Any?): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 48f2861724..32d6bb108a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -820,7 +820,7 @@ class ReaderActivity : BaseRxActivity() * Sets the visibility of the bottom page indicator according to [visible]. */ fun setPageNumberVisibility(visible: Boolean) { - binding.pageNumber.visibility = if (visible) View.VISIBLE else View.INVISIBLE + binding.pageNumber.isVisible = visible } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt index 73fda3cc52..61fdee35dc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt @@ -4,6 +4,7 @@ import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.Canvas import android.graphics.Rect +import androidx.core.graphics.createBitmap import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.InputStream @@ -99,7 +100,7 @@ object ImageUtil { val singlePage = Rect(0, 0, width / 2, height) - val half = Bitmap.createBitmap(width / 2, height, Bitmap.Config.ARGB_8888) + val half = createBitmap(width / 2, height) val part = when (side) { Side.RIGHT -> Rect(width - width / 2, 0, width, height) Side.LEFT -> Rect(0, 0, width / 2, height) @@ -122,7 +123,7 @@ object ImageUtil { val height = imageBitmap.height val width = imageBitmap.width - val result = Bitmap.createBitmap(width / 2, height * 2, Bitmap.Config.ARGB_8888) + val result = createBitmap(width / 2, height * 2) val canvas = Canvas(result) // right -> upper val rightPart = when (upperSide) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/DialogCustomDownloadView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/DialogCustomDownloadView.kt index 44c5f23f05..67a4feb296 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/DialogCustomDownloadView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/DialogCustomDownloadView.kt @@ -6,6 +6,7 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout +import androidx.core.widget.doOnTextChanged import eu.kanade.tachiyomi.databinding.DownloadCustomAmountBinding import timber.log.Timber @@ -65,16 +66,14 @@ class DialogCustomDownloadView @JvmOverloads constructor(context: Context, attrs } // When user inputs custom number set amount equal to input. - binding.myNumber.addTextChangedListener(object : SimpleTextWatcher() { - override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) { - try { - amount = getAmount(text.toString().toInt()) - } catch (error: NumberFormatException) { - // Catch NumberFormatException to prevent parse exception when input is empty. - Timber.e(error) - } + binding.myNumber.doOnTextChanged { text, _, _, _ -> + try { + amount = getAmount(text.toString().toInt()) + } catch (error: NumberFormatException) { + // Catch NumberFormatException to prevent parse exception when input is empty. + Timber.e(error) } - }) + } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleTextWatcher.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleTextWatcher.kt deleted file mode 100644 index 06870c2399..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleTextWatcher.kt +++ /dev/null @@ -1,15 +0,0 @@ -package eu.kanade.tachiyomi.widget - -import android.text.Editable -import android.text.TextWatcher - -open class SimpleTextWatcher : TextWatcher { - override fun beforeTextChanged(text: CharSequence, start: Int, count: Int, after: Int) { - } - - override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) { - } - - override fun afterTextChanged(text: Editable) { - } -} diff --git a/buildSrc/src/main/kotlin/AndroidConfig.kt b/buildSrc/src/main/kotlin/AndroidConfig.kt index 1182a47922..61c935a13b 100644 --- a/buildSrc/src/main/kotlin/AndroidConfig.kt +++ b/buildSrc/src/main/kotlin/AndroidConfig.kt @@ -3,5 +3,5 @@ object AndroidConfig { const val minSdk = 21 const val targetSdk = 29 const val buildTools = "30.0.3" - const val ndk = "22.0.7026061" + const val ndk = "22.1.7171670" }