Example usage for android.graphics Typeface DEFAULT

List of usage examples for android.graphics Typeface DEFAULT

Introduction

In this page you can find the example usage for android.graphics Typeface DEFAULT.

Prototype

Typeface DEFAULT

To view the source code for android.graphics Typeface DEFAULT.

Click Source Link

Document

The default NORMAL typeface object

Usage

From source file:com.jjoe64.graphview_demos.fragments.StartSensors.java

void loadDefaultSettingValues() {
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
        mDisplayType = Integer.valueOf(res);

        res = pref.getString("fontsize_list", Integer.toString(12));
        mTextFontSize = Integer.valueOf(res);

        res = pref.getString("typeface_list", Integer.toString(3));
        switch (Integer.valueOf(res)) {
        case 0://  w ww .  j  a  v a2s  .  c  o m
            mTextTypeface = Typeface.DEFAULT;
            break;
        case 1:
            mTextTypeface = Typeface.SANS_SERIF;
            break;
        case 2:
            mTextTypeface = Typeface.SERIF;
            break;
        case 3:
            mTextTypeface = Typeface.MONOSPACE;
            break;
        }
        //mTvSerial.setTypeface(mTextTypeface);
        //etWrite.setTypeface(mTextTypeface);

        res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mReadLinefeedCode = Integer.valueOf(res);

        res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mWriteLinefeedCode = Integer.valueOf(res);

        res = pref.getString("email_edittext", "@gmail.com");
        mEmailAddress = res;

        res = pref.getString("baudrate_list", Integer.toString(57600));
        mBaudrate = Integer.valueOf(res);

        res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
        mDataBits = Integer.valueOf(res);

        res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
        mParity = Integer.valueOf(res);

        res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
        mStopBits = Integer.valueOf(res);

        res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
        mFlowControl = Integer.valueOf(res);
    }

From source file:jp.ksksue.app.terminal.AndroidUSBSerialMonitorLite.java

