Android Open Source - whoisit-android Capitalized Text View






From Project

Back to project page whoisit-android.

License

The source code is released under:

MIT License

If you think the Android project whoisit-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mitchbarry.android.whoisit.ui.view;
//from  www . j a v a  2 s.  co m
import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.Button;

import com.mitchbarry.android.whoisit.util.Strings;

import java.util.Locale;

/**
 * A button who's text is always uppercase which uses the roboto font.
 * Inspired by {@link com.actionbarsherlock.internal.widget.CapitalizingTextView}
 */
public class CapitalizedTextView extends Button {

    private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH;
    private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;

    public CapitalizedTextView(Context context) {
        super( context );
        if (!isInEditMode())
            setTF( context );
    }

    public CapitalizedTextView(Context context, AttributeSet attrs) {
        super( context, attrs );
        if (!isInEditMode())
            setTF(context);
    }

    public CapitalizedTextView(Context context, AttributeSet attrs, int defStyle) {
        super( context, attrs, defStyle );
        if (!isInEditMode())
            setTF(context);

    }

    @Override
    public void setText(CharSequence text, BufferType type) {
        if (IS_GINGERBREAD) {
            try {
                super.setText(text.toString().toUpperCase(Locale.ROOT), type);
            } catch (NoSuchFieldError e) {
                //Some manufacturer broke Locale.ROOT. See #572.
                super.setText(text.toString().toUpperCase(), type);
            }
        } else {
            super.setText(text.toString().toUpperCase(), type);
        }
    }

    private void setTF(Context context) {
        setTypeface( Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Regular.ttf") );
    }

}




Java Source Code List

com.mitchbarry.android.whoisit.AndroidModule.java
com.mitchbarry.android.whoisit.Injector.java
com.mitchbarry.android.whoisit.RootModule.java
com.mitchbarry.android.whoisit.WhoIsItApplication.java
com.mitchbarry.android.whoisit.WhoIsItModule.java
com.mitchbarry.android.whoisit.core.Constants.java
com.mitchbarry.android.whoisit.core.PhoneCallListener.java
com.mitchbarry.android.whoisit.core.PhoneCallReceiver.java
com.mitchbarry.android.whoisit.core.PhoneGroup.java
com.mitchbarry.android.whoisit.core.PhoneMatch.java
com.mitchbarry.android.whoisit.core.SMSReceiver.java
com.mitchbarry.android.whoisit.core.WhoIsItMatcher.java
com.mitchbarry.android.whoisit.db.DatabaseHelper.java
com.mitchbarry.android.whoisit.db.DatabaseManager.java
com.mitchbarry.android.whoisit.ui.AboutActivity.java
com.mitchbarry.android.whoisit.ui.AsyncLoader.java
com.mitchbarry.android.whoisit.ui.BootstrapActivity.java
com.mitchbarry.android.whoisit.ui.BootstrapFragmentActivity.java
com.mitchbarry.android.whoisit.ui.BootstrapPagerAdapter.java
com.mitchbarry.android.whoisit.ui.CarouselActivity.java
com.mitchbarry.android.whoisit.ui.HeaderFooterListAdapter.java
com.mitchbarry.android.whoisit.ui.ItemListFragment.java
com.mitchbarry.android.whoisit.ui.PhoneGroupActivity.java
com.mitchbarry.android.whoisit.ui.PhoneGroupListAdapter.java
com.mitchbarry.android.whoisit.ui.PhoneGroupListFragment.java
com.mitchbarry.android.whoisit.ui.PhoneMatchListAdapter.java
com.mitchbarry.android.whoisit.ui.PhoneMatchListFragment.java
com.mitchbarry.android.whoisit.ui.ThrowableLoader.java
com.mitchbarry.android.whoisit.ui.view.CapitalizedTextView.java
com.mitchbarry.android.whoisit.util.Ln.java
com.mitchbarry.android.whoisit.util.SafeAsyncTask.java
com.mitchbarry.android.whoisit.util.Strings.java