FileDocCategorySizeDatePackage
ShortcutPreference.javaAPI DocAndroid 1.5 API5110Wed May 06 22:42:48 BST 2009com.android.settings.quicklaunch

ShortcutPreference

public class ShortcutPreference extends android.preference.Preference implements Comparable
Preference type for a shortcut in {@link QuickLaunchSettings}.

Fields Summary
private static Object
sStaticVarsLock
private static String
STRING_ASSIGN_APPLICATION
private static String
STRING_NO_SHORTCUT
private static int
sDimAlpha
private static android.content.res.ColorStateList
sRegularTitleColor
private static android.content.res.ColorStateList
sDimTitleColor
private static android.content.res.ColorStateList
sRegularSummaryColor
private static android.content.res.ColorStateList
sDimSummaryColor
private char
mShortcut
private boolean
mHasBookmark
Constructors Summary
public ShortcutPreference(android.content.Context context, char shortcut)

    
         
        super(context);

        synchronized (sStaticVarsLock) {
            // Init statics. This should only happen for the first ShortcutPreference created,
            // the rest will already have them initialized.
            if (STRING_ASSIGN_APPLICATION == null) {
                STRING_ASSIGN_APPLICATION = context.getString(R.string.quick_launch_assign_application);
                STRING_NO_SHORTCUT = context.getString(R.string.quick_launch_no_shortcut);
    
                TypedValue outValue = new TypedValue();
                context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true);
                sDimAlpha = (int) (outValue.getFloat() * 255);
            }
        }
        
        mShortcut = shortcut;

        setWidgetLayoutResource(R.layout.preference_widget_shortcut);
    
Methods Summary
public intcompareTo(android.preference.Preference another)

        if (!(another instanceof ShortcutPreference)) return super.compareTo(another);

        // Letters before digits
        char other = ((ShortcutPreference) another).mShortcut;
        if (Character.isDigit(mShortcut) && Character.isLetter(other)) return 1;
        else if (Character.isDigit(other) && Character.isLetter(mShortcut)) return -1;
        else return mShortcut - other;
    
public chargetShortcut()

        return mShortcut;
    
public java.lang.CharSequencegetSummary()

        return mHasBookmark ? super.getSummary() : STRING_NO_SHORTCUT;
    
public java.lang.CharSequencegetTitle()

        return mHasBookmark ? super.getTitle() : STRING_ASSIGN_APPLICATION;
    
public booleanhasBookmark()

        return mHasBookmark;
    
protected voidonBindView(android.view.View view)

        super.onBindView(view);
        
        TextView shortcutView = (TextView) view.findViewById(R.id.shortcut);
        if (shortcutView != null) {
            shortcutView.setText(String.valueOf(mShortcut));
        }
    
        TextView titleView = (TextView) view.findViewById(android.R.id.title);

        synchronized (sStaticVarsLock) {
            if (sRegularTitleColor == null) {
                sRegularTitleColor = titleView.getTextColors();
                sDimTitleColor = sRegularTitleColor.withAlpha(sDimAlpha);
            }
        }
        
        ColorStateList color = mHasBookmark ? sRegularTitleColor : sDimTitleColor;
        if (color != null) {
            titleView.setTextColor(color);
        }
        
        TextView summaryView = (TextView) view.findViewById(android.R.id.summary);

        synchronized (sStaticVarsLock) {
            if (sRegularSummaryColor == null) {
                sRegularSummaryColor = summaryView.getTextColors();
                sDimSummaryColor = sRegularSummaryColor.withAlpha(sDimAlpha);
            }
        }
        
        color = mHasBookmark ? sRegularSummaryColor : sDimSummaryColor;
        if (color != null) {
            summaryView.setTextColor(color);
        }
        
    
public voidsetHasBookmark(boolean hasBookmark)

        if (hasBookmark != mHasBookmark) {
            mHasBookmark = hasBookmark;
            notifyChanged();
        }
    
public voidsetShortcut(char shortcut)

        if (shortcut != mShortcut) {
            mShortcut = shortcut;
            notifyChanged();
        }