Alexandre Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 32 | package com.savoirfairelinux.sflphone.client; |
| 33 | |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 34 | import android.content.ComponentName; |
| 35 | import android.content.ServiceConnection; |
Alexandre Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 36 | import android.os.Bundle; |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 37 | import android.os.IBinder; |
Alexandre Savard | 5261f82 | 2012-10-05 15:23:56 -0400 | [diff] [blame^] | 38 | import android.preference.Preference; |
Alexandre Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 39 | import android.preference.PreferenceActivity; |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 40 | import android.preference.PreferenceManager; |
| 41 | import android.preference.EditTextPreference; |
| 42 | import android.util.Log; |
Alexandre Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 43 | |
| 44 | import com.savoirfairelinux.sflphone.R; |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 45 | import com.savoirfairelinux.sflphone.service.SipService; |
| 46 | import com.savoirfairelinux.sflphone.service.ISipService; |
Alexandre Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 47 | |
Alexandre Savard | 5261f82 | 2012-10-05 15:23:56 -0400 | [diff] [blame^] | 48 | import java.util.ArrayList; |
| 49 | |
Alexandre Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 50 | public class AccountCreationActivity extends PreferenceActivity |
| 51 | { |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 52 | static final String TAG = "SFLPhonePreferenceActivity"; |
| 53 | private ISipService service; |
| 54 | private boolean mBound = false; |
| 55 | private PreferenceManager mPreferenceManager = null; |
| 56 | |
Alexandre Savard | 5261f82 | 2012-10-05 15:23:56 -0400 | [diff] [blame^] | 57 | 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 Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 64 | 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 Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 79 | @Override |
| 80 | protected void onCreate(Bundle savedInstanceState) { |
| 81 | super.onCreate(savedInstanceState); |
| 82 | |
| 83 | addPreferencesFromResource(R.xml.account_creation_preferences); |
Alexandre Savard | 5261f82 | 2012-10-05 15:23:56 -0400 | [diff] [blame^] | 84 | |
| 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 Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | @Override |
| 110 | protected void onStop() { |
| 111 | super.onStop(); |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 112 | 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 Savard | 53d2ddd | 2012-09-30 22:04:40 -0400 | [diff] [blame] | 120 | } |