--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012 Tobias Brunner
+ Hochschule fuer Technik Rapperswil
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item android:id="@+id/add_profile"
+ android:title="@string/add_profile"
+ android:showAsAction="always|withText" />
+
+</menu>
+/*
+ * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012 Giuliano Grassi
+ * Copyright (C) 2012 Ralf Sager
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
package org.strongswan.android.ui;
+import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.net.VpnService;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startVpnService();
+
+ ActionBar bar = getActionBar();
+ bar.setDisplayShowTitleEnabled(false);
}
private void startVpnService()
import org.strongswan.android.data.VpnProfileDataSource;
import org.strongswan.android.ui.adapter.VpnProfileAdapter;
+import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
public class VpnProfileListFragment extends Fragment
{
+ private static final int ADD_REQUEST = 1;
+
private List<VpnProfile> mVpnProfiles;
private VpnProfileDataSource mDataSource;
private VpnProfileAdapter mListAdapter;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
Context context = getActivity().getApplicationContext();
super.onDestroy();
mDataSource.close();
}
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
+ {
+ inflater.inflate(R.menu.profile_list, menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId())
+ {
+ case R.id.add_profile:
+ Intent connectionIntent = new Intent(getActivity(),
+ VpnProfileDetailActivity.class);
+ startActivityForResult(connectionIntent, ADD_REQUEST);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ switch (requestCode)
+ {
+ case ADD_REQUEST:
+ if (resultCode != Activity.RESULT_OK)
+ {
+ return;
+ }
+ long id = data.getLongExtra(VpnProfileDataSource.KEY_ID, 0);
+ VpnProfile profile = mDataSource.getVpnProfile(id);
+ if (profile != null)
+ {
+ mVpnProfiles.add(profile);
+ mListAdapter.notifyDataSetChanged();
+ }
+ return;
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
}