Example usage for android.graphics Typeface SERIF

List of usage examples for android.graphics Typeface SERIF

Introduction

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

Prototype

Typeface SERIF

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

Click Source Link

Document

The NORMAL style of the default serif typeface.

Usage

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

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_WORD_LIST_ACTIVITY) {
            if (resultCode == getActivity().RESULT_OK) {
                try {
                    String strWord = data.getStringExtra("word");
                    //etWrite.setText(strWord);
                    // Set a cursor position last
                    //etWrite.setSelection(etWrite.getText().length());
                } catch (Exception e) {
                    Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
                }//from  w w  w.java 2  s  .  c o m
            }
        } else if (requestCode == REQUEST_PREFERENCE) {

            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);
            //mTvSerial.setTextSize(mTextFontSize);

            res = pref.getString("typeface_list", Integer.toString(3));
            switch (Integer.valueOf(res)) {
            case 0:
                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;

            int intRes;

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

                mBaudrate = intRes;
                mSerial.setBaudrate(mBaudrate);
            }

            res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
            intRes = Integer.valueOf(res);
            if (mDataBits != intRes) {
                mDataBits = Integer.valueOf(res);
                mSerial.setDataBits(mDataBits);
            }

            res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
            intRes = Integer.valueOf(res);
            if (mParity != intRes) {
                mParity = intRes;
                mSerial.setParity(mParity);
            }

            res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
            intRes = Integer.valueOf(res);
            if (mStopBits != intRes) {
                mStopBits = intRes;
                mSerial.setStopBits(mStopBits);
            }

            res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
            intRes = Integer.valueOf(res);
            if (mFlowControl != intRes) {
                mFlowControl = intRes;
                if (mFlowControl == UartConfig.FLOW_CONTROL_ON) {
                    mSerial.setDtrRts(true, true);
                } else {
                    mSerial.setDtrRts(false, false);
                }
            }

            /*
            res = pref.getString("break_list", Integer.toString(FTDriver.FTDI_SET_NOBREAK));
            intRes = Integer.valueOf(res) << 14;
            if (mBreak != intRes) {
            mBreak = intRes;
            mSerial.setSerialPropertyBreak(mBreak, FTDriver.CH_A);
            mSerial.setSerialPropertyToChip(FTDriver.CH_A);
            }
            */
        }
    }

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

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_WORD_LIST_ACTIVITY) {
            if (resultCode == getActivity().RESULT_OK) {
                try {
                    String strWord = data.getStringExtra("word");
                    //etWrite.setText(strWord);
                    // Set a cursor position last
                    //etWrite.setSelection(etWrite.getText().length());
                } catch (Exception e) {
                    Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
                }/*from   w  w w .jav  a 2 s.c o  m*/
            }
        } else if (requestCode == REQUEST_PREFERENCE) {

            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);
            mTvSerial.setTextSize(mTextFontSize);

            res = pref.getString("typeface_list", Integer.toString(3));
            switch (Integer.valueOf(res)) {
            case 0:
                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;

            int intRes;

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

                mBaudrate = intRes;
                mSerial.setBaudrate(mBaudrate);
            }

            res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
            intRes = Integer.valueOf(res);
            if (mDataBits != intRes) {
                mDataBits = Integer.valueOf(res);
                mSerial.setDataBits(mDataBits);
            }

            res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
            intRes = Integer.valueOf(res);
            if (mParity != intRes) {
                mParity = intRes;
                mSerial.setParity(mParity);
            }

            res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
            intRes = Integer.valueOf(res);
            if (mStopBits != intRes) {
                mStopBits = intRes;
                mSerial.setStopBits(mStopBits);
            }

            res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
            intRes = Integer.valueOf(res);
            if (mFlowControl != intRes) {
                mFlowControl = intRes;
                if (mFlowControl == UartConfig.FLOW_CONTROL_ON) {
                    mSerial.setDtrRts(true, true);
                } else {
                    mSerial.setDtrRts(false, false);
                }
            }

            /*
            res = pref.getString("break_list", Integer.toString(FTDriver.FTDI_SET_NOBREAK));
            intRes = Integer.valueOf(res) << 14;
            if (mBreak != intRes) {
            mBreak = intRes;
            mSerial.setSerialPropertyBreak(mBreak, FTDriver.CH_A);
            mSerial.setSerialPropertyToChip(FTDriver.CH_A);
            }
            */
        }
    }

