diff --git a/res/layout/accounts.xml b/res/layout/accounts.xml
index 7716e595c..f82a26b48 100644
--- a/res/layout/accounts.xml
+++ b/res/layout/accounts.xml
@@ -1,20 +1,26 @@
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center">
+ android:layout_height="wrap_content"/>
+
+
diff --git a/res/layout/status.xml b/res/layout/status.xml
index e7d6fb4bb..38ba0a392 100644
--- a/res/layout/status.xml
+++ b/res/layout/status.xml
@@ -10,17 +10,16 @@
android:id="@+id/statusBar"
linphone:direction="topToBottom"
android:layout_width="match_parent"
- android:layout_height="80dp"
+ android:layout_height="wrap_content"
linphone:handle="@+id/handle"
linphone:content="@+id/content">
-
-
-
+ android:layout_height="wrap_content"
+ android:stackFromBottom="true"
+ android:background="@android:color/black"/>
> hashMapAccountsStateList = new ArrayList>();
- for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
- HashMap entitiesHashMap = new HashMap();
- entitiesHashMap.put("Identity", lpc.getIdentity().split("sip:")[1]);
- entitiesHashMap.put("State", Integer.toString(getStatusIconResource(lpc.getState())));
- hashMapAccountsStateList.add(entitiesHashMap);
- }
- Adapter adapterForList = new SimpleAdapter(getActivity(), hashMapAccountsStateList, R.layout.accounts,
- new String[] {"Identity", "State" },
- new int[] { R.id.Identity, R.id.State });
- accounts.setAdapter((ListAdapter) adapterForList);
-
- sliderContent.addView(accounts);
+ sliderContent.setDividerHeight(0);
+ AccountsListAdapter adapter = new AccountsListAdapter(LinphoneManager.getLc().getProxyConfigList());
+ sliderContent.setAdapter(adapter);
}
public void registrationStateChanged(final RegistrationState state) {
@@ -294,4 +279,78 @@ public class StatusFragment extends Fragment {
exit.setVisibility(View.VISIBLE);
}
}
+
+ class AccountsListAdapter extends BaseAdapter {
+ private LinphoneProxyConfig[] accounts;
+ private SharedPreferences prefs;
+ private List checkboxes;
+
+ AccountsListAdapter(LinphoneProxyConfig[] lpcs) {
+ accounts = lpcs;
+ prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ checkboxes = new ArrayList();
+ }
+
+ private OnCheckedChangeListener defaultListener = new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putInt(getString(R.string.pref_default_account), (Integer) buttonView.getTag());
+ editor.commit();
+ sliderContent.invalidate();
+
+ for (CheckBox cb : checkboxes) {
+ cb.setChecked(false);
+ cb.setEnabled(true);
+ }
+ buttonView.setChecked(true);
+ buttonView.setEnabled(false);
+ }
+ }
+ };
+
+ public int getCount() {
+ return accounts.length;
+ }
+
+ public Object getItem(int position) {
+ return accounts[position];
+ }
+
+ public long getItemId(int position) {
+ return position;
+ }
+
+ public View getView(final int position, View convertView, ViewGroup parent) {
+ View view = null;
+ if (convertView != null) {
+ view = convertView;
+ } else {
+ view = LayoutInflater.from(getActivity()).inflate(R.layout.accounts, parent, false);
+ }
+
+ LinphoneProxyConfig lpc = (LinphoneProxyConfig) getItem(position);
+
+ ImageView status = (ImageView) view.findViewById(R.id.State);
+ status.setImageResource(getStatusIconResource(lpc.getState()));
+
+ TextView identity = (TextView) view.findViewById(R.id.Identity);
+ identity.setText(lpc.getIdentity().split("sip:")[1]);
+
+ CheckBox isDefault = (CheckBox) view.findViewById(R.id.Default);
+ checkboxes.add(isDefault);
+ isDefault.setTag(position);
+ isDefault.setChecked(false);
+ isDefault.setEnabled(true);
+
+ if (prefs.getInt(getString(R.string.pref_default_account), 0) == position) {
+ isDefault.setChecked(true);
+ isDefault.setEnabled(false);
+ }
+ isDefault.setOnCheckedChangeListener(defaultListener);
+
+ return view;
+ }
+ }
}
diff --git a/src/org/linphone/ui/SlidingDrawer.java b/src/org/linphone/ui/SlidingDrawer.java
index b7bf9bf9a..cc5016496 100644
--- a/src/org/linphone/ui/SlidingDrawer.java
+++ b/src/org/linphone/ui/SlidingDrawer.java
@@ -257,7 +257,7 @@ public class SlidingDrawer extends ViewGroup {
- mTopOffset;
mContent.measure(MeasureSpec.makeMeasureSpec(widthSpecSize,
MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height,
- MeasureSpec.EXACTLY));
+ MeasureSpec.AT_MOST));
} else {
int width = widthSpecSize - handle.getMeasuredWidth() - mTopOffset;
mContent.measure(MeasureSpec.makeMeasureSpec(width,
@@ -267,6 +267,10 @@ public class SlidingDrawer extends ViewGroup {
setMeasuredDimension(widthSpecSize, heightSpecSize);
}
+
+ private int getCustomBottom() {
+ return mContent.getBottom() + mHandleHeight;
+ }
@Override
protected void dispatchDraw(Canvas canvas) {
@@ -282,7 +286,7 @@ public class SlidingDrawer extends ViewGroup {
if (isVertical) {
if (mInvert) {
canvas.drawBitmap(cache, 0, handle.getTop()
- - (getBottom() - getTop()) + mHandleHeight,
+ - (getCustomBottom() - getTop()) + mHandleHeight,
null);
} else {
canvas.drawBitmap(cache, 0, handle.getBottom(), null);
@@ -340,7 +344,7 @@ public class SlidingDrawer extends ViewGroup {
handleLeft = (width - handleWidth) / 2;
if (mInvert) {
Log.d(LOG_TAG, "content.layout(1)");
- handleTop = mExpanded ? height - mBottomOffset - handleHeight
+ handleTop = mExpanded ? getCustomBottom() - mBottomOffset - handleHeight
: mTopOffset;
content.layout(0, mTopOffset, content.getMeasuredWidth(),
mTopOffset + content.getMeasuredHeight());
@@ -483,7 +487,7 @@ public class SlidingDrawer extends ViewGroup {
boolean c4;
if (mInvert) {
- c1 = (mExpanded && (getBottom() - handleBottom) < mTapThreshold
+ c1 = (mExpanded && (getCustomBottom() - handleBottom) < mTapThreshold
+ mBottomOffset);
c2 = (!mExpanded && handleTop < mTopOffset
+ mHandleHeight - mTapThreshold);
@@ -495,7 +499,7 @@ public class SlidingDrawer extends ViewGroup {
c1 = (mExpanded && handleTop < mTapThreshold
+ mTopOffset);
c2 = (!mExpanded && handleTop > mBottomOffset
- + getBottom() - getTop() - mHandleHeight
+ + getCustomBottom() - getTop() - mHandleHeight
- mTapThreshold);
c3 = (mExpanded && handleLeft < mTapThreshold
+ mTopOffset);
@@ -556,7 +560,7 @@ public class SlidingDrawer extends ViewGroup {
boolean c3;
if (mExpanded) {
- int bottom = mVertical ? getBottom() : getRight();
+ int bottom = mVertical ? getCustomBottom() + mHandleHeight : getRight();
int handleHeight = mVertical ? mHandleHeight : mHandleWidth;
Log.d(LOG_TAG, "position: " + position + ", velocity: " + velocity
@@ -688,7 +692,7 @@ public class SlidingDrawer extends ViewGroup {
if (mVertical) {
if (position == EXPANDED_FULL_OPEN) {
if (mInvert)
- handle.offsetTopAndBottom(mBottomOffset + getBottom()
+ handle.offsetTopAndBottom(mBottomOffset + getCustomBottom()
- getTop() - mHandleHeight);
else
handle.offsetTopAndBottom(mTopOffset - handle.getTop());
@@ -697,7 +701,7 @@ public class SlidingDrawer extends ViewGroup {
if (mInvert) {
handle.offsetTopAndBottom(mTopOffset - handle.getTop());
} else {
- handle.offsetTopAndBottom(mBottomOffset + getBottom()
+ handle.offsetTopAndBottom(mBottomOffset + getCustomBottom()
- getTop() - mHandleHeight - handle.getTop());
}
invalidate();
@@ -706,9 +710,9 @@ public class SlidingDrawer extends ViewGroup {
int deltaY = position - top;
if (position < mTopOffset) {
deltaY = mTopOffset - top;
- } else if (deltaY > mBottomOffset + getBottom() - getTop()
+ } else if (deltaY > mBottomOffset + getCustomBottom() - getTop()
- mHandleHeight - top) {
- deltaY = mBottomOffset + getBottom() - getTop()
+ deltaY = mBottomOffset + getCustomBottom() - getTop()
- mHandleHeight - top;
}
@@ -785,7 +789,7 @@ public class SlidingDrawer extends ViewGroup {
int height = getBottom() - getTop() - handleHeight - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(getRight()
- getLeft(), MeasureSpec.EXACTLY), MeasureSpec
- .makeMeasureSpec(height, MeasureSpec.EXACTLY));
+ .makeMeasureSpec(height, MeasureSpec.AT_MOST));
Log.d(LOG_TAG, "content.layout(2)");