|
@@ -12,7 +12,6 @@ import android.content.BroadcastReceiver
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.content.IntentFilter
|
|
|
-import android.content.RestrictionsManager
|
|
|
import android.os.Build
|
|
|
import android.os.Handler
|
|
|
import android.os.Looper
|
|
@@ -20,23 +19,6 @@ import android.widget.Toast
|
|
|
import com.google.common.io.Resources
|
|
|
import com.owncloud.android.R
|
|
|
import com.owncloud.android.datamodel.ReceiverFlag
|
|
|
-import com.owncloud.android.utils.appConfig.AppConfigKeys
|
|
|
-
|
|
|
-fun <T : Any> Context.getRestriction(appConfigKey: AppConfigKeys, defaultValue: T): T {
|
|
|
- val restrictionsManager = getSystemService(Context.RESTRICTIONS_SERVICE) as? RestrictionsManager
|
|
|
- return restrictionsManager?.getRestriction(appConfigKey.key, defaultValue) ?: defaultValue
|
|
|
-}
|
|
|
-
|
|
|
-@Suppress("UNCHECKED_CAST")
|
|
|
-private fun <T : Any> RestrictionsManager.getRestriction(key: String, defaultValue: T): T {
|
|
|
- val appRestrictions = getApplicationRestrictions()
|
|
|
- return when (defaultValue) {
|
|
|
- is String -> appRestrictions.getString(key, defaultValue) as T? ?: defaultValue
|
|
|
- is Int -> appRestrictions.getInt(key, defaultValue) as T? ?: defaultValue
|
|
|
- is Boolean -> appRestrictions.getBoolean(key, defaultValue) as T? ?: defaultValue
|
|
|
- else -> defaultValue
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
fun Context.hourPlural(hour: Int): String = resources.getQuantityString(R.plurals.hours, hour, hour)
|
|
|
|