Merge branch 'pr/257' into dev

This commit is contained in:
rebelonion 2024-03-17 23:12:40 -05:00
commit 1fd91b9ec6
10 changed files with 47 additions and 29 deletions

View file

@ -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"

View file

@ -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
} }

View file

@ -275,7 +275,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
@ -458,7 +458,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(

View file

@ -355,15 +355,13 @@ class AnimeDownloaderService : Service() {
return false return false
} }
@OptIn(DelicateCoroutinesApi::class)
private fun saveMediaInfo(task: AnimeDownloadTask) { private fun saveMediaInfo(task: AnimeDownloadTask) {
GlobalScope.launch(Dispatchers.IO) { CoroutineScope(Dispatchers.IO).launch {
val directory = File( val directory = File(
getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
"${DownloadsManager.animeLocation}/${task.title}" "${DownloadsManager.animeLocation}/${task.title}"
) )
val episodeDirectory = File(directory, task.episode) val episodeDirectory = File(directory, task.episode)
if (!directory.exists()) directory.mkdirs()
if (!episodeDirectory.exists()) episodeDirectory.mkdirs() if (!episodeDirectory.exists()) episodeDirectory.mkdirs()
val file = File(directory, "media.json") val file = File(directory, "media.json")

View file

@ -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)

View file

@ -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,

View file

@ -14,6 +14,7 @@ import android.os.PowerManager
import android.util.TypedValue import android.util.TypedValue
import androidx.annotation.AttrRes import androidx.annotation.AttrRes
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.content.PermissionChecker import androidx.core.content.PermissionChecker
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import androidx.core.graphics.alpha import androidx.core.graphics.alpha
@ -85,7 +86,7 @@ fun Context.getThemeColor(attr: Int): Int {
val tv = TypedValue() val tv = TypedValue()
return if (this.theme.resolveAttribute(attr, tv, true)) { return if (this.theme.resolveAttribute(attr, tv, true)) {
if (tv.resourceId != 0) { if (tv.resourceId != 0) {
getColor(tv.resourceId) ContextCompat.getColor(this, tv.resourceId)
} else { } else {
tv.data tv.data
} }

View file

@ -10,6 +10,7 @@ import androidx.core.app.NotificationChannelGroupCompat
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
import androidx.core.app.NotificationManagerCompat.NotificationWithIdAndTag import androidx.core.app.NotificationManagerCompat.NotificationWithIdAndTag
import androidx.core.content.ContextCompat
import androidx.core.content.PermissionChecker import androidx.core.content.PermissionChecker
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
@ -65,7 +66,7 @@ fun Context.notificationBuilder(
block: (NotificationCompat.Builder.() -> Unit)? = null block: (NotificationCompat.Builder.() -> Unit)? = null
): NotificationCompat.Builder { ): NotificationCompat.Builder {
val builder = NotificationCompat.Builder(this, channelId) val builder = NotificationCompat.Builder(this, channelId)
.setColor(getColor(android.R.color.holo_blue_dark)) .setColor(ContextCompat.getColor(this, android.R.color.holo_blue_dark))
if (block != null) { if (block != null) {
builder.block() builder.block()
} }

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Dantotsu" parent="Theme.Base">
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>

View file

@ -29,10 +29,6 @@
</item> </item>
</style> </style>
<style name="Theme.Dantotsu" parent="Theme.Base">
<item name="android:windowLightStatusBar">false</item>
</style>
<style name="Theme.Dantotsu.NoActionBar"> <style name="Theme.Dantotsu.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>