From source file:ch.ethz.dcg.jukefox.manager.libraryimport.AndroidAlbumCoverFetcherThread.java

private void drawTextOnBitmap(CompleteAlbum album, Bitmap bitmapHigh, int bitmapSize, float textHeight) {
    Canvas canvas = new Canvas(bitmapHigh);
    canvas.drawARGB(0, 125, 125, 125);// w ww  .  ja v a2  s.  c om
    Paint paint = new Paint();
    paint.setColor(Color.BLACK);
    paint.setTypeface(Typeface.SERIF);
    paint.setSubpixelText(true);
    paint.setTextSize(textHeight);
    paint.setAntiAlias(true);
    String artist = album.getArtists().get(0).getName();
    String shortenedText = new String(artist);

    int textLength = artist.length();
    if (textLength > 18) {
        shortenedText = artist.substring(0, 15) + "...";
        textLength = 18;
    } else if (textLength < 8) {
        while (shortenedText.length() < 8) {
            shortenedText = " " + shortenedText + " ";
        }
    }
    float pixelLength = paint.measureText(shortenedText);
    paint.setTextSize(textHeight * (bitmapSize * 2 / 3) / pixelLength);

    canvas.drawText(shortenedText, bitmapSize / 6, bitmapSize / 3, paint);

    shortenedText = album.getName();
    textLength = album.getName().length();
    if (textLength > 18) {
        shortenedText = album.getName().substring(0, 15) + "...";
        textLength = 18;
    } else if (textLength < 8) {
        while (shortenedText.length() < 8) {
            shortenedText = " " + shortenedText + " ";
        }
    }
    paint.setTextSize(bitmapSize / 10f);
    pixelLength = paint.measureText(shortenedText);
    textHeight = textHeight * bitmapSize * 2f / 3f / pixelLength;
    paint.setTextSize(textHeight);

    canvas.drawText(shortenedText, bitmapSize / 6f, bitmapSize * 2 / 3f + textHeight, paint);
}

From source file:com.zainsoft.ramzantimetable.QiblaActivity.java

/** Called when the activity is first created. */
@Override/*from   www  . ja  v a 2  s .c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_qibla_direction);
    // registering for listeners
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    registerListeners();
    // Checking if the GPS is on or off. If it was on the default location
    // will be set and if its on, appropriate
    Context context = getApplicationContext();
    perfs = PreferenceManager.getDefaultSharedPreferences(context);
    perfs.registerOnSharedPreferenceChangeListener(this);
    String gpsPerfKey = getString(R.string.gps_pref_key);
    TextView text1 = (TextView) findViewById(R.id.location_text_line2);
    TextView text2 = (TextView) findViewById(R.id.noLocationText);
    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/kufi.ttf");
    tf = Typeface.create(tf, Typeface.BOLD);

    if ("fa".equals(Locale.getDefault().getLanguage())) {
        text1.setTypeface(tf);
        text2.setTypeface(tf);
    } else {
        text1.setTypeface(Typeface.SERIF);
        text2.setTypeface(Typeface.SERIF);
    }

    boolean isGPS = false;

    /*  if(hasPermission( LOC_PERMS[0] )) {
    checkForGPSnShowQibla();
      } else {
    requestLocationPermission();
      }
    */
    this.qiblaImageView = (ImageView) findViewById(R.id.arrowImage);
    this.compassImageView = (ImageView) findViewById(R.id.compassImage);
}

