#17037: Remove multi-level PreferenceScreen launch separate Activities instead
diff --git a/src/com/savoirfairelinux/sflphone/client/AccountManagementFragment.java b/src/com/savoirfairelinux/sflphone/client/AccountManagementFragment.java
index eb01d29..4cfa8a7 100644
--- a/src/com/savoirfairelinux/sflphone/client/AccountManagementFragment.java
+++ b/src/com/savoirfairelinux/sflphone/client/AccountManagementFragment.java
@@ -65,12 +65,14 @@
import com.savoirfairelinux.sflphone.utils.AccountDetailAdvanced;
import com.savoirfairelinux.sflphone.utils.AccountDetailSrtp;
import com.savoirfairelinux.sflphone.utils.AccountDetailTls;
+import com.savoirfairelinux.sflphone.client.AccountPreferenceActivity;
public class AccountManagementFragment extends PreferenceFragment
{
static final String TAG = "AccountManagementFragment";
static final String DEFAULT_ACCOUNT_ID = "IP2IP";
static final int ACCOUNT_CREATE_REQUEST = 1;
+ static final int ACCOUNT_EDIT_REQUEST = 2;
private ISipService service;
// HashMap<String,HashMap<String,String>> mAccountList = new HashMap<String,HashMap<String,String>>();
@@ -79,11 +81,7 @@
ArrayList<AccountDetail.PreferenceEntry> advancedDetailKeys;
ArrayList<AccountDetail.PreferenceEntry> srtpDetailKeys;
ArrayList<AccountDetail.PreferenceEntry> tlsDetailKeys;
- AccountDetailBasic basicDetails;
- AccountDetailAdvanced advancedDetails;
- AccountDetailSrtp srtpDetails;
- AccountDetailTls tlsDetails;
- PreferenceScreen mRoot;
+ PreferenceScreen mRoot = null;
Activity context = getActivity();
@@ -95,11 +93,6 @@
advancedDetailKeys = AccountDetailAdvanced.getPreferenceEntries();
srtpDetailKeys = AccountDetailSrtp.getPreferenceEntries();
tlsDetailKeys = AccountDetailTls.getPreferenceEntries();
-
- basicDetails = new AccountDetailBasic();
- advancedDetails = new AccountDetailAdvanced();
- srtpDetails = new AccountDetailSrtp();
- tlsDetails = new AccountDetailTls();
}
@Override
@@ -145,7 +138,19 @@
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == ACCOUNT_CREATE_REQUEST) {
+ switch(requestCode) {
+ case ACCOUNT_CREATE_REQUEST:
+ Log.i(TAG, "ACCOUNT_CREATE_REQUEST Done");
+ break;
+ case ACCOUNT_EDIT_REQUEST:
+ if(resultCode == AccountPreferenceActivity.ACCOUNT_MODIFIED) {
+ Bundle bundle = data.getExtras();
+ String accountID = bundle.getString("AccountID");
+ Log.i(TAG, "Update account settings for " + accountID);
+ }
+ break;
+ default:
+ break;
}
}
@@ -161,7 +166,7 @@
for(String s : newList) {
if(!currentList.contains(s)) {
Log.i("receiver", "ADDING ACCOUNT!!!!!! " + s);
- mRoot.addPreference(createAccountPreferenceScreen(s).mScreen);
+ mRoot.addPreference(createAccountPreferenceScreen(s));
}
}
}
@@ -201,12 +206,19 @@
Preference.OnPreferenceClickListener launchAccountCreationOnClick = new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
if(preference.getTitle() == "Create New Account") {
- launchAccountCreationPanel(preference);
+ launchAccountCreationActivity(preference);
}
return true;
}
};
+ Preference.OnPreferenceClickListener launchAccountEditOnClick = new Preference.OnPreferenceClickListener() {
+ public boolean onPreferenceClick(Preference preference) {
+ launchAccountEditActivity(preference);
+ return true;
+ }
+ };
+
Preference.OnPreferenceClickListener removeSelectedAccountOnClick = new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
if(preference.getTitle() == "Delete Account") {
@@ -216,13 +228,20 @@
}
};
- private void launchAccountCreationPanel(Preference preference)
+ private void launchAccountCreationActivity(Preference preference)
{
- Log.i("MainSandbox", "launchPreferencePanel");
+ Log.i(TAG, "Launch account creation activity");
Intent intent = preference.getIntent();
startActivityForResult(intent, ACCOUNT_CREATE_REQUEST);
}
+ private void launchAccountEditActivity(Preference preference)
+ {
+ Log.i(TAG, "Launch account edit activity");
+ Intent intent = preference.getIntent();
+ startActivityForResult(intent, ACCOUNT_EDIT_REQUEST);
+ }
+
private void deleteSelectedAccount(String accountID) {
Log.i(TAG, "DeleteSelectedAccount");
try {
@@ -282,7 +301,7 @@
defaultAccountCat.setTitle(R.string.default_account_category);
mRoot.addPreference(defaultAccountCat);
- mRoot.addPreference(createAccountPreferenceScreen(DEFAULT_ACCOUNT_ID).mScreen);
+ mRoot.addPreference(createAccountPreferenceScreen(DEFAULT_ACCOUNT_ID));
// Account list category
PreferenceCategory accountListCat = new PreferenceCategory(currentContext);
@@ -297,18 +316,47 @@
for(String s : accountList) {
// mRoot.addPreference(getAccountPreferenceScreen(s));
- mRoot.addPreference(createAccountPreferenceScreen(s).mScreen);
+ mRoot.addPreference(createAccountPreferenceScreen(s));
}
return mRoot;
}
+ Preference createAccountPreferenceScreen(String accountID) {
+
+ HashMap<String, String> preferenceMap = getAccountDetails(accountID);
+
+ AccountDetailBasic basicDetails = new AccountDetailBasic(preferenceMap);
+ AccountDetailAdvanced advancedDetails = new AccountDetailAdvanced(preferenceMap);
+ AccountDetailSrtp srtpDetails = new AccountDetailSrtp(preferenceMap);
+ AccountDetailTls tlsDetails = new AccountDetailTls(preferenceMap);
+
+ Bundle bundle = new Bundle();
+ bundle.putString("AccountID", accountID);
+ bundle.putStringArrayList(AccountDetailBasic.BUNDLE_TAG, basicDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailAdvanced.BUNDLE_TAG, advancedDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailSrtp.BUNDLE_TAG, srtpDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailTls.BUNDLE_TAG, tlsDetails.getValuesOnly());
+
+ Intent intent = new Intent().setClass(getActivity(), AccountPreferenceActivity.class);
+ intent.putExtras(bundle);
+
+ Preference editAccount = new Preference(getActivity());
+ editAccount.setTitle(accountID);
+ editAccount.setOnPreferenceClickListener(launchAccountEditOnClick);
+ editAccount.setIntent(intent);
+
+ return editAccount;
+ }
+
+ /*
AccountPreferenceScreen createAccountPreferenceScreen(String accountID) {
AccountPreferenceScreen preference = new AccountPreferenceScreen(getPreferenceManager(), getActivity(), accountID);
mAccountList.put(accountID, preference);
return preference;
}
+ */
private class AccountPreferenceScreen
{
diff --git a/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
new file mode 100644
index 0000000..5703f5f
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Additional permission under GNU GPL version 3 section 7:
+ *
+ * If you modify this program, or any covered work, by linking or
+ * combining it with the OpenSSL project's OpenSSL library (or a
+ * modified version of that library), containing parts covered by the
+ * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ * grants you additional permission to convey the resulting work.
+ * Corresponding Source for a non-source form of such a combination
+ * shall include the source code for the parts of OpenSSL used as well
+ * as that of the covered work.
+ */
+
+package com.savoirfairelinux.sflphone.client;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.ServiceConnection;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.preference.EditTextPreference;
+import android.preference.CheckBoxPreference;
+import android.util.Log;
+
+import com.savoirfairelinux.sflphone.R;
+// import com.savoirfairelinux.sflphone.service.SipService;
+// import com.savoirfairelinux.sflphone.service.ISipService;
+import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import com.savoirfairelinux.sflphone.utils.AccountDetailsHandler;
+import com.savoirfairelinux.sflphone.utils.AccountDetailBasic;
+import com.savoirfairelinux.sflphone.utils.AccountDetailAdvanced;
+import com.savoirfairelinux.sflphone.utils.AccountDetailSrtp;
+import com.savoirfairelinux.sflphone.utils.AccountDetailTls;
+
+import java.util.HashMap;
+import java.util.ArrayList;
+
+public class AccountPreferenceActivity extends PreferenceActivity
+{
+ private static final String TAG = "AccoutPreferenceActivity";
+ public static final int ACCOUNT_MODIFIED = Activity.RESULT_FIRST_USER + 0;
+ public static final int ACCOUNT_NOT_MODIFIED = Activity.RESULT_FIRST_USER + 1;
+
+ private AccountDetailBasic basicDetails;
+ private AccountDetailAdvanced advancedDetails;
+ private AccountDetailSrtp srtpDetails;
+ private AccountDetailTls tlsDetails;
+ private PreferenceManager mPreferenceManager;
+ private HashMap<String, String> mPreferenceMap;
+ private String mAccountID;
+
+ Preference.OnPreferenceChangeListener changeNewAccountPreferenceListener = new Preference.OnPreferenceChangeListener() {
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ preference.setSummary(getString(R.string.account_current_value_label) + (CharSequence)newValue);
+ return true;
+ }
+ };
+
+ Preference.OnPreferenceChangeListener changeNewAccountTwoStateListener = new Preference.OnPreferenceChangeListener() {
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ return true;
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.account_creation_preferences);
+ mPreferenceManager = getPreferenceManager();
+
+ Bundle b = getIntent().getExtras();
+ mAccountID = b.getString("AccountID");
+ ArrayList<String> basicPreferenceList = b.getStringArrayList(AccountDetailBasic.BUNDLE_TAG);
+ ArrayList<String> advancedPreferenceList = b.getStringArrayList(AccountDetailAdvanced.BUNDLE_TAG);
+ ArrayList<String> srtpPreferenceList = b.getStringArrayList(AccountDetailSrtp.BUNDLE_TAG);
+ ArrayList<String> tlsPreferenceList = b.getStringArrayList(AccountDetailTls.BUNDLE_TAG);
+
+ basicDetails = new AccountDetailBasic(basicPreferenceList);
+ advancedDetails = new AccountDetailAdvanced(advancedPreferenceList);
+ srtpDetails = new AccountDetailSrtp(srtpPreferenceList);
+ tlsDetails = new AccountDetailTls(tlsPreferenceList);
+
+ setPreferenceDetails(basicDetails);
+ }
+
+ private void setPreferenceDetails(AccountDetail details) {
+ for(AccountDetail.PreferenceEntry p : details.getDetailValues()) {
+ Preference pref = mPreferenceManager.findPreference(p.mKey);
+ if(pref != null) {
+ Log.i(TAG, "setPreferenceDetails FOUND " + p.mKey + " = " + p.mValue);
+ if(!p.isTwoState) {
+ ((EditTextPreference)pref).setText(p.mValue);
+ pref.setSummary(getString(R.string.account_current_value_label) + p.mValue);
+ }
+ }
+ }
+ }
+
+ private void addPreferenceListener(AccountDetail details) {
+ for(AccountDetail.PreferenceEntry p : details.getDetailValues()) {
+ Preference pref = mPreferenceManager.findPreference(p.mKey);
+ if(pref != null) {
+ if(!p.isTwoState) {
+ pref.setOnPreferenceChangeListener(changeNewAccountPreferenceListener);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ addPreferenceListener(basicDetails);
+ addPreferenceListener(advancedDetails);
+ addPreferenceListener(srtpDetails);
+ addPreferenceListener(tlsDetails);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+
+ Bundle bundle = new Bundle();
+ bundle.putString("AccountID", mAccountID);
+ bundle.putStringArrayList(AccountDetailBasic.BUNDLE_TAG, basicDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailAdvanced.BUNDLE_TAG, advancedDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailSrtp.BUNDLE_TAG, srtpDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailTls.BUNDLE_TAG, tlsDetails.getValuesOnly());
+
+ Intent resultIntent = new Intent();
+ resultIntent.putExtras(bundle);
+
+ setResult(ACCOUNT_MODIFIED, resultIntent);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ @Override
+ public void onBackPressed() {
+ Bundle bundle = new Bundle();
+ bundle.putString("AccountID", mAccountID);
+ bundle.putStringArrayList(AccountDetailBasic.BUNDLE_TAG, basicDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailAdvanced.BUNDLE_TAG, advancedDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailSrtp.BUNDLE_TAG, srtpDetails.getValuesOnly());
+ bundle.putStringArrayList(AccountDetailTls.BUNDLE_TAG, tlsDetails.getValuesOnly());
+
+ Intent resultIntent = new Intent();
+ resultIntent.putExtras(bundle);
+
+ setResult(ACCOUNT_MODIFIED, resultIntent);
+ finish();
+ }
+
+ private void updateAccountDetails(HashMap<String, String> accountDetails, AccountDetail det) {
+ for(AccountDetail.PreferenceEntry p : det.getDetailValues()) {
+ Preference pref = mPreferenceManager.findPreference(p.mKey);
+ if(pref != null) {
+ if(p.isTwoState) {
+ CheckBoxPreference boxPref = (CheckBoxPreference) pref;
+ accountDetails.put(p.mKey, boxPref.isChecked() ? "true" : "false");
+ }
+ else {
+ EditTextPreference textPref = (EditTextPreference)pref;
+ accountDetails.put(p.mKey, textPref.getText());
+ }
+ }
+ }
+ }
+
+ private void updateAccountDetails() {
+ HashMap<String, String> accountDetails = new HashMap<String, String>();
+
+ updateAccountDetails(accountDetails, basicDetails);
+ updateAccountDetails(accountDetails, advancedDetails);
+ updateAccountDetails(accountDetails, srtpDetails);
+ updateAccountDetails(accountDetails, tlsDetails);
+ }
+}
+
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetail.java b/src/com/savoirfairelinux/sflphone/utils/AccountDetail.java
index 0243e29..86519b9 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetail.java
+++ b/src/com/savoirfairelinux/sflphone/utils/AccountDetail.java
@@ -26,8 +26,7 @@
import com.savoirfairelinux.sflphone.service.ServiceConstants;
import com.savoirfairelinux.sflphone.service.StringMap;
-import java.util.Collection;
-import java.util.Set;
+import java.util.ArrayList;
public interface AccountDetail {
@@ -36,12 +35,14 @@
public String mKey;
public int mLabelId;
public boolean isTwoState;
+ public String mValue;
public PreferenceEntry(String key, int labelId)
{
mKey = key;
mLabelId = labelId;
isTwoState = false;
+ mValue = "";
}
public PreferenceEntry(String key, int labelId, boolean twoState)
@@ -49,11 +50,24 @@
mKey = key;
mLabelId = labelId;
isTwoState = twoState;
+ mValue = "";
+ }
+
+ public PreferenceEntry(String key, int labelId, boolean twoState, String value)
+ {
+ mKey = key;
+ mLabelId = labelId;
+ isTwoState = twoState;
+ mValue = value;
}
}
- public Set<String> getDetailKeys();
+ public ArrayList<PreferenceEntry> getDetailValues();
- public Collection<PreferenceEntry> getDetailValues();
+ public ArrayList<String> getValuesOnly();
+
+ public String getDetailString(String key);
+
+ public boolean getDetailBoolean();
}
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailAdvanced.java b/src/com/savoirfairelinux/sflphone/utils/AccountDetailAdvanced.java
index b9e9eee..0faa79a 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailAdvanced.java
+++ b/src/com/savoirfairelinux/sflphone/utils/AccountDetailAdvanced.java
@@ -24,6 +24,8 @@
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import android.util.Log;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
@@ -31,6 +33,9 @@
public class AccountDetailAdvanced implements AccountDetail {
+ private static final String TAG = "AccountDetailAdvanced";
+ public static final String BUNDLE_TAG = "AdvancedPreferenceArrayList";
+
public static final String CONFIG_ACCOUNT_MAILBOX = "Account.mailbox";
public static final String CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.registrationExpire";
public static final String CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus";
@@ -60,7 +65,7 @@
public static final String CONFIG_STUN_SERVER = "STUN.server";
public static final String CONFIG_STUN_ENABLE = "STUN.enable";
- private HashMap<String, AccountDetail.PreferenceEntry> privateMap;
+ private ArrayList<AccountDetail.PreferenceEntry> privateArray;
public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
{
@@ -91,55 +96,66 @@
public AccountDetailAdvanced()
{
- privateMap = new HashMap<String, AccountDetail.PreferenceEntry>();
-
- privateMap.put(CONFIG_ACCOUNT_REGISTRATION_EXPIRE,
- new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_EXPIRE, R.string.account_registration_exp_label));
- privateMap.put(CONFIG_ACCOUNT_REGISTRATION_STATUS,
- new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_STATUS, R.string.account_registration_status_label));
- privateMap.put(CONFIG_ACCOUNT_REGISTRATION_STATE_CODE,
- new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, R.string.account_registration_code_label));
- privateMap.put(CONFIG_ACCOUNT_REGISTRATION_STATE_DESC,
- new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, R.string.account_registration_state_label));
- privateMap.put(CONFIG_CREDENTIAL_NUMBER,
- new PreferenceEntry(CONFIG_CREDENTIAL_NUMBER, R.string.account_credential_count_label));
- privateMap.put(CONFIG_ACCOUNT_DTMF_TYPE,
- new PreferenceEntry(CONFIG_ACCOUNT_DTMF_TYPE, R.string.account_config_dtmf_type_label));
- privateMap.put(CONFIG_RINGTONE_PATH,
- new PreferenceEntry(CONFIG_RINGTONE_PATH, R.string.account_ringtone_path_label));
- privateMap.put(CONFIG_RINGTONE_ENABLED,
- new PreferenceEntry(CONFIG_RINGTONE_ENABLED, R.string.account_ringtone_enabled_label, true));
- privateMap.put(CONFIG_KEEP_ALIVE_ENABLED,
- new PreferenceEntry(CONFIG_KEEP_ALIVE_ENABLED, R.string.account_keep_alive_label, true));
- privateMap.put(CONFIG_ACCOUNT_AUTOANSWER,
- new PreferenceEntry(CONFIG_ACCOUNT_AUTOANSWER, R.string.account_account_interface_label, true));
- privateMap.put(CONFIG_LOCAL_INTERFACE,
- new PreferenceEntry(CONFIG_LOCAL_INTERFACE, R.string.account_local_interface_label));
- privateMap.put(CONFIG_INTERFACE,
- new PreferenceEntry(CONFIG_INTERFACE, R.string.account_account_interface_label));
- privateMap.put(CONFIG_PUBLISHED_SAMEAS_LOCAL,
- new PreferenceEntry(CONFIG_PUBLISHED_SAMEAS_LOCAL, R.string.account_published_same_as_local_label, true));
- privateMap.put(CONFIG_LOCAL_PORT,
- new PreferenceEntry(CONFIG_LOCAL_PORT, R.string.account_local_port_label));
- privateMap.put(CONFIG_PUBLISHED_PORT,
- new PreferenceEntry(CONFIG_PUBLISHED_PORT, R.string.account_published_port_label));
- privateMap.put(CONFIG_PUBLISHED_ADDRESS,
- new PreferenceEntry(CONFIG_PUBLISHED_ADDRESS, R.string.account_published_address_label));
- privateMap.put(CONFIG_DISPLAY_NAME,
- new PreferenceEntry(CONFIG_DISPLAY_NAME, R.string.account_displayname_label));
- privateMap.put(CONFIG_STUN_SERVER,
- new PreferenceEntry(CONFIG_STUN_SERVER, R.string.account_stun_server_label));
- privateMap.put(CONFIG_STUN_ENABLE,
- new PreferenceEntry(CONFIG_STUN_ENABLE, R.string.account_stun_enable_label, true));
+ privateArray = getPreferenceEntries();
}
- public Set<String> getDetailKeys()
+ public AccountDetailAdvanced(HashMap<String, String> pref)
{
- return privateMap.keySet();
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
}
- public Collection<AccountDetail.PreferenceEntry> getDetailValues()
+ public AccountDetailAdvanced(ArrayList<String> pref)
{
- return privateMap.values();
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ }
+ }
}
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public boolean getDetailBoolean()
+ {
+ return true;
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailBasic.java b/src/com/savoirfairelinux/sflphone/utils/AccountDetailBasic.java
index 046e4f5..97e42e9 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailBasic.java
+++ b/src/com/savoirfairelinux/sflphone/utils/AccountDetailBasic.java
@@ -24,6 +24,8 @@
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import android.util.Log;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
@@ -31,9 +33,12 @@
public class AccountDetailBasic implements AccountDetail {
+ private static final String TAG = "AccountDetailBasic";
+ public static final String BUNDLE_TAG = "BasicPreferenceArrayList";
+
+ public static final String CONFIG_ACCOUNT_ENABLE = "Account.enable";
public static final String CONFIG_ACCOUNT_TYPE = "Account.type";
public static final String CONFIG_ACCOUNT_ALIAS = "Account.alias";
- public static final String CONFIG_ACCOUNT_ENABLE = "Account.enable";
public static final String CONFIG_ACCOUNT_HOSTNAME = "Account.hostname";
public static final String CONFIG_ACCOUNT_USERNAME = "Account.username";
public static final String CONFIG_ACCOUNT_ROUTESET = "Account.routeset";
@@ -42,16 +47,15 @@
public static final String CONFIG_ACCOUNT_DEFAULT_REALM = "*";
public static final String CONFIG_ACCOUNT_USERAGENT = "Account.useragent";
- private HashMap<String, AccountDetail.PreferenceEntry> privateMap;
-
+ private ArrayList<AccountDetail.PreferenceEntry> privateArray;
public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
{
ArrayList<AccountDetail.PreferenceEntry> preference = new ArrayList<AccountDetail.PreferenceEntry>();
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_ENABLE, R.string.account_enabled_label, true));
preference.add(new PreferenceEntry(CONFIG_ACCOUNT_TYPE, R.string.account_type_label));
preference.add(new PreferenceEntry(CONFIG_ACCOUNT_ALIAS, R.string.account_alias_label));
- preference.add(new PreferenceEntry(CONFIG_ACCOUNT_ENABLE, R.string.account_enabled_label, true));
preference.add(new PreferenceEntry(CONFIG_ACCOUNT_HOSTNAME, R.string.account_hostname_label));
preference.add(new PreferenceEntry(CONFIG_ACCOUNT_USERNAME, R.string.account_username_label));
preference.add(new PreferenceEntry(CONFIG_ACCOUNT_ROUTESET, R.string.account_routeset_label));
@@ -65,37 +69,66 @@
public AccountDetailBasic()
{
- privateMap = new HashMap<String, AccountDetail.PreferenceEntry>();
-
- privateMap.put(CONFIG_ACCOUNT_TYPE,
- new PreferenceEntry(CONFIG_ACCOUNT_TYPE, R.string.account_type_label));
- privateMap.put(CONFIG_ACCOUNT_ALIAS,
- new PreferenceEntry(CONFIG_ACCOUNT_ALIAS, R.string.account_alias_label));
- privateMap.put(CONFIG_ACCOUNT_ENABLE,
- new PreferenceEntry(CONFIG_ACCOUNT_ENABLE, R.string.account_enabled_label, true));
- privateMap.put(CONFIG_ACCOUNT_HOSTNAME,
- new PreferenceEntry(CONFIG_ACCOUNT_HOSTNAME, R.string.account_hostname_label));
- privateMap.put(CONFIG_ACCOUNT_USERNAME,
- new PreferenceEntry(CONFIG_ACCOUNT_USERNAME, R.string.account_username_label));
- privateMap.put(CONFIG_ACCOUNT_ROUTESET,
- new PreferenceEntry(CONFIG_ACCOUNT_ROUTESET, R.string.account_routeset_label));
- privateMap.put(CONFIG_ACCOUNT_PASSWORD,
- new PreferenceEntry(CONFIG_ACCOUNT_PASSWORD, R.string.account_password_label));
- privateMap.put(CONFIG_ACCOUNT_REALM,
- new PreferenceEntry(CONFIG_ACCOUNT_REALM, R.string.account_realm_label));
- privateMap.put(CONFIG_ACCOUNT_DEFAULT_REALM,
- new PreferenceEntry(CONFIG_ACCOUNT_DEFAULT_REALM, R.string.account_useragent_label));
- privateMap.put(CONFIG_ACCOUNT_USERAGENT,
- new PreferenceEntry(CONFIG_ACCOUNT_USERAGENT, R.string.account_autoanswer_label));
+ privateArray = getPreferenceEntries();
}
- public Set<String> getDetailKeys()
+ public AccountDetailBasic(HashMap<String, String> pref)
{
- return privateMap.keySet();
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
}
- public Collection<AccountDetail.PreferenceEntry> getDetailValues()
+ public AccountDetailBasic(ArrayList<String> pref)
{
- return privateMap.values();
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ index++;
+ }
+ }
+ }
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public boolean getDetailBoolean()
+ {
+ return true;
}
}
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailSrtp.java b/src/com/savoirfairelinux/sflphone/utils/AccountDetailSrtp.java
index 1122924..d205419 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailSrtp.java
+++ b/src/com/savoirfairelinux/sflphone/utils/AccountDetailSrtp.java
@@ -24,6 +24,8 @@
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import android.util.Log;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
@@ -31,6 +33,9 @@
public class AccountDetailSrtp implements AccountDetail{
+ private static final String TAG = "AccountDetailSrtp";
+ public static final String BUNDLE_TAG = "SrtpPreferenceArrayList";
+
public static final String CONFIG_SRTP_ENABLE = "SRTP.enable";
public static final String CONFIG_SRTP_KEY_EXCHANGE = "SRTP.keyExchange";
public static final String CONFIG_SRTP_ENCRYPTION_ALGO = "SRTP.encryptionAlgorithm"; // Provided by ccRTP,0=NULL,1=AESCM,2=AESF8
@@ -40,7 +45,7 @@
public static final String CONFIG_ZRTP_NOT_SUPP_WARNING = "ZRTP.notSuppWarning";
public static final String CONFIG_ZRTP_DISPLAY_SAS_ONCE = "ZRTP.displaySasOnce";
- private HashMap<String, AccountDetail.PreferenceEntry> privateMap;
+ private ArrayList<AccountDetail.PreferenceEntry> privateArray;
public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
{
@@ -60,33 +65,66 @@
public AccountDetailSrtp()
{
- privateMap = new HashMap<String, AccountDetail.PreferenceEntry>();
-
- privateMap.put(CONFIG_SRTP_ENABLE,
- new PreferenceEntry(CONFIG_SRTP_ENABLE, R.string.account_srtp_enabled_label, true));
- privateMap.put(CONFIG_SRTP_KEY_EXCHANGE,
- new PreferenceEntry(CONFIG_SRTP_KEY_EXCHANGE, R.string.account_srtp_exchange_label, true));
- privateMap.put(CONFIG_SRTP_ENCRYPTION_ALGO,
- new PreferenceEntry(CONFIG_SRTP_ENCRYPTION_ALGO, R.string.account_encryption_algo_label, true));
- privateMap.put(CONFIG_SRTP_RTP_FALLBACK,
- new PreferenceEntry(CONFIG_SRTP_RTP_FALLBACK, R.string.account_srtp_fallback_label, true));
- privateMap.put(CONFIG_ZRTP_HELLO_HASH,
- new PreferenceEntry(CONFIG_ZRTP_HELLO_HASH, R.string.account_hello_hash_enable_label, true));
- privateMap.put(CONFIG_ZRTP_DISPLAY_SAS,
- new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS, R.string.account_display_sas_label, true));
- privateMap.put(CONFIG_ZRTP_NOT_SUPP_WARNING,
- new PreferenceEntry(CONFIG_ZRTP_NOT_SUPP_WARNING, R.string.account_not_supported_warning_label, true));
- privateMap.put(CONFIG_ZRTP_DISPLAY_SAS_ONCE,
- new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS_ONCE, R.string.account_display_sas_once_label, true));
+ privateArray = getPreferenceEntries();
}
- public Set<String> getDetailKeys()
+ public AccountDetailSrtp(HashMap<String, String> pref)
{
- return privateMap.keySet();
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
}
- public Collection<AccountDetail.PreferenceEntry> getDetailValues()
+ public AccountDetailSrtp(ArrayList<String> pref)
{
- return privateMap.values();
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ index++;
+ }
+ }
+ }
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public boolean getDetailBoolean()
+ {
+ return true;
}
}
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailTls.java b/src/com/savoirfairelinux/sflphone/utils/AccountDetailTls.java
index 03efcd0..bd2d6e5 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailTls.java
+++ b/src/com/savoirfairelinux/sflphone/utils/AccountDetailTls.java
@@ -24,12 +24,17 @@
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import android.util.Log;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
import java.util.HashMap;
public class AccountDetailTls implements AccountDetail {
+
+ private static final String TAG = "AccountDetailTls";
+ public static final String BUNDLE_TAG = "TlsPreferenceArrayList";
public static final String CONFIG_TLS_LISTENER_PORT = "TLS.listenerPort";
public static final String CONFIG_TLS_ENABLE = "TLS.enable";
@@ -46,7 +51,7 @@
public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiationTimeoutSec";
public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC = "TLS.negotiationTimemoutMsec";
- private HashMap<String, AccountDetail.PreferenceEntry> privateMap;
+ private ArrayList<AccountDetail.PreferenceEntry> privateArray;
public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
{
@@ -72,45 +77,66 @@
public AccountDetailTls()
{
- privateMap = new HashMap<String, AccountDetail.PreferenceEntry>();
-
- privateMap.put(CONFIG_TLS_LISTENER_PORT,
- new PreferenceEntry(CONFIG_TLS_LISTENER_PORT, R.string.account_listener_port_label));
- privateMap.put(CONFIG_TLS_ENABLE,
- new PreferenceEntry(CONFIG_TLS_ENABLE, R.string.account_tls_enabled_label, true));
- privateMap.put(CONFIG_TLS_CA_LIST_FILE,
- new PreferenceEntry(CONFIG_TLS_CA_LIST_FILE, R.string.account_tls_certificate_list_label));
- privateMap.put(CONFIG_TLS_CERTIFICATE_FILE,
- new PreferenceEntry(CONFIG_TLS_CERTIFICATE_FILE, R.string.account_tls_certificate_file_label));
- privateMap.put(CONFIG_TLS_PRIVATE_KEY_FILE,
- new PreferenceEntry(CONFIG_TLS_PRIVATE_KEY_FILE, R.string.account_tls_private_key_file_label));
- privateMap.put(CONFIG_TLS_PASSWORD,
- new PreferenceEntry(CONFIG_TLS_PASSWORD, R.string.account_tls_password_label));
- privateMap.put(CONFIG_TLS_METHOD,
- new PreferenceEntry(CONFIG_TLS_METHOD, R.string.account_tls_method_label));
- privateMap.put(CONFIG_TLS_CIPHERS,
- new PreferenceEntry(CONFIG_TLS_CIPHERS, R.string.account_tls_ciphers_label));
- privateMap.put(CONFIG_TLS_SERVER_NAME,
- new PreferenceEntry(CONFIG_TLS_SERVER_NAME, R.string.account_tls_server_name_label));
- privateMap.put(CONFIG_TLS_VERIFY_SERVER,
- new PreferenceEntry(CONFIG_TLS_VERIFY_SERVER, R.string.account_tls_verify_label, true));
- privateMap.put(CONFIG_TLS_VERIFY_CLIENT,
- new PreferenceEntry(CONFIG_TLS_VERIFY_CLIENT, R.string.account_tls_verify_client_label, true));
- privateMap.put(CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE,
- new PreferenceEntry(CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, R.string.account_tls_require_client_certificat_label, true));
- privateMap.put(CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC,
- new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, R.string.account_tls_negotiation_timeout_sec));
- privateMap.put(CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC,
- new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, R.string.account_tls_negotiation_timeout_msec));
- }
-
- public Set<String> getDetailKeys()
- {
- return privateMap.keySet();
+ privateArray = getPreferenceEntries();
}
- public Collection<AccountDetail.PreferenceEntry> getDetailValues()
+ public AccountDetailTls(HashMap<String, String> pref)
{
- return privateMap.values();
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
+ }
+
+ public AccountDetailTls(ArrayList<String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ index++;
+ }
+ }
+ }
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public boolean getDetailBoolean()
+ {
+ return true;
}
}