1/* 2 * Copyright (C) 2008 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 17package com.android.settings; 18 19import com.android.providers.subscribedfeeds.R; 20 21import android.content.Context; 22import android.graphics.drawable.Drawable; 23import android.preference.Preference; 24import android.view.View; 25import android.widget.ImageView; 26 27/** 28 * ProviderPreference is used to display an image to the left of a provider name. 29 * The preference ultimately calls AccountManager.addAccount() for the account type. 30 */ 31public class ProviderPreference extends Preference { 32 private Drawable mProviderIcon; 33 private ImageView mProviderIconView; 34 private CharSequence mProviderName; 35 private String mAccountType; 36 37 public ProviderPreference(Context context, String accountType, Drawable icon, CharSequence providerName) { 38 super(context); 39 mAccountType = accountType; 40 mProviderIcon = icon; 41 mProviderName = providerName; 42 setLayoutResource(R.layout.provider_preference); 43 setPersistent(false); 44 setTitle(mProviderName); 45 //setSummary(mProviderName); 46 } 47 48 @Override 49 protected void onBindView(View view) { 50 super.onBindView(view); 51 mProviderIconView = (ImageView) view.findViewById(R.id.providerIcon); 52 mProviderIconView.setImageDrawable(mProviderIcon); 53 setTitle(mProviderName); 54 //setSummary(mProviderName); 55 } 56 57 public String getAccountType() { 58 return mAccountType; 59 } 60} 61