From source file:com.bookkos.bircle.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    _context = getApplicationContext();/*from w  w  w. j ava  2  s . c  om*/
    _activity = this;

    currentTime = new Time("Asia/Tokyo");

    //      exceptionHandler = new ExceptionHandler(_context);   
    //      Thread.setDefaultUncaughtExceptionHandler(exceptionHandler);

    // sharedPreference???, user_id?group_id?registration_id??
    getUserData();

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // ??
    WindowManager window_manager = getWindowManager();
    Display display = window_manager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    displayWidth = point.x;
    displayHeight = point.y;

    displayInch = getInch();
    // ??4???????
    textSize = 17 * (displayInch / 4);

    actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_USE_LOGO);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    String title_text = "";
    subGroupText = "";
    groupText = groupName;

    if (displayInch < 4.7) {
        title_text = "<small><small><small>??: </small></small></small>";
        resizeTitleSizeTooSmall();
    } else if (displayInch >= 4.7 && displayInch < 5.5) {
        title_text = "<small><small>??: </small></small>";
        resizeTitleSizeSmall();
    } else if (displayInch >= 5.5 && displayInch < 6.5) {
        title_text = "<small>??: </small>";
        resizeTitleSizeMiddle();
    } else if (displayInch >= 6.5 && displayInch < 8) {
        title_text = "<small>??: </small>";
        resizeTitleSizeLarge();
    } else {
        title_text = "??: ";
    }
    String modify_group_text = title_text + "<font color=#FF0000>" + groupName + "</font>";
    actionBar.setTitle(Html.fromHtml(modify_group_text));

    Resources resources = _context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    titleBarHeight = resources.getDimensionPixelSize(resourceId);

    setContentView(R.layout.capture);

    returnBorrowHelpView = (ImageView) findViewById(R.id.return_borrow_help_view);
    returnBorrowHelpView.setImageResource(R.drawable.return_borrow_help);
    returnBorrowHelpView.setTranslationY(displayHeight / 5 + titleBarHeight);
    returnBorrowHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth,
            displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER));

    registHelpView = (ImageView) findViewById(R.id.regist_help_view);
    registHelpView.setImageResource(R.drawable.regist_help);
    registHelpView.setTranslationY(displayHeight / 5 + titleBarHeight);
    registHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth,
            displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER));
    registHelpView.setVisibility(View.GONE);

    leftDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    leftDrawer = (ListView) findViewById(R.id.left_drawer);
    textView = (TextView) findViewById(R.id.textView);

    modeText = (TextView) findViewById(R.id.mode_text);
    modeText.setTextColor(Color.rgb(56, 234, 123));
    modeText.setTextSize(textSize);
    modeText.setTypeface(Typeface.SERIF.MONOSPACE, Typeface.BOLD);
    strokeColor = Color.rgb(56, 234, 123);

    borrowReturnButton = (Button) findViewById(R.id.borrowReturnButton);
    registButton = (Button) findViewById(R.id.registButton);
    returnHistoryButton = (Button) findViewById(R.id.return_history_button);
    helpViewButton = (Button) findViewById(R.id.help_view_button);

    registSelectShelfRelativeLayout = (RelativeLayout) findViewById(R.id.regist_select_shelf_relative_layout);
    textViewLinearLayout = (LinearLayout) findViewById(R.id.text_view_linear_layout);
    buttonLinearLayout = (LinearLayout) findViewById(R.id.button_linear_layout);
    listViewLinearLayout = (LinearLayout) findViewById(R.id.list_view_linear_layout);
    decisionButton = (Button) findViewById(R.id.decision_button);
    cancelButton = (Button) findViewById(R.id.cancel_button);
    shelfListView = (ListView) findViewById(R.id.shelf_list_view);
    tempTextView = (TextView) findViewById(R.id.temp_text_view);
    //      bookListViewAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
    bookListViewAdapter = new BookListViewAdapter(_context, R.layout.book_list_row, this);

    bookRegistRelativeLayout = (RelativeLayout) findViewById(R.id.book_regist_relative_layout);
    bookRegistLinearLayout = (LinearLayout) findViewById(R.id.book_regist_linear_layout);
    bookRegistListViewLinearLayout = (LinearLayout) findViewById(R.id.book_regist_list_view_linear_layout);
    bookRegistListView = (ListView) findViewById(R.id.book_regist_list_view);
    bookRegistTextView = (TextView) findViewById(R.id.book_regist_text_view);
    bookRegistCancelButton = (Button) findViewById(R.id.book_regist_cancel_button);

    registFlag = 0;

    int borrowReturnButton_width = displayWidth / 5 * 2;
    int borrowReturnButton_height = displayHeight / 10;
    int borrowReturnButton_x = ((displayWidth / 2) - borrowReturnButton_width) / 2;
    int borrowReturnButton_y = displayHeight / 2 + titleBarHeight;
    borrowReturnButton.setTranslationX(borrowReturnButton_x);
    borrowReturnButton.setTranslationY(borrowReturnButton_y);
    borrowReturnButton
            .setLayoutParams(new FrameLayout.LayoutParams(borrowReturnButton_width, borrowReturnButton_height));
    borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123));
    borrowReturnButton.setText("??\n");
    borrowReturnButton.setTextSize(textSize * 7 / 10);
    borrowReturnButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            arrayList.clear();
            registFlag = 0;

            borrowReturnButton.setText("??\n");
            borrowReturnButton.setEnabled(false);
            borrowReturnButton.setTextColor(Color.WHITE);
            borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123));

            registButton.setText("?\n??");
            registButton.setEnabled(true);
            registButton.setTextColor(Color.GRAY);
            registButton.setBackgroundColor(Color.argb(170, 21, 38, 45));

            modeText.setText("??");
            modeText.setTextColor(Color.rgb(56, 234, 123));
            returnBorrowHelpView.setVisibility(View.VISIBLE);
            registHelpView.setVisibility(View.GONE);
            strokeColor = Color.rgb(56, 234, 123);
        }
    });

    int registButton_width = displayWidth / 5 * 2;
    int registButton_height = displayHeight / 10;
    int registButton_x = (displayWidth / 2) + ((displayWidth / 2) - registButton_width) / 2;
    int registButton_y = displayHeight / 2 + titleBarHeight;
    registButton.setTranslationX(registButton_x);
    registButton.setTranslationY(registButton_y);
    registButton.setLayoutParams(new FrameLayout.LayoutParams(registButton_width, registButton_height));
    registButton.setBackgroundColor(Color.argb(170, 21, 38, 45));
    registButton.setTextColor(Color.GRAY);
    registButton.setTextSize(textSize * 7 / 10);
    registButton.setText("?\n??");
    registButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            arrayList.clear();
            registFlag = 1;

            borrowReturnButton.setText("??\n??");
            borrowReturnButton.setEnabled(true);
            borrowReturnButton.setTextColor(Color.GRAY);
            borrowReturnButton.setBackgroundColor(Color.argb(170, 9, 54, 16));

            registButton.setText("?\n");
            registButton.setEnabled(false);
            registButton.setTextColor(Color.WHITE);
            registButton.setBackgroundColor(Color.rgb(62, 162, 229));

            modeText.setText("?");
            modeText.setTextColor(Color.rgb(62, 162, 229));
            returnBorrowHelpView.setVisibility(View.GONE);
            registHelpView.setVisibility(View.VISIBLE);
            strokeColor = Color.rgb(62, 162, 229);
        }
    });

    returnHistoryButton.setText("????");
    returnHistoryButton.setTextSize(textSize * 7 / 10);
    returnHistoryButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            leftDrawerLayout.openDrawer(Gravity.RIGHT);
            //            animateTranslationY(bookRegistRelativeLayout, displayHeight, displayHeight - displayHeight / 4 - titleBarHeight);
        }
    });
    getReturnHistory();
    getCurrentTime();

    setHelpView();
    setScanUnregisterBookView();
    setBookRegistView();

    arrayList = new ArrayList<String>();
    tempRegistIsbn = "";

    initBookRegistUrl = book_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initLendRegistUrl = lend_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initTemporaryLendRegistUrl = temporary_lend_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initCatalogRegistUrl = catalog_register_url + "?group_id=" + groupId + "&book_code=";
    initManuallyCatalogRegistUrl = manually_catalog_register_url + "?group_id=" + groupId + "&book_code=";
    getStatusUrl = get_status_url + "?group_id=" + groupId + "&user_id=" + userId;

    hasSurface = false;

    inactivityTimer = new InactivityTimer(this);
    bircleBeepManager = new BircleBeepManager(this);
    ambientLightManager = new AmbientLightManager(this);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    toastText = "";
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    // This needs to be before super.onCreate, otherwise ActionbarSherlock
    // doesn't makes the background of the actionbar white when you're
    // in the dark theme.
    setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);

    Log.d(LOG, "onCreate:" + this);
    super.onCreate(savedInstanceState);

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // Don't auto-launch if this fails.
    prefs.edit().remove(C.DICT_FILE).commit();

    setContentView(R.layout.dictionary_activity);

    application = (DictionaryApplication) getApplication();
    theme = application.getSelectedTheme();
    textColorFg = getResources().getColor(theme.tokenRowFgColor);

    final Intent intent = getIntent();
    String intentAction = intent.getAction();
    /**/*from   ww  w  .j  ava2 s .  c  om*/
     * @author Dominik Kppl Querying the Intent
     *         com.hughes.action.ACTION_SEARCH_DICT is the advanced query
     *         Arguments: SearchManager.QUERY -> the phrase to search from
     *         -> language in which the phrase is written to -> to which
     *         language shall be translated
     */
    if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        String from = intent.getStringExtra("from");
        if (from != null)
            from = from.toLowerCase(Locale.US);
        String to = intent.getStringExtra("to");
        if (to != null)
            to = to.toLowerCase(Locale.US);
        if (query != null) {
            getIntent().putExtra(C.SEARCH_TOKEN, query);
        }
        if (intent.getStringExtra(C.DICT_FILE) == null && (from != null || to != null)) {
            Log.d(LOG, "DictSearch: from: " + from + " to " + to);
            List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null);
            for (DictionaryInfo info : dicts) {
                boolean hasFrom = from == null;
                boolean hasTo = to == null;
                for (IndexInfo index : info.indexInfos) {
                    if (!hasFrom && index.shortName.toLowerCase(Locale.US).equals(from))
                        hasFrom = true;
                    if (!hasTo && index.shortName.toLowerCase(Locale.US).equals(to))
                        hasTo = true;
                }
                if (hasFrom && hasTo) {
                    if (from != null) {
                        int which_index = 0;
                        for (; which_index < info.indexInfos.size(); ++which_index) {
                            if (info.indexInfos.get(which_index).shortName.toLowerCase(Locale.US).equals(from))
                                break;
                        }
                        intent.putExtra(C.INDEX_SHORT_NAME, info.indexInfos.get(which_index).shortName);

                    }
                    intent.putExtra(C.DICT_FILE, application.getPath(info.uncompressedFilename).toString());
                    break;
                }
            }

        }
    }
    /**
     * @author Dominik Kppl Querying the Intent Intent.ACTION_SEARCH is a
     *         simple query Arguments follow from android standard (see
     *         documentation)
     */
    if (intentAction != null && intentAction.equals(Intent.ACTION_SEARCH)) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (query != null)
            getIntent().putExtra(C.SEARCH_TOKEN, query);
    }
    /**
     * @author Dominik Kppl If no dictionary is chosen, use the default
     *         dictionary specified in the preferences If this step does
     *         fail (no default directory specified), show a toast and
     *         abort.
     */
    if (intent.getStringExtra(C.DICT_FILE) == null) {
        String dictfile = prefs.getString(getString(R.string.defaultDicKey), null);
        if (dictfile != null)
            intent.putExtra(C.DICT_FILE, application.getPath(dictfile).toString());
    }
    String dictFilename = intent.getStringExtra(C.DICT_FILE);

    if (dictFilename == null) {
        Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show();
        startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
        finish();
        return;
    }
    if (dictFilename != null)
        dictFile = new File(dictFilename);

    ttsReady = false;
    textToSpeech = new TextToSpeech(getApplicationContext(), new OnInitListener() {
        @Override
        public void onInit(int status) {
            ttsReady = true;
            updateTTSLanguage(indexIndex);
        }
    });

    try {
        final String name = application.getDictionaryName(dictFile.getName());
        this.setTitle("QuickDic: " + name);
        dictRaf = new RandomAccessFile(dictFile, "r");
        dictionary = new Dictionary(dictRaf);
    } catch (Exception e) {
        Log.e(LOG, "Unable to load dictionary.", e);
        if (dictRaf != null) {
            try {
                dictRaf.close();
            } catch (IOException e1) {
                Log.e(LOG, "Unable to close dictRaf.", e1);
            }
            dictRaf = null;
        }
        Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()), Toast.LENGTH_LONG)
                .show();
        startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
        finish();
        return;
    }
    String targetIndex = intent.getStringExtra(C.INDEX_SHORT_NAME);
    if (savedInstanceState != null && savedInstanceState.getString(C.INDEX_SHORT_NAME) != null) {
        targetIndex = savedInstanceState.getString(C.INDEX_SHORT_NAME);
    }
    indexIndex = 0;
    for (int i = 0; i < dictionary.indices.size(); ++i) {
        if (dictionary.indices.get(i).shortName.equals(targetIndex)) {
            indexIndex = i;
            break;
        }
    }
    Log.d(LOG, "Loading index " + indexIndex);
    index = dictionary.indices.get(indexIndex);
    setListAdapter(new IndexAdapter(index));

    // Pre-load the collators.
    new Thread(new Runnable() {
        public void run() {
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
            final long startMillis = System.currentTimeMillis();
            try {
                TransliteratorManager.init(new TransliteratorManager.Callback() {
                    @Override
                    public void onTransliteratorReady() {
                        uiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                onSearchTextChange(searchView.getQuery().toString());
                            }
                        });
                    }
                });

                for (final Index index : dictionary.indices) {
                    final String searchToken = index.sortedIndexEntries.get(0).token;
                    final IndexEntry entry = index.findExact(searchToken);
                    if (entry == null || !searchToken.equals(entry.token)) {
                        Log.e(LOG, "Couldn't find token: " + searchToken + ", "
                                + (entry == null ? "null" : entry.token));
                    }
                }
                indexPrepFinished = true;
            } catch (Exception e) {
                Log.w(LOG,
                        "Exception while prepping.  This can happen if dictionary is closed while search is happening.");
            }
            Log.d(LOG, "Prepping indices took:" + (System.currentTimeMillis() - startMillis));
        }
    }).start();

    String fontName = prefs.getString(getString(R.string.fontKey), "FreeSerif.otf.jpg");
    if ("SYSTEM".equals(fontName)) {
        typeface = Typeface.DEFAULT;
    } else if ("SERIF".equals(fontName)) {
        typeface = Typeface.SERIF;
    } else if ("SANS_SERIF".equals(fontName)) {
        typeface = Typeface.SANS_SERIF;
    } else if ("MONOSPACE".equals(fontName)) {
        typeface = Typeface.MONOSPACE;
    } else {
        if ("FreeSerif.ttf.jpg".equals(fontName)) {
            fontName = "FreeSerif.otf.jpg";
        }
        try {
            typeface = Typeface.createFromAsset(getAssets(), fontName);
        } catch (Exception e) {
            Log.w(LOG, "Exception trying to use typeface, using default.", e);
            Toast.makeText(this, getString(R.string.fontFailure, e.getLocalizedMessage()), Toast.LENGTH_LONG)
                    .show();
        }
    }
    if (typeface == null) {
        Log.w(LOG, "Unable to create typeface, using default.");
        typeface = Typeface.DEFAULT;
    }
    final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14");
    try {
        fontSizeSp = Integer.parseInt(fontSize.trim());
    } catch (NumberFormatException e) {
        fontSizeSp = 14;
    }

    // ContextMenu.
    registerForContextMenu(getListView());

    // Cache some prefs.
    wordList = application.getWordListFile();
    saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey), false);
    clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey), false);
    Log.d(LOG, "wordList=" + wordList + ", saveOnlyFirstSubentry=" + saveOnlyFirstSubentry);

    onCreateSetupActionBarAndSearchView();

    // Set the search text from the intent, then the saved state.
    String text = getIntent().getStringExtra(C.SEARCH_TOKEN);
    if (savedInstanceState != null) {
        text = savedInstanceState.getString(C.SEARCH_TOKEN);
    }
    if (text == null) {
        text = "";
    }
    setSearchText(text, true);
    Log.d(LOG, "Trying to restore searchText=" + text);

    setDictionaryPrefs(this, dictFile, index.shortName, searchView.getQuery().toString());

    updateLangButton();
    searchView.requestFocus();

    // http://stackoverflow.com/questions/2833057/background-listview-becomes-black-when-scrolling
    //        getListView().setCacheColorHint(0);
}

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

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_WORD_LIST_ACTIVITY) {
        if (resultCode == RESULT_OK) {
            try {
                String strWord = data.getStringExtra("word");
                etWrite.setText(strWord);
                // Set a cursor position last
                etWrite.setSelection(etWrite.getText().length());
            } catch (Exception e) {
                Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
            }/*w  w w. j a v a 2s  .  co m*/
        }
    } else if (requestCode == REQUEST_PREFERENCE) {

        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);
        mTvSerial.setTextSize(mTextFontSize);

        res = pref.getString("typeface_list", Integer.toString(3));
        switch (Integer.valueOf(res)) {
        case 0:
            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;

        int intRes;

        res = pref.getString("baudrate_list", Integer.toString(9600));
        intRes = Integer.valueOf(res);
        if (mBaudrate != intRes) {
            mBaudrate = intRes;
            mSerial.setBaudrate(mBaudrate);
        }

        res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
        intRes = Integer.valueOf(res);
        if (mDataBits != intRes) {
            mDataBits = Integer.valueOf(res);
            mSerial.setDataBits(mDataBits);
        }

        res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
        intRes = Integer.valueOf(res);
        if (mParity != intRes) {
            mParity = intRes;
            mSerial.setParity(mParity);
        }

        res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
        intRes = Integer.valueOf(res);
        if (mStopBits != intRes) {
            mStopBits = intRes;
            mSerial.setStopBits(mStopBits);
        }

        res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
        intRes = Integer.valueOf(res);
        if (mFlowControl != intRes) {
            mFlowControl = intRes;
            if (mFlowControl == UartConfig.FLOW_CONTROL_ON) {
                mSerial.setDtrRts(true, true);
            } else {
                mSerial.setDtrRts(false, false);
            }
        }

        /*
        res = pref.getString("break_list", Integer.toString(FTDriver.FTDI_SET_NOBREAK));
        intRes = Integer.valueOf(res) << 14;
        if (mBreak != intRes) {
        mBreak = intRes;
        mSerial.setSerialPropertyBreak(mBreak, FTDriver.CH_A);
        mSerial.setSerialPropertyToChip(FTDriver.CH_A);
        }
        */

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

From source file:com.mschlauch.comfortreader.FullscreenActivity.java

public void retreiveSavedOptions() {
    switchofallmenus = true;// w  w  w . j a v a2s  .c o  m
    spinner.setVisibility(View.VISIBLE);
    String eins = "";
    new AsyncTask<String, Void, String>() {

        @Override
        protected String doInBackground(String... urlStr) {
            // do stuff on non-UI thread
            settingsload.reloadSelectedBook();

            wordsperminute = settingsload.getWordsPerMinute();
            segmenterObject.minblocksize = settingsload.getMinBlockSize();
            segmenterObject.maxblocksize = settingsload.getMaxBlockSize();
            segmenterObject.textcolor = settingsload.getTextColor();
            segmenterObject.emphasiscolor = settingsload.getFocusColor();
            segmenterObject.backgroundcolor = settingsload.getBackgroundColor();

            segmenterObject.maxcharactersperline = settingsload.getMaxBlockSize();
            segmenterObject.loadPreviewcolorString();

            int actual = settingsload.getGlobalPosition();
            segmenterObject.globalposition = actual;
            segmenterObject.globalpositionbefore = actual;
            //Load Content
            String text = settingsload.getTexttoRead() + "";
            String textdefault = getString(R.string.support_standarttext);
            Log.i("fullscreen", "text  is: " + text);

            segmenterObject.loadTexttoRead(textdefault);
            if (text.equals("standarttext")) {
                segmenterObject.loadTexttoRead(textdefault);
                segmenterObject.globalposition = 0;
                segmenterObject.emphasiscolor = Color.parseColor("#ffee00");
                segmenterObject.textcolor = Color.parseColor("#ffffff");
            } else {
                segmenterObject.loadTexttoRead(text);
            }

            if (text.length() > 16) {

            } else {
                //it is importanted that the default text is already segmentable.

            }
            Log.i("fullscreen 2", " real text  is: " + segmenterObject.texttoread);

            segmenterObject.loadallprehtmls();

            String out = "";
            return out;

        }

        @Override
        protected void onPostExecute(String htmlCode) {
            // do stuff on UI thread with the html

            contentView.setTextSize(settingsload.getFontSize());
            contentView.setBackgroundColor(settingsload.getBackgroundColor());

            String parole = settingsload.getOrientationMode();

            Log.i("Fullscreen", "orientation loading" + parole);
            if (parole.equals("1")) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
            } else if (parole.equals("2")) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
            } else if (parole.equals("0")) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
            }

            parole = settingsload.getFontName();

            Log.i("Fullscreen", "orientation loading" + parole);
            if (parole.equals("sans")) {
                contentView.setTypeface(Typeface.SANS_SERIF);
            } else if (parole.equals("serif")) {
                contentView.setTypeface(Typeface.SERIF);
            } else if (parole.equals("mono")) {
                contentView.setTypeface(Typeface.MONOSPACE);
            }

            spinner.setVisibility(View.GONE);

            switchofallmenus = false;
            previousButtonClicked(null);
            nextButtonClicked(null);

        }
    }.execute(eins);

    //Line Spacing...
    // contentView.setLineSpacing(0,(float) 1.28);

    //actual = retrieveNumber("maxlinelength");

    //settingsload.adjustGlobalPositionToPercentage(settingsload.getGlobalPositionSeekbarValue());

    //Log.i("fullscreen", "globalposition:" + actual);

    // get the seekbar etc right...

    //   startdialog();

}

From source file:com.me.resume.MainActivity.java

/**
 * // w  w  w .  j  av a  2s  . c  o  m
 * @param tag
 */
private void fillTagFlowView(String tag) {
    String[] tags = tag.split(";");
    List<String> ll = Arrays.asList(tags);
    if (ll != null && ll.size() > 0) {
        MarginLayoutParams lp = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lp.leftMargin = 5;
        lp.rightMargin = 5;
        lp.topMargin = 5;
        lp.bottomMargin = 5;
        for (int i = 0, cun = ll.size(); i < cun; i++) {
            TextView tview = new TextView(this);
            tview.setText(ll.get(i).toString().trim());
            tview.setTextSize(CommUtil.px2sp(self, CommUtil.getFloatValue(self, R.dimen.main_tiny_text)));
            tview.setTextColor(Color.parseColor(getRanColor().get(new Random().nextInt(10))));
            tview.setTypeface(Typeface.SERIF);
            tview.setBackgroundResource(R.drawable.home_tag_text_corner);
            tagFlowLayout.addView(tview, lp);
        }
    }
}

From source file:com.jjoe64.graphview_demos.fragments.Home.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 w  w . j  a v  a  2  s .co 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);
}