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.documentsui.sidebar; 18 19 import android.content.pm.ResolveInfo; 20 import android.view.View; 21 import android.widget.ImageView; 22 import android.widget.TextView; 23 24 import com.android.documentsui.ActionHandler; 25 import com.android.documentsui.R; 26 27 28 /** 29 * Similar to {@link ProfileItem} but only used in the navigation rail. 30 */ 31 public class NavRailProfileItem extends ProfileItem { 32 NavRailProfileItem(ResolveInfo info, String title, ActionHandler actionHandler)33 public NavRailProfileItem(ResolveInfo info, String title, ActionHandler actionHandler) { 34 super(R.layout.nav_rail_item_root, info, title, actionHandler); 35 } 36 37 @Override bindView(View convertView)38 public void bindView(View convertView) { 39 final ImageView icon = convertView.findViewById(android.R.id.icon); 40 final TextView titleView = convertView.findViewById(android.R.id.title); 41 42 titleView.setText(title); 43 titleView.setContentDescription(userId.getUserBadgedLabel(convertView.getContext(), title)); 44 45 bindIcon(icon); 46 } 47 } 48