1 /* 2 * Copyright (C) 2020 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.settings.security; 18 19 import android.net.Uri; 20 import android.security.AppUriAuthenticationPolicy; 21 import android.view.LayoutInflater; 22 import android.view.View; 23 import android.view.ViewGroup; 24 import android.widget.TextView; 25 26 import androidx.annotation.NonNull; 27 import androidx.recyclerview.widget.RecyclerView; 28 29 import com.android.settings.R; 30 31 import java.util.List; 32 33 /** 34 * Child adapter for the requesting credential management app. This adapter displays the list of 35 * URIs for each app in the requesting app's authentication policy, when 36 * {@link RequestManageCredentials} is started. 37 * 38 * @hide 39 * @see CredentialManagementAppAdapter 40 * @see RequestManageCredentials 41 * @see AppUriAuthenticationPolicy 42 */ 43 public class UriAuthenticationPolicyAdapter extends 44 RecyclerView.Adapter<UriAuthenticationPolicyAdapter.UriViewHolder> { 45 46 private final List<Uri> mUris; 47 48 /** 49 * View holder for each URI which is part of the authentication policy in the 50 * request manage credentials screen. 51 */ 52 public class UriViewHolder extends RecyclerView.ViewHolder { 53 TextView mUriNameView; 54 UriViewHolder(@onNull View view)55 public UriViewHolder(@NonNull View view) { 56 super(view); 57 mUriNameView = itemView.findViewById(R.id.uri_name); 58 } 59 } 60 UriAuthenticationPolicyAdapter(List<Uri> uris)61 UriAuthenticationPolicyAdapter(List<Uri> uris) { 62 this.mUris = uris; 63 } 64 65 @Override onCreateViewHolder(ViewGroup parent, int viewType)66 public UriAuthenticationPolicyAdapter.UriViewHolder onCreateViewHolder(ViewGroup parent, 67 int viewType) { 68 View view = LayoutInflater.from(parent.getContext()).inflate( 69 R.layout.app_authentication_uri_item, parent, false); 70 return new UriViewHolder(view); 71 } 72 73 @Override onBindViewHolder(UriAuthenticationPolicyAdapter.UriViewHolder holder, int position)74 public void onBindViewHolder(UriAuthenticationPolicyAdapter.UriViewHolder holder, 75 int position) { 76 Uri uri = mUris.get(position); 77 holder.mUriNameView.setText(Uri.decode(uri.toString())); 78 } 79 80 @Override getItemCount()81 public int getItemCount() { 82 return mUris.size(); 83 } 84 } 85