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

Commit 1e0e6a05 authored by Heemin Seog's avatar Heemin Seog Committed by Android (Google) Code Review
Browse files

Merge "Refactor roles to use common base as permissions" into qt-dev

parents 545d4b7a 0eaba2cc
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -26,12 +26,13 @@ import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;

import com.android.packageinstaller.auto.AutoSettingsFrameFragment;
import com.android.packageinstaller.role.model.Role;
import com.android.packageinstaller.role.ui.DefaultAppChildFragment;
import com.android.permissioncontroller.R;

/** Screen to pick a default app for a particular {@link Role}. */
public class AutoDefaultAppFragment extends DefaultAppFrameFragment implements
public class AutoDefaultAppFragment extends AutoSettingsFrameFragment implements
        DefaultAppChildFragment.Parent {

    private String mRoleName;
@@ -65,6 +66,11 @@ public class AutoDefaultAppFragment extends DefaultAppFrameFragment implements
        mUser = arguments.getParcelable(Intent.EXTRA_USER);
    }

    @Override
    public void onCreatePreferences(Bundle bundle, String s) {
        // Preferences will be added via shared logic in {@link DefaultAppChildFragment}.
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
+7 −1
Original line number Diff line number Diff line
@@ -22,12 +22,13 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.packageinstaller.auto.AutoSettingsFrameFragment;
import com.android.packageinstaller.role.ui.DefaultAppListChildFragment;
import com.android.packageinstaller.role.ui.TwoTargetPreference;
import com.android.permissioncontroller.R;

/** Shows various roles for which a default app can be picked. */
public class AutoDefaultAppListFragment extends DefaultAppFrameFragment implements
public class AutoDefaultAppListFragment extends AutoSettingsFrameFragment implements
        DefaultAppListChildFragment.Parent {

    /** Create a new instance of this fragment. */
@@ -36,6 +37,11 @@ public class AutoDefaultAppListFragment extends DefaultAppFrameFragment implemen
        return new AutoDefaultAppListFragment();
    }

    @Override
    public void onCreatePreferences(Bundle bundle, String s) {
        // Preferences will be added via shared logic in {@link DefaultAppListChildFragment}.
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
+0 −71
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.packageinstaller.role.ui.auto;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceFragmentCompat;

import com.android.permissioncontroller.R;

/** Base fragment to be used by car variants of the default app settings screens. */
public class DefaultAppFrameFragment extends PreferenceFragmentCompat {

    private TextView mLabelView;
    private CharSequence mLabel;

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        View backButton = rootView.findViewById(R.id.back_button);
        backButton.setOnClickListener(v -> getActivity().onBackPressed());

        mLabelView = rootView.findViewById(R.id.label);
        updateHeaderLabel();

        return rootView;
    }

    /** Sets the header text of this fragment. */
    public void setHeaderLabel(CharSequence label) {
        mLabel = label;
        updateHeaderLabel();
    }

    /** Gets the header text of this fragment. */
    public CharSequence getHeaderLabel() {
        return mLabel;
    }

    @Override
    public void onCreatePreferences(Bundle bundle, String s) {
        // We'll manually add preferences later.
    }

    private void updateHeaderLabel() {
        if (mLabelView != null) {
            mLabelView.setText(mLabel);
        }
    }
}