2022-12-25 20:38:52 +05:30
|
|
|
package com.github.libretube.util
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import com.github.libretube.constants.PreferenceKeys
|
2023-01-31 21:13:39 +05:30
|
|
|
import com.github.libretube.helpers.NetworkHelper
|
|
|
|
import com.github.libretube.helpers.PreferenceHelper
|
2022-12-25 20:38:52 +05:30
|
|
|
|
|
|
|
object DataSaverMode {
|
|
|
|
fun isEnabled(context: Context): Boolean {
|
|
|
|
val pref = PreferenceHelper.getString(PreferenceKeys.DATA_SAVER_MODE, "disabled")
|
|
|
|
return when (pref) {
|
|
|
|
"enabled" -> true
|
|
|
|
"disabled" -> false
|
2023-01-21 17:44:06 +05:30
|
|
|
"metered" -> NetworkHelper.isNetworkMetered(context)
|
2022-12-25 20:38:52 +05:30
|
|
|
else -> throw IllegalArgumentException()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|