1 /* 2 ** 3 ** Copyright 2007, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 package android.widget; 18 19 import android.content.Context; 20 import android.graphics.drawable.Drawable; 21 import android.view.LayoutInflater; 22 import android.view.View; 23 24 import com.android.internal.R; 25 26 /** 27 * Allows the device admin to show certain dialogs. Should be integrated into settings. 28 * 29 * @deprecated 30 * {@hide} 31 */ 32 @Deprecated 33 public class AppSecurityPermissions { 34 35 /** 36 * Utility to retrieve a view displaying a single permission. This provides 37 * the old UI layout for permissions; it is only here for the device admin 38 * settings to continue to use. 39 */ getPermissionItemView(Context context, CharSequence grpName, CharSequence description, boolean dangerous)40 public static View getPermissionItemView(Context context, 41 CharSequence grpName, CharSequence description, boolean dangerous) { 42 LayoutInflater inflater = (LayoutInflater)context.getSystemService( 43 Context.LAYOUT_INFLATER_SERVICE); 44 Drawable icon = context.getDrawable(dangerous 45 ? R.drawable.ic_bullet_key_permission : R.drawable.ic_text_dot); 46 return getPermissionItemViewOld(context, inflater, grpName, 47 description, dangerous, icon); 48 } 49 getPermissionItemViewOld(Context context, LayoutInflater inflater, CharSequence grpName, CharSequence permList, boolean dangerous, Drawable icon)50 private static View getPermissionItemViewOld(Context context, LayoutInflater inflater, 51 CharSequence grpName, CharSequence permList, boolean dangerous, Drawable icon) { 52 View permView = inflater.inflate(R.layout.app_permission_item_old, null); 53 54 TextView permGrpView = permView.findViewById(R.id.permission_group); 55 TextView permDescView = permView.findViewById(R.id.permission_list); 56 57 ImageView imgView = (ImageView)permView.findViewById(R.id.perm_icon); 58 imgView.setImageDrawable(icon); 59 if(grpName != null) { 60 permGrpView.setText(grpName); 61 permDescView.setText(permList); 62 } else { 63 permGrpView.setText(permList); 64 permDescView.setVisibility(View.GONE); 65 } 66 return permView; 67 } 68 } 69