summaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-11-27 03:13:34 +0100
committerSamuel Holland <samuel@sholland.org>2017-11-27 03:13:34 +0100
commitad16d2cc7b5a39c95450f9d7bd26a0895e8af76b (patch)
tree9e8624bbc218a0f454f15effbeb97c9f50261598 /app/src/main
parentb0bb46382c2887559d664f85581060748db3cd79 (diff)
Settings: show quick tile config if no primary is defined
This seems like a horrific set of hacks. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/wireguard/android/ConfigListPreference.java2
-rw-r--r--app/src/main/java/com/wireguard/android/QuickTileService.java8
-rw-r--r--app/src/main/java/com/wireguard/android/SettingsActivity.java8
-rw-r--r--app/src/main/res/values/strings.xml2
4 files changed, 17 insertions, 3 deletions
diff --git a/app/src/main/java/com/wireguard/android/ConfigListPreference.java b/app/src/main/java/com/wireguard/android/ConfigListPreference.java
index 131b0a43..e0bcc672 100644
--- a/app/src/main/java/com/wireguard/android/ConfigListPreference.java
+++ b/app/src/main/java/com/wireguard/android/ConfigListPreference.java
@@ -34,4 +34,6 @@ public class ConfigListPreference extends ListPreference {
public ConfigListPreference(final Context context) {
this(context, null);
}
+
+ public void show() { showDialog(null); }
}
diff --git a/app/src/main/java/com/wireguard/android/QuickTileService.java b/app/src/main/java/com/wireguard/android/QuickTileService.java
index 31ebe568..e512b1ad 100644
--- a/app/src/main/java/com/wireguard/android/QuickTileService.java
+++ b/app/src/main/java/com/wireguard/android/QuickTileService.java
@@ -30,7 +30,13 @@ public class QuickTileService extends TileService {
else
service.enable(config.getName());
} else {
- startActivityAndCollapse(new Intent(this, ConfigActivity.class));
+ if (service != null && service.getConfigs().isEmpty()) {
+ startActivityAndCollapse(new Intent(this, ConfigActivity.class));
+ } else {
+ final Intent intent = new Intent(this, SettingsActivity.class);
+ intent.putExtra("showQuickTile", true);
+ startActivityAndCollapse(intent);
+ }
}
}
diff --git a/app/src/main/java/com/wireguard/android/SettingsActivity.java b/app/src/main/java/com/wireguard/android/SettingsActivity.java
index 6fa3f897..be9f5bf4 100644
--- a/app/src/main/java/com/wireguard/android/SettingsActivity.java
+++ b/app/src/main/java/com/wireguard/android/SettingsActivity.java
@@ -10,7 +10,11 @@ public class SettingsActivity extends Activity {
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.replace(android.R.id.content, new SettingsFragment()).commit();
+ final Bundle args = new Bundle();
+ args.putBoolean("showQuickTile", getIntent().getBooleanExtra("showQuickTile", false));
+ final SettingsFragment fragment = new SettingsFragment();
+ fragment.setArguments(args);
+ transaction.replace(android.R.id.content, fragment).commit();
}
public static class SettingsFragment extends PreferenceFragment {
@@ -18,6 +22,8 @@ public class SettingsActivity extends Activity {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
+ if (getArguments().getBoolean("showQuickTile"))
+ ((ConfigListPreference) findPreference("primary_config")).show();
}
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9ed7bb3e..232dfc56 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -29,7 +29,7 @@
<string name="persistent_keepalive">Persistent keepalive</string>
<string name="placeholder_text">No configuration selected</string>
<string name="pre_shared_key">Pre-shared key</string>
- <string name="primary_config">Primary configuration</string>
+ <string name="primary_config">Quick tile configuration</string>
<string name="primary_config_summary">This configuration will be controlled by the quick settings tile</string>
<string name="private_key">Private key</string>
<string name="public_key">Public key</string>