2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.settings.vpn;
19 import com.android.settings.R;
21 import android.content.Intent;
22 import android.net.vpn.VpnManager;
23 import android.net.vpn.VpnType;
24 import android.os.Bundle;
25 import android.preference.Preference;
26 import android.preference.PreferenceActivity;
27 import android.preference.PreferenceScreen;
29 import java.util.HashMap;
33 * The activity to select a VPN type.
35 public class VpnTypeSelection extends PreferenceActivity {
36 private Map<String, VpnType> mTypeMap = new HashMap<String, VpnType>();
39 public void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState);
42 addPreferencesFromResource(R.xml.vpn_type);
47 public boolean onPreferenceTreeClick(PreferenceScreen ps, Preference pref) {
48 setResult(mTypeMap.get(pref.getTitle().toString()));
53 private void initTypeList() {
54 PreferenceScreen root = getPreferenceScreen();
55 for (VpnType t : VpnManager.getSupportedVpnTypes()) {
56 String displayName = t.getDisplayName();
57 mTypeMap.put(displayName, t);
59 Preference pref = new Preference(this);
60 pref.setTitle(displayName);
61 root.addPreference(pref);
65 private void setResult(VpnType type) {
66 Intent intent = new Intent(this, VpnSettings.class);
67 intent.putExtra(VpnSettings.KEY_VPN_TYPE, type.toString());
68 setResult(RESULT_OK, intent);