diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2018-04-27 22:29:27 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2018-04-30 17:30:24 +0530 |
commit | 4ec0b3a908679f7943488b97f62f9e354edd68b3 (patch) | |
tree | b6defa7c341d82af4cdfa34d4c9ae2157b7165bf /app/src/main/java/com/wireguard/android/activity/SettingsActivity.java | |
parent | af57824c148107c13164c460fbd8718b6b0d88f4 (diff) |
Prefer AppCompat classes
AppCompat is the preferred way to go for any app targetting
a wider range of SDKs.
Replace all activities and fragments with their AppCompat
variants and fixup method calls to use support variants.
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/activity/SettingsActivity.java')
-rw-r--r-- | app/src/main/java/com/wireguard/android/activity/SettingsActivity.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java index 41761b32..273c7da8 100644 --- a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java @@ -1,10 +1,11 @@ package com.wireguard.android.activity; -import android.app.Activity; import android.content.pm.PackageManager; import android.os.Bundle; -import android.preference.Preference; -import android.preference.PreferenceFragment; +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.preference.Preference; +import android.support.v7.preference.PreferenceFragmentCompat; import com.wireguard.android.Application; import com.wireguard.android.R; @@ -19,7 +20,7 @@ import java.util.List; * Interface for changing application-global persistent settings. */ -public class SettingsActivity extends Activity { +public class SettingsActivity extends AppCompatActivity { @FunctionalInterface public interface PermissionRequestCallback { void done(String[] permissions, int[] grantResults); @@ -56,7 +57,7 @@ public class SettingsActivity extends Activity { } @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { final PermissionRequestCallback f = permissionRequestCallbacks.get(requestCode); if (f != null) { permissionRequestCallbacks.remove(requestCode); @@ -67,17 +68,16 @@ public class SettingsActivity extends Activity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (getFragmentManager().findFragmentById(android.R.id.content) == null) { - getFragmentManager().beginTransaction() + if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) { + getSupportFragmentManager().beginTransaction() .add(android.R.id.content, new SettingsFragment()) .commit(); } } - public static class SettingsFragment extends PreferenceFragment { + public static class SettingsFragment extends PreferenceFragmentCompat { @Override - public void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + public void onCreatePreferences(final Bundle savedInstanceState, final String key) { addPreferencesFromResource(R.xml.preferences); if (Application.getComponent().getBackendType() != WgQuickBackend.class) { final Preference toolsInstaller = |