1703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan/* 2703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * Copyright (C) 2011 The Android Open Source Project 3703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * 4703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * Licensed under the Apache License, Version 2.0 (the "License"); 5703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * you may not use this file except in compliance with the License. 6703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * You may obtain a copy of the License at 7703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * 8703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * http://www.apache.org/licenses/LICENSE-2.0 9703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * 10703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * Unless required by applicable law or agreed to in writing, software 11703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * distributed under the License is distributed on an "AS IS" BASIS, 12703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * See the License for the specific language governing permissions and 14703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan * limitations under the License. 15703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan */ 16703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan 17703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuanpackage com.android.contacts.group; 18703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan 19703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuanimport android.content.Context; 20703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuanimport android.view.LayoutInflater; 21703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuanimport android.view.View; 22703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuanimport android.widget.ImageView; 23d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmannimport android.widget.TextView; 24703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan 25e0b2f1e2d01d1ac52ba207dc7ce76971d853298eChiao Chengimport com.android.contacts.R; 260d5588da244d0992c3ff8f25d0875fdf95a8c644Chiao Chengimport com.android.contacts.common.model.AccountTypeManager; 27428f008513d1591cc08fcfe2cf0c9237fb313241Chiao Chengimport com.android.contacts.common.model.account.AccountType; 28e0b2f1e2d01d1ac52ba207dc7ce76971d853298eChiao Cheng 29703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuanpublic class GroupDetailDisplayUtils { 30703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan 31703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan private GroupDetailDisplayUtils() { 32703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan // Disallow explicit creation of this class. 33703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan } 34703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan 35703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan public static View getNewGroupSourceView(Context context) { 36703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan LayoutInflater inflater = (LayoutInflater)context.getSystemService( 37703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan Context.LAYOUT_INFLATER_SERVICE); 38703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan return inflater.inflate(R.layout.group_source_button, null); 39703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan } 40703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan 412b3f3c54d3beb017b2f59f19e9ce0ecc3e039dbcDave Santoro public static void bindGroupSourceView(Context context, View view, String accountTypeString, 422b3f3c54d3beb017b2f59f19e9ce0ecc3e039dbcDave Santoro String dataSet) { 43d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(context); 44d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann AccountType accountType = accountTypeManager.getAccountType(accountTypeString, dataSet); 45d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann 46d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann TextView label = (TextView) view.findViewById(android.R.id.title); 47d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann if (label == null) { 48d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann throw new IllegalStateException("Group source view must contain a TextView with id" 49d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann + "android.R.id.label"); 50d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann } 51d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann label.setText(accountType.getViewGroupLabel(context)); 52d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann 53703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan ImageView accountIcon = (ImageView) view.findViewById(android.R.id.icon); 54703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan if (accountIcon == null) { 55d7dfdee089842b5c8cf65f9d4251fb428ad79aa2Daniel Lehmann throw new IllegalStateException("Group source view must contain an ImageView with id" 56703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan + "android.R.id.icon"); 57703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan } 58703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan accountIcon.setImageDrawable(accountType.getDisplayIcon(context)); 59703cda7119b710446f7abc38843043b7cbbf3a47Katherine Kuan } 60e0b2f1e2d01d1ac52ba207dc7ce76971d853298eChiao Cheng} 61