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

Commit 0ecfd8fc authored by Nate Myren's avatar Nate Myren
Browse files

Ensure preference navigates without nav graph

Ensure the PermissionControlPreference will fall back to the old version
of navigation if it doesn't have a nav graph

Test: On auto, attempt to navigate to an App Permission Screen
Fixes: 150033427
Change-Id: I73395d01fff23999098cf91df0380d1408ac1e8f
parent 58507ad2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public class GrantPermissionsAutoViewHandler implements GrantPermissionsViewHand
                .setPositiveButton(mContext.getString(R.string.grant_dialog_button_allow), this);
        if (buttonVisibilities[DENY_AND_DONT_ASK_AGAIN_BUTTON]) {
            builder.setNeutralButton(
                    mContext.getString(R.string.grant_dialog_button_deny_dont_ask_again), this);
                    mContext.getString(R.string.grant_dialog_button_deny_and_dont_ask_again), this);
        }
        if (groupCount > 1) {
            builder.setSubtitle(mContext.getString(R.string.current_permission_template,
+15 −5
Original line number Diff line number Diff line
@@ -183,8 +183,8 @@ public class PermissionControlPreference extends Preference {
        setIcons(holder, mSummaryIcons, R.id.summary_widget_frame);
        setIcons(holder, mTitleIcons, R.id.title_widget_frame);

        if (mHasNavGraph) {
        setOnPreferenceClickListener(pref -> {
            if (mHasNavGraph) {
                Bundle args = new Bundle();
                args.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName);
                args.putString(Intent.EXTRA_PERMISSION_GROUP_NAME, mPermGroupName);
@@ -194,10 +194,20 @@ public class PermissionControlPreference extends Preference {
                args.putString(GRANT_CATEGORY, mGranted);
                Navigation.findNavController(holder.itemView).navigate(R.id.perm_groups_to_app,
                        args);
            } else {
                // TODO ntmyren, yianyliu: Remove once Auto has been adapted to new permission model
                // see b/150229448
                Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSION);
                intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackageName);
                intent.putExtra(Intent.EXTRA_PERMISSION_GROUP_NAME, mPermGroupName);
                intent.putExtra(Intent.EXTRA_USER, mUser);
                intent.putExtra(AppPermissionActivity.EXTRA_CALLER_NAME, mCaller);
                intent.putExtra(EXTRA_SESSION_ID, mSessionId);
                mContext.startActivity(intent);
            }
            return true;
        });
    }
    }

    private void setIcons(PreferenceViewHolder holder, @Nullable List<Integer> icons, int frameId) {
        ViewGroup frame = (ViewGroup) holder.findViewById(frameId);