LibreTube/app/src/main/java/com/github/libretube/util/DataSaverMode.kt

19 lines
610 B
Kotlin
Raw Normal View History

package com.github.libretube.util
import android.content.Context
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.helpers.NetworkHelper
import com.github.libretube.helpers.PreferenceHelper
object DataSaverMode {
fun isEnabled(context: Context): Boolean {
val pref = PreferenceHelper.getString(PreferenceKeys.DATA_SAVER_MODE, "disabled")
return when (pref) {
"enabled" -> true
"disabled" -> false
"metered" -> NetworkHelper.isNetworkMetered(context)
else -> throw IllegalArgumentException()
}
}
}