From e3cae63fc19a431d902fb8ae50eab732e735b2a0 Mon Sep 17 00:00:00 2001 From: Ta-wei Yen Date: Tue, 27 Oct 2015 16:09:09 -0700 Subject: DiatactsActivity title indicate dialpad status, removed excessive "showing item" messages. + DiatactsActivity set its' title to "Phone Dialpad" or just "Phone", so user using Talkback can know the state of the activity when it is launched + SpeedDialFragment and SearchFragment no longer send accessibility events when its' content is changed. + Add AccessibilityDelegate ContentChangedFilter to filter out TYPE_WINDOW_CONTENT_CHANGED event for View. Bug:25190037 Change-Id: If1fa34cc9a5d24dec3fe261da9c071bb5388ec58 --- src/com/android/dialer/DialtactsActivity.java | 12 ++++--- .../android/dialer/dialpad/DialpadFragment.java | 6 ++-- .../android/dialer/list/ContentChangedFilter.java | 40 ++++++++++++++++++++++ src/com/android/dialer/list/SearchFragment.java | 7 +++- src/com/android/dialer/list/SpeedDialFragment.java | 5 +++ 5 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 src/com/android/dialer/list/ContentChangedFilter.java (limited to 'src/com/android/dialer') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 9105e6f5a..dabe590ad 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -48,7 +48,6 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.View.OnDragListener; -import android.view.View.OnTouchListener; import android.view.ViewTreeObserver; import android.view.animation.Animation; import android.view.animation.AnimationUtils; @@ -83,16 +82,14 @@ import com.android.dialer.list.SearchFragment; import com.android.dialer.list.SmartDialSearchFragment; import com.android.dialer.list.SpeedDialFragment; import com.android.dialer.settings.DialerSettingsActivity; +import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil; -import com.android.dialer.util.TelecomUtil; import com.android.dialer.util.IntentUtil.CallIntentBuilder; -import com.android.dialer.util.DialerUtils; +import com.android.dialer.util.TelecomUtil; import com.android.dialer.widget.ActionBarController; import com.android.dialer.widget.SearchEditTextLayout; -import com.android.dialer.widget.SearchEditTextLayout.Callback; import com.android.dialerbind.DatabaseHelperManager; import com.android.dialerbind.ObjectFactory; -import com.android.incallui.Call.LogState; import com.android.phone.common.animation.AnimUtils; import com.android.phone.common.animation.AnimationListenerAdapter; @@ -756,6 +753,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mActionBarController.onDialpadUp(); mListsFragment.getView().animate().alpha(0).withLayer(); + + //adjust the title, so the user will know where we're at when the activity start/resumes. + setTitle(R.string.launcherDialpadActivityLabel); } /** @@ -808,6 +808,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O exitSearchUi(); } } + //reset the title to normal. + setTitle(R.string.launcherActivityLabel); } /** diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 517711016..760b02032 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -16,6 +16,8 @@ package com.android.dialer.dialpad; +import com.google.common.annotations.VisibleForTesting; + import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -27,7 +29,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; -import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -80,14 +81,13 @@ import com.android.dialer.R; import com.android.dialer.SpecialCharSequenceMgr; import com.android.dialer.calllog.PhoneAccountUtils; import com.android.dialer.util.DialerUtils; -import com.android.dialer.util.TelecomUtil; import com.android.dialer.util.IntentUtil.CallIntentBuilder; +import com.android.dialer.util.TelecomUtil; import com.android.incallui.Call.LogState; import com.android.phone.common.CallLogAsync; import com.android.phone.common.animation.AnimUtils; import com.android.phone.common.dialpad.DialpadKeyButton; import com.android.phone.common.dialpad.DialpadView; -import com.google.common.annotations.VisibleForTesting; import java.util.HashSet; import java.util.List; diff --git a/src/com/android/dialer/list/ContentChangedFilter.java b/src/com/android/dialer/list/ContentChangedFilter.java new file mode 100644 index 000000000..e552aa3f0 --- /dev/null +++ b/src/com/android/dialer/list/ContentChangedFilter.java @@ -0,0 +1,40 @@ +package com.android.dialer.list; + +import android.view.View; +import android.view.View.AccessibilityDelegate; +import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; + +/** + * AccessibilityDelegate that will filter out TYPE_WINDOW_CONTENT_CHANGED + * Used to suppress "Showing items x of y" from firing of ListView whenever it's content changes. + * AccessibilityEvent can only be rejected at a view's parent once it is generated, + * use addToParent() to add this delegate to the parent. + */ +public class ContentChangedFilter extends AccessibilityDelegate { + //the view we don't want TYPE_WINDOW_CONTENT_CHANGED to fire. + private View mView; + + /** + * Add this delegate to the parent of @param view to filter out TYPE_WINDOW_CONTENT_CHANGED + */ + public static void addToParent(View view){ + View parent = (View) view.getParent(); + parent.setAccessibilityDelegate(new ContentChangedFilter(view)); + } + + private ContentChangedFilter(View view){ + super(); + mView = view; + } + @Override + public boolean onRequestSendAccessibilityEvent (ViewGroup host, View child, AccessibilityEvent event){ + if(child == mView){ + if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED){ + return false; + } + } + return super.onRequestSendAccessibilityEvent(host,child,event); + } + +} diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index c8711e769..9b0f53621 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -44,8 +44,8 @@ import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.list.PhoneNumberPickerFragment; import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.common.util.ViewUtil; -import com.android.dialer.dialpad.DialpadFragment.ErrorDialogFragment; import com.android.dialer.R; +import com.android.dialer.dialpad.DialpadFragment.ErrorDialogFragment; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil; import com.android.dialer.widget.EmptyContentView; @@ -136,6 +136,11 @@ public class SearchFragment extends PhoneNumberPickerFragment { listView.setBackgroundColor(res.getColor(R.color.background_dialer_results)); listView.setClipToPadding(false); setVisibleScrollbarEnabled(false); + + //Turn of accessibility live region as the list constantly update itself and spam messages. + listView.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE); + ContentChangedFilter.addToParent(listView); + listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { diff --git a/src/com/android/dialer/list/SpeedDialFragment.java b/src/com/android/dialer/list/SpeedDialFragment.java index e30f40633..19180f81e 100644 --- a/src/com/android/dialer/list/SpeedDialFragment.java +++ b/src/com/android/dialer/list/SpeedDialFragment.java @@ -255,6 +255,11 @@ public class SpeedDialFragment extends Fragment implements OnItemClickListener, mListView.setOnScrollListener(mScrollListener); mListView.setFastScrollEnabled(false); mListView.setFastScrollAlwaysVisible(false); + + //prevent content changes of the list from firing accessibility events. + mListView.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE); + ContentChangedFilter.addToParent(mListView); + Trace.endSection(); return mParentView; } -- cgit v1.2.3