List of usage examples for android.graphics Typeface MONOSPACE
Typeface MONOSPACE
To view the source code for android.graphics Typeface MONOSPACE.
Click Source Link
From source file:za.jamie.soundstage.widgets.PagerSlidingTabStrip.java
private void setTypefaceFromAttrs(String familyName, int typefaceIndex, int styleIndex) { Typeface tf = null;/*from w w w .j a v a2s .c om*/ if (familyName != null) { tf = Typeface.create(familyName, styleIndex); if (tf != null) { setTypeface(tf); return; } } switch (typefaceIndex) { case SANS: tf = Typeface.SANS_SERIF; break; case SERIF: tf = Typeface.SERIF; break; case MONOSPACE: tf = Typeface.MONOSPACE; break; } setTypeface(tf, styleIndex); }
From source file:com.notepadlite.NoteViewFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override// ww w . j av a 2 s. c o m public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Get filename of saved note filename = getArguments().getString("filename"); // Change window title String title; try { title = listener.loadNoteTitle(filename); } catch (IOException e) { title = getResources().getString(R.string.view_note); } getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null, getResources().getColor(R.color.primary)); getActivity().setTaskDescription(taskDescription); } // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view noteContents = (TextView) getActivity().findViewById(R.id.textView); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteContents.setTextColor(getResources().getColor(R.color.text_color_primary)); noteContents.setBackgroundColor(getResources().getColor(R.color.window_background)); scrollView.setBackgroundColor(getResources().getColor(R.color.window_background)); } if (theme.contains("dark")) { noteContents.setTextColor(getResources().getColor(R.color.text_color_primary_dark)); noteContents.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); scrollView.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); } if (theme.contains("sans")) noteContents.setTypeface(Typeface.SANS_SERIF); if (theme.contains("serif")) noteContents.setTypeface(Typeface.SERIF); if (theme.contains("monospace")) noteContents.setTypeface(Typeface.MONOSPACE); switch (pref.getString("font_size", "normal")) { case "smallest": noteContents.setTextSize(12); break; case "small": noteContents.setTextSize(14); break; case "normal": noteContents.setTextSize(16); break; case "large": noteContents.setTextSize(18); break; case "largest": noteContents.setTextSize(20); break; } // Load note contents try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); // Add NoteListFragment or WelcomeFragment Fragment fragment; if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) fragment = new NoteListFragment(); else fragment = new WelcomeFragment(); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); } // Set TextView contents noteContents.setText(contentsOnLoad); // Show a toast message if this is the user's first time viewing a note final SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); firstLoad = sharedPref.getInt("first-load", 0); if (firstLoad == 0) { // Show dialog with info DialogFragment firstLoad = new FirstViewDialogFragment(); firstLoad.show(getFragmentManager(), "firstloadfragment"); // Set first-load preference to 1; we don't need to show the dialog anymore SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("first-load", 1); editor.apply(); } // Detect single and double-taps using GestureDetector final GestureDetector detector = new GestureDetector(getActivity(), new GestureDetector.OnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } @Override public boolean onDown(MotionEvent e) { return false; } }); detector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true)) { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("show_double_tap_message", false); editor.apply(); } Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true) && showMessage) { showToastLong(R.string.double_tap); showMessage = false; } return false; } }); noteContents.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return false; } }); }
From source file:com.inmobi.ultrapush.AnalyzeActivity.java
@SuppressWarnings("deprecation") private void setTextViewFontSize() { TextView tv = (TextView) findViewById(R.id.textview_cur); // At this point tv.getWidth(), tv.getLineCount() will return 0 Paint mTestPaint = new Paint(); mTestPaint.setTextSize(tv.getTextSize()); mTestPaint.setTypeface(Typeface.MONOSPACE); final String text = getString(R.string.textview_peak_text); Display display = getWindowManager().getDefaultDisplay(); // pixels left float px = display.getWidth() - getResources().getDimension(R.dimen.textview_RMS_layout_width) - 5; float fs = tv.getTextSize(); // size in pixel while (mTestPaint.measureText(text) > px && fs > 5) { fs -= 0.5;/* www . j a va 2s . c o m*/ mTestPaint.setTextSize(fs); } ((TextView) findViewById(R.id.textview_cur)).setTextSize(fs / DPRatio); ((TextView) findViewById(R.id.textview_peak)).setTextSize(fs / DPRatio); }
From source file:com.anjalimacwan.fragment.NoteEditFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*from w w w .j a va 2 s .com*/ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity() instanceof MainActivity && getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view noteContents = (EditText) getActivity().findViewById(R.id.editText1); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView1); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary)); noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (theme.contains("dark")) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark)); noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (theme.contains("sans")) noteContents.setTypeface(Typeface.SANS_SERIF); if (theme.contains("serif")) noteContents.setTypeface(Typeface.SERIF); if (theme.contains("monospace")) noteContents.setTypeface(Typeface.MONOSPACE); switch (pref.getString("font_size", "normal")) { case "smallest": noteContents.setTextSize(12); break; case "small": noteContents.setTextSize(14); break; case "normal": noteContents.setTextSize(16); break; case "large": noteContents.setTextSize(18); break; case "largest": noteContents.setTextSize(20); break; } // Get filename try { if (!getArguments().getString("filename").equals("new")) { filename = getArguments().getString("filename"); if (!filename.equals("draft")) isSavedNote = true; } } catch (NullPointerException e) { filename = "new"; } // Load note from existing file if (isSavedNote) { try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); finish(null); } // Set TextView contents length = contentsOnLoad.length(); noteContents.setText(contentsOnLoad); if (!pref.getBoolean("direct_edit", false)) noteContents.setSelection(length, length); } else if (filename.equals("draft")) { SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); String draftContents = sharedPref.getString("draft-contents", null); length = draftContents.length(); noteContents.setText(draftContents); if (!pref.getBoolean("direct_edit", false)) noteContents.setSelection(length, length); } // Show soft keyboard InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(noteContents, InputMethodManager.SHOW_IMPLICIT); }
From source file:com.notepadlite.NoteEditFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/* w w w .j a v a2 s . c o m*/ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity() instanceof MainActivity && getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view noteContents = (EditText) getActivity().findViewById(R.id.editText1); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView1); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteContents.setTextColor(getResources().getColor(R.color.text_color_primary)); noteContents.setBackgroundColor(getResources().getColor(R.color.window_background)); scrollView.setBackgroundColor(getResources().getColor(R.color.window_background)); } if (theme.contains("dark")) { noteContents.setTextColor(getResources().getColor(R.color.text_color_primary_dark)); noteContents.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); scrollView.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); } if (theme.contains("sans")) noteContents.setTypeface(Typeface.SANS_SERIF); if (theme.contains("serif")) noteContents.setTypeface(Typeface.SERIF); if (theme.contains("monospace")) noteContents.setTypeface(Typeface.MONOSPACE); switch (pref.getString("font_size", "normal")) { case "smallest": noteContents.setTextSize(12); break; case "small": noteContents.setTextSize(14); break; case "normal": noteContents.setTextSize(16); break; case "large": noteContents.setTextSize(18); break; case "largest": noteContents.setTextSize(20); break; } // Get filename try { if (!getArguments().getString("filename").equals("new")) { filename = getArguments().getString("filename"); if (!filename.equals("draft")) isSavedNote = true; } } catch (NullPointerException e) { filename = "new"; } // Load note from existing file if (isSavedNote) { try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); finish(null); } // Set TextView contents length = contentsOnLoad.length(); noteContents.setText(contentsOnLoad); noteContents.setSelection(length, length); } else if (filename.equals("draft")) { SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); String draftContents = sharedPref.getString("draft-contents", null); length = draftContents.length(); noteContents.setText(draftContents); noteContents.setSelection(length, length); } // Show soft keyboard InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(noteContents, InputMethodManager.SHOW_IMPLICIT); }
From source file:com.farmerbb.notepad.fragment.NoteEditFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from ww w .j a v a 2 s . com public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity() instanceof MainActivity && getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view noteContents = getActivity().findViewById(R.id.editText1); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = getActivity().findViewById(R.id.scrollView1); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary)); noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (theme.contains("dark")) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark)); noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (theme.contains("sans")) noteContents.setTypeface(Typeface.SANS_SERIF); if (theme.contains("serif")) noteContents.setTypeface(Typeface.SERIF); if (theme.contains("monospace")) noteContents.setTypeface(Typeface.MONOSPACE); switch (pref.getString("font_size", "normal")) { case "smallest": noteContents.setTextSize(12); break; case "small": noteContents.setTextSize(14); break; case "normal": noteContents.setTextSize(16); break; case "large": noteContents.setTextSize(18); break; case "largest": noteContents.setTextSize(20); break; } // Get filename try { if (!getArguments().getString("filename").equals("new")) { filename = getArguments().getString("filename"); if (!filename.equals("draft")) isSavedNote = true; } } catch (NullPointerException e) { filename = "new"; } // Load note from existing file if (isSavedNote) { try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); finish(null); } // Set TextView contents length = contentsOnLoad.length(); noteContents.setText(contentsOnLoad); if (!pref.getBoolean("direct_edit", false)) noteContents.setSelection(length, length); } else if (filename.equals("draft")) { SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); String draftContents = sharedPref.getString("draft-contents", null); length = draftContents.length(); noteContents.setText(draftContents); if (!pref.getBoolean("direct_edit", false)) noteContents.setSelection(length, length); } // Show soft keyboard InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(noteContents, InputMethodManager.SHOW_IMPLICIT); }
From source file:com.jjoe64.graphview_demos.fragments.Home.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. j av a2 s .co 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:piuk.blockchain.android.ui.WalletTransactionsFragment.java
public void initAdapter() { adapter = new ArrayAdapter<Transaction>(activity, 0) { final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity); final DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); final int colorSignificant = getResources().getColor(R.color.significant); final int colorInsignificant = getResources().getColor(R.color.insignificant); final int colorSent = getResources().getColor(R.color.color_sent); final int colorReceived = getResources().getColor(R.color.color_received); @Override// w ww. j a v a2s . c o m public View getView(final int position, View row, final ViewGroup parent) { if (row == null) row = getLayoutInflater(null).inflate(R.layout.transaction_row, null); final CurrencyAmountView rowValue = (CurrencyAmountView) row .findViewById(R.id.transaction_row_value); final TextView rowLabel = (TextView) row.findViewById(R.id.transaction_row_address); final TextView rowTime = (TextView) row.findViewById(R.id.transaction_row_time); try { synchronized (adapter) { final Transaction tx = getItem(position); if (tx.getHash() == null) { rowLabel.setTextColor(Color.BLACK); rowLabel.setText(R.string.no_transactions); rowLabel.setTypeface(Typeface.DEFAULT); rowLabel.setTextColor(Color.BLACK); rowTime.setVisibility(View.INVISIBLE); rowValue.setVisibility(View.INVISIBLE); rowLabel.setGravity(Gravity.CENTER); return row; } else { rowTime.setVisibility(View.VISIBLE); rowValue.setVisibility(View.VISIBLE); rowLabel.setGravity(Gravity.LEFT); final TransactionConfidence confidence = tx.getConfidence(); final ConfidenceType confidenceType = confidence.getConfidenceType(); try { BigInteger value = null; if (tx instanceof MyTransaction) { value = ((MyTransaction) tx).getResult(); } else { value = tx.getValue(application.bitcoinjWallet); } final boolean sent = value.signum() < 0; final int textColor; if (confidenceType == ConfidenceType.NOT_SEEN_IN_CHAIN) { textColor = colorInsignificant; } else if (confidenceType == ConfidenceType.BUILDING) { textColor = colorSignificant; } else if (confidenceType == ConfidenceType.NOT_IN_BEST_CHAIN) { textColor = colorSignificant; } else if (confidenceType == ConfidenceType.DEAD) { textColor = Color.RED; } else { textColor = colorInsignificant; } final String address; if (sent) if (tx.getOutputs().size() == 0) address = "Unknown"; else address = tx.getOutputs().get(0).getScriptPubKey().getToAddress() .toString(); else if (tx.getInputs().size() == 0) address = "Generation"; else address = tx.getInputs().get(0).getFromAddress().toString(); String label = null; if (tx instanceof MyTransaction && ((MyTransaction) tx).getTag() != null) label = ((MyTransaction) tx).getTag(); else label = AddressBookProvider.resolveLabel(activity.getContentResolver(), address); final Date time = tx.getUpdateTime(); rowTime.setText( time != null ? (DateUtils.isToday(time.getTime()) ? timeFormat.format(time) : dateFormat.format(time)) : null); rowTime.setTextColor(textColor); rowLabel.setTextColor(textColor); rowLabel.setText(label != null ? label : address); rowLabel.setTypeface(label != null ? Typeface.DEFAULT : Typeface.MONOSPACE); rowValue.setCurrencyCode(null); rowValue.setAmountSigned(true); rowValue.setTextColor(textColor); rowValue.setAmount(value); if (sent) { rowValue.setTextColor(colorSent); } else { rowValue.setTextColor(colorReceived); } return row; } catch (final ScriptException x) { throw new RuntimeException(x); } } } } catch (Exception e) { e.printStackTrace(); rowLabel.setTextColor(Color.BLACK); rowLabel.setText(R.string.unknown_error); rowLabel.setTypeface(Typeface.DEFAULT); rowLabel.setTextColor(Color.BLACK); rowLabel.setGravity(Gravity.CENTER); rowTime.setVisibility(View.INVISIBLE); rowValue.setVisibility(View.INVISIBLE); return row; } } }; setAdapterContent(); setListAdapter(adapter); }
From source file:mbullington.dialogue.activity.ConversationActivity.java
/** * On create/*ww w . j a v a 2s. c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); serverId = getIntent().getExtras().getInt("serverId"); server = Dialogue.getInstance().getServerById(serverId); Settings settings = new Settings(this); // Finish activity if server does not exist anymore - See #55 if (server == null) { this.finish(); } setContentView(R.layout.conversations); ButterKnife.inject(this); Slide enterTransition = new Slide(); enterTransition.excludeTarget(android.R.id.statusBarBackground, true); getWindow().setEnterTransition(enterTransition); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.back_arrow); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ConversationActivity.this.finish(); } }); setTitle(server.getTitle()); boolean isLandscape = (getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); EditText input = (EditText) findViewById(R.id.input); input.setOnKeyListener(inputKeyListener); pager = (ViewPager) findViewById(R.id.pager); pagerAdapter = new ConversationPagerAdapter(this, server); pager.setAdapter(pagerAdapter); final float density = getResources().getDisplayMetrics().density; indicator = (ConversationIndicator) findViewById(R.id.titleIndicator); indicator.setServer(server); indicator.setTypeface(Typeface.MONOSPACE); indicator.setViewPager(pager); indicator.setFooterColor(0xFF31B6E7); indicator.setFooterLineHeight(1 * density); indicator.setFooterIndicatorHeight(3 * density); indicator.setFooterIndicatorStyle(IndicatorStyle.Underline); indicator.setSelectedColor(0xFFFFFFFF); indicator.setSelectedBold(true); indicator.setBackgroundColor(0xFF181818); historySize = settings.getHistorySize(); if (server.getStatus() == Status.PRE_CONNECTING) { server.clearConversations(); pagerAdapter.clearConversations(); server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize); } float fontSize = settings.getFontSize(); indicator.setTextSize(fontSize * density); input.setTextSize(settings.getFontSize()); input.setTypeface(Typeface.MONOSPACE); // Optimization : cache field lookups Collection<Conversation> mConversations = server.getConversations(); for (Conversation conversation : mConversations) { // Only scroll to new conversation if it was selected before if (conversation.getStatus() == Conversation.STATUS_SELECTED) { onNewConversation(conversation.getName()); } else { createNewConversation(conversation.getName()); } } int setInputTypeFlags = 0; setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT; if (settings.autoCapSentences()) { setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } if (isLandscape && settings.imeExtract()) { setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE; } if (!settings.imeExtract()) { input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI); } input.setInputType(input.getInputType() | setInputTypeFlags); // Create a new scrollback history scrollback = new Scrollback(); }
From source file:indrora.atomic.activity.ConversationActivity.java
/** * On create/*from ww w .j av a 2s. c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _scheme = App.getColorScheme(); serverId = getIntent().getExtras().getInt("serverId"); server = Atomic.getInstance().getServerById(serverId); settings = new Settings(this); // Finish activity if server does not exist anymore - See #55 if (server == null) { this.finish(); } ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setTitle(server.getTitle()); setContentView(R.layout.conversations); boolean isLandscape = (getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); EditText input = (EditText) findViewById(R.id.input); input.setOnKeyListener(inputKeyListener); // Fix from https://groups.google.com/forum/#!topic/yaaic/Z4bXZXvW7UM input.setOnClickListener(new EditText.OnClickListener() { public void onClick(View v) { openSoftKeyboard(v); } }); pager = (ViewPager) findViewById(R.id.pager); pagerAdapter = new ConversationPagerAdapter(this, server); pager.setAdapter(pagerAdapter); final float density = getResources().getDisplayMetrics().density; indicator = (ConversationIndicator) findViewById(R.id.titleIndicator); indicator.setServer(server); indicator.setTypeface(Typeface.MONOSPACE); indicator.setViewPager(pager); indicator.setFooterColor(0xFF31B6E7); indicator.setFooterLineHeight(1 * density); indicator.setFooterIndicatorHeight(3 * density); indicator.setFooterIndicatorStyle(IndicatorStyle.Underline); indicator.setSelectedColor(0xFFFFFFFF); indicator.setSelectedBold(true); indicator.setBackgroundColor(0xFF181818); indicator.setVisibility(View.GONE); indicator.setOnPageChangeListener(this); historySize = settings.getHistorySize(); if (server.getStatus() == Status.PRE_CONNECTING) { server.clearConversations(); pagerAdapter.clearConversations(); server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize); } float fontSize = settings.getFontSize(); indicator.setTextSize(fontSize * density); input.setTextSize(settings.getFontSize()); input.setTypeface(Typeface.MONOSPACE); // Optimization : cache field lookups Collection<Conversation> mConversations = server.getConversations(); for (Conversation conversation : mConversations) { // Only scroll to new conversation if it was selected before if (conversation.getStatus() == Conversation.STATUS_SELECTED) { onNewConversation(conversation.getName()); } else { createNewConversation(conversation.getName()); } } int setInputTypeFlags = 0; setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT; if (settings.autoCapSentences()) { setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } if (isLandscape && settings.imeExtract()) { setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE; } if (!settings.imeExtract()) { input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI); } input.setInputType(input.getInputType() | setInputTypeFlags); // Add handling for tab-completing from the input box. int tabCompleteDrawableResource = (settings.getUseDarkColors() ? R.drawable.ic_tabcomplete_light : R.drawable.ic_tabcomplete_dark); // The drawable that makes up the actual clicky final Drawable tabcompleteDrawable = getResources().getDrawable(tabCompleteDrawableResource); // Set the bounds to the Intrinsic width // We'll resize this later (well, the input box will handle that for us) tabcompleteDrawable.setBounds(0, 0, tabcompleteDrawable.getIntrinsicWidth(), tabcompleteDrawable.getIntrinsicWidth()); // Set the input compound drawables. input.setCompoundDrawables(null, null, tabcompleteDrawable, null); // Magic. final EditText tt = input; final ConversationActivity cv = this; input.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // This is where we handle some things. boolean tappedX = event .getX() > (tt.getWidth() - tt.getPaddingRight() - tabcompleteDrawable.getIntrinsicWidth()); if (event.getAction() == MotionEvent.ACTION_UP && tappedX) { cv.doNickCompletion(tt); } return false; } }); setupColors(); setupIndicator(); // Create a new scrollback history scrollback = new Scrollback(); if (getIntent().getExtras().containsKey(EXTRA_TARGET)) { ShuffleToHighlight(getIntent()); } }