mirror of
https://github.com/mihonapp/mihon.git
synced 2024-10-31 21:20:59 -04:00
55e9d2880c
Added auto update check (every 12 hour) Warning message optional fix #256 Lots of bug fixes!
24 lines
No EOL
962 B
Kotlin
24 lines
No EOL
962 B
Kotlin
package eu.kanade.tachiyomi.util
|
|
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.content.IntentFilter
|
|
import android.net.ConnectivityManager
|
|
import android.os.BatteryManager
|
|
|
|
object DeviceUtil {
|
|
fun isPowerConnected(context: Context): Boolean {
|
|
val intent = context.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
|
intent?.let {
|
|
val plugged = it.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1)
|
|
return plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB || plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS
|
|
}
|
|
return false
|
|
}
|
|
|
|
fun isNetworkConnected(context: Context): Boolean {
|
|
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
val activeNetwork = cm.activeNetworkInfo
|
|
return activeNetwork != null && activeNetwork.isConnectedOrConnecting
|
|
}
|
|
} |