Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 575ae388 authored by Yorke Lee's avatar Yorke Lee
Browse files

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
parent 3cf92c74
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
        android:paddingLeft="16dp"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:text="@string/permission_single_turn_on"
        android:background="?android:attr/selectableItemBackground"
        android:clickable="true"
        style="@style/TextActionStyle" />
+2 −2
Original line number Diff line number Diff line
@@ -808,8 +808,8 @@
    <!-- Shown as a prompt to turn on the phone permission to show voicemails -->
    <string name="permission_no_voicemail">To access your voicemail,\n turn on the Phone permission.</string>

    <!-- Shown as a prompt to turn on contacts and location permissions to allow contact and nearby places search -->
    <string name="permission_no_search">To search your contacts and nearby locations, turn on the Contacts and Location permissions.</string>
    <!-- Shown as a prompt to turn on contacts permissions to allow contact search -->
    <string name="permission_no_search">To search your contacts, turn on the Contacts permissions.</string>

    <!-- Shown as a prompt to turn on the phone permission to allow a call to be placed -->
    <string name="permission_place_call">To place a call,\n turn on the Phone permission.</string>
+10 −15
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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;
+12 −1
Original line number Diff line number Diff line
@@ -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;
Loading