1 /* 2 * Copyright (C) 2017 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; 18 19 import android.annotation.NonNull; 20 import android.content.Context; 21 import android.content.pm.PackageManager; 22 import android.content.pm.ResolveInfo; 23 24 import androidx.car.widget.TextListItem; 25 26 import com.android.car.settings.R; 27 import com.android.car.settings.common.BaseFragment; 28 29 /** 30 * Represents an application in application settings page. 31 */ 32 public class ApplicationLineItem extends TextListItem { 33 ApplicationLineItem( @onNull Context context, PackageManager pm, ResolveInfo resolveInfo, BaseFragment.FragmentController fragmentController)34 public ApplicationLineItem( 35 @NonNull Context context, 36 PackageManager pm, 37 ResolveInfo resolveInfo, 38 BaseFragment.FragmentController fragmentController) { 39 this(context, pm, resolveInfo, fragmentController, true); 40 } 41 ApplicationLineItem( @onNull Context context, PackageManager pm, ResolveInfo resolveInfo, BaseFragment.FragmentController fragmentController, boolean clickable)42 public ApplicationLineItem( 43 @NonNull Context context, 44 PackageManager pm, 45 ResolveInfo resolveInfo, 46 BaseFragment.FragmentController fragmentController, 47 boolean clickable) { 48 super(context); 49 setTitle(resolveInfo.loadLabel(pm).toString()); 50 setPrimaryActionIcon(resolveInfo.loadIcon(pm), /* useLargeIcon= */ false); 51 if (clickable) { 52 setSupplementalIcon(R.drawable.ic_chevron_right, /* showDivider= */ false); 53 setOnClickListener(v -> 54 fragmentController.launchFragment( 55 ApplicationDetailFragment.getInstance(resolveInfo))); 56 } 57 } 58 } 59