void loadDefaultSettingValues() {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
    mDisplayType = Integer.valueOf(res);

    res = pref.getString("fontsize_list", Integer.toString(12));
    mTextFontSize = Integer.valueOf(res);

    res = pref.getString("typeface_list", Integer.toString(3));
    switch (Integer.valueOf(res)) {
    case 0:/*  w  w  w.  ja  v a 2s. c om*/
        mTextTypeface = Typeface.DEFAULT;
        break;
    case 1:
        mTextTypeface = Typeface.SANS_SERIF;
        break;
    case 2:
        mTextTypeface = Typeface.SERIF;
        break;
    case 3:
        mTextTypeface = Typeface.MONOSPACE;
        break;
    }
    mTvSerial.setTypeface(mTextTypeface);
    etWrite.setTypeface(mTextTypeface);

    res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
    mReadLinefeedCode = Integer.valueOf(res);

    res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
    mWriteLinefeedCode = Integer.valueOf(res);

    res = pref.getString("email_edittext", "@gmail.com");
    mEmailAddress = res;

    res = pref.getString("baudrate_list", Integer.toString(9600));
    mBaudrate = Integer.valueOf(res);

    res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
    mDataBits = Integer.valueOf(res);

    res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
    mParity = Integer.valueOf(res);

    res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
    mStopBits = Integer.valueOf(res);

    res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
    mFlowControl = Integer.valueOf(res);

    res = pref.getString("play_interval", "3");
    mPlayIntervalSeconds = Integer.valueOf(res);
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java

protected boolean setValueFromTheme(TypedArray remoteTypedArray, final int[] padding, final int localAttrId,
        final int remoteTypedArrayIndex) {
    try {/*from  w w  w.j av  a 2 s  . c o  m*/
        switch (localAttrId) {
        case android.R.attr.background:
            Drawable keyboardBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex);
            if (keyboardBackground == null)
                return false;
            CompatUtils.setViewBackgroundDrawable(this, keyboardBackground);
            break;
        case android.R.attr.paddingLeft:
            padding[0] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (padding[0] == -1)
                return false;
            break;
        case android.R.attr.paddingTop:
            padding[1] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (padding[1] == -1)
                return false;
            break;
        case android.R.attr.paddingRight:
            padding[2] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (padding[2] == -1)
                return false;
            break;
        case android.R.attr.paddingBottom:
            padding[3] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (padding[3] == -1)
                return false;
            break;
        case R.attr.keyBackground:
            mKeyBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex);
            if (mKeyBackground == null)
                return false;
            break;
        case R.attr.keyHysteresisDistance:
            mKeyHysteresisDistance = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1);
            if (mKeyHysteresisDistance == -1)
                return false;
            break;
        case R.attr.verticalCorrection:
            mOriginalVerticalCorrection = mVerticalCorrection = remoteTypedArray
                    .getDimensionPixelOffset(remoteTypedArrayIndex, -1);
            if (mOriginalVerticalCorrection == -1)
                return false;
            break;
        case R.attr.keyTextSize:
            mKeyTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (mKeyTextSize == -1)
                return false;
            // you might ask yourself "why did Menny sqrt root the factor?"
            // I'll tell you; the factor is mostly for the height, not the
            // font size,
            // but I also factorize the font size because I want the text to
            // be a little like
            // the key size.
            // the whole factor maybe too much, so I ease that a bit.
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mKeyTextSize = (float) (mKeyTextSize
                        * Math.sqrt(AnyApplication.getConfig().getKeysHeightFactorInLandscape()));
            else
                mKeyTextSize = (float) (mKeyTextSize
                        * Math.sqrt(AnyApplication.getConfig().getKeysHeightFactorInPortrait()));
            Logger.d(TAG, "AnySoftKeyboardTheme_keyTextSize " + mKeyTextSize);
            break;
        case R.attr.keyTextColor:
            mKeyTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex);
            if (mKeyTextColor == null) {
                mKeyTextColor = new ColorStateList(new int[][] { { 0 } },
                        new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) });
            }
            break;
        case R.attr.labelTextSize:
            mLabelTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (mLabelTextSize == -1)
                return false;
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape();
            else
                mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait();
            break;
        case R.attr.keyboardNameTextSize:
            mKeyboardNameTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (mKeyboardNameTextSize == -1)
                return false;
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mKeyboardNameTextSize = mKeyboardNameTextSize
                        * AnyApplication.getConfig().getKeysHeightFactorInLandscape();
            else
                mKeyboardNameTextSize = mKeyboardNameTextSize
                        * AnyApplication.getConfig().getKeysHeightFactorInPortrait();
            break;
        case R.attr.keyboardNameTextColor:
            mKeyboardNameTextColor = remoteTypedArray.getColor(remoteTypedArrayIndex, Color.WHITE);
            break;
        case R.attr.shadowColor:
            mShadowColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0);
            break;
        case R.attr.shadowRadius:
            mShadowRadius = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            break;
        case R.attr.shadowOffsetX:
            mShadowOffsetX = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            break;
        case R.attr.shadowOffsetY:
            mShadowOffsetY = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            break;
        case R.attr.backgroundDimAmount:
            mBackgroundDimAmount = remoteTypedArray.getFloat(remoteTypedArrayIndex, -1f);
            if (mBackgroundDimAmount == -1f)
                return false;
            break;
        case R.attr.keyPreviewBackground:
            Drawable keyPreviewBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex);
            if (keyPreviewBackground == null)
                return false;
            mPreviewPopupTheme.setPreviewKeyBackground(keyPreviewBackground);
            break;
        case R.attr.keyPreviewTextColor:
            mPreviewPopupTheme.setPreviewKeyTextColor(remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFF));
            break;
        case R.attr.keyPreviewTextSize:
            mPreviewPopupTheme
                    .setPreviewKeyTextSize(remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0));
            break;
        case R.attr.keyPreviewLabelTextSize:
            mPreviewPopupTheme
                    .setPreviewLabelTextSize(remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0));
            break;
        case R.attr.keyPreviewOffset:
            mPreviewPopupTheme
                    .setVerticalOffset(remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0));
            break;
        case R.attr.previewAnimationType:
            int previewAnimationType = remoteTypedArray.getInteger(remoteTypedArrayIndex, -1);
            if (previewAnimationType == -1)
                return false;
            mPreviewPopupTheme.setPreviewAnimationType(previewAnimationType);
            break;
        case R.attr.keyTextStyle:
            int textStyle = remoteTypedArray.getInt(remoteTypedArrayIndex, 0);
            switch (textStyle) {
            case 0:
                mKeyTextStyle = Typeface.DEFAULT;
                break;
            case 1:
                mKeyTextStyle = Typeface.DEFAULT_BOLD;
                break;
            case 2:
                mKeyTextStyle = Typeface.defaultFromStyle(Typeface.ITALIC);
                break;
            default:
                mKeyTextStyle = Typeface.defaultFromStyle(textStyle);
                break;
            }
            mPreviewPopupTheme.setKeyStyle(mKeyTextStyle);
            break;
        case R.attr.keyHorizontalGap:
            float themeHorizontalKeyGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1);
            if (themeHorizontalKeyGap == -1)
                return false;
            mKeyboardDimens.setHorizontalKeyGap(themeHorizontalKeyGap);
            break;
        case R.attr.keyVerticalGap:
            float themeVerticalRowGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1);
            if (themeVerticalRowGap == -1)
                return false;
            mKeyboardDimens.setVerticalRowGap(themeVerticalRowGap);
            break;
        case R.attr.keyNormalHeight:
            int themeNormalKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1);
            if (themeNormalKeyHeight == -1)
                return false;
            mKeyboardDimens.setNormalKeyHeight(themeNormalKeyHeight);
            break;
        case R.attr.keyLargeHeight:
            int themeLargeKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1);
            if (themeLargeKeyHeight == -1)
                return false;
            mKeyboardDimens.setLargeKeyHeight(themeLargeKeyHeight);
            break;
        case R.attr.keySmallHeight:
            int themeSmallKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1);
            if (themeSmallKeyHeight == -1)
                return false;
            mKeyboardDimens.setSmallKeyHeight(themeSmallKeyHeight);
            break;
        case R.attr.hintTextSize:
            mHintTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1);
            if (mHintTextSize == -1)
                return false;
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape();
            else
                mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait();
            break;
        case R.attr.hintTextColor:
            mHintTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex);
            if (mHintTextColor == null) {
                mHintTextColor = new ColorStateList(new int[][] { { 0 } },
                        new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) });
            }
            break;
        case R.attr.hintLabelVAlign:
            mHintLabelVAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.BOTTOM);
            break;
        case R.attr.hintLabelAlign:
            mHintLabelAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.RIGHT);
            break;
        case R.attr.hintOverflowLabel:
            mHintOverflowLabel = remoteTypedArray.getString(remoteTypedArrayIndex);
            break;
        }
        return true;
    } catch (Exception e) {
        // on API changes, so the incompatible themes wont crash me..
        e.printStackTrace();
        return false;
    }
}

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static Typeface getUserTypeface(final Context context, final String fontFamily,
        final Typeface defTypeface) {
    if (context == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return Typeface.DEFAULT;
    final int fontStyle = defTypeface != null ? defTypeface.getStyle() : Typeface.NORMAL;
    final Typeface tf = Typeface.create(fontFamily, fontStyle);
    if (tf != null)
        return tf;
    return Typeface.create(Typeface.DEFAULT, fontStyle);
}

From source file:usbong.android.retrocc.UsbongDecisionTreeEngineActivity.java

public void initTreeLoader() {
    setContentView(R.layout.tree_list_interface);

    isInTreeLoader = true;/*  w  w  w  .  j a va 2 s .co  m*/

    Button comicsButton = (Button) findViewById(R.id.comics_button);
    comicsButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            initTreeLoader(UsbongConstants.ITEMS_LIST_COMICS);
        }
    });

    Button toysButton = (Button) findViewById(R.id.toys_button);
    toysButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            initTreeLoader(UsbongConstants.ITEMS_LIST_TOYS);
        }
    });

    if (currCategory == UsbongConstants.ITEMS_LIST_COMICS) {
        comicsButton.setTypeface(Typeface.DEFAULT_BOLD);
        toysButton.setTypeface(Typeface.DEFAULT);
    } else {
        comicsButton.setTypeface(Typeface.DEFAULT);
        toysButton.setTypeface(Typeface.DEFAULT_BOLD);
    }

    resetContainers();//added by Mike, 20170213

    //      listOfTreesArrayList = UsbongUtils.getTreeArrayList(UsbongUtils.USBONG_TREES_FILE_PATH);
    listOfTreesArrayList = UsbongUtils
            .getItemArrayList(UsbongUtils.USBONG_TREES_FILE_PATH + currCategory + ".txt");

    mCustomAdapter = new CustomDataAdapter(this, R.layout.tree_loader, listOfTreesArrayList);
    mCustomAdapter.sort(); //edited by Mike, 20170203
    /*
          //Reference: http://stackoverflow.com/questions/8908549/sorting-of-listview-by-name-of-the-product-using-custom-adaptor;
          //last accessed: 2 Jan. 2014; answer by Alex Lockwood
          mCustomAdapter.sort(new Comparator<String>() {
              public int compare(String arg0, String arg1) {
      return arg0.compareTo(arg1);
              }
          });
    */
    treesListView = (ListView) findViewById(R.id.tree_list_view);
    treesListView.setLongClickable(true);
    treesListView.setAdapter(mCustomAdapter);

    String pleaseMakeSureThatXMLTreeExistsString = (String) getResources()
            .getText(R.string.pleaseMakeSureThatXMLTreeExistsString);
    String alertString = (String) getResources().getText(R.string.alertStringValueEnglish);

    if (listOfTreesArrayList.isEmpty()) {
        new AlertDialog.Builder(UsbongDecisionTreeEngineActivity.this).setTitle(alertString)
                .setMessage(pleaseMakeSureThatXMLTreeExistsString)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //UsbongDecisionTreeEngineActivity is already the Main Menu
                        /*
                                       finish();    
                                       Intent toUsbongMainActivityIntent = new Intent(UsbongDecisionTreeEngineActivity.this, UsbongMainActivity.class);
                                       toUsbongMainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
                                       startActivity(toUsbongMainActivityIntent);
                        */
                    }
                }).show();
    }
}

