* #31603: display account IP2IP (was hidden until now)
diff --git a/src/org/sflphone/client/AccountEditionActivity.java b/src/org/sflphone/client/AccountEditionActivity.java
index acc282d..fefc12b 100644
--- a/src/org/sflphone/client/AccountEditionActivity.java
+++ b/src/org/sflphone/client/AccountEditionActivity.java
@@ -44,6 +44,7 @@
import org.sflphone.account.AccountDetailTls;
import org.sflphone.fragments.AudioManagementFragment;
import org.sflphone.fragments.EditionFragment;
+import org.sflphone.model.Account;
import org.sflphone.service.ISipService;
import org.sflphone.service.SipService;
@@ -77,12 +78,10 @@
public static final String KEY_MODE = "mode";
private boolean mBound = false;
private ISipService service;
- private String mAccountID;
- HashMap<String, String> basicPreferenceList;
- HashMap<String, String> advancedPreferenceList;
- HashMap<String, String> srtpPreferenceList;
- HashMap<String, String> tlsPreferenceList;
-
+
+ private Account acc_selected;
+
+
PreferencesPagerAdapter mPreferencesPagerAdapter;
private ServiceConnection mConnection = new ServiceConnection() {
@@ -134,12 +133,8 @@
}
});
- basicPreferenceList = (HashMap<String, String>) getIntent().getExtras().getSerializable(AccountDetailBasic.BUNDLE_TAG);
- advancedPreferenceList = (HashMap<String, String>) getIntent().getExtras().getSerializable(AccountDetailAdvanced.BUNDLE_TAG);
- srtpPreferenceList = (HashMap<String, String>) getIntent().getExtras().getSerializable(AccountDetailSrtp.BUNDLE_TAG);
- tlsPreferenceList = (HashMap<String, String>) getIntent().getExtras().getSerializable(AccountDetailTls.BUNDLE_TAG);
-
- mAccountID = getIntent().getExtras().getString("AccountID");
+ acc_selected = getIntent().getExtras().getParcelable("account");
+
if (!mBound) {
Log.i(TAG, "onCreate: Binding service...");
Intent intent = new Intent(this, SipService.class);
@@ -214,7 +209,7 @@
accountDetails.put("Account.type", "SIP");
try {
- service.setAccountDetails(mAccountID, accountDetails);
+ service.setAccountDetails(acc_selected.getAccountID(), accountDetails);
} catch (RemoteException e) {
e.printStackTrace();
}
@@ -289,10 +284,10 @@
@Override
public void onClick(DialogInterface dialog, int whichButton) {
Bundle bundle = new Bundle();
- bundle.putString("AccountID", mAccountID);
+ bundle.putString("AccountID", acc_selected.getAccountID());
try {
- service.removeAccount(mAccountID);
+ service.removeAccount(acc_selected.getAccountID());
} catch (RemoteException e) {
e.printStackTrace();
}
@@ -369,22 +364,22 @@
@Override
public HashMap<String, String> getBasicDetails() {
- return basicPreferenceList;
+ return acc_selected.getBasicDetails().getDetailsHashMap();
}
@Override
public HashMap<String, String> getAdvancedDetails() {
- return advancedPreferenceList;
+ return acc_selected.getAdvancedDetails().getDetailsHashMap();
}
@Override
public HashMap<String, String> getSRTPDetails() {
- return srtpPreferenceList;
+ return acc_selected.getSrtpDetails().getDetailsHashMap();
}
@Override
public HashMap<String, String> getTLSDetails() {
- return tlsPreferenceList;
+ return acc_selected.getTlsDetails().getDetailsHashMap();
}
@Override
@@ -394,7 +389,7 @@
@Override
public String getAccountID(){
- return mAccountID;
+ return acc_selected.getAccountID();
}
}
diff --git a/src/org/sflphone/fragments/AccountManagementFragment.java b/src/org/sflphone/fragments/AccountManagementFragment.java
index 8602a75..a458397 100644
--- a/src/org/sflphone/fragments/AccountManagementFragment.java
+++ b/src/org/sflphone/fragments/AccountManagementFragment.java
@@ -75,7 +75,7 @@
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
-public class AccountManagementFragment extends ListFragment implements LoaderCallbacks<ArrayList<Account>>, AccountsInterface {
+public class AccountManagementFragment extends ListFragment implements LoaderCallbacks<Bundle>, AccountsInterface {
static final String TAG = "AccountManagementFragment";
static final String DEFAULT_ACCOUNT_ID = "IP2IP";
static final int ACCOUNT_CREATE_REQUEST = 1;
@@ -98,7 +98,6 @@
}
}
-
};
private Callbacks mCallbacks = sDummyCallbacks;
@@ -171,7 +170,7 @@
}
});
- list.setEmptyView(view.findViewById(android.R.id.empty));
+ list.setEmptyView(view.findViewById(android.R.id.empty));
}
@Override
@@ -191,22 +190,22 @@
}
@Override
- public Loader<ArrayList<Account>> onCreateLoader(int id, Bundle args) {
+ public Loader<Bundle> onCreateLoader(int id, Bundle args) {
AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
l.forceLoad();
-
return l;
}
@Override
- public void onLoadFinished(Loader<ArrayList<Account>> loader, ArrayList<Account> results) {
+ public void onLoadFinished(Loader<Bundle> loader, Bundle bun) {
mAdapter.removeAll();
- mAdapter.addAll(results);
+ ArrayList<Account> accounts = bun.getParcelableArrayList(AccountsLoader.ACCOUNTS);
+ mAdapter.addAll(accounts);
}
@Override
- public void onLoaderReset(Loader<ArrayList<Account>> arg0) {
+ public void onLoaderReset(Loader<Bundle> arg0) {
// TODO Auto-generated method stub
}
@@ -235,12 +234,7 @@
Intent intent = new Intent().setClass(getActivity(), AccountEditionActivity.class);
Bundle bundle = new Bundle();
- bundle.putString("AccountID", acc.getAccountID());
- bundle.putSerializable(AccountDetailBasic.BUNDLE_TAG, acc.getBasicDetails().getDetailsHashMap());
- bundle.putSerializable(AccountDetailAdvanced.BUNDLE_TAG, acc.getAdvancedDetails().getDetailsHashMap());
- bundle.putSerializable(AccountDetailSrtp.BUNDLE_TAG, acc.getSrtpDetails().getDetailsHashMap());
- bundle.putSerializable(AccountDetailTls.BUNDLE_TAG, acc.getTlsDetails().getDetailsHashMap());
-
+ bundle.putParcelable("account", acc);
intent.putExtras(bundle);
startActivityForResult(intent, ACCOUNT_EDIT_REQUEST);
@@ -286,9 +280,9 @@
accounts.remove(item);
notifyDataSetChanged();
}
-
+
@Override
- public boolean hasStableIds(){
+ public boolean hasStableIds() {
return true;
}
@@ -386,7 +380,7 @@
}
}
-
+
private String generateAccountOrder() {
String result = DEFAULT_ACCOUNT_ID + File.separator;
for (Account a : accounts) {
diff --git a/src/org/sflphone/fragments/MenuFragment.java b/src/org/sflphone/fragments/MenuFragment.java
index 53e359e..cabfc66 100644
--- a/src/org/sflphone/fragments/MenuFragment.java
+++ b/src/org/sflphone/fragments/MenuFragment.java
@@ -66,7 +66,7 @@
import android.widget.RadioButton;
import android.widget.Spinner;
-public class MenuFragment extends Fragment implements LoaderCallbacks<ArrayList<Account>>, AccountsInterface {
+public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, AccountsInterface {
private static final String TAG = MenuFragment.class.getSimpleName();
public static final String ARG_SECTION_NUMBER = "section_number";
@@ -78,7 +78,6 @@
AccountsReceiver accountReceiver;
private Callbacks mCallbacks = sDummyCallbacks;
-
private static Callbacks sDummyCallbacks = new Callbacks() {
@Override
@@ -221,21 +220,22 @@
}
@Override
- public Loader<ArrayList<Account>> onCreateLoader(int id, Bundle args) {
+ public Loader<Bundle> onCreateLoader(int id, Bundle args) {
AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
l.forceLoad();
return l;
}
@Override
- public void onLoadFinished(Loader<ArrayList<Account>> loader, ArrayList<Account> results) {
+ public void onLoadFinished(Loader<Bundle> loader, Bundle bun) {
mAccountAdapter.removeAll();
- mAccountAdapter.addAll(results);
+ ArrayList<Account> accounts = bun.getParcelableArrayList(AccountsLoader.ACCOUNTS);
+ mAccountAdapter.addAll(accounts);
}
@Override
- public void onLoaderReset(Loader<ArrayList<Account>> arg0) {
+ public void onLoaderReset(Loader<Bundle> arg0) {
// TODO Auto-generated method stub
}
diff --git a/src/org/sflphone/loaders/AccountsLoader.java b/src/org/sflphone/loaders/AccountsLoader.java
index 65a0f38..b95c00f 100644
--- a/src/org/sflphone/loaders/AccountsLoader.java
+++ b/src/org/sflphone/loaders/AccountsLoader.java
@@ -8,13 +8,15 @@
import android.content.AsyncTaskLoader;
import android.content.Context;
+import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
-public class AccountsLoader extends AsyncTaskLoader<ArrayList<Account>> {
+public class AccountsLoader extends AsyncTaskLoader<Bundle> {
private static final String TAG = AccountsLoader.class.getSimpleName();
-
+ public static final String ACCOUNTS = "accounts";
+ public static final String ACCOUNT_IP2IP = "IP2IP";
ISipService service;
public AccountsLoader(Context context, ISipService ref) {
@@ -24,21 +26,23 @@
@SuppressWarnings("unchecked") // Hashmap runtime cast
@Override
- public ArrayList<Account> loadInBackground() {
+ public Bundle loadInBackground() {
- ArrayList<Account> result = new ArrayList<Account>();
-
- ArrayList<String> accountIDs;
- HashMap<String, String> details;
+ ArrayList<Account> accounts = new ArrayList<Account>();
+ Account IP2IP = null;
+
try {
- accountIDs = (ArrayList<String>) service.getAccountList();
+ ArrayList<String> accountIDs = (ArrayList<String>) service.getAccountList();
+ HashMap<String, String> details;
for (String id : accountIDs) {
- if (id.contentEquals("IP2IP")) {
+ if (id.contentEquals(ACCOUNT_IP2IP)) {
+ details = (HashMap<String, String>) service.getAccountDetails(id);
+ IP2IP = new Account(ACCOUNT_IP2IP, details);
continue;
}
details = (HashMap<String, String>) service.getAccountDetails(id);
- result.add(new Account(id, details));
+ accounts.add(new Account(id, details));
}
} catch (RemoteException e) {
@@ -47,6 +51,9 @@
Log.e(TAG, e1.toString());
}
+ Bundle result = new Bundle();
+ result.putParcelableArrayList(ACCOUNTS, accounts);
+ result.putParcelable(ACCOUNT_IP2IP, IP2IP);
return result;
}