2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2012 Giuliano Grassi
4 * Copyright (C) 2012 Ralf Sager
5 * Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 package org
.strongswan
.android
.ui
;
20 import org
.strongswan
.android
.R
;
21 import org
.strongswan
.android
.data
.VpnProfile
;
22 import org
.strongswan
.android
.data
.VpnProfileDataSource
;
24 import android
.app
.Activity
;
25 import android
.os
.Bundle
;
26 import android
.util
.Log
;
27 import android
.widget
.EditText
;
29 public class VpnProfileDetailActivity
extends Activity
31 private VpnProfileDataSource mDataSource
;
33 private VpnProfile mProfile
;
34 private EditText mName
;
35 private EditText mGateway
;
36 private EditText mUsername
;
37 private EditText mPassword
;
40 public void onCreate(Bundle savedInstanceState
)
42 super.onCreate(savedInstanceState
);
44 /* the title is set when we load the profile, if any */
45 getActionBar().setDisplayHomeAsUpEnabled(true
);
47 mDataSource
= new VpnProfileDataSource(this);
50 setContentView(R
.layout
.profile_detail_view
);
52 mName
= (EditText
)findViewById(R
.id
.name
);
53 mPassword
= (EditText
)findViewById(R
.id
.password
);
54 mGateway
= (EditText
)findViewById(R
.id
.gateway
);
55 mUsername
= (EditText
)findViewById(R
.id
.username
);
57 mId
= savedInstanceState
== null ? null
: savedInstanceState
.getLong(VpnProfileDataSource
.KEY_ID
);
60 Bundle extras
= getIntent().getExtras();
61 mId
= extras
== null ? null
: extras
.getLong(VpnProfileDataSource
.KEY_ID
);
68 protected void onDestroy()
75 protected void onSaveInstanceState(Bundle outState
)
77 super.onSaveInstanceState(outState
);
78 outState
.putLong(VpnProfileDataSource
.KEY_ID
, mId
);
82 * Load an existing profile if we got an ID
84 private void loadProfileData()
86 getActionBar().setTitle(R
.string
.add_profile
);
89 mProfile
= mDataSource
.getVpnProfile(mId
);
92 mName
.setText(mProfile
.getName());
93 mGateway
.setText(mProfile
.getGateway());
94 mUsername
.setText(mProfile
.getUsername());
95 mPassword
.setText(mProfile
.getPassword());
96 getActionBar().setTitle(mProfile
.getName());
100 Log
.e(VpnProfileDetailActivity
.class.getSimpleName(),
101 "VPN profile with id " + mId
+ " not found");