Better multi-account management + fix landscape fc

This commit is contained in:
Sylvain Berfini 2012-02-08 10:38:44 +01:00
parent caa668604b
commit ff5672fae4
4 changed files with 105 additions and 37 deletions

View file

@ -15,20 +15,70 @@
</LinearLayout>
<View android:layout_width="0px" android:visibility="invisible" android:layout_weight="1" android:layout_height="fill_parent" />
<FrameLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="23sp">
<LinearLayout android:id="@+id/CallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom">
<org.linphone.ui.CallButton android:id="@+id/Call"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/startcall_green"/>
<org.linphone.ui.HangCallButton android:id="@+id/Decline" android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"/>
</LinearLayout>
<View android:layout_width="0px" android:visibility="invisible" android:layout_weight="1" android:layout_height="fill_parent" />
<EditText android:id="@+id/status_label" android:layout_width="fill_parent"
android:clickable="false" android:focusable="false"
android:cursorVisible="false" android:textSize="12sp" android:height="15sp"
android:background="@android:color/transparent" android:textColor="@android:color/white"
android:lines="1" android:layout_height="wrap_content"></EditText>
<LinearLayout android:id="@+id/CallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom">
<org.linphone.ui.CallButton android:id="@+id/Call"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/startcall_green"/>
<org.linphone.ui.HangCallButton android:id="@+id/Decline" android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"/>
</LinearLayout>
</LinearLayout>
<SlidingDrawer
android:id="@+id/drawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:handle="@+id/handle"
android:layout_weight="1"
android:content="@+id/accounts">
<LinearLayout
android:id="@id/handle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000"
android:gravity="center_vertical">
<EditText
android:id="@+id/status_label"
android:clickable="false"
android:focusable="false"
android:cursorVisible="false"
android:textSize="12sp"
android:background="#000000"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="4"
android:textColor="@android:color/white" />
<ImageView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="100"
android:src="@drawable/conf_details"/>
</LinearLayout>
<ListView
android:id="@id/accounts"
android:background="#CC000000"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</SlidingDrawer>
</FrameLayout>
</LinearLayout>

View file

@ -95,19 +95,21 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
private void displayRegisterStatus() {
ListView accounts = (ListView) findViewById(R.id.accounts);
accounts.setDividerHeight(0);
ArrayList<HashMap<String,String>> hashMapAccountsStateList = new ArrayList<HashMap<String,String>>();
for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
HashMap<String, String> entitiesHashMap = new HashMap<String, String>();
entitiesHashMap.put("Identity", lpc.getIdentity().split("sip:")[1]);
entitiesHashMap.put("State", getStatusIcon(lpc.getState()));
hashMapAccountsStateList.add(entitiesHashMap);
if (accounts != null) {
accounts.setDividerHeight(0);
ArrayList<HashMap<String,String>> hashMapAccountsStateList = new ArrayList<HashMap<String,String>>();
for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
HashMap<String, String> entitiesHashMap = new HashMap<String, String>();
entitiesHashMap.put("Identity", lpc.getIdentity().split("sip:")[1]);
entitiesHashMap.put("State", getStatusIcon(lpc.getState()));
hashMapAccountsStateList.add(entitiesHashMap);
}
Adapter adapterForList = new SimpleAdapter(this, hashMapAccountsStateList, R.layout.accounts,
new String[] {"Identity", "State"},
new int[] { R.id.Identity, R.id.State });
accounts.setAdapter((ListAdapter) adapterForList);
accounts.invalidate();
}
Adapter adapterForList = new SimpleAdapter(this, hashMapAccountsStateList, R.layout.accounts,
new String[] {"Identity", "State"},
new int[] { R.id.Identity, R.id.State });
accounts.setAdapter((ListAdapter) adapterForList);
accounts.invalidate();
}
public void onCreate(Bundle savedInstanceState) {
@ -123,15 +125,17 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
mStatus = (TextView) findViewById(R.id.status_label);
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.drawer);
drawer.setOnDrawerScrollListener(new OnDrawerScrollListener() {
public void onScrollEnded() {
if (drawer != null) {
drawer.setOnDrawerScrollListener(new OnDrawerScrollListener() {
public void onScrollEnded() {
}
}
public void onScrollStarted() {
displayRegisterStatus();
}
});
public void onScrollStarted() {
displayRegisterStatus();
}
});
}
AddressAware numpad = (AddressAware) findViewById(R.id.Dialer);
if (numpad != null)

View file

@ -123,6 +123,7 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
// Get the good preference screen
accounts = (PreferenceCategory) root.getPreference(0);
accounts.removeAll();
Preference addAccount = (Preference) root.getPreference(1);
addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
@ -198,7 +199,20 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ADD_SIP_ACCOUNT) {
//Verify if last created account is filled
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
int n = prefs.getInt(getString(R.string.pref_extra_accounts), 1);
String keyUsername = getString(R.string.pref_username_key) + (n-1 == 0 ? "" : Integer.toString(n-1));
if (prefs.getString(keyUsername, "").equals("")) {
//If not, we suppress it to not display a blank field
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(getString(R.string.pref_extra_accounts), n-1);
editor.commit();
}
createDynamicAccountsPreferences();
}
}

View file

@ -144,7 +144,7 @@ public class LinphonePreferencesSIPAccountActivity extends PreferenceActivity {
private String getAccountNumber(int n) {
if (n > 0)
return n + "";
return Integer.toString(n);
else
return "";
}