From source file:org.de.jmg.learn._MainActivity.java

public void getVokabel(final boolean showBeds, boolean LoadNext, boolean requestFocusEdWord, boolean DontPrompt)
        throws Exception {

    if (iv != null) {
        iv.setVisibility(View.GONE);
    }//from  w  ww .j a va2s.c  om
    if (iv2 != null)
        iv2.setVisibility(View.GONE);
    try {
        if (_btnRight == null)
            return;
        EndEdit(DontPrompt);
        setBtnsEnabled(true);
        if (showBeds && _vok.getIndex() >= 1) {
            _btnRight.setEnabled(true);
            _btnWrong.setEnabled(true);
            _btnEdit.setEnabled(true);
            _btnSkip.setEnabled(true);
            _btnView.setEnabled(true);
        } else {
            _btnRight.setEnabled(false);
            _btnWrong.setEnabled(false);
            if (_vok.getIndex() < 1) {
                _btnEdit.setEnabled(false);
                _btnSkip.setEnabled(false);
                _btnView.setEnabled(false);
            }
        }
        if (LoadNext)
            _vok.setLernIndex((short) (_vok.getLernIndex() + 1));

        View v;
        TextView t;
        String txtBed = getString(R.string.cloze);

        if (showBeds) {
            v = findViewById(R.id.txtMeaning1);
            t = (TextView) v;
            assert t != null;
            t.setText(lib.getSpanableString(_vok.getBedeutung1()));
            txtBed = t.getText().toString();
        }

        v = findViewById(R.id.word);
        t = (TextView) v;
        assert t != null;
        String txtWord = getString(R.string.cloze);
        if (!_vok.reverse || showBeds) {
            t.setText(lib.getSpanableString(_vok.getWort()), TextView.BufferType.SPANNABLE);
            txtWord = t.getText().toString();
            txtWord = replaceClozes(txtWord, txtBed);
            speak(txtWord, _vok.getLangWord(), "word", true);
        } else {
            t.setText("");
        }

        if (_vok.getSprache() == EnumSprachen.Hebrew || _vok.getSprache() == EnumSprachen.Griechisch
                || (_vok.getFontWort().getName().equalsIgnoreCase("Cardo"))) {
            t.setTypeface(_vok.TypefaceCardo);
            _txtedWord.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
            _txtedWord.setTypeface(Typeface.DEFAULT);
        }
        t.scrollTo(0, 0);

        v = findViewById(R.id.Comment);
        t = (TextView) v;
        assert t != null;
        t.setVisibility(View.VISIBLE);

        SpannableString tspanKom = lib.getSpanableString(_vok.getKommentar());
        URLSpan[] urlSpans = tspanKom.getSpans(0, tspanKom.length(), URLSpan.class);
        for (final URLSpan span : urlSpans) {
            int start = tspanKom.getSpanStart(span);
            int end = tspanKom.getSpanEnd(span);
            String txt = tspanKom.toString().substring(start, end);
            if (txtIsPicture(txt)) {
                tspanKom.removeSpan(span);
                tspanKom.setSpan(new urlclickablespan(span.getURL()) {
                    @Override
                    public void onClick(View widget) {
                        Bitmap b;
                        try {
                            b = lib.downloadpicture(this.url);
                        } catch (Exception ex) {
                            b = null;
                        }
                        if (b != null) {
                            if (iv == null) {
                                iv = new ImageView(context);
                                SetTouchListener(iv);
                            }
                            b = resizeBM(b);
                            iv.setImageBitmap(b);
                            if (iv.getParent() == null) {
                                try {
                                    LayoutParams p = _txtMeaning1.getLayoutParams();
                                    //p.width = LayoutParams.WRAP_CONTENT;
                                    //p.height = LayoutParams.WRAP_CONTENT;
                                    rellayoutMain.addView(iv, p);
                                } catch (Exception ex) {
                                    Log.e("addImageView", ex.getMessage(), ex);
                                }
                            } else {
                                Log.d("ImageView", "exists");
                            }
                            _txtMeaning1.setVisibility(View.GONE);
                            iv.setVisibility(View.VISIBLE);
                        }
                    }
                }, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        t.setText(tspanKom, TextView.BufferType.SPANNABLE);

        if (_vok.getSprache() == EnumSprachen.Hebrew || _vok.getSprache() == EnumSprachen.Griechisch
                || (_vok.getFontKom().getName().equalsIgnoreCase("Cardo"))) {
            t.setTypeface(_vok.TypefaceCardo);
            _txtedKom.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
            _txtedKom.setTypeface(Typeface.DEFAULT);
        }
        if (_isSmallDevice && libString.IsNullOrEmpty(t.getText().toString())) {
            t.setVisibility(View.GONE);
        } else {
            t.setVisibility(View.VISIBLE);
        }
        t.scrollTo(0, 0);

        v = findViewById(R.id.txtMeaning1);
        t = (TextView) v;
        assert t != null;
        if (!libString.IsNullOrEmpty(_vok.getBedeutung2())) {
            t.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        }
        if (_vok.reverse || showBeds) {
            SpannableString tspan = lib.getSpanableString(_vok.getBedeutung1());
            //final String picname = _main.getString(R.string.picture);
            t.setVisibility(View.VISIBLE);
            if (txtIsPicture(tspan.toString())) {
                URLSpan urlspn[] = tspan.getSpans(0, tspan.length(), URLSpan.class);
                for (URLSpan url : urlspn) {
                    Bitmap b;
                    try {
                        b = lib.downloadpicture(url.getURL());
                    } catch (Exception ex) {
                        b = null;
                    }
                    if (b != null) {
                        if (iv == null) {
                            iv = new ImageView(context);
                            SetTouchListener(iv);
                        }
                        b = resizeBM(b);
                        iv.setImageBitmap(b);
                        if (iv.getParent() == null) {
                            try {
                                LayoutParams p = t.getLayoutParams();
                                //p.width = LayoutParams.WRAP_CONTENT;
                                //p.height = LayoutParams.WRAP_CONTENT;
                                rellayoutMain.addView(iv, p);
                            } catch (Exception ex) {
                                Log.e("Imagview", ex.getMessage(), ex);
                            }
                        } else {
                            Log.d("ImageView", "exists");
                        }
                        t.setVisibility(View.GONE);
                        iv.setVisibility(View.VISIBLE);
                    }
                }

            } else {
                // iv.setVisibility(View.GONE);
                t.setVisibility(View.VISIBLE);
            }

            t.setText(tspan);
        } else {
            t.setText(Vokabel.getComment(_vok.getBedeutung1()));
        }
        if (_vok.reverse || showBeds) {
            String txt = t.getText().toString();
            txt = replaceClozes(txt, txtWord);
            speak(txt, _vok.getLangMeaning(), "meaning1", _vok.reverse);
        }
        if (_vok.getFontBed().getName().equalsIgnoreCase("Cardo")) {
            t.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
        }
        t.setOnFocusChangeListener(FocusListenerMeaning1);
        t.scrollTo(0, 0);

        v = findViewById(R.id.txtMeaning2);
        t = (TextView) v;
        assert t != null;
        t.setText((_vok.reverse || showBeds ? _vok.getBedeutung2() : Vokabel.getComment(_vok.getBedeutung2())));
        if (_vok.getFontBed().getName().equalsIgnoreCase("Cardo")) {
            t.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
        }
        if (libString.IsNullOrEmpty(_vok.getBedeutung2()) || _vok.getCardMode()) {
            t.setVisibility(View.GONE);
            _txtMeaning1.setImeOptions(EditorInfo.IME_ACTION_DONE);
        } else {
            t.setVisibility(View.VISIBLE);
            _txtMeaning1.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            if (_vok.reverse || showBeds) {
                String txt = t.getText().toString();
                //if (txtWord != null)
                //   txt = txt.replaceAll("_{2,}", txtWord).replaceAll("\\.{4,}", txtWord);
                speak(txt, _vok.getLangMeaning(), "meaning2");
            }
        }

        v = findViewById(R.id.txtMeaning3);
        t = (TextView) v;
        assert t != null;
        t.setText((_vok.reverse || showBeds ? _vok.getBedeutung3() : Vokabel.getComment(_vok.getBedeutung3())));
        if (_vok.getFontBed().getName().equalsIgnoreCase("Cardo")) {
            t.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
        }
        if (libString.IsNullOrEmpty(_vok.getBedeutung3()) || _vok.getCardMode()) {
            t.setVisibility(View.GONE);
            _txtMeaning2.setImeOptions(EditorInfo.IME_ACTION_DONE);
        } else {
            t.setVisibility(View.VISIBLE);
            _txtMeaning2.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            _txtMeaning3.setImeOptions(EditorInfo.IME_ACTION_DONE);
            if (_vok.reverse || showBeds) {
                String txt = t.getText().toString();
                //if (txtWord != null)
                //   txt = txt.replaceAll("_{2,}", txtWord).replaceAll("\\.{4,}", txtWord);
                speak(txt, _vok.getLangMeaning(), "meaning3");
            }
        }

        if (_vok.reverse && showBeds)
            speak(txtWord, _vok.getLangWord(), "word");

        lib.setBgEditText(_txtMeaning1, _MeaningBG);
        lib.setBgEditText(_txtMeaning2, _MeaningBG);
        lib.setBgEditText(_txtMeaning3, _MeaningBG);
        if (!_isSmallDevice && !requestFocusEdWord) {
            _txtMeaning1.requestFocus();
        } else {
            if (!requestFocusEdWord)
                _txtWord.requestFocus();
            else
                _txtedWord.requestFocus();
        }
        SetActionBarTitle();

        _scrollView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {

                lib.removeLayoutListener(_scrollView.getViewTreeObserver(), this);
                hideKeyboard();
                if (showBeds) {
                    _scrollView.scrollTo(0, _txtMeaning1.getTop());
                } else {
                    _txtWord.requestFocus();
                    _scrollView.fullScroll(View.FOCUS_UP);
                }
            }
        });

    } catch (Exception e) {

        lib.ShowException(_main, e);
    }

}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Typeface getUserTypeface(final Context context, final Typeface defTypeface) {
    if (context == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return Typeface.DEFAULT;
    final int fontStyle = defTypeface != null ? defTypeface.getStyle() : Typeface.NORMAL;
    final String fontFamily = getThemeFontFamily(context);
    final Typeface tf = Typeface.create(fontFamily, fontStyle);
    if (tf != null)
        return tf;
    return Typeface.create(Typeface.DEFAULT, fontStyle);
}

From source file:sharedcode.turboeditor.activity.MainActivity.java

public void onEvent(EventBusEvents.APreferenceValueWasChanged event) {

    if (event.hasType(EventBusEvents.APreferenceValueWasChanged.Type.THEME_CHANGE)) {
        ThemeUtils.setWindowsBackground(this);
    }/*from   ww w  .  ja  v a  2s.  c om*/

    if (event.hasType(WRAP_CONTENT)) {
        if (PreferenceHelper.getWrapContent(this)) {
            horizontalScroll.removeView(mEditor);
            verticalScroll.removeView(horizontalScroll);
            verticalScroll.addView(mEditor);
        } else {
            verticalScroll.removeView(mEditor);
            verticalScroll.addView(horizontalScroll);
            horizontalScroll.addView(mEditor);
        }
    } else if (event.hasType(LINE_NUMERS)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(null, true);
        mEditor.enableTextChangedListener();
        if (PreferenceHelper.getLineNumbers(this)) {
            mEditor.setPadding(
                    EditTextPadding.getPaddingWithLineNumbers(this, PreferenceHelper.getFontSize(this)),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        } else {
            mEditor.setPadding(EditTextPadding.getPaddingWithoutLineNumbers(this),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        }
    } else if (event.hasType(SYNTAX)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(null, true);
        mEditor.enableTextChangedListener();
    } else if (event.hasType(MONOSPACE)) {
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (event.hasType(THEME_CHANGE)) {
        if (PreferenceHelper.getLightTheme(this)) {
            mEditor.setTextColor(getResources().getColor(R.color.textColorInverted));
        } else {
            mEditor.setTextColor(getResources().getColor(R.color.textColor));
        }
    } else if (event.hasType(TEXT_SUGGESTIONS) || event.hasType(READ_ONLY)) {
        if (PreferenceHelper.getReadOnly(this)) {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
            mEditor.setReadOnly(true);
        } else {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
            mEditor.setReadOnly(false);
            if (PreferenceHelper.getSuggestionActive(this)) {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            } else {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                        | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            }
        }
        // sometimes it becomes monospace after setting the input type
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (event.hasType(FONT_SIZE)) {
        if (PreferenceHelper.getLineNumbers(this)) {
            mEditor.setPadding(
                    EditTextPadding.getPaddingWithLineNumbers(this, PreferenceHelper.getFontSize(this)),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        } else {
            mEditor.setPadding(EditTextPadding.getPaddingWithoutLineNumbers(this),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        }
        mEditor.setTextSize(PreferenceHelper.getFontSize(this));
    } else if (event.hasType(ENCODING)) {
        String oldEncoding, newEncoding;
        oldEncoding = currentEncoding;
        newEncoding = PreferenceHelper.getEncoding(this);
        try {
            final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
            mEditor.disableTextChangedListener();
            mEditor.replaceTextKeepCursor(new String(oldText, newEncoding), true);
            mEditor.enableTextChangedListener();
            currentEncoding = newEncoding;
        } catch (UnsupportedEncodingException ignored) {
            try {
                final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
                mEditor.disableTextChangedListener();
                mEditor.replaceTextKeepCursor(new String(oldText, "UTF-8"), true);
                mEditor.enableTextChangedListener();
            } catch (UnsupportedEncodingException ignored2) {
            }
        }
    }
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

public boolean setValueFromTheme(TypedArray remoteTypedArray, final int[] padding, final int localAttrId,
        final int remoteTypedArrayIndex) {
    try {/* w ww  . j a v  a  2  s  .  com*/

        if (localAttrId == android.R.attr.background) {
            Drawable keyboardBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex);
            Log.d(TAG, "AnySoftKeyboardTheme_android_background " + (keyboardBackground != null));
            super.setBackgroundDrawable(keyboardBackground);
        } else if (localAttrId == android.R.attr.paddingLeft) {
            padding[0] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_android_paddingLeft " + padding[0]);
        } else if (localAttrId == android.R.attr.paddingTop) {
            padding[1] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_android_paddingTop " + padding[1]);
        } else if (localAttrId == android.R.attr.paddingRight) {
            padding[2] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_android_paddingRight " + padding[2]);
        } else if (localAttrId == android.R.attr.paddingBottom) {
            padding[3] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_android_paddingBottom " + padding[3]);
        } else if (localAttrId == R.attr.keyBackground) {
            mKeyBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex);
            Log.d(TAG, "AnySoftKeyboardTheme_keyBackground " + (mKeyBackground != null));
        } else if (localAttrId == R.attr.keyHysteresisDistance) {
            mKeyHysteresisDistance = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_keyHysteresisDistance " + mKeyHysteresisDistance);
        } else if (localAttrId == R.attr.verticalCorrection) {
            mVerticalCorrection = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_verticalCorrection " + mVerticalCorrection);
        } else if (localAttrId == R.attr.keyPreviewBackground) {
            mPreviewKeyBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex);
            Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewBackground " + (mPreviewKeyBackground != null));
        } else if (localAttrId == R.attr.keyPreviewTextColor) {
            mPreviewKeyTextColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFF);
            Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewTextColor " + mPreviewKeyTextColor);
        } else if (localAttrId == R.attr.keyPreviewTextSize) {
            mPreviewKeyTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewTextSize " + mPreviewKeyTextSize);
        } else if (localAttrId == R.attr.keyPreviewLabelTextSize) {
            mPreviewLabelTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewLabelTextSize " + mPreviewLabelTextSize);
        } else if (localAttrId == R.attr.keyPreviewOffset) {
            mPreviewOffset = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewOffset " + mPreviewOffset);
        } else if (localAttrId == R.attr.keyTextSize) {
            mKeyTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 18);
            // you might ask yourself "why did Menny sqrt root the factor?"
            // I'll tell you; the factor is mostly for the height, not the
            // font size,
            // but I also factorize the font size because I want the text to
            // be a little like
            // the key size.
            // the whole factor maybe too much, so I ease that a bit.
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mKeyTextSize = mKeyTextSize
                        * FloatMath.sqrt(AnyApplication.getConfig().getKeysHeightFactorInLandscape());
            else
                mKeyTextSize = mKeyTextSize
                        * FloatMath.sqrt(AnyApplication.getConfig().getKeysHeightFactorInPortrait());
            Log.d(TAG, "AnySoftKeyboardTheme_keyTextSize " + mKeyTextSize);
        } else if (localAttrId == R.attr.keyTextColor) {
            mKeyTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex);
            if (mKeyTextColor == null) {
                Log.d(TAG, "Creating an empty ColorStateList for mKeyTextColor");
                mKeyTextColor = new ColorStateList(new int[][] { { 0 } },
                        new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) });
            }
            Log.d(TAG, "AnySoftKeyboardTheme_keyTextColor " + mKeyTextColor);
        } else if (localAttrId == R.attr.labelTextSize) {
            mLabelTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 14);
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape();
            else
                mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait();
            Log.d(TAG, "AnySoftKeyboardTheme_labelTextSize " + mLabelTextSize);
        } else if (localAttrId == R.attr.keyboardNameTextSize) {
            mKeyboardNameTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 10);
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mKeyboardNameTextSize = mKeyboardNameTextSize
                        * AnyApplication.getConfig().getKeysHeightFactorInLandscape();
            else
                mKeyboardNameTextSize = mKeyboardNameTextSize
                        * AnyApplication.getConfig().getKeysHeightFactorInPortrait();
            Log.d(TAG, "AnySoftKeyboardTheme_keyboardNameTextSize " + mKeyboardNameTextSize);
        } else if (localAttrId == R.attr.keyboardNameTextColor) {
            mKeyboardNameTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex);
            if (mKeyboardNameTextColor == null) {
                Log.d(TAG, "Creating an empty ColorStateList for mKeyboardNameTextColor");
                mKeyboardNameTextColor = new ColorStateList(new int[][] { { 0 } },
                        new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFAAAAAA) });
            }
            Log.d(TAG, "AnySoftKeyboardTheme_keyboardNameTextColor " + mKeyboardNameTextColor);
        } else if (localAttrId == R.attr.shadowColor) {
            mShadowColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_shadowColor " + mShadowColor);
        } else if (localAttrId == R.attr.shadowRadius) {
            mShadowRadius = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_shadowRadius " + mShadowRadius);
        } else if (localAttrId == R.attr.shadowOffsetX) {
            mShadowOffsetX = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_shadowOffsetX " + mShadowOffsetX);
        } else if (localAttrId == R.attr.shadowOffsetY) {
            mShadowOffsetY = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_shadowOffsetY " + mShadowOffsetY);
        } else if (localAttrId == R.attr.backgroundDimAmount) {
            mBackgroundDimAmount = remoteTypedArray.getFloat(remoteTypedArrayIndex, 0.5f);
            Log.d(TAG, "AnySoftKeyboardTheme_backgroundDimAmount " + mBackgroundDimAmount);
        } else if (localAttrId == R.attr.keyTextStyle) {
            int textStyle = remoteTypedArray.getInt(remoteTypedArrayIndex, 0);
            switch (textStyle) {
            case 0:
                mKeyTextStyle = Typeface.DEFAULT;
                break;
            case 1:
                mKeyTextStyle = Typeface.DEFAULT_BOLD;
                break;
            case 2:
                mKeyTextStyle = Typeface.defaultFromStyle(Typeface.ITALIC);
                break;
            default:
                mKeyTextStyle = Typeface.defaultFromStyle(textStyle);
                break;
            }
            Log.d(TAG, "AnySoftKeyboardTheme_keyTextStyle " + mKeyTextStyle);
        } else if (localAttrId == R.attr.symbolColorScheme) {
            mSymbolColorScheme = remoteTypedArray.getInt(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_symbolColorScheme " + mSymbolColorScheme);
        } else if (localAttrId == R.attr.keyHorizontalGap) {
            float themeHorizotalKeyGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            mKeyboardDimens.setHorizontalKeyGap(themeHorizotalKeyGap);
            Log.d(TAG, "AnySoftKeyboardTheme_keyHorizontalGap " + themeHorizotalKeyGap);
        } else if (localAttrId == R.attr.keyVerticalGap) {
            float themeVerticalRowGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            mKeyboardDimens.setVerticalRowGap(themeVerticalRowGap);
            Log.d(TAG, "AnySoftKeyboardTheme_keyVerticalGap " + themeVerticalRowGap);
        } else if (localAttrId == R.attr.keyNormalHeight) {
            float themeNormalKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            mKeyboardDimens.setNormalKeyHeight(themeNormalKeyHeight);
            Log.d(TAG, "AnySoftKeyboardTheme_keyNormalHeight " + themeNormalKeyHeight);
        } else if (localAttrId == R.attr.keyLargeHeight) {
            float themeLargeKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            mKeyboardDimens.setLargeKeyHeight(themeLargeKeyHeight);
            Log.d(TAG, "AnySoftKeyboardTheme_keyLargeHeight " + themeLargeKeyHeight);
        } else if (localAttrId == R.attr.keySmallHeight) {
            float themeSmallKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0);
            mKeyboardDimens.setSmallKeyHeight(themeSmallKeyHeight);
            Log.d(TAG, "AnySoftKeyboardTheme_keySmallHeight " + themeSmallKeyHeight);
        } else if (localAttrId == R.attr.hintTextSize) {
            mHintTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0);
            Log.d(TAG, "AnySoftKeyboardTheme_hintTextSize " + mHintTextSize);
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape();
            else
                mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait();
            Log.d(TAG, "AnySoftKeyboardTheme_hintTextSize with factor " + mHintTextSize);
        } else if (localAttrId == R.attr.hintTextColor) {
            mHintTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex);
            if (mHintTextColor == null) {
                Log.d(TAG, "Creating an empty ColorStateList for mHintTextColor");
                mHintTextColor = new ColorStateList(new int[][] { { 0 } },
                        new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) });
            }
            Log.d(TAG, "AnySoftKeyboardTheme_hintTextColor " + mHintTextColor);
        } else if (localAttrId == R.attr.hintLabelVAlign) {
            mHintLabelVAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.BOTTOM);
            Log.d(TAG, "AnySoftKeyboardTheme_hintLabelVAlign " + mHintLabelVAlign);
        } else if (localAttrId == R.attr.hintLabelAlign) {
            mHintLabelAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.RIGHT);
            Log.d(TAG, "AnySoftKeyboardTheme_hintLabelAlign " + mHintLabelAlign);
        } else if (localAttrId == R.attr.hintOverflowLabel) {
            mHintOverflowLabel = remoteTypedArray.getString(remoteTypedArrayIndex);
            Log.d(TAG, "AnySoftKeyboardTheme_hintOverflowLabel " + mHintOverflowLabel);
        }

        return true;
    } catch (Exception e) {
        // on API changes, so the incompatible themes wont crash me..
        e.printStackTrace();
        return false;
    }
}

