Skip to content
Snippets Groups Projects
Commit af0f3c68 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#17195: Propagate account selection to other AccountManagementUI

parent 530e9f51
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,8 @@ public class AccountSelectionDialog extends AlertDialog
// public void onClick(DialogInterface dialog, int which) {
public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
Log.i(TAG, "Selected Account: " + ((TextView)view).getText());
mButton.setText(((TextView)view).getText());
// mButton.setText(((TextView)view).getText());
mButton.accountSelectedNotifyAccountList(((TextView)view).getText().toString());
}
};
......
......@@ -339,6 +339,7 @@ public class CallElementList extends ListFragment implements LoaderManager.Loade
mAccountSelectionButton = (AccountSelectionButton) inflatedView.findViewById(R.id.account_selection_button);
mAccountList.addManagementUI(mAccountSelectionButton);
mAccountSelectionButton.setAccountList(mAccountList);
return inflatedView;
}
......
......@@ -280,6 +280,7 @@ public class ContactListFragment extends ListFragment implements OnQueryTextList
// Button accountSelectionButton = (Button) inflatedView.findViewById(R.id.account_selection_button);
mAccountSelectionButton = (AccountSelectionButton) inflatedView.findViewById(R.id.account_selection_button);
mAccountList.addManagementUI(mAccountSelectionButton);
mAccountSelectionButton.setAccountList(mAccountList);
return inflatedView;
}
......
......@@ -66,6 +66,14 @@ public class AccountList extends BroadcastReceiver
mUserInterfaceList.add(ui);
}
public void accountSelected(String accountID, AccountManagementUI userInterface) {
if(!mUserInterfaceList.isEmpty()) {
for(AccountManagementUI ui : mUserInterfaceList) {
ui.setSelectedAccount(accountID);
}
}
}
@Override
public void onReceive(Context context, Intent intent)
{
......@@ -106,12 +114,9 @@ public class AccountList extends BroadcastReceiver
if(newList.size() > mList.size()) {
for(AccountManagementUI ui : mUserInterfaceList) {
Log.i(TAG, "UPDATE UI");
ui.accountAdded(newList);
}
}
} else {
Log.i(TAG, "UI LIST IS EMPTY");
}
mList = newList;
......
......@@ -32,8 +32,16 @@ package com.savoirfairelinux.sflphone.utils;
import java.util.ArrayList;
import com.savoirfairelinux.sflphone.utils.AccountList;
public interface AccountManagementUI
{
public void setAccountList(AccountList accountList);
public void accountSelectedNotifyAccountList(String accountID);
public void setSelectedAccount(String accountID);
public void accountAdded(ArrayList<String> newList);
public void accountRemoved();
......
......@@ -48,6 +48,7 @@ public class AccountSelectionButton extends Button implements AccountManagementU
private ISipService mService;
private Context mContext;
private ArrayList<String> mList = new ArrayList<String>();
private AccountList mAccountList = null;
public AccountSelectionButton(Context context) {
super(context);
......@@ -78,6 +79,20 @@ public class AccountSelectionButton extends Button implements AccountManagementU
});
}
public void setAccountList(AccountList accountList) {
mAccountList = accountList;
}
public void accountSelectedNotifyAccountList(String accountID) {
if(mAccountList != null) {
mAccountList.accountSelected(accountID, this);
}
}
public void setSelectedAccount(String accountID) {
setText(accountID);
}
public void accountAdded(ArrayList<String> newList) {
Log.i(TAG, "Account added");
mList = newList;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment