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