From source file:com.free.searcher.MainFragment.java

private void initFind() {
    container = (RelativeLayout) activity.findViewById(R.id.layoutId);
    findBox = (EditText) container.findViewById(R.id.findBox);
    findBox.setText(currentSearching);//ww  w . ja  v  a2 s .c  om
    findBox.setTypeface(Typeface.DEFAULT, Typeface.BOLD);

    findBox.setOnKeyListener(new OnKeyListener() {
        @SuppressWarnings("deprecation")
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            Log.d("onKey", "keyCode=" + keyCode + ",event=" + event + ",v=" + v);
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && ((keyCode == KeyEvent.KEYCODE_ENTER))) {
                webView.findAllAsync(findBox.getText().toString());
            }
            return false;
        }
    });

    //      findBox.setOnFocusChangeListener(new OnFocusChangeListener() {
    //            @Override
    //            public void onFocusChange(View p1, boolean p2) {
    //               webView.findAllAsync(findBox.getText().toString());
    //            }
    //         });

    findRet = (TextView) container.findViewById(R.id.findRet);

    backButton = (Button) container.findViewById(R.id.backButton);
    backButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    backButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (findBox.isFocused()) {
                webView.findAllAsync(findBox.getText().toString());
            }
            webView.requestFocus();
            webView.findNext(false);
        }
    });

    nextButton = (Button) container.findViewById(R.id.nextButton);
    nextButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    nextButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (findBox.isFocused()) {
                webView.findAllAsync(findBox.getText().toString());
            }
            webView.requestFocus();
            webView.findNext(true);
        }
    });

    clearButton = (Button) container.findViewById(R.id.clearButton);
    clearButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    clearButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            findBox.setText("");
            webView.findAllAsync(findBox.getText().toString());
            findBox.requestFocus();
        }
    });

    closeButton = (Button) container.findViewById(R.id.closeButton);
    closeButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    closeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showFind = false;
            container.setVisibility(View.INVISIBLE);
        }
    });

    webView.findAllAsync(findBox.getText().toString());
    webView.setFindListener(new WebView.FindListener() {
        @Override
        public void onFindResultReceived(int p1, int p2, boolean p3) {
            findRet.setText((p1 + (p2 > 0 ? 1 : 0)) + "/" + p2);
        }
    });
    if (showFind) {
        container.setVisibility(View.VISIBLE);
    } else {
        container.setVisibility(View.INVISIBLE);
    }
}