feat: support API 21 with compat
This commit is contained in:
parent
c033bb0445
commit
a8ad018c44
5 changed files with 35 additions and 20 deletions
|
@ -11,7 +11,7 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId "ani.dantotsu"
|
||||
minSdk 23
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode((System.currentTimeMillis() / 60000).toInteger())
|
||||
versionName "2.2.0"
|
||||
|
|
|
@ -244,21 +244,35 @@ fun isOnline(context: Context): Boolean {
|
|||
val connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
return tryWith {
|
||||
val cap = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
|
||||
return@tryWith if (cap != null) {
|
||||
when {
|
||||
cap.hasTransport(TRANSPORT_BLUETOOTH) ||
|
||||
cap.hasTransport(TRANSPORT_CELLULAR) ||
|
||||
cap.hasTransport(TRANSPORT_ETHERNET) ||
|
||||
cap.hasTransport(TRANSPORT_LOWPAN) ||
|
||||
cap.hasTransport(TRANSPORT_USB) ||
|
||||
cap.hasTransport(TRANSPORT_VPN) ||
|
||||
cap.hasTransport(TRANSPORT_WIFI) ||
|
||||
cap.hasTransport(TRANSPORT_WIFI_AWARE) -> true
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val cap = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
|
||||
return@tryWith if (cap != null) {
|
||||
when {
|
||||
cap.hasTransport(TRANSPORT_BLUETOOTH) ||
|
||||
cap.hasTransport(TRANSPORT_CELLULAR) ||
|
||||
cap.hasTransport(TRANSPORT_ETHERNET) ||
|
||||
cap.hasTransport(TRANSPORT_LOWPAN) ||
|
||||
cap.hasTransport(TRANSPORT_USB) ||
|
||||
cap.hasTransport(TRANSPORT_VPN) ||
|
||||
cap.hasTransport(TRANSPORT_WIFI) ||
|
||||
cap.hasTransport(TRANSPORT_WIFI_AWARE) -> true
|
||||
|
||||
else -> false
|
||||
}
|
||||
} else false
|
||||
else -> false
|
||||
}
|
||||
} else false
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
return@tryWith connectivityManager.activeNetworkInfo?.run {
|
||||
type == ConnectivityManager.TYPE_BLUETOOTH ||
|
||||
type == ConnectivityManager.TYPE_ETHERNET ||
|
||||
type == ConnectivityManager.TYPE_MOBILE ||
|
||||
type == ConnectivityManager.TYPE_MOBILE_DUN ||
|
||||
type == ConnectivityManager.TYPE_MOBILE_HIPRI ||
|
||||
type == ConnectivityManager.TYPE_WIFI ||
|
||||
type == ConnectivityManager.TYPE_WIMAX ||
|
||||
type == ConnectivityManager.TYPE_VPN
|
||||
} ?: false
|
||||
}
|
||||
} ?: false
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
binding.root.doOnAttach {
|
||||
initActivity(this)
|
||||
window.navigationBarColor = getColor(android.R.color.transparent)
|
||||
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.transparent)
|
||||
selectedOption = if (fragment != null) {
|
||||
when (fragment) {
|
||||
AnimeFragment::class.java.name -> 0
|
||||
|
@ -381,7 +381,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
override fun onRestart() {
|
||||
super.onRestart()
|
||||
window.navigationBarColor = getColor(android.R.color.transparent)
|
||||
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.transparent)
|
||||
}
|
||||
|
||||
private val Int.toPx get() = TypedValue.applyDimension(
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.util.TypedValue
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.ItemNovelResponseBinding
|
||||
|
@ -59,11 +60,11 @@ class NovelResponseAdapter(
|
|||
}
|
||||
if (binding.itemEpisodeFiller.text.contains("Downloading")) {
|
||||
binding.itemEpisodeFiller.setTextColor(
|
||||
fragment.requireContext().getColor(android.R.color.holo_blue_light)
|
||||
ContextCompat.getColor(fragment.requireContext(), android.R.color.holo_blue_light)
|
||||
)
|
||||
} else if (binding.itemEpisodeFiller.text.contains("Downloaded")) {
|
||||
binding.itemEpisodeFiller.setTextColor(
|
||||
fragment.requireContext().getColor(android.R.color.holo_green_light)
|
||||
ContextCompat.getColor(fragment.requireContext(), android.R.color.holo_green_light)
|
||||
)
|
||||
} else {
|
||||
binding.itemEpisodeFiller.setTextColor(color)
|
||||
|
|
|
@ -65,7 +65,7 @@ class ProfileFragment : Fragment() {
|
|||
binding.profileUserBio.setInitialScale(1)
|
||||
val styledHtml = getFullAniHTML(
|
||||
user.about ?: "",
|
||||
activity.getColor(R.color.bg_opp)
|
||||
ContextCompat.getColor(activity, R.color.bg_opp)
|
||||
)
|
||||
binding.profileUserBio.loadDataWithBaseURL(
|
||||
null,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue