From c87d0c3f30534fc67385e4ecfaa708693236ce8c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 30 Jul 2012 09:39:49 +0200 Subject: [PATCH] Fix sliding drawer issues --- src/org/linphone/StatusFragment.java | 40 ++++++++++++-------------- src/org/linphone/ui/SlidingDrawer.java | 25 ++++------------ 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/src/org/linphone/StatusFragment.java b/src/org/linphone/StatusFragment.java index 0d04b00d4..0607a99c4 100644 --- a/src/org/linphone/StatusFragment.java +++ b/src/org/linphone/StatusFragment.java @@ -41,8 +41,6 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.CheckBox; import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.LinearLayout.LayoutParams; import android.widget.ListView; import android.widget.TextView; @@ -56,7 +54,7 @@ public class StatusFragment extends Fragment { private ImageView statusLed, callQuality, encryption; private ListView sliderContent; private SlidingDrawer drawer; - private LinearLayout allAccountsLed; +// private LinearLayout allAccountsLed; private Runnable mCallQualityUpdater; private boolean isInCall, isAttached = false; @@ -69,7 +67,7 @@ public class StatusFragment extends Fragment { statusLed = (ImageView) view.findViewById(R.id.statusLed); callQuality = (ImageView) view.findViewById(R.id.callQuality); encryption = (ImageView) view.findViewById(R.id.encryption); - allAccountsLed = (LinearLayout) view.findViewById(R.id.moreStatusLed); +// allAccountsLed = (LinearLayout) view.findViewById(R.id.moreStatusLed); drawer = (SlidingDrawer) view.findViewById(R.id.statusBar); drawer.setOnDrawerOpenListener(new OnDrawerOpenListener() { @@ -152,27 +150,27 @@ public class StatusFragment extends Fragment { public void run() { statusLed.setImageResource(getStatusIconResource(state, true)); statusText.setText(getStatusIconText(state)); - setMiniLedsForEachAccount(); +// setMiniLedsForEachAccount(); } }); } - private void setMiniLedsForEachAccount() { - if (allAccountsLed == null) - return; - - if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) { - allAccountsLed.removeAllViews(); - for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) { - ImageView led = new ImageView(getActivity()); - LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); - led.setLayoutParams(params); - led.setAdjustViewBounds(true); - led.setImageResource(getStatusIconResource(lpc.getState(), false)); - allAccountsLed.addView(led); - } - } - } +// private void setMiniLedsForEachAccount() { +// if (allAccountsLed == null) +// return; +// +// if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) { +// allAccountsLed.removeAllViews(); +// for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) { +// ImageView led = new ImageView(getActivity()); +// LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); +// led.setLayoutParams(params); +// led.setAdjustViewBounds(true); +// led.setImageResource(getStatusIconResource(lpc.getState(), false)); +// allAccountsLed.addView(led); +// } +// } +// } private int getStatusIconResource(LinphoneCore.RegistrationState state, boolean isDefaultAccount) { try { diff --git a/src/org/linphone/ui/SlidingDrawer.java b/src/org/linphone/ui/SlidingDrawer.java index cc5016496..de1ee6e9e 100644 --- a/src/org/linphone/ui/SlidingDrawer.java +++ b/src/org/linphone/ui/SlidingDrawer.java @@ -29,7 +29,6 @@ import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.util.AttributeSet; -import android.util.Log; import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.VelocityTracker; @@ -333,7 +332,6 @@ public class SlidingDrawer extends ViewGroup { int handleWidth = handle.getMeasuredWidth(); int handleHeight = handle.getMeasuredHeight(); - Log.d(LOG_TAG, "handleHeight: " + handleHeight); int handleLeft; int handleTop; @@ -343,9 +341,7 @@ public class SlidingDrawer extends ViewGroup { if (mVertical) { handleLeft = (width - handleWidth) / 2; if (mInvert) { - Log.d(LOG_TAG, "content.layout(1)"); - handleTop = mExpanded ? getCustomBottom() - mBottomOffset - handleHeight - : mTopOffset; + handleTop = mExpanded ? content.getMeasuredHeight() - mBottomOffset : mTopOffset; content.layout(0, mTopOffset, content.getMeasuredWidth(), mTopOffset + content.getMeasuredHeight()); } else { @@ -508,9 +504,6 @@ public class SlidingDrawer extends ViewGroup { - mTapThreshold); } - Log.d(LOG_TAG, "ACTION_UP: " + "c1: " + c1 + ", c2: " + c2 - + ", c3: " + c3 + ", c4: " + c4); - if (vertical ? c1 || c2 : c3 || c4) { if (mAllowSingleTap) { @@ -563,8 +556,6 @@ public class SlidingDrawer extends ViewGroup { int bottom = mVertical ? getCustomBottom() + mHandleHeight : getRight(); int handleHeight = mVertical ? mHandleHeight : mHandleWidth; - Log.d(LOG_TAG, "position: " + position + ", velocity: " + velocity - + ", mMaximumMajorVelocity: " + mMaximumMajorVelocity); c1 = mInvert ? velocity < mMaximumMajorVelocity : velocity > mMaximumMajorVelocity; c2 = mInvert ? (bottom - (position + handleHeight)) + mBottomOffset > handleHeight @@ -572,8 +563,6 @@ public class SlidingDrawer extends ViewGroup { + (mVertical ? mHandleHeight : mHandleWidth); c3 = mInvert ? velocity < -mMaximumMajorVelocity : velocity > -mMaximumMajorVelocity; - Log.d(LOG_TAG, "EXPANDED. c1: " + c1 + ", c2: " + c2 + ", c3: " - + c3); if (always || (c1 || (c2 && c3))) { // We are expanded, So animate to CLOSE! mAnimatedAcceleration = mMaximumAcceleration; @@ -613,12 +602,6 @@ public class SlidingDrawer extends ViewGroup { c3 = mInvert ? velocity < -mMaximumMajorVelocity : velocity > -mMaximumMajorVelocity; - Log.d(LOG_TAG, "COLLAPSED. position: " + position + ", velocity: " - + velocity + ", mMaximumMajorVelocity: " - + mMaximumMajorVelocity); - Log.d(LOG_TAG, "COLLAPSED. always: " + always + ", c1: " + c1 - + ", c2: " + c2 + ", c3: " + c3); - if (!always && (c1 || (c2 && c3))) { mAnimatedAcceleration = mMaximumAcceleration; @@ -791,8 +774,6 @@ public class SlidingDrawer extends ViewGroup { - getLeft(), MeasureSpec.EXACTLY), MeasureSpec .makeMeasureSpec(height, MeasureSpec.AT_MOST)); - Log.d(LOG_TAG, "content.layout(2)"); - if (mInvert) content.layout(0, mTopOffset, content.getMeasuredWidth(), mTopOffset + content.getMeasuredHeight()); @@ -967,6 +948,10 @@ public class SlidingDrawer extends ViewGroup { * @see #toggle() */ public void animateClose() { + if (!isOpened()) { + return; + } + prepareContent(); final OnDrawerScrollListener scrollListener = mOnDrawerScrollListener; if (scrollListener != null) {