aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt38
1 files changed, 0 insertions, 38 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
index 8d4c181..feac43c 100644
--- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
@@ -5,13 +5,9 @@
package com.wireguard.android.activity
import android.content.Intent
-import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
-import android.util.SparseArray
import android.view.MenuItem
-import androidx.core.app.ActivityCompat
-import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
@@ -23,35 +19,11 @@ import com.wireguard.android.util.ModuleLoader
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import java.util.ArrayList
-import java.util.Arrays
/**
* Interface for changing application-global persistent settings.
*/
class SettingsActivity : ThemeChangeAwareActivity() {
- private val permissionRequestCallbacks = SparseArray<(permissions: Array<String>, granted: IntArray) -> Unit>()
- private var permissionRequestCounter = 0
-
- fun ensurePermissions(permissions: Array<String>, cb: (permissions: Array<String>, granted: IntArray) -> Unit) {
- val needPermissions: MutableList<String> = ArrayList(permissions.size)
- permissions.forEach {
- if (ContextCompat.checkSelfPermission(this, it) != PackageManager.PERMISSION_GRANTED) {
- needPermissions.add(it)
- }
- }
- if (needPermissions.isEmpty()) {
- val granted = IntArray(permissions.size)
- Arrays.fill(granted, PackageManager.PERMISSION_GRANTED)
- cb.invoke(permissions, granted)
- return
- }
- val idx = permissionRequestCounter++
- permissionRequestCallbacks.put(idx, cb)
- ActivityCompat.requestPermissions(this,
- needPermissions.toTypedArray(), idx)
- }
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (supportFragmentManager.findFragmentById(android.R.id.content) == null) {
@@ -69,16 +41,6 @@ class SettingsActivity : ThemeChangeAwareActivity() {
return super.onOptionsItemSelected(item)
}
- override fun onRequestPermissionsResult(requestCode: Int,
- permissions: Array<String>,
- grantResults: IntArray) {
- val f = permissionRequestCallbacks[requestCode]
- if (f != null) {
- permissionRequestCallbacks.remove(requestCode)
- f.invoke(permissions, grantResults)
- }
- }
-
class SettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, key: String?) {
addPreferencesFromResource(R.xml.preferences)