1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.car.settings.applications.managedomainurls; 18 19 import android.content.Context; 20 import android.os.Bundle; 21 import android.os.UserHandle; 22 23 import androidx.annotation.XmlRes; 24 25 import com.android.car.settings.R; 26 import com.android.car.settings.common.SettingsFragment; 27 import com.android.settingslib.applications.ApplicationsState; 28 29 /** 30 * Fragment for the verified links settings page. 31 */ 32 public class VerifiedLinksFragment extends SettingsFragment { 33 private static final String ARG_PACKAGE_NAME = "arg_package_name"; 34 private ApplicationsState mState; 35 private ApplicationsState.AppEntry mAppEntry; 36 37 /** Creates a new instance of this fragment for the package specified in the arguments. */ newInstance(String pkg)38 public static VerifiedLinksFragment newInstance(String pkg) { 39 VerifiedLinksFragment fragment = new VerifiedLinksFragment(); 40 Bundle args = new Bundle(); 41 args.putString(ARG_PACKAGE_NAME, pkg); 42 fragment.setArguments(args); 43 return fragment; 44 } 45 46 @Override 47 @XmlRes getPreferenceScreenResId()48 protected int getPreferenceScreenResId() { 49 return R.xml.verified_links_fragment; 50 } 51 52 @Override onAttach(Context context)53 public void onAttach(Context context) { 54 super.onAttach(context); 55 mState = ApplicationsState.getInstance(requireActivity().getApplication()); 56 String pkgName = getArguments().getString(ARG_PACKAGE_NAME); 57 mAppEntry = mState.getEntry(pkgName, UserHandle.myUserId()); 58 59 use(VerifiedLinkGroupPreferenceController.class, 60 R.string.pk_opening_links_verified_links_list) 61 .setAppEntry(mAppEntry); 62 } 63 } 64