From 575ae388961252a771488c357e425fca191594b2 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Thu, 16 Jul 2015 11:36:07 -0700 Subject: Add permission prompts for contacts and dialpad search Update the following fragments to handle denied permissions -Contacts Search (Contacts and Location) -Dialpad Search (Phone) Tweak and remove some of the onTouch listener logic as they are no longer valid with the new UI. Instead of intercepting the touches when the query is empty and returning to the main dialer activity, allow the fragments to remain on screen if the permission request UI is showing. Modify signature of onEmptyViewActionButtonClicked to remove unused permissions parameter. Bug: 22174668 Change-Id: I96d00f2ab45df936dca602ac025f723638ac02c4 --- src/com/android/dialer/DialtactsActivity.java | 25 +++++------ .../android/dialer/calllog/CallLogFragment.java | 2 +- .../android/dialer/dialpad/DialpadFragment.java | 13 +++++- .../android/dialer/list/AllContactsFragment.java | 2 +- .../android/dialer/list/RegularSearchFragment.java | 49 +++++++++++++++++++- src/com/android/dialer/list/SearchFragment.java | 18 +++++++- .../dialer/list/SmartDialSearchFragment.java | 52 +++++++++++++++++++++- src/com/android/dialer/list/SpeedDialFragment.java | 2 +- .../android/dialer/widget/EmptyContentView.java | 31 +++++++++---- 9 files changed, 163 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 85197a530..98f34b57d 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -103,6 +103,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O DialpadFragment.OnDialpadQueryChangedListener, OnListFragmentScrolledListener, CallLogFragment.HostInterface, + DialpadFragment.HostInterface, ListsFragment.HostInterface, SpeedDialFragment.HostInterface, SearchFragment.HostInterface, @@ -486,8 +487,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } }); - setupActivityOverlay(); - Trace.endSection(); Trace.beginSection(TAG + " initialize smart dialing"); @@ -497,19 +496,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O Trace.endSection(); } - private void setupActivityOverlay() { - final View activityOverlay = findViewById(R.id.activity_overlay); - activityOverlay.setOnTouchListener(new OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (!mIsDialpadShown) { - maybeExitSearchUi(); - } - return false; - } - }); - } - @Override protected void onResume() { Trace.beginSection(TAG + " onResume"); @@ -1147,7 +1133,16 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } catch (Exception ignored) { // Skip any exceptions for this piece of code } + } + @Override + public boolean onDialpadSpacerTouchWithEmptyQuery() { + if (mInDialpadSearch && mSmartDialSearchFragment != null + && !mSmartDialSearchFragment.isShowingPermissionRequest()) { + hideDialpadFragment(true /* animate */, true /* clearDialpad */); + return true; + } + return false; } @Override diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index d1a9827eb..59e2c7f38 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -486,7 +486,7 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis } @Override - public void onEmptyViewActionButtonClicked(String[] permissions) { + public void onEmptyViewActionButtonClicked() { final Activity activity = getActivity(); if (activity == null) { return; diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index b18069fdd..d35abd75b 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -135,6 +135,15 @@ public class DialpadFragment extends Fragment void onDialpadQueryChanged(String query); } + public interface HostInterface { + /** + * Notifies the parent activity that the space above the dialpad has been tapped with + * no query in the dialpad present. In most situations this will cause the dialpad to + * be dismissed, unless there happens to be content showing. + */ + boolean onDialpadSpacerTouchWithEmptyQuery(); + } + private static final boolean DEBUG = DialtactsActivity.DEBUG; // This is the amount of screen the dialpad fragment takes up when fully displayed @@ -385,7 +394,9 @@ public class DialpadFragment extends Fragment @Override public boolean onTouch(View v, MotionEvent event) { if (isDigitsEmpty()) { - hideAndClearDialpad(true); + if (getActivity() != null) { + return ((HostInterface) getActivity()).onDialpadSpacerTouchWithEmptyQuery(); + } return true; } return false; diff --git a/src/com/android/dialer/list/AllContactsFragment.java b/src/com/android/dialer/list/AllContactsFragment.java index 19d8a438a..0de84347e 100644 --- a/src/com/android/dialer/list/AllContactsFragment.java +++ b/src/com/android/dialer/list/AllContactsFragment.java @@ -133,7 +133,7 @@ public class AllContactsFragment extends ContactEntryListFragment