summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/vpn2
diff options
context:
space:
mode:
authorZoltan Szatmary-Ban <szatmz@google.com>2014-07-31 16:49:52 +0100
committerZoltan Szatmary-Ban <szatmz@google.com>2014-08-01 14:41:57 +0000
commitca90af1064f966c1ef764a3388020c94ba4a1121 (patch)
tree49e48947f9b5f21b5ed5c1872ce939a704c51921 /src/com/android/settings/vpn2
parentf3d72098b0008a9a8e137985d7fbc0e0470adc9c (diff)
downloadpackages_apps_Settings-ca90af1064f966c1ef764a3388020c94ba4a1121.zip
packages_apps_Settings-ca90af1064f966c1ef764a3388020c94ba4a1121.tar.gz
packages_apps_Settings-ca90af1064f966c1ef764a3388020c94ba4a1121.tar.bz2
Toggle between profiles in VPN Settings
This adds a spinner to the VPN settings screen which can be used to toggle between the Settings app in the primary and managed profile so that the user can edit settings belonging to both profiles. Bug:16030111 Change-Id: I3b800264c634900412e8eebdbcf43a2b6913c2be
Diffstat (limited to 'src/com/android/settings/vpn2')
-rw-r--r--src/com/android/settings/vpn2/VpnSettings.java49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index ea6325e..5be9046 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -16,11 +16,13 @@
package com.android.settings.vpn2;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
@@ -29,10 +31,13 @@ import android.os.Handler;
import android.os.Message;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.os.UserManager;
+import android.os.Process;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
+import android.provider.Settings;
import android.security.Credentials;
import android.security.KeyStore;
import android.text.TextUtils;
@@ -44,11 +49,14 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.Spinner;
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
@@ -56,6 +64,10 @@ import com.android.internal.net.VpnProfile;
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.UserSpinnerAdapter;
+import com.android.settings.UserSpinnerAdapter.UserDetails;
+import com.android.settings.Utils;
+
import com.google.android.collect.Lists;
import java.util.ArrayList;
@@ -64,11 +76,12 @@ import java.util.List;
public class VpnSettings extends SettingsPreferenceFragment implements
Handler.Callback, Preference.OnPreferenceClickListener,
- DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
+ DialogInterface.OnClickListener, DialogInterface.OnDismissListener, OnItemSelectedListener {
private static final String TAG = "VpnSettings";
private static final String TAG_LOCKDOWN = "lockdown";
+ private static final String ACTION_VPN_SETTINGS = "android.net.vpn.SETTINGS";
private static final String EXTRA_PICK_LOCKDOWN = "android.net.vpn.PICK_LOCKDOWN";
// TODO: migrate to using DialogFragment when editing
@@ -89,6 +102,7 @@ public class VpnSettings extends SettingsPreferenceFragment implements
private String mSelectedKey;
private boolean mUnavailable;
+ private UserSpinnerAdapter mProfileSpinnerAdapter;
@Override
public void onCreate(Bundle savedState) {
@@ -116,6 +130,39 @@ public class VpnSettings extends SettingsPreferenceFragment implements
}
@Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ Context context = getActivity();
+ mProfileSpinnerAdapter = Utils.createUserSpinnerAdapter(mUm, getActivity());
+ if (mProfileSpinnerAdapter != null) {
+ Spinner spinner = (Spinner) getActivity().getLayoutInflater().inflate(
+ R.layout.spinner_view, null);
+
+ spinner.setAdapter(mProfileSpinnerAdapter);
+ spinner.setOnItemSelectedListener(this);
+ setPinnedHeaderView(spinner);
+ }
+ }
+
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ UserHandle selectedUser = mProfileSpinnerAdapter.getUserHandle(position);
+ if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
+ Intent intent = new Intent(ACTION_VPN_SETTINGS);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ Activity activity = getActivity();
+ activity.startActivityAsUser(intent, selectedUser);
+ activity.finish();
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ // Nothing to do
+ }
+
+ @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.vpn, menu);