diff options
author | Yorke Lee <yorkelee@google.com> | 2015-06-27 14:03:25 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-06-29 15:34:57 -0700 |
commit | 6bc6716bcecf319109d47a90e8f223c96c5a66fb (patch) | |
tree | cd2be0e5dadbabb8c1989b77d5ed2aa363d15718 | |
parent | bab70c36308ca61950b9b64afe754d9ec2d98b30 (diff) |
Accessibility fix for Dialer search results
In portrait mode, resize the listview to fit above the dialpad,
so that accessibility services can correctly traverse the
view hierarchy.
Bug: 20172384
Change-Id: I35fb49be7bea5d13d951c4d954ddaf9d8d12780e
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 9 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 7 | ||||
-rw-r--r-- | src/com/android/dialer/list/SearchFragment.java | 68 |
3 files changed, 79 insertions, 5 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 653ed8b30..b8a1d4dce 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -1281,11 +1281,20 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O return mActionBarController; } + @Override public boolean isDialpadShown() { return mIsDialpadShown; } @Override + public int getDialpadHeight() { + if (mDialpadFragment != null) { + return mDialpadFragment.getDialpadHeight(); + } + return 0; + } + + @Override public int getActionBarHideOffset() { return getActionBar().getHideOffset(); } diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 5b1e21129..b18069fdd 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -1669,6 +1669,13 @@ public class DialpadFragment extends Fragment ((DialpadSlidingRelativeLayout) getView()).setYFraction(yFraction); } + public int getDialpadHeight() { + if (mDialpadView == null) { + return 0; + } + return mDialpadView.getHeight(); + } + public void process_quote_emergency_unquote(String query) { if (PseudoEmergencyAnimator.PSEUDO_EMERGENCY_NUMBER.equals(query)) { if (mPseudoEmergencyAnimator == null) { diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index 78c3ad3c1..1f33d5b75 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -21,17 +21,23 @@ import android.animation.AnimatorListenerAdapter; import android.app.Activity; import android.app.DialogFragment; import android.content.Intent; +import android.content.res.Configuration; import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; import android.text.TextUtils; import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.view.animation.Interpolator; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; +import android.widget.LinearLayout; import android.widget.ListView; +import android.widget.Space; import com.android.contacts.common.list.ContactEntryListAdapter; import com.android.contacts.common.list.ContactListItemView; @@ -63,11 +69,20 @@ public class SearchFragment extends PhoneNumberPickerFragment { private int mShowDialpadDuration; private int mHideDialpadDuration; + /** + * Used to resize the list view containing search results so that it fits the available space + * above the dialpad. Does not have a user-visible effect in regular touch usage (since the + * dialpad hides that portion of the ListView anyway), but improves usability in accessibility + * mode. + */ + private Space mSpacer; + private HostInterface mActivity; public interface HostInterface { public boolean isActionBarShowing(); public boolean isDialpadShown(); + public int getDialpadHeight(); public int getActionBarHideOffset(); public int getActionBarHeight(); } @@ -270,17 +285,35 @@ public class SearchFragment extends PhoneNumberPickerFragment { mActivity.isDialpadShown() ? 0 : mActionBarHeight -mShadowHeight; } if (animate) { - Interpolator interpolator = - mActivity.isDialpadShown() ? AnimUtils.EASE_IN : AnimUtils.EASE_OUT ; - int duration = - mActivity.isDialpadShown() ? mShowDialpadDuration : mHideDialpadDuration; + // If the dialpad will be shown, then this animation involves sliding the list up. + final boolean slideUp = mActivity.isDialpadShown(); + + Interpolator interpolator = slideUp ? AnimUtils.EASE_IN : AnimUtils.EASE_OUT ; + int duration = slideUp ? mShowDialpadDuration : mHideDialpadDuration; getView().setTranslationY(startTranslationValue); getView().animate() .translationY(endTranslationValue) .setInterpolator(interpolator) - .setDuration(duration); + .setDuration(duration) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + if (!slideUp) { + resizeListView(); + } + } + + @Override + public void onAnimationEnd(Animator animation) { + if (slideUp) { + resizeListView(); + } + } + }); + } else { getView().setTranslationY(endTranslationValue); + resizeListView(); } // There is padding which should only be applied when the dialpad is not shown. @@ -293,6 +326,19 @@ public class SearchFragment extends PhoneNumberPickerFragment { listView.getPaddingBottom()); } + public void resizeListView() { + if (mSpacer == null) { + return; + } + int spacerHeight = mActivity.isDialpadShown() ? mActivity.getDialpadHeight() : 0; + if (spacerHeight != mSpacer.getHeight()) { + final LinearLayout.LayoutParams lp = + (LinearLayout.LayoutParams) mSpacer.getLayoutParams(); + lp.height = spacerHeight; + mSpacer.setLayoutParams(lp); + } + } + @Override protected void startLoading() { if (PermissionsUtil.hasContactsPermissions(getActivity())) { @@ -306,4 +352,16 @@ public class SearchFragment extends PhoneNumberPickerFragment { public void setOnTouchListener(View.OnTouchListener onTouchListener) { mActivityOnTouchListener = onTouchListener; } + + @Override + protected View inflateView(LayoutInflater inflater, ViewGroup container) { + final LinearLayout parent = (LinearLayout) super.inflateView(inflater, container); + final int orientation = getResources().getConfiguration().orientation; + if (orientation == Configuration.ORIENTATION_PORTRAIT) { + mSpacer = new Space(getActivity()); + parent.addView(mSpacer, + new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0)); + } + return parent; + } } |