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

Commit 1662e171 authored by Evan Severson's avatar Evan Severson
Browse files

Only show one deny button & make them look identical

Never show both "deny" and "deny & don't ask again" buttons in the same
prompt. Make both buttons look identical by using the same style and
text. Allow backing out or clicking outside of the dialog to leave the
current dialog. Add new result to distinguish between being denied and
prompt being cancelled

Test: PermissionsHostTest
Change-Id: I66d699fb406901941ffd23451bba45feaff0535a
parent c0d3f088
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@
    style="@style/PermissionGrantScrollView">

    <LinearLayout
        android:id="@+id/grant_singleton"
        style="@style/PermissionGrantSingleton">

        <!-- The dialog -->
        <LinearLayout
            android:id="@+id/grant_dialog"
            android:theme="@style/Theme.PermissionGrantDialog"
            style="@style/PermissionGrantDialog">

@@ -86,8 +88,8 @@

                <Button
                    android:id="@+id/permission_deny_and_dont_ask_again_button"
                    android:text="@string/grant_dialog_button_deny_and_dont_ask_again"
                    style="@style/PermissionGrantButtonDenyDontAskAgain" />
                    android:text="@string/grant_dialog_button_deny"
                    style="@style/PermissionGrantButtonDeny" />
            </LinearLayout>

        </LinearLayout>
+0 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@
            <item type="style" name="PermissionGrantButtonAllowAlways" />
            <item type="style" name="PermissionGrantButtonAllowForeground" />
            <item type="style" name="PermissionGrantButtonDeny" />
            <item type="style" name="PermissionGrantButtonDenyDontAskAgain" />
            <!-- END PERMISSION GRANT DIALOG -->


+0 −2
Original line number Diff line number Diff line
@@ -112,8 +112,6 @@
           parent="@style/PermissionGrantButton"></style>
    <style name="PermissionGrantButtonDeny"
           parent="@style/PermissionGrantButton"></style>
    <style name="PermissionGrantButtonDenyDontAskAgain"
           parent="@style/PermissionGrantButton"></style>

    <!-- END PERMISSION GRANT DIALOG -->

+10 −15
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.permissioncontroller.PermissionControllerStatsLog.PERM
import static com.android.permissioncontroller.PermissionControllerStatsLog.PERMISSION_GRANT_REQUEST_RESULT_REPORTED__RESULT__USER_DENIED_WITH_PREJUDICE;
import static com.android.permissioncontroller.PermissionControllerStatsLog.PERMISSION_GRANT_REQUEST_RESULT_REPORTED__RESULT__USER_GRANTED;
import static com.android.permissioncontroller.PermissionControllerStatsLog.PERMISSION_GRANT_REQUEST_RESULT_REPORTED__RESULT__USER_GRANTED_ONE_TIME;
import static com.android.permissioncontroller.permission.ui.GrantPermissionsViewHandler.CANCELED;
import static com.android.permissioncontroller.permission.ui.GrantPermissionsViewHandler.DENIED;
import static com.android.permissioncontroller.permission.ui.GrantPermissionsViewHandler.DENIED_DO_NOT_ASK_AGAIN;
import static com.android.permissioncontroller.permission.ui.GrantPermissionsViewHandler.GRANTED_ALWAYS;
@@ -55,7 +56,6 @@ import android.text.Spanned;
import android.util.ArrayMap;
import android.util.Log;
import android.util.Pair;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
@@ -661,7 +661,8 @@ public class GrantPermissionsActivity extends Activity
                mButtonLabels[LABEL_DENY_BUTTON] = getString(R.string.grant_dialog_button_deny);
                if (isForegroundPermissionUserSet || isBackgroundPermissionUserSet) {
                    mButtonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] =
                            getString(R.string.grant_dialog_button_deny_and_dont_ask_again);
                            getString(R.string.grant_dialog_button_deny);
                    mButtonLabels[LABEL_DENY_BUTTON] = null;
                } else {
                    mButtonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] = null;
                }
@@ -698,11 +699,9 @@ public class GrantPermissionsActivity extends Activity
                        mButtonLabels[LABEL_ALLOW_BUTTON] =
                                getString(R.string.grant_dialog_button_allow_background);
                        mButtonLabels[LABEL_ALLOW_ONE_TIME] = null;
                        mButtonLabels[LABEL_DENY_BUTTON] =
                                getString(R.string.grant_dialog_button_deny_background);
                        mButtonLabels[LABEL_DENY_BUTTON] = null;
                        mButtonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] =
                                getString(R.string
                                        .grant_dialog_button_deny_background_and_dont_ask_again);
                                getString(R.string.grant_dialog_button_deny_background);
                    } else {
                        // Not reached as the permissions should be auto-granted
                        return false;
@@ -777,6 +776,9 @@ public class GrantPermissionsActivity extends Activity

        logGrantPermissionActivityButtons(name, result);
        switch (result) {
            case CANCELED:
                setResultAndFinish();
                return;
            case GRANTED_ALWAYS :
                if (foregroundGroupState != null) {
                    onPermissionGrantResultSingleState(foregroundGroupState, true, false, false);
@@ -871,15 +873,8 @@ public class GrantPermissionsActivity extends Activity
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)  {
        // We do not allow backing out.
        return keyCode == KeyEvent.KEYCODE_BACK;
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event)  {
        // We do not allow backing out.
        return keyCode == KeyEvent.KEYCODE_BACK;
    public void onBackPressed() {
        mViewHandler.onBackPressed();
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -33,9 +33,10 @@ import java.lang.annotation.Retention;
 */
public interface GrantPermissionsViewHandler {
    @Retention(SOURCE)
    @IntDef({GRANTED_ALWAYS, GRANTED_FOREGROUND_ONLY, DENIED, DENIED_DO_NOT_ASK_AGAIN,
    @IntDef({CANCELED, GRANTED_ALWAYS, GRANTED_FOREGROUND_ONLY, DENIED, DENIED_DO_NOT_ASK_AGAIN,
            GRANTED_ONE_TIME})
    @interface Result {}
    int CANCELED = -1;
    int GRANTED_ALWAYS = 0;
    int GRANTED_FOREGROUND_ONLY = 1;
    int DENIED = 2;
Loading