blob: e9a5b99f306a3bac268c1a00c73fb3d9210e64b9 [file] [log] [blame]
Alexandre Savard53d2ddd2012-09-30 22:04:40 -04001/*
2 * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3 *
4 * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Additional permission under GNU GPL version 3 section 7:
21 *
22 * If you modify this program, or any covered work, by linking or
23 * combining it with the OpenSSL project's OpenSSL library (or a
24 * modified version of that library), containing parts covered by the
25 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
26 * grants you additional permission to convey the resulting work.
27 * Corresponding Source for a non-source form of such a combination
28 * shall include the source code for the parts of OpenSSL used as well
29 * as that of the covered work.
30 */
31
32package com.savoirfairelinux.sflphone.client;
33
Alexandre Savard3bbb4792012-10-05 11:30:01 -040034import android.content.ComponentName;
35import android.content.ServiceConnection;
Alexandre Savard53d2ddd2012-09-30 22:04:40 -040036import android.os.Bundle;
Alexandre Savard3bbb4792012-10-05 11:30:01 -040037import android.os.IBinder;
Alexandre Savard5261f822012-10-05 15:23:56 -040038import android.preference.Preference;
Alexandre Savard53d2ddd2012-09-30 22:04:40 -040039import android.preference.PreferenceActivity;
Alexandre Savard3bbb4792012-10-05 11:30:01 -040040import android.preference.PreferenceManager;
41import android.preference.EditTextPreference;
42import android.util.Log;
Alexandre Savard53d2ddd2012-09-30 22:04:40 -040043
44import com.savoirfairelinux.sflphone.R;
Alexandre Savard3bbb4792012-10-05 11:30:01 -040045import com.savoirfairelinux.sflphone.service.SipService;
46import com.savoirfairelinux.sflphone.service.ISipService;
Alexandre Savard53d2ddd2012-09-30 22:04:40 -040047
Alexandre Savard5261f822012-10-05 15:23:56 -040048import java.util.ArrayList;
49
Alexandre Savard53d2ddd2012-09-30 22:04:40 -040050public class AccountCreationActivity extends PreferenceActivity
51{
Alexandre Savard3bbb4792012-10-05 11:30:01 -040052 static final String TAG = "SFLPhonePreferenceActivity";
53 private ISipService service;
54 private boolean mBound = false;
55 private PreferenceManager mPreferenceManager = null;
56
Alexandre Savard5261f822012-10-05 15:23:56 -040057 Preference.OnPreferenceChangeListener changeNewAccountPreferenceListener = new Preference.OnPreferenceChangeListener() {
58 public boolean onPreferenceChange(Preference preference, Object newValue) {
59 preference.setSummary(getString(R.string.account_current_value_label) + (CharSequence)newValue);
60 return true;
61 }
62 };
63
Alexandre Savard3bbb4792012-10-05 11:30:01 -040064 private ServiceConnection mConnection = new ServiceConnection() {
65 @Override
66 public void onServiceConnected(ComponentName className, IBinder binder) {
67 service = ISipService.Stub.asInterface(binder);
68 mBound = true;
69 Log.d(TAG, "Service connected");
70 }
71
72 @Override
73 public void onServiceDisconnected(ComponentName arg0) {
74 mBound = false;
75 Log.d(TAG, "Service disconnected");
76 }
77 };
78
Alexandre Savard53d2ddd2012-09-30 22:04:40 -040079 @Override
80 protected void onCreate(Bundle savedInstanceState) {
81 super.onCreate(savedInstanceState);
82
83 addPreferencesFromResource(R.xml.account_creation_preferences);
Alexandre Savard5261f822012-10-05 15:23:56 -040084
85 mPreferenceManager = getPreferenceManager();
86 }
87
88 @Override
89 protected void onStart() {
90 super.onStart();
91 ArrayList<String> preferenceKey = new ArrayList<String>();
92 preferenceKey.add("AccountAlias");
93 preferenceKey.add("AccountUserName");
94 preferenceKey.add("AccountHostname");
95 preferenceKey.add("AccountPassword");
96 preferenceKey.add("AccountRealm");
97 preferenceKey.add("AccountUserAgent");
98 preferenceKey.add("AccountAutoAnswer");
99
100 for(String s : preferenceKey) {
101 EditTextPreference pref = (EditTextPreference) mPreferenceManager.findPreference(s);
102 if(pref != null)
103 pref.setOnPreferenceChangeListener(changeNewAccountPreferenceListener);
104 else
105 Log.i(TAG, "NO PREFERENCE FOUND " + s);
106 }
Alexandre Savard3bbb4792012-10-05 11:30:01 -0400107 }
108
109 @Override
110 protected void onStop() {
111 super.onStop();
Alexandre Savard3bbb4792012-10-05 11:30:01 -0400112 EditTextPreference accountAliasPref = (EditTextPreference) mPreferenceManager.findPreference("AccountAlias");
113 EditTextPreference accountUsername = (EditTextPreference) mPreferenceManager.findPreference("AccountUserName");
114 EditTextPreference accountHostname = (EditTextPreference) mPreferenceManager.findPreference("AccountHostname");
115 EditTextPreference accountPassword = (EditTextPreference) mPreferenceManager.findPreference("AccountPassword");
116 EditTextPreference accountRoutset = (EditTextPreference) mPreferenceManager.findPreference("AccountRealm");
117 EditTextPreference accountUseragent = (EditTextPreference) mPreferenceManager.findPreference("AccountUserAgent");
118 EditTextPreference accountAutoAnswer = (EditTextPreference) mPreferenceManager.findPreference("AccountAutoAnswer");
119 }
Alexandre Savard53d2ddd2012-09-30 22:04:40 -0400120}