mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-10 16:02:05 -04:00
Merge pull request #3436 from kiwix/Issue#3430
Fixed `Toast.getView()` and `Html.fromHtml()` is deprecated
This commit is contained in:
commit
1fd71b51c9
@ -18,18 +18,14 @@
|
||||
|
||||
package org.kiwix.kiwixmobile.zimManager.libraryView.adapter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.View.MeasureSpec
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import com.tonyodev.fetch2.Status
|
||||
import org.kiwix.kiwixmobile.R
|
||||
import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder
|
||||
import org.kiwix.kiwixmobile.core.downloader.model.Base64String
|
||||
import org.kiwix.kiwixmobile.core.extensions.setBitmap
|
||||
import org.kiwix.kiwixmobile.core.extensions.setTextAndVisibility
|
||||
import org.kiwix.kiwixmobile.core.extensions.toast
|
||||
import org.kiwix.kiwixmobile.core.utils.BookUtils
|
||||
import org.kiwix.kiwixmobile.core.zim_manager.KiloByte
|
||||
import org.kiwix.kiwixmobile.databinding.ItemDownloadBinding
|
||||
@ -75,9 +71,10 @@ sealed class LibraryViewHolder<in T : LibraryListItem>(containerView: View) :
|
||||
else
|
||||
View.VISIBLE
|
||||
itemLibraryBinding.unableToDownload.setOnLongClickListener {
|
||||
val context = itemLibraryBinding.root.context
|
||||
when (item.fileSystemState) {
|
||||
CannotWrite4GbFile -> it.centreToast(R.string.file_system_does_not_support_4gb)
|
||||
DetectingFileSystem -> it.centreToast(R.string.detecting_file_system)
|
||||
CannotWrite4GbFile -> context.toast(R.string.file_system_does_not_support_4gb)
|
||||
DetectingFileSystem -> context.toast(R.string.detecting_file_system)
|
||||
else -> {
|
||||
if (item.canBeDownloaded && !hasAvailableSpaceInStorage) {
|
||||
clickAction.invoke(item)
|
||||
@ -119,21 +116,3 @@ sealed class LibraryViewHolder<in T : LibraryListItem>(containerView: View) :
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ShowToast")
|
||||
private fun View.centreToast(@StringRes id: Int) {
|
||||
val locationXAndY = intArrayOf(0, 0)
|
||||
getLocationOnScreen(locationXAndY)
|
||||
val midX = locationXAndY[0] + width / 2
|
||||
val midY = locationXAndY[1] + height / 2
|
||||
Toast.makeText(context, id, Toast.LENGTH_LONG).apply {
|
||||
view?.let { view ->
|
||||
view.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED)
|
||||
setGravity(
|
||||
Gravity.TOP or Gravity.START,
|
||||
midX - view.measuredWidth / 2,
|
||||
midY - view.measuredHeight
|
||||
)
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
@ -18,12 +18,12 @@
|
||||
|
||||
package org.kiwix.kiwixmobile.core.utils.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.net.Uri
|
||||
import android.text.Html
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup.LayoutParams
|
||||
import android.widget.FrameLayout
|
||||
@ -33,6 +33,7 @@ import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.extensions.getAttribute
|
||||
import org.kiwix.kiwixmobile.core.utils.StyleUtils.fromHtml
|
||||
import javax.inject.Inject
|
||||
|
||||
class AlertDialogShower @Inject constructor(private val activity: Activity) :
|
||||
@ -89,7 +90,8 @@ class AlertDialogShower @Inject constructor(private val activity: Activity) :
|
||||
).show()
|
||||
true
|
||||
}
|
||||
text = Html.fromHtml("</br><a href=$uri> <b>$uri</b>")
|
||||
@SuppressLint("SetTextI18n")
|
||||
text = "</br><a href=$uri> <b>$uri</b>".fromHtml()
|
||||
}
|
||||
frameLayout.addView(textView)
|
||||
setView(frameLayout)
|
||||
|
Loading…
x
Reference in New Issue
Block a user