Java Code Examples for android.graphics.Typeface
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project android-thaiime, under directory /latinime/src/com/sugree/inputmethod/latin/.
Source file: SuggestionsView.java

private static int getTextWidth(CharSequence text,TextPaint paint){ if (TextUtils.isEmpty(text)) return 0; final Typeface savedTypeface=paint.getTypeface(); paint.setTypeface(getTextTypeface(text)); final int len=text.length(); final float[] widths=new float[len]; final int count=paint.getTextWidths(text,0,len,widths); int width=0; for (int i=0; i < count; i++) { width+=Math.round(widths[i] + 0.5f); } paint.setTypeface(savedTypeface); return width; }
Example 2
From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.
Source file: PathBarLayer.java

public final void computeLabel(float widthLeft){ Typeface typeface=sPathFormat.bold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT; String label=""; if (origString != null) { label=origString.substring(0,StringTexture.lengthToFit(sPathFormat.fontSize,widthLeft,typeface,origString)); if (label.length() != origString.length()) { label+="..."; } } this.texture=new StringTexture(label,sPathFormat); }
Example 3
From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/latin/.
Source file: SuggestionsView.java

private static int getTextWidth(CharSequence text,TextPaint paint){ if (TextUtils.isEmpty(text)) return 0; final Typeface savedTypeface=paint.getTypeface(); paint.setTypeface(getTextTypeface(text)); final int len=text.length(); final float[] widths=new float[len]; final int count=paint.getTextWidths(text,0,len,widths); int width=0; for (int i=0; i < count; i++) { width+=Math.round(widths[i] + 0.5f); } paint.setTypeface(savedTypeface); return width; }
Example 4
From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.
Source file: BooksOnBookshelf.java

/** * Add a text box to the sort options dialogue. * @param sortDialog * @param stringId * @param listener */ private void makeText(final LinearLayout parent,final LayoutInflater inf,final int stringId,OnClickListener listener){ TextView view=(TextView)inf.inflate(R.layout.booklist_style_menu_text,null); Typeface tf=view.getTypeface(); view.setTypeface(tf,Typeface.ITALIC); view.setText(stringId); view.setOnClickListener(listener); parent.addView(view); }
Example 5
From project cicada, under directory /apollolib/src/org/cicadasong/apollo/.
Source file: SimulatedDisplayView.java

public SimulatedDisplayView(Context context,AttributeSet attrs){ super(context,attrs); Typeface fontMetawatch11px=Typeface.createFromAsset(context.getAssets(),"fonts/metawatch_16pt_11pxl_proto1.ttf"); textPaint=new Paint(); textPaint.setTypeface(fontMetawatch11px); textPaint.setTextSize(16); }
Example 6
From project droidgiro-android, under directory /src/se/droidgiro/scanner/resultlist/.
Source file: ResultListAdapter.java

protected void bindHolder(ViewHolder holder){ ResultViewHolder resultHolder=(ResultViewHolder)holder; ResultListHandler.ListItem listItem=(ResultListHandler.ListItem)resultHolder.data; Typeface ocrb=Typeface.createFromAsset(context.getAssets(),"fonts/ocrb10.ttf"); resultHolder.listItemDataView.setTypeface(ocrb); resultHolder.listItemDataView.setText(listItem.listItemData); resultHolder.listItemTypeView.setText(listItem.listItemType); }
Example 7
From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/alarmclock/.
Source file: DigitalClock.java

@Override protected void onFinishInflate(){ super.onFinishInflate(); final Typeface tf=Typeface.MONOSPACE; mTimeDisplay=(TextView)findViewById(R.id.timeDisplay); mTimeDisplay.setTypeface(tf); mAmPm=new AmPm(this); mCalendar=Calendar.getInstance(); setDateFormat(); }
Example 8
From project Game_3, under directory /android/src/playn/android/.
Source file: AndroidGraphics.java

/** * Registers a font with the graphics system. * @param path the path to the font resource (relative to the asset manager's path prefix). * @param name the name under which to register the font. * @param style the style variant of the specified name provided by the font file. For exampleone might {@code registerFont("myfont.ttf", "My Font", Font.Style.PLAIN)} and{@code registerFont("myfontb.ttf", "My Font", Font.Style.BOLD)} to provide both the plain andbold variants of a particular font. */ public void registerFont(String path,String name,Font.Style style){ try { Typeface face=Typeface.createFromFile(platform.assets().cacheAsset(path,name + path.substring(path.lastIndexOf('.')))); fonts.put(Pair.create(name,style),face); } catch ( Exception e) { platform.log().warn("Failed to load font [name=" + name + ", path="+ path+ "]",e); } }
Example 9
@Override public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); fillData(); RepositoryActivity repoActivity=(RepositoryActivity)getSherlockActivity(); Gh4Application app=(Gh4Application)getActivity().getApplicationContext(); Typeface boldCondensed=app.boldCondensed; TextView tvReadmeTitle=(TextView)getView().findViewById(R.id.readme_title); tvReadmeTitle.setTypeface(boldCondensed); tvReadmeTitle.setTextColor(Color.parseColor("#0099cc")); showLoading(R.id.pb_readme,R.id.readme); }
Example 10
From project ICS_LatinIME_QHD, under directory /java/src/com/android/inputmethod/latin/.
Source file: SuggestionsView.java

private static int getTextWidth(CharSequence text,TextPaint paint){ if (TextUtils.isEmpty(text)) return 0; final Typeface savedTypeface=paint.getTypeface(); paint.setTypeface(getTextTypeface(text)); final int len=text.length(); final float[] widths=new float[len]; final int count=paint.getTextWidths(text,0,len,widths); int width=0; for (int i=0; i < count; i++) { width+=Math.round(widths[i] + 0.5f); } paint.setTypeface(savedTypeface); return width; }
Example 11
From project NotePad, under directory /src/com/nononsenseapps/notepad/.
Source file: NotesEditorFragment.java

private void setFontSettings(){ if (mText != null && mTitle != null) { float size=PreferenceManager.getDefaultSharedPreferences(activity).getInt(MainPrefs.KEY_FONT_SIZE_EDITOR,getResources().getInteger(R.integer.default_editor_font_size)); Typeface tf=TextPreviewPreference.getTypeface(PreferenceManager.getDefaultSharedPreferences(activity).getString(MainPrefs.KEY_FONT_TYPE_EDITOR,MainPrefs.SANS)); mText.setTextSize(size); mText.setTypeface(tf); mTitle.setTextSize(size); mTitle.setTypeface(tf); mTitle.setPaintFlags(mTitle.getPaintFlags() | Paint.FAKE_BOLD_TEXT_FLAG); } }
Example 12
From project npr-android-app, under directory /src/org/npr/android/util/.
Source file: TypefaceCache.java

public static Typeface getTypeface(String file,Context context){ Typeface result=map.get(file); if (result == null) { result=Typeface.createFromAsset(context.getAssets(),file); map.put(file,result); } return result; }
Example 13
From project OAK, under directory /oak-library/src/main/java/oak/.
Source file: TextViewWithFont.java

public static Typeface getStaticTypeFace(Context context,String fontFileName){ if (mFontMap == null) { initializeFontMap(context); } Typeface typeface=mFontMap.get(fontFileName); if (typeface == null) { throw new IllegalArgumentException("Font name must match file name in assets/fonts/ directory: " + fontFileName); } return typeface; }
Example 14
From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.
Source file: AAMain.java

/** * Called when the activity is created and put into memory. This is where all GUI elements should be set up and any other member variables that is used throughout the class */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); articles=new ArrayList<Article>(); settings=this.getSharedPreferences("settings",0); AlarmReceiver.stopAlarm(this); adapter=new ArticleAdapter(this); this.setListAdapter(adapter); ib_refresh=(ImageButton)findViewById(R.id.ib_refresh); TextView tv=(TextView)findViewById(R.id.AATitle); Typeface face=Typeface.createFromAsset(getAssets(),"fonts/WREXHAM_.TTF"); tv.setTypeface(face); finishReceiver=new BroadcastReceiver(){ @Override public void onReceive( Context context, Intent intent){ articles.clear(); Bundle articleBundle=intent.getBundleExtra("articles"); ArrayList<String> titles=articleBundle.getStringArrayList("titles"); for ( String title : titles) articles.add((Article)articleBundle.getSerializable(title)); progressDialog.cancel(); refresh(); } } ; this.registerReceiver(finishReceiver,new IntentFilter("RSSFinish")); ib_refresh.setOnClickListener(new OnClickListener(){ /** * Handles when the user clicks the refresh button * @param v - view that was clicked */ @Override public void onClick( View v){ runService(); } } ); runService(); }
Example 15
From project andlytics, under directory /src/com/github/andlyticsproject/.
Source file: BaseChartListAdapter.java

@Override public final View getView(int position,View convertView,ViewGroup parent){ int i; ViewHolder holder; if (convertView == null) { convertView=activity.getLayoutInflater().inflate(R.layout.base_chart_list_item,null); holder=new ViewHolder(maxColumns + (usesSmooth ? 1 : 0)); for (i=0; i < maxColumns; i++) { holder.fields[i]=createTextView("",false,i > 0); if (i > 0) { holder.fields[i].setOnClickListener(columnClickListener); holder.fields[i].setTag(i); } ((ViewGroup)convertView).addView(holder.fields[i]); } if (usesSmooth) { holder.fields[i]=createTextView("*",false,false); ((ViewGroup)convertView).addView(holder.fields[i],1); } convertView.setTag(holder); } else { holder=(ViewHolder)convertView.getTag(); } Typeface typeface=holder.fields[0].getTypeface(); for (i=0; i < maxColumns; i++) holder.fields[i].setTypeface(typeface,Typeface.NORMAL); int diff=maxColumns - numColumns[currentPage]; for (i=0; i < maxColumns; i++) holder.fields[i].setVisibility(View.VISIBLE); if (numColumns[currentPage] < maxColumns) { for (i=maxColumns - diff; i < maxColumns; i++) holder.fields[i].setVisibility(View.GONE); } updateChartValue(position,currentPage,0,holder.fields[0]); for (i=1; i < numColumns[currentPage]; i++) updateChartValue(position,currentPage,i,holder.fields[i]); holder.fields[currentColumn].setTypeface(typeface,Typeface.BOLD); if (usesSmooth) { holder.fields[holder.fields.length - 1].setVisibility(isSmothValue(currentPage,position) ? View.VISIBLE : View.INVISIBLE); } return convertView; }
Example 16
From project Android, under directory /app/src/main/java/com/github/mobile/ui/gist/.
Source file: GistFragment.java

private void updateFiles(Gist gist){ final Activity activity=getActivity(); if (activity == null) return; for ( View header : fileHeaders) adapter.removeHeader(header); fileHeaders.clear(); Map<String,GistFile> files=gist.getFiles(); if (files == null || files.isEmpty()) return; final LayoutInflater inflater=activity.getLayoutInflater(); final Typeface octicons=TypefaceUtils.getOcticons(activity); for ( GistFile file : files.values()) { View fileView=inflater.inflate(layout.gist_file_item,null); ((TextView)fileView.findViewById(id.tv_file)).setText(file.getFilename()); ((TextView)fileView.findViewById(id.tv_file_icon)).setTypeface(octicons); adapter.addHeader(fileView,file,true); fileHeaders.add(fileView); } }
Example 17
From project android_packages_apps_QiblaCompass, under directory /src/com/farsitel/qiblacompass/activities/.
Source file: QiblaActivity.java

/** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); registerListeners(); 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; try { isGPS=Boolean.parseBoolean(perfs.getString(gpsPerfKey,"false")); } catch ( ClassCastException e) { isGPS=perfs.getBoolean(gpsPerfKey,false); } if (!isGPS) { unregisterForGPS(); useDefaultLocation(perfs,getString(R.string.state_location_pref_key)); } else { registerForGPS(); onGPSOn(); } this.qiblaImageView=(ImageView)findViewById(R.id.arrowImage); this.compassImageView=(ImageView)findViewById(R.id.compassImage); }
Example 18
From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/activities/mission/.
Source file: MissionDialog.java

private void applyTypeface(){ TextView a=(TextView)findViewById(R.id.textView1); TextView b=(TextView)findViewById(R.id.textView2); TextView c=(TextView)findViewById(R.id.textView3); TextView d=(TextView)findViewById(R.id.textView4); TextView e=(TextView)findViewById(R.id.textView5); TextView f=(TextView)findViewById(R.id.textView6); TextView g=(TextView)findViewById(R.id.textView7); TextView h=(TextView)findViewById(R.id.textView8); TextView b1=(TextView)findViewById(R.id.button1); TextView b2=(TextView)findViewById(R.id.button2); TextView red=(TextView)findViewById(R.id.redtw); Button bt1=(Button)findViewById(R.id.button1); Button bt2=(Button)findViewById(R.id.button2); Typeface marke=CustomFonts.handWriteFont(currentContext); a.setTypeface(marke); b.setTypeface(marke); c.setTypeface(marke); d.setTypeface(marke); e.setTypeface(marke); f.setTypeface(marke); g.setTypeface(marke); h.setTypeface(marke); b1.setTypeface(marke); b2.setTypeface(marke); bt1.setTypeface(marke); bt2.setTypeface(marke); red.setTypeface(marke); }
Example 19
/** * Create the activity and display the card bundled in the intent. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); if (BuzzWordsApplication.DEBUG) { Log.d(TAG,"onCreate()"); } this.setContentView(R.layout.editteamname); setupViewReferences(); Typeface antonFont=Typeface.createFromAsset(getAssets(),"fonts/Anton.ttf"); TextView label=(TextView)this.findViewById(R.id.EditTeamName_Title); label.setTypeface(antonFont); Intent curIntent=this.getIntent(); Bundle teamBundle=curIntent.getExtras(); mTeam=(Team)teamBundle.getSerializable(getString(R.string.teamBundleKey)); mEditTeamName.setText(mTeam.getName()); mEditTeamName.setSelection(mEditTeamName.getText().length()); TextView hint=(TextView)this.findViewById(R.id.EditTeamName_Hint); hint.setText(getString(R.string.editTeamName_hint,mTeam.getDefaultName())); mButtonCancel.setOnClickListener(mCancelListener); mButtonAccept.setOnClickListener(mAcceptListener); }
Example 20
From project cocos2d, under directory /cocos2d-android/src/org/cocos2d/opengl/.
Source file: CCTexture2D.java

private static CGSize calculateTextSize(String text,String fontname,float fontSize){ Typeface typeface; if (!typefaces.containsKey(fontname)) { try { CCDirector.theApp.getAssets().open(fontname); typeface=Typeface.createFromAsset(CCDirector.theApp.getAssets(),fontname); } catch ( IOException e) { typeface=Typeface.create(fontname,Typeface.NORMAL); } typefaces.put(fontname,typeface); } else { typeface=typefaces.get(fontname); } Paint textPaint=new Paint(); textPaint.setTypeface(typeface); textPaint.setTextSize(fontSize); textPaint.setAntiAlias(true); int ascent=(int)Math.ceil(-textPaint.ascent()); int descent=(int)Math.ceil(textPaint.descent()); int measuredTextWidth=(int)Math.ceil(textPaint.measureText(text)); return CGSize.make(measuredTextWidth,ascent + descent); }
Example 21
From project cw-android, under directory /Fonts/FontSampler/src/com/commonsware/android/fonts/.
Source file: FontSampler.java

@Override public void onCreate(Bundle icicle){ super.onCreate(icicle); setContentView(R.layout.main); TextView tv=(TextView)findViewById(R.id.custom); Typeface face=Typeface.createFromAsset(getAssets(),"fonts/HandmadeTypewriter.ttf"); tv.setTypeface(face); File font=new File(Environment.getExternalStorageDirectory(),"MgOpenCosmeticaBold.ttf"); if (font.exists()) { tv=(TextView)findViewById(R.id.file); face=Typeface.createFromFile(font); tv.setTypeface(face); } else { findViewById(R.id.filerow).setVisibility(View.GONE); } }
Example 22
From project cw-omnibus, under directory /Fonts/FontSampler/src/com/commonsware/android/fonts/.
Source file: FontSampler.java

@Override public void onCreate(Bundle icicle){ super.onCreate(icicle); setContentView(R.layout.main); TextView tv=(TextView)findViewById(R.id.custom); Typeface face=Typeface.createFromAsset(getAssets(),"fonts/HandmadeTypewriter.ttf"); tv.setTypeface(face); File font=new File(Environment.getExternalStorageDirectory(),"MgOpenCosmeticaBold.ttf"); if (font.exists()) { tv=(TextView)findViewById(R.id.file); face=Typeface.createFromFile(font); tv.setTypeface(face); } else { findViewById(R.id.filerow).setVisibility(View.GONE); } }
Example 23
From project E12Planner, under directory /src/com/neoware/europlanner/.
Source file: PlannerHomeActivity.java

@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); LinearLayout newsLayout=(LinearLayout)findViewById(R.id.news_button); newsLayout.setOnClickListener(this); LinearLayout teamsLayout=(LinearLayout)findViewById(R.id.teams_button); teamsLayout.setOnClickListener(this); LinearLayout venuesLayout=(LinearLayout)findViewById(R.id.venues_button); venuesLayout.setOnClickListener(this); LinearLayout gamesLayout=(LinearLayout)findViewById(R.id.games_button); gamesLayout.setOnClickListener(this); Typeface font=Typeface.createFromAsset(getAssets(),fontName); TextView newsTv=(TextView)findViewById(R.id.newsMenuTv); newsTv.setTypeface(font); TextView gamesTv=(TextView)findViewById(R.id.gamesMenuTv); gamesTv.setTypeface(font); TextView venuesTv=(TextView)findViewById(R.id.venuesMenuTv); venuesTv.setTypeface(font); TextView teamsTv=(TextView)findViewById(R.id.teamsMenuTv); teamsTv.setTypeface(font); }
Example 24
From project FBReaderJ, under directory /src/org/geometerplus/zlibrary/ui/android/view/.
Source file: AndroidFontUtil.java

public static Typeface typeface(String family,boolean bold,boolean italic){ family=realFontFamilyName(family); final int style=(bold ? Typeface.BOLD : 0) | (italic ? Typeface.ITALIC : 0); Typeface[] typefaces=ourTypefaces.get(family); if (typefaces == null) { typefaces=new Typeface[4]; ourTypefaces.put(family,typefaces); } Typeface tf=typefaces[style]; if (tf == null) { File[] files=getFontMap(false).get(family); if (files != null) { try { if (files[style] != null) { tf=createFontFromFile(files[style]); } else { for (int i=0; i < 4; ++i) { if (files[i] != null) { tf=(typefaces[i] != null) ? typefaces[i] : createFontFromFile(files[i]); typefaces[i]=tf; break; } } } } catch ( Throwable e) { } } if (tf == null) { tf=Typeface.create(family,style); } typefaces[style]=tf; } return tf; }
Example 25
From project finch, under directory /src/com/bourke/finch/activities/.
Source file: BaseFinchActivity.java

private void initActionBar(){ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { BitmapDrawable bg=(BitmapDrawable)getResources().getDrawable(R.drawable.bg_light_grey_stripe); bg.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); getSupportActionBar().setBackgroundDrawable(bg); } getSupportActionBar().setDisplayShowHomeEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true); mActionCustomView=getLayoutInflater().inflate(R.layout.actionbar_layout,null); mUnreadCountView=(TextView)mActionCustomView.findViewById(R.id.ab_text_unread_count); TextView titleTextView=(TextView)mActionCustomView.findViewById(R.id.ab_text_title); Typeface typeface=Typeface.createFromAsset(getAssets(),Constants.SHADOWS_INTO_LIGHT_REG); titleTextView.setTypeface(typeface); titleTextView.setText("Finch"); getSupportActionBar().setCustomView(mActionCustomView); ViewTreeObserver vto=mActionCustomView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener(){ @Override public void onGlobalLayout(){ mActionCustomView.getViewTreeObserver().removeGlobalOnLayoutListener(this); showUserInActionbar(false); } } ); }
Example 26
From project God-Save-The-Bag, under directory /src/com/estudio/cheke/game/gstb/.
Source file: SVGParser.java

private boolean doText(Attributes atts,Paint paint){ if ("none".equals(atts.getValue("display"))) { return false; } if (atts.getValue("font-size") != null) { paint.setTextSize(getFloatAttr("font-size",atts,10f)); } Typeface typeface=setTypeFace(atts); if (typeface != null) { paint.setTypeface(typeface); } Align align=getTextAlign(atts); if (align != null) { paint.setTextAlign(getTextAlign(atts)); } return true; }
Example 27
From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/text/style/.
Source file: StyleSpan.java

private static void apply(Paint paint,int style){ int oldStyle; Typeface old=paint.getTypeface(); if (old == null) { oldStyle=0; } else { oldStyle=old.getStyle(); } int want=oldStyle | style; Typeface tf; if (old == null) { tf=Typeface.defaultFromStyle(want); } else { tf=Typeface.create(old,want); } int fake=want & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); }
Example 28
From project mediautilities, under directory /src/com/larvalabs/svgandroid/.
Source file: SVGParser.java

private boolean doText(Attributes atts,Paint paint){ if ("none".equals(atts.getValue("display"))) { return false; } if (atts.getValue("font-size") != null) { paint.setTextSize(getFloatAttr("font-size",atts,10f)); } Typeface typeface=setTypeFace(atts); if (typeface != null) { paint.setTypeface(typeface); } Align align=getTextAlign(atts); if (align != null) { paint.setTextAlign(getTextAlign(atts)); } return true; }
Example 29
/** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); Typeface timerFont=Typeface.createFromAsset(getAssets(),"fonts/Clockopia.ttf"); recordingButton=((ToggleButton)findViewById(R.id.recording_button)); Button libraryButton=((Button)findViewById(R.id.library_button)); Button instrumentalButton=((Button)findViewById(R.id.instrumental_button)); TextView timerDisplay=(TextView)findViewById(R.id.recording_timer); recordingButton.setChecked(false); recordingButton.setOnCheckedChangeListener(recordBtnListener); libraryButton.setOnClickListener(this); instrumentalButton.setOnClickListener(this); timerDisplay.setTypeface(timerFont); timer=new Timer(timerDisplay); autotalentTask=new AutotalentTask(Mic.this,postAutotalentTask); if (PreferenceHelper.getScreenLock(Mic.this)) { PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE); wakeLock=pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"recordingWakeLock"); } if (UpdateHelper.isAppUpdated(Mic.this)) { UpdateHelper.onAppUpdate(Mic.this); } else { AudioHelper.configureRecorder(Mic.this); } }
Example 30
From project MWM-for-Android, under directory /src/org/metawatch/manager/.
Source file: NotificationBuilder.java

static Bitmap smartLines(Context context,String iconPath,String[] lines){ String font=null; int size=8; int realSize=7; switch (Preferences.fontSize) { case FontSize.SMALL: font="metawatch_8pt_5pxl_CAPS.ttf"; realSize=5; break; case FontSize.MEDIUM: font="metawatch_8pt_7pxl_CAPS.ttf"; realSize=7; break; case FontSize.LARGE: font="metawatch_16pt_11pxl.ttf"; realSize=11; size=16; break; } Bitmap bitmap=Bitmap.createBitmap(96,96,Bitmap.Config.RGB_565); Canvas canvas=new Canvas(bitmap); Paint paint=new Paint(); paint.setColor(Color.BLACK); paint.setTextSize(size); Typeface typeface=Typeface.createFromAsset(context.getAssets(),font); paint.setTypeface(typeface); canvas.drawColor(Color.WHITE); Bitmap icon=Utils.loadBitmapFromAssets(context,iconPath); int spaceForItem=96 / (1 + lines.length); canvas.drawBitmap(icon,96 / 2 - icon.getWidth() / 2,spaceForItem / 2 - icon.getHeight() / 2,paint); for (int i=0; i < lines.length; i++) { int x=(int)(96 / 2 - paint.measureText(lines[i]) / 2); if (x < 0) x=0; int y=spaceForItem * (i + 1) + spaceForItem / 2 + realSize / 2; canvas.drawText(lines[i],x,y,paint); } return bitmap; }
Example 31
From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/app/.
Source file: AmenoidApp.java

@Override public void onCreate(){ this.cache=new SimpleWebImageCache<ThumbnailBus,ThumbnailMessage>(null,null,101,bus); Config.init(getApplicationContext()); DEVELOPER_MODE=getResources().getBoolean(R.bool.debuggable); if (getResources().getBoolean(R.bool.strict)) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyDropBox().penaltyLog().build()); } super.onCreate(); prefs=PreferenceManager.getDefaultSharedPreferences(this); amenTypeThin=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeThin.ttf"); amenTypeBold=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeBold.ttf"); instance=this; builder=new AlertDialog.Builder(this); Log.v(TAG,"onCreate"); final String authToken=readAuthTokenFromPrefs(prefs); final User me=readMeFromPrefs(prefs); String email=prefs.getString(Constants.PREFS_EMAIL,null); if (TextUtils.isEmpty(email)) { email=prefs.getString(Constants.PREFS_USER_NAME,""); if (!TextUtils.isEmpty(email) && email.contains("@")) { SharedPreferences.Editor editor=prefs.edit(); editor.putString(Constants.PREFS_EMAIL,email); editor.commit(); } } final String password=prefs.getString(Constants.PREFS_PASSWORD,null); if (authToken != null && me != null) { configureAmenService(); service.init(authToken,me); } else if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) { getService(email,password); } else { getService(); } }
Example 32
From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.
Source file: ConflictsActivity.java

/** * Shows or hides conflicts warning text below the list view and above add/sync buttons. It should be visible only when at least one field is in conflict. * @param isVisible Whether warning should be visible. */ private void showWarning(final boolean isVisible){ mWarningText.setVisibility(isVisible ? View.VISIBLE : View.GONE); StyleSpan boldSpan=new StyleSpan(Typeface.BOLD); String text=mWarningText.getText().toString(); if (text.contains("|")) { SpannableStringBuilder ssb=new SpannableStringBuilder(text); ssb.setSpan(boldSpan,0,text.indexOf(':'),Spannable.SPAN_INCLUSIVE_INCLUSIVE); Bitmap syncIcon=BitmapFactory.decodeResource(getResources(),R.drawable.ic_sync); int syncIndex=text.indexOf('|'); ssb.setSpan(new ImageSpan(syncIcon),syncIndex,syncIndex + 1,Spannable.SPAN_INCLUSIVE_INCLUSIVE); mWarningText.setText(ssb,BufferType.SPANNABLE); } }
Example 33
From project android-client_2, under directory /src/org/mifos/androidclient/util/.
Source file: TabColorUtils.java

public static void setTabColor(TabHost tabs){ for (int i=0; i < tabs.getTabWidget().getChildCount(); i++) { tabs.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#F2D1A6")); TextView tv=(TextView)tabs.getTabWidget().getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(Color.parseColor("#000166")); tv.setTypeface(Typeface.DEFAULT_BOLD); } tabs.getTabWidget().getChildAt(tabs.getCurrentTab()).setBackgroundColor(Color.parseColor("#FF9600")); TextView tv=(TextView)tabs.getTabWidget().getChildAt(tabs.getCurrentTab()).findViewById(android.R.id.title); tv.setTextColor(Color.parseColor("#ffffff")); tv.setTypeface(Typeface.DEFAULT_BOLD); }
Example 34
From project android-joedayz, under directory /Proyectos/AndroidFoursquare/src/com/mycompany/fsq/.
Source file: FoursquareDialog.java

private void setUpTitle(){ requestWindowFeature(Window.FEATURE_NO_TITLE); Drawable icon=getContext().getResources().getDrawable(R.drawable.foursquare_icon); mTitle=new TextView(getContext()); mTitle.setText("Foursquare"); mTitle.setTextColor(Color.WHITE); mTitle.setTypeface(Typeface.DEFAULT_BOLD); mTitle.setBackgroundColor(0xFF0cbadf); mTitle.setPadding(MARGIN + PADDING,MARGIN,MARGIN,MARGIN); mTitle.setCompoundDrawablePadding(MARGIN + PADDING); mTitle.setCompoundDrawablesWithIntrinsicBounds(icon,null,null,null); mContent.addView(mTitle); }
Example 35
From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.
Source file: CanvasRenderer.java

@Override void setupRenderer(Bitmap bitmap){ this.canvas=new Canvas(bitmap); this.symbolMatrix=new Matrix(); this.bitmapFilterPaint=new Paint(Paint.FILTER_BITMAP_FLAG); this.tileFrame=new float[]{0,0,0,Tile.TILE_SIZE,0,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,0}; this.path=new Path(); this.path.setFillType(Path.FillType.EVEN_ODD); this.stringBuilder=new StringBuilder(16); PAINT_TILE_COORDINATES.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); PAINT_TILE_COORDINATES.setTextSize(20); PAINT_TILE_COORDINATES_STROKE.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); PAINT_TILE_COORDINATES_STROKE.setStyle(Paint.Style.STROKE); PAINT_TILE_COORDINATES_STROKE.setStrokeWidth(5); PAINT_TILE_COORDINATES_STROKE.setTextSize(20); PAINT_TILE_COORDINATES_STROKE.setColor(Color.WHITE); }
Example 36
From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/language/.
Source file: TranslateAsyncTask.java

@Override protected synchronized void onPostExecute(Boolean result){ super.onPostExecute(result); if (result) { if (targetLanguageTextView != null) { targetLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL),Typeface.NORMAL); } textView.setText(translatedText); textView.setVisibility(View.VISIBLE); textView.setTextColor(activity.getResources().getColor(R.color.translation_text)); int scaledSize=Math.max(22,32 - translatedText.length() / 4); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,scaledSize); } else { Log.e(TAG,"FAILURE"); targetLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC); targetLanguageTextView.setText("Unavailable"); } if (progressView != null) { progressView.setVisibility(View.GONE); } }
Example 37
From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/list/view/.
Source file: TaskView.java

private void updateWhen(Task task){ if (Preferences.displayDueDate(getContext())) { CharSequence dateRange=DateUtils.displayDateRange(getContext(),task.getStartDate(),task.getDueDate(),!task.isAllDay()); mDateDisplay.setText(dateRange); if (task.getDueDate() < System.currentTimeMillis()) { mDateDisplay.setTypeface(Typeface.DEFAULT_BOLD); mDateDisplay.setTextColor(Color.RED); } else { mDateDisplay.setTypeface(Typeface.DEFAULT); mDateDisplay.setTextColor(getContext().getResources().getColor(R.drawable.dark_blue)); } mDateDisplay.setVisibility(View.VISIBLE); } else { mDateDisplay.setVisibility(View.INVISIBLE); } }
Example 38
From project Android-Terminal-Emulator, under directory /libraries/emulatorview/src/jackpal/androidterm/emulatorview/.
Source file: PaintRenderer.java

public PaintRenderer(int fontSize,ColorScheme scheme){ super(scheme); mTextPaint=new Paint(); mTextPaint.setTypeface(Typeface.MONOSPACE); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(fontSize); mCharHeight=(int)FloatMath.ceil(mTextPaint.getFontSpacing()); mCharAscent=(int)FloatMath.ceil(mTextPaint.ascent()); mCharDescent=mCharHeight + mCharAscent; mCharWidth=mTextPaint.measureText(EXAMPLE_CHAR,0,1); }
Example 39
From project android-viewflow, under directory /viewflow/src/org/taptwo/android/widget/.
Source file: TitleFlowIndicator.java

/** * The contructor used with an inflater * @param context * @param attrs */ public TitleFlowIndicator(Context context,AttributeSet attrs){ super(context,attrs); int typefaceIndex=attrs.getAttributeIntValue("http://schemas.android.com/apk/res/android","typeface",0); int textStyleIndex=attrs.getAttributeIntValue("http://schemas.android.com/apk/res/android","textStyle",0); TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.TitleFlowIndicator); String customTypeface=a.getString(R.styleable.TitleFlowIndicator_customTypeface); int footerColor=a.getColor(R.styleable.TitleFlowIndicator_footerColor,FOOTER_COLOR); footerLineHeight=a.getDimension(R.styleable.TitleFlowIndicator_footerLineHeight,FOOTER_LINE_HEIGHT); footerTriangleHeight=a.getDimension(R.styleable.TitleFlowIndicator_footerTriangleHeight,FOOTER_TRIANGLE_HEIGHT); int selectedColor=a.getColor(R.styleable.TitleFlowIndicator_selectedColor,SELECTED_COLOR); boolean selectedBold=a.getBoolean(R.styleable.TitleFlowIndicator_selectedBold,SELECTED_BOLD); int textColor=a.getColor(R.styleable.TitleFlowIndicator_textColor,TEXT_COLOR); float textSize=a.getDimension(R.styleable.TitleFlowIndicator_textSize,TEXT_SIZE); float selectedSize=a.getDimension(R.styleable.TitleFlowIndicator_selectedSize,textSize); titlePadding=a.getDimension(R.styleable.TitleFlowIndicator_titlePadding,TITLE_PADDING); clipPadding=a.getDimension(R.styleable.TitleFlowIndicator_clipPadding,CLIP_PADDING); initDraw(textColor,textSize,selectedColor,selectedBold,selectedSize,footerLineHeight,footerColor); if (customTypeface != null) typeface=Typeface.createFromAsset(context.getAssets(),customTypeface); else typeface=getTypefaceByIndex(typefaceIndex); typeface=Typeface.create(typeface,textStyleIndex); }
Example 40
From project android-wheel, under directory /wheel/src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 41
From project android-wheel-datetime-picker, under directory /src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 42
From project android-wheel_1, under directory /wheel/src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 43
From project androidquery, under directory /src/com/androidquery/.
Source file: AbstractAQuery.java

/** * Set the text typeface of a TextView. * @param typeface typeface * @return self */ public T typeface(Typeface tf){ if (view instanceof TextView) { TextView tv=(TextView)view; tv.setTypeface(tf); } return self(); }
Example 44
From project android_7, under directory /src/org/immopoly/android/widget/.
Source file: ClusterMarker.java

static void init(DisplayMetrics displayMetrics,int markerHeight){ textSize=(int)(TEXT_SIZE_DP * displayMetrics.density + 0.5f); textY=6 * displayMetrics.density; textX=-2.5f * displayMetrics.density; textPaint.setColor(0xFFFFFFFF); textPaint.setTextSize(textSize); textPaint.setAntiAlias(true); textPaint.setTextAlign(Align.CENTER); textPaint.setTypeface(Typeface.DEFAULT_BOLD); shadowPaint.setColor(0xFFB25200); shadowPaint.setTextSize(textSize); shadowPaint.setAntiAlias(true); shadowPaint.setTextAlign(Align.CENTER); shadowPaint.setFlags(Paint.FAKE_BOLD_TEXT_FLAG); }
Example 45
From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/fuelgauge/.
Source file: BatteryHistoryChart.java

public void setTypeface(Typeface tf,int style){ if (style > 0) { if (tf == null) { tf=Typeface.defaultFromStyle(style); } else { tf=Typeface.create(tf,style); } mTextPaint.setTypeface(tf); int typefaceStyle=tf != null ? tf.getStyle() : 0; int need=style & ~typefaceStyle; mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0); mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0); } else { mTextPaint.setFakeBoldText(false); mTextPaint.setTextSkewX(0); mTextPaint.setTypeface(tf); } }
Example 46
From project android_ioio_combination_lock, under directory /src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 47
From project android_packages_apps_CellBroadcastReceiver, under directory /src/com/android/cellbroadcastreceiver/.
Source file: CellBroadcastListItem.java

private static CharSequence formatMessage(CellBroadcastMessage message){ String body=message.getMessageBody(); SpannableStringBuilder buf=new SpannableStringBuilder(body); if (!message.isRead()) { buf.setSpan(Typeface.DEFAULT_BOLD,0,buf.length(),Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } return buf; }
Example 48
From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/ui/.
Source file: AlbumLabelMaker.java

private static TextPaint getTextPaint(int textSize,int color,boolean isBold){ TextPaint paint=new TextPaint(); paint.setTextSize(textSize); paint.setAntiAlias(true); paint.setColor(color); paint.setShadowLayer(2f,0f,0f,Color.BLACK); if (isBold) { paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); } return paint; }
Example 49
From project android_packages_apps_phone, under directory /src/com/android/phone/.
Source file: InCallScreen.java

private View createWildPromptView(){ LinearLayout result=new LinearLayout(this); result.setOrientation(LinearLayout.VERTICAL); result.setPadding(5,5,5,5); LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT); TextView promptMsg=new TextView(this); promptMsg.setTextSize(14); promptMsg.setTypeface(Typeface.DEFAULT_BOLD); promptMsg.setText(getResources().getText(R.string.wild_prompt_str)); result.addView(promptMsg,lp); mWildPromptText=new EditText(this); mWildPromptText.setKeyListener(DialerKeyListener.getInstance()); mWildPromptText.setMovementMethod(null); mWildPromptText.setTextSize(14); mWildPromptText.setMaxLines(1); mWildPromptText.setHorizontallyScrolling(true); mWildPromptText.setBackgroundResource(android.R.drawable.editbox_background); LinearLayout.LayoutParams lp2=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT); lp2.setMargins(0,3,0,0); result.addView(mWildPromptText,lp2); return result; }
Example 50
From project android_packages_apps_QuickSearchBox, under directory /src/com/android/quicksearchbox/.
Source file: SearchWidgetProvider.java

private static CharSequence formatVoiceSearchHint(Context context,CharSequence hint){ if (TextUtils.isEmpty(hint)) return null; SpannableStringBuilder spannedHint=new SpannableStringBuilder(context.getString(R.string.voice_search_hint_quotation_start)); spannedHint.append(hint); Object[] items=spannedHint.getSpans(0,spannedHint.length(),Object.class); for ( Object item : items) { if (item instanceof Annotation) { Annotation annotation=(Annotation)item; if (annotation.getKey().equals("action") && annotation.getValue().equals("true")) { final int start=spannedHint.getSpanStart(annotation); final int end=spannedHint.getSpanEnd(annotation); spannedHint.removeSpan(item); spannedHint.setSpan(new StyleSpan(Typeface.BOLD),start,end,0); } } } spannedHint.append(context.getString(R.string.voice_search_hint_quotation_end)); return spannedHint; }
Example 51
From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.
Source file: AppListItem.java

/** * Sets section header or makes it invisible if the title is null. */ public void setSectionHeader(String title){ if (!TextUtils.isEmpty(title)) { if (mHeaderTextView == null) { mHeaderTextView=new TextView(mContext); mHeaderTextView.setTypeface(mHeaderTextView.getTypeface(),Typeface.BOLD); mHeaderTextView.setTextColor(mContext.getResources().getColor(R.color.dim_foreground_light)); mHeaderTextView.setTextSize(14); mHeaderTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); addView(mHeaderTextView); } mHeaderTextView.setText(title); mHeaderTextView.setVisibility(View.VISIBLE); mHeaderVisible=true; } else { if (mHeaderTextView != null) { mHeaderTextView.setVisibility(View.GONE); } mHeaderVisible=false; } }
Example 52
From project apps-for-android, under directory /CLiCkin2DaBeaT/src/com/google/clickin2dabeat/.
Source file: GameView.java

@Override public void onDraw(Canvas canvas){ if (parent.mode != C2B.GAME_MODE) { return; } int currentTime=parent.getCurrentTime(); for (int i=0; i < drawnTargets.size(); i++) { Target t=drawnTargets.get(i); if (t == null) { break; } canvas.drawCircle(t.x,t.y,TARGET_RADIUS,innerPaint); borderPaint.setColor(t.color); haloPaint.setColor(t.color); canvas.drawCircle(t.x,t.y,TARGET_RADIUS - 5,borderPaint); canvas.drawCircle(t.x,t.y,TARGET_RADIUS,borderPaint); float percentageOff=((float)(t.time - currentTime)) / PRE_THRESHOLD; int haloSize=(int)(TARGET_RADIUS + (percentageOff * TARGET_RADIUS)); canvas.drawCircle(t.x,t.y,haloSize,haloPaint); } String scoreText="Score: " + Integer.toString(score); int x=getWidth() - 100; int y=30; Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.RED); paint.setTextAlign(Paint.Align.CENTER); paint.setTextSize(24); paint.setTypeface(Typeface.DEFAULT_BOLD); y-=paint.ascent() / 2; canvas.drawText(scoreText,x,y,paint); x=getWidth() / 2; canvas.drawText(lastRating,x,y,paint); String comboText="Combo: " + Integer.toString(comboCount); x=60; canvas.drawText(comboText,x,y,paint); }
Example 53
From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + mLabelPaddingLeft; final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 54
From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/ui/fragment/.
Source file: TwunchListFragment.java

@Override public void bindView(View view,Context context,Cursor cursor){ ViewHolder vh=(ViewHolder)view.getTag(); vh.title.setText(cursor.getString(TwunchesQuery.NAME)); vh.address.setText(cursor.getString(TwunchesQuery.ADDRESS)); vh.address.setTypeface(null,cursor.getInt(TwunchesQuery.NEW) == 1 ? Typeface.BOLD : Typeface.NORMAL); long distance=cursor.getLong(TwunchesQuery.DISTANCE); if (distance > 0) { vh.distance.setText(String.format(view.getContext().getString(R.string.distance),distance / 1000f)); vh.distance.setVisibility(View.VISIBLE); } else { vh.distance.setVisibility(View.INVISIBLE); } vh.date.setText(String.format(view.getContext().getString(R.string.date),DateUtils.formatDateTime(view.getContext(),cursor.getLong(TwunchesQuery.DATE),DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_DATE),DateUtils.formatDateTime(view.getContext(),cursor.getLong(TwunchesQuery.DATE),DateUtils.FORMAT_SHOW_TIME))); vh.date.setTypeface(null,cursor.getInt(TwunchesQuery.NEW) == 1 ? Typeface.BOLD : Typeface.NORMAL); int days=(int)((cursor.getLong(TwunchesQuery.DATE) - Util.getStartOfToday()) / DateUtils.DAY_IN_MILLIS); vh.days.setText(days == 0 ? getString(R.string.today) : String.format(getResources().getQuantityString(R.plurals.days_to_twunch,days),days)); }
Example 55
From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.
Source file: BirthdayWidget.java

private void addSpan(SpannableString caption,int daysToEvent){ if (daysToEvent < 6) { caption.setSpan(new StyleSpan(Typeface.BOLD),0,caption.length(),0); } if (daysToEvent < 2) { caption.setSpan(new ForegroundColorSpan(Color.RED),0,caption.length(),0); } }
Example 56
From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/util/.
Source file: ViewPagerTabs.java

public void addTabLabels(final int... labelResId){ final Context context=getContext(); paint.setTypeface(Typeface.DEFAULT_BOLD); for ( final int resId : labelResId) { final String label=context.getString(resId); final int width=(int)paint.measureText(label); if (width > maxWidth) maxWidth=width; labels.add(label); } }
Example 57
From project BookingRoom, under directory /src/org/androidaalto/bookingroom/view/.
Source file: ScreensaverView.java

private void drawMessage(Canvas canvas,Paint p){ p.setTextSize(BIG_FONT_SIZE); p.setTextAlign(Paint.Align.CENTER); p.setTypeface(Typeface.DEFAULT_BOLD); p.setAntiAlias(true); Rect bounds=mRect; p.getTextBounds(msg,0,msg.length(),bounds); int x=width / 2; int y=height - bounds.height() / 2; p.setColor(Color.WHITE); canvas.drawText(msg,x,y,p); }
Example 58
From project box-android-sdk, under directory /BoxAndroidLibrarySample/src/com/box/androidlib/sample/activity/.
Source file: Browse.java

@Override public View getView(int position,View convertView,ViewGroup parent){ TextView tv=new TextView(context); if (items[position].type == TreeListItem.TYPE_FOLDER) { tv.append("FOLDER: "); } else if (items[position].type == TreeListItem.TYPE_FILE) { tv.append("FILE: "); } tv.append(items[position].name); tv.append("\n"); tv.append(DateFormat.getDateFormat(getApplicationContext()).format(new Date(items[position].updated * 1000))); tv.setPadding(10,20,10,20); tv.setTypeface(Typeface.DEFAULT_BOLD); return tv; }
Example 59
From project BusFollower, under directory /src/net/argilo/busfollower/.
Source file: StopChooserActivity.java

@Override public View getView(int position,View v,ViewGroup parent){ RecentQuery query=queries.get(position); if (v == null) { LayoutInflater li=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v=li.inflate(resourceId,null); } TextView text1=(TextView)v.findViewById(android.R.id.text1); text1.setSingleLine(); text1.setEllipsize(TextUtils.TruncateAt.END); if (query.getRoute() == null) { text1.setTypeface(null,Typeface.BOLD); text1.setText(context.getString(R.string.stop_number) + " " + query.getStop().getNumber()+ " "+ query.getStop().getName()); } else { text1.setTypeface(null,Typeface.NORMAL); text1.setText(" \u00BB " + context.getString(R.string.route_number) + " "+ query.getRoute().getNumber()+ " "+ query.getRoute().getHeading()); } return v; }
Example 60
From project CalendarView_1, under directory /src/org/kazzz/view/calendar/.
Source file: MonthlyCalendarView.java

@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){ this.cellWidth=w / 7f; this.captionHeight=this.cellWidth / 2f; this.cellHeight=(h - this.captionHeight) / 6f; this.getRect(this.selCol,this.selRow,this.selRect); this.weekdayText.setStyle(Style.FILL); this.weekdayText.setTextSize(this.cellHeight * 0.35f); this.weekdayText.setTextScaleX(this.cellWidth / this.cellHeight); this.weekdayText.setTextAlign(Paint.Align.LEFT); this.weekdayText.setTypeface(Typeface.DEFAULT); this.metricsForD=weekdayText.getFontMetrics(); this.holidayText.setStyle(Style.FILL); this.holidayText.setTextSize(this.cellHeight * 0.17f); this.holidayText.setTextScaleX(this.cellWidth / this.cellHeight); this.holidayText.setTextAlign(Paint.Align.LEFT); this.metricsForH=holidayText.getFontMetrics(); super.onSizeChanged(w,h,oldw,oldh); }
Example 61
From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/utils/.
Source file: ActivityHelper.java

public boolean addActionButton(int buttonId,int imageResourceId,int textId,View.OnClickListener clickListener,boolean separatorAfter){ final ViewGroup actionBar=getActionBar(); if (actionBar == null) { return false; } ImageView separator=new ImageView(activity); separator.setLayoutParams(new ViewGroup.LayoutParams(2,ViewGroup.LayoutParams.FILL_PARENT)); separator.setBackgroundResource(R.drawable.actionbar_separator); if (!separatorAfter) { actionBar.addView(separator); } LinearLayout linearLayout=new LinearLayout(activity); linearLayout.setId(buttonId); linearLayout.setBackgroundResource(R.drawable.btn_actionbar_selector); linearLayout.setLayoutParams(new ViewGroup.LayoutParams(buttonWidth,buttonHeight)); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); ImageView image=new ImageView(activity); image.setImageResource(imageResourceId); image.setPadding(0,padding,0,0); TextView text=new TextView(activity); text.setTextSize(TypedValue.COMPLEX_UNIT_DIP,10); text.setGravity(Gravity.CENTER); text.setText(activity.getString(textId)); text.setTypeface(null,Typeface.BOLD); linearLayout.addView(image); linearLayout.addView(text); linearLayout.setClickable(true); linearLayout.setOnClickListener(clickListener); actionBar.addView(linearLayout); if (separatorAfter) { actionBar.addView(separator); } tvMaxWidth-=buttonWidth; titleText.setMaxWidth(tvMaxWidth); return true; }
Example 62
From project Common-Sense-Net-2, under directory /RealFarm/src/com/commonsensenet/realfarm/view/.
Source file: AdviceAdapter.java

private void setSituationView(View view,AdviceSituationItem group){ TextView tv; tv=(TextView)view.findViewById(R.id.center_text); tv.setTypeface(null,Typeface.NORMAL); tv.setText(group.getProblem().getShortName()); tv=(TextView)view.findViewById(R.id.loss); tv.setTypeface(null,Typeface.NORMAL); tv.setText(group.getRecommendation().getProbablity() + "% loss"); tv=(TextView)view.findViewById(R.id.percentage); tv.setTypeface(null,Typeface.NORMAL); tv.setText(""); ImageView iw; iw=(ImageView)view.findViewById(R.id.image_left); if (group.getProblem().getImage1() != -1) { iw.setImageResource(group.getProblem().getImage1()); } iw=(ImageView)view.findViewById(R.id.leftImage); BitmapFactory.Options options=new BitmapFactory.Options(); options.inTempStorage=new byte[16 * 1024]; options.inSampleSize=12; Bitmap bitmapImage=BitmapFactory.decodeFile(group.getPlotImage(),options); if (bitmapImage != null) { Matrix matrix=new Matrix(); matrix.postRotate(90); Bitmap rotatedImage=Bitmap.createBitmap(bitmapImage,0,0,bitmapImage.getWidth(),bitmapImage.getHeight(),matrix,true); iw.setImageBitmap(rotatedImage); } else { iw.setImageResource(R.drawable.ic_plots); } LinearLayout ll=(LinearLayout)view.findViewById(R.id.situation_row); setDatePassed(ll,1.0F); if (group.getRecommendation().getIsUnread() == 0) { ((TextView)(view.findViewById(R.id.center_text))).setTypeface(null,Typeface.BOLD); ((TextView)(view.findViewById(R.id.loss))).setTypeface(null,Typeface.BOLD); ((TextView)(view.findViewById(R.id.percentage))).setTypeface(null,Typeface.BOLD); } }
Example 63
From project conference-mobile-app, under directory /android-app/src/com/google/android/apps/iosched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + mLabelPaddingLeft; final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 64
From project connectbot, under directory /src/sk/vx/connectbot/util/.
Source file: EntropyView.java

private void setUpEntropy(){ mPaint=new Paint(); mPaint.setAntiAlias(true); mPaint.setTypeface(Typeface.DEFAULT); mPaint.setTextAlign(Paint.Align.CENTER); mPaint.setTextSize(16); mPaint.setColor(Color.WHITE); mFontMetrics=mPaint.getFontMetrics(); mEntropy=new byte[SHA1_MAX_BYTES]; mEntropyByteIndex=0; mEntropyBitIndex=0; listeners=new Vector<OnEntropyGatheredListener>(); }
Example 65
From project creamed_glacier_app_settings, under directory /src/com/android/settings/fuelgauge/.
Source file: BatteryHistoryChart.java

public void setTypeface(Typeface tf,int style){ if (style > 0) { if (tf == null) { tf=Typeface.defaultFromStyle(style); } else { tf=Typeface.create(tf,style); } mTextPaint.setTypeface(tf); int typefaceStyle=tf != null ? tf.getStyle() : 0; int need=style & ~typefaceStyle; mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0); mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0); } else { mTextPaint.setFakeBoldText(false); mTextPaint.setTextSkewX(0); mTextPaint.setTypeface(tf); } }
Example 66
From project date-slider, under directory /src/com/codeslap/dateslider/.
Source file: TimeView.java

/** * this method should be overwritten by inheriting classes to define its own look and feel * @param isCenterView true if the element is in the center of the scrollLayout * @param textSize textSize in dps */ void setupView(boolean isCenterView,float textSize){ setGravity(Gravity.CENTER); setTextSize(textSize); if (isCenterView) { setTypeface(Typeface.DEFAULT_BOLD); setTextColor(0xFF333333); } else { setTextColor(0xFF666666); } }
Example 67
From project DateSlider, under directory /src/com/googlecode/android/widgets/DateSlider/labeler/.
Source file: WeekLabeler.java

/** * Here we set up the text characteristics for the TextView, i.e. red colour, serif font and semi-transparent white background for the centerView... and shadow!!! */ @Override protected void setupView(boolean isCenterView,int textSize){ setGravity(Gravity.CENTER); setTextColor(0xFF883333); setTextSize(TypedValue.COMPLEX_UNIT_DIP,textSize); setTypeface(Typeface.SERIF); if (isCenterView) { setTypeface(Typeface.create(Typeface.SERIF,Typeface.BOLD)); setBackgroundColor(0x55FFFFFF); setShadowLayer(2.5f,3,3,0xFF999999); } }
Example 68
From project dccsched, under directory /src/com/underhilllabs/dccsched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + ((hourHeight - labelHeight) / 2); final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 69
From project dcnyc10-android, under directory /android/src/com/lullabot/android/apps/iosched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + mLabelPaddingLeft; final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 70
From project devoxx-france-android-in-fine, under directory /src/com/infine/android/devoxx/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + mLabelPaddingLeft; final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label=hour + "h00"; final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 71
From project DigitbooksExamples, under directory /DigitbooksExamples/src/fr/digitbooks/android/examples/chapitre07/.
Source file: BallsView.java

private void initializeBallsView(){ mBalls=new ArrayList<Ball>(); mBallBitmap=BitmapFactory.decodeResource(getResources(),R.drawable.ball); mState=STATE_STOPPED; mTextPaint.setColor(Color.RED); mTextPaint.setTextAlign(Align.CENTER); mTextPaint.setTypeface(Typeface.DEFAULT_BOLD); mTextPaint.setTextSize(13.0f); mRectPaint.setColor(Color.BLUE); mRectPaint.setStrokeWidth(3.0f); mRectPaint.setStyle(Style.STROKE); mRectPaint.setPathEffect(new DashPathEffect(new float[]{5,5},0)); }
Example 72
private void setUpTitle(){ requestWindowFeature(Window.FEATURE_NO_TITLE); Drawable icon=getContext().getResources().getDrawable(R.drawable.facebook_icon); mTitle=new TextView(getContext()); mTitle.setText("Facebook"); mTitle.setTextColor(Color.WHITE); mTitle.setTypeface(Typeface.DEFAULT_BOLD); mTitle.setBackgroundColor(FB_BLUE); mTitle.setPadding(MARGIN + PADDING,MARGIN,MARGIN,MARGIN); mTitle.setCompoundDrawablePadding(MARGIN + PADDING); mTitle.setCompoundDrawablesWithIntrinsicBounds(icon,null,null,null); mContent.addView(mTitle); }
Example 73
From project Ebento, under directory /src/mobisocial/bento/ebento/ui/.
Source file: RsvpFragment.java

private void setSelected(Button b){ if (UIUtils.isHoneycomb()) { b.setTextColor(getActivity().getResources().getColor(R.color.system_blue)); } else { b.setTextColor(getActivity().getResources().getColor(R.color.system_green)); } b.setTypeface(null,Typeface.BOLD); }
Example 74
From project eoit, under directory /EOIT/src/fr/eoit/activity/fragment/parameter/.
Source file: SeekBarPreference.java

@Override protected View onCreateView(ViewGroup parent){ LinearLayout layout=new LinearLayout(getContext()); layout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams params1=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); params1.gravity=Gravity.LEFT; params1.weight=1.0f; LinearLayout.LayoutParams params2=new LinearLayout.LayoutParams(80,LinearLayout.LayoutParams.WRAP_CONTENT); params2.gravity=Gravity.RIGHT; LinearLayout.LayoutParams params3=new LinearLayout.LayoutParams(30,LinearLayout.LayoutParams.WRAP_CONTENT); params3.gravity=Gravity.CENTER; layout.setPadding(15,5,10,5); layout.setOrientation(LinearLayout.HORIZONTAL); TextView view=new TextView(getContext()); view.setText(getTitle()); view.setTextSize(18); view.setTypeface(Typeface.SANS_SERIF,Typeface.NORMAL); view.setGravity(Gravity.LEFT); view.setLayoutParams(params1); SeekBar bar=new SeekBar(getContext()); bar.setMax(maximum); bar.setProgress(this.oldValue); bar.setLayoutParams(params2); bar.setOnSeekBarChangeListener(this); this.monitorBox=new TextView(getContext()); this.monitorBox.setTextSize(12); this.monitorBox.setTypeface(Typeface.MONOSPACE,Typeface.ITALIC); this.monitorBox.setLayoutParams(params3); this.monitorBox.setPadding(2,5,0,0); this.monitorBox.setText(bar.getProgress() + ""); layout.addView(view); layout.addView(bar); layout.addView(this.monitorBox); layout.setId(android.R.id.widget_frame); return layout; }
Example 75
From project evodroid, under directory /src/com/sonorth/evodroid/util/.
Source file: AppHtml.java

private static void endHeader(SpannableStringBuilder text){ int len=text.length(); Object obj=getLast(text,Header.class); int where=text.getSpanStart(obj); text.removeSpan(obj); while (len > where && text.charAt(len - 1) == '\n') { len--; } if (where != len) { Header h=(Header)obj; text.setSpan(new RelativeSizeSpan(HEADER_SIZES[h.mLevel]),where,len,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); text.setSpan(new StyleSpan(Typeface.BOLD),where,len,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }
Example 76
From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.
Source file: Notification.java

@Override public View getView(int position,View convertView,ViewGroup parent){ if (convertView == null) { LayoutInflater inf=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView=inf.inflate(R.layout.pl_listitem,null); } Notification post=(Notification)getItem(position); final ImageView profileImage=(ImageView)convertView.findViewById(R.id.profileImage); profileImage.setImageResource(R.drawable.ic_launcher); try { String piurl=post.photo; Log.i(TAG,"Going to download profile img: " + piurl); final TwAjax pidl=new TwAjax(getContext(),true,false); final File pifile=new File(Max.IMG_CACHE_DIR + "/pi_" + Max.cleanFilename(piurl)); if (pifile.isFile()) { profileImage.setImageURI(Uri.parse("file://" + pifile.getAbsolutePath())); } else { pidl.urlDownloadToFile(piurl,pifile.getAbsolutePath(),new Runnable(){ @Override public void run(){ profileImage.setImageURI(Uri.parse("file://" + pifile.getAbsolutePath())); } } ); } } catch ( Exception e) { } TextView userName=(TextView)convertView.findViewById(R.id.userName); userName.setText(post.content); if (!post.isUnread) userName.setTypeface(Typeface.DEFAULT); TextView htmlContent=(TextView)convertView.findViewById(R.id.htmlContent); htmlContent.setText(post.date); return convertView; }
Example 77
From project galaxyCar, under directory /galaxyCar/src/org/psywerx/car/view/.
Source file: StevecView.java

public StevecView(Context context,AttributeSet attrs){ super(context,attrs); mTimestamp=System.nanoTime(); mTextPaint=new Paint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setColor(Color.LTGRAY); mTextPaint.setTextSize(29); mTextPaint.setTypeface(Typeface.createFromAsset(context.getAssets(),"fonts/Digitaldream.ttf")); setSpeed(0); }
Example 78
From project GeekAlarm, under directory /android/src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 79
From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.
Source file: MessageView.java

private void appendTimeStamp(SpannableStringBuilder buf,Date date){ DateFormat format=new SimpleDateFormat(mResources.getString(R.string.time_stamp)); String dateStr=format.format(date); SpannableString spanText=new SpannableString(dateStr); int len=spanText.length(); spanText.setSpan(new StyleSpan(Typeface.ITALIC),0,len,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanText.setSpan(new RelativeSizeSpan(0.8f),0,len,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanText.setSpan(new ForegroundColorSpan(mResources.getColor(android.R.color.darker_gray)),0,len,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); buf.append('\n'); buf.append(spanText); }
Example 80
From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/actions/utils/.
Source file: GraphCanvas.java

public GraphCanvas(Context context,AttributeSet attrs,int defStyle){ super(context,attrs,defStyle); mContext=context; whiteText=new Paint(); whiteText.setColor(Color.WHITE); whiteText.setAntiAlias(true); whiteText.setTextSize((int)(density * 12)); whiteCenteredText=new Paint(); whiteCenteredText.setColor(Color.WHITE); whiteCenteredText.setAntiAlias(true); whiteCenteredText.setTextAlign(Paint.Align.CENTER); whiteCenteredText.setTextSize((int)(density * 12)); ltgreyMatrixDashed=new Paint(); ltgreyMatrixDashed.setColor(Color.LTGRAY); ltgreyMatrixDashed.setStrokeWidth(1); ltgreyMatrixDashed.setPathEffect(new DashPathEffect(new float[]{2,4},0)); greenGraphLine=new Paint(); greenGraphLine.setPathEffect(new CornerPathEffect(8)); greenGraphLine.setStyle(Paint.Style.STROKE); greenGraphLine.setStrokeWidth(4); greenGraphLine.setAntiAlias(true); greenGraphLine.setColor(Color.GREEN); dkgreyMatrixLine=new Paint(); dkgreyMatrixLine.setColor(Color.DKGRAY); dkgreyMatrixLine.setStrokeWidth(2); dkgrayLargeType=new Paint(); dkgrayLargeType.setColor(Color.LTGRAY); dkgrayLargeType.setAntiAlias(true); dkgrayLargeType.setTextAlign(Paint.Align.CENTER); dkgrayLargeType.setTextSize((int)(density * 21)); dkgrayLargeType.setTypeface(Typeface.DEFAULT_BOLD); }
Example 81
From project HtmlSpanner, under directory /src/main/java/net/nightwhistler/htmlspanner/.
Source file: HtmlSpanner.java

/** * Creates a new HtmlSpanner using the given HtmlCleaner instance. This allows for a custom-configured HtmlCleaner. * @param cleaner */ public HtmlSpanner(HtmlCleaner cleaner){ this.htmlCleaner=cleaner; this.handlers=new HashMap<String,TagNodeHandler>(); this.fontFamily=new FontFamily("default",Typeface.DEFAULT); registerBuiltInHandlers(); }
Example 82
From project huiswerk, under directory /print/zxing-1.6/android/src/com/google/zxing/client/android/book/.
Source file: SearchBookContentsListItem.java

public void set(SearchBookContentsResult result){ pageNumberView.setText(result.getPageNumber()); String snippet=result.getSnippet(); if (snippet.length() > 0) { if (result.getValidSnippet()) { String lowerQuery=SearchBookContentsResult.getQuery().toLowerCase(); String lowerSnippet=snippet.toLowerCase(); Spannable styledSnippet=new SpannableString(snippet); StyleSpan boldSpan=new StyleSpan(Typeface.BOLD); int queryLength=lowerQuery.length(); int offset=0; while (true) { int pos=lowerSnippet.indexOf(lowerQuery,offset); if (pos < 0) { break; } styledSnippet.setSpan(boldSpan,pos,pos + queryLength,0); offset=pos + queryLength; } snippetView.setText(styledSnippet); } else { snippetView.setText(snippet); } } else { snippetView.setText(""); } }
Example 83
From project iosched, under directory /android/src/com/google/android/apps/iosched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + mLabelPaddingLeft; final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 84
From project iosched2011, under directory /android/src/com/google/android/apps/iosched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + mLabelPaddingLeft; final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 85
From project iosched_1, under directory /src/com/google/android/apps/iosched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + ((hourHeight - labelHeight) / 2); final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 86
From project iosched_2, under directory /android/src/com/google/android/apps/iosched/ui/widget/.
Source file: TimeRulerView.java

@Override protected synchronized void onDraw(Canvas canvas){ super.onDraw(canvas); final int hourHeight=mHourHeight; final Paint dividerPaint=mDividerPaint; dividerPaint.setColor(mDividerColor); dividerPaint.setStyle(Style.FILL); final Paint labelPaint=mLabelPaint; labelPaint.setColor(mLabelColor); labelPaint.setTextSize(mLabelTextSize); labelPaint.setTypeface(Typeface.DEFAULT_BOLD); labelPaint.setAntiAlias(true); final FontMetricsInt metrics=labelPaint.getFontMetricsInt(); final int labelHeight=Math.abs(metrics.ascent); final int labelOffset=labelHeight + mLabelPaddingLeft; final int right=getRight(); final int hours=mEndHour - mStartHour; for (int i=0; i < hours; i++) { final int dividerY=hourHeight * i; final int nextDividerY=hourHeight * (i + 1); canvas.drawLine(0,dividerY,right,dividerY,dividerPaint); canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint); final int hour=mStartHour + i; String label; if (hour == 0) { label="12am"; } else if (hour <= 11) { label=hour + "am"; } else if (hour == 12) { label="12pm"; } else { label=(hour - 12) + "pm"; } final float labelWidth=labelPaint.measureText(label); canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint); } }
Example 87
/** * Set up the additional headers text view with the supplied header data. * @param additionalHeaders List of header entries. Each entry consists of a headername and a header value. Header names may appear multiple times. <p/> This method is always called from within the UI thread by {@link #showAdditionalHeaders()}. */ private void populateAdditionalHeadersView(final List<HeaderEntry> additionalHeaders){ SpannableStringBuilder sb=new SpannableStringBuilder(); boolean first=true; for ( HeaderEntry additionalHeader : additionalHeaders) { if (!first) { sb.append("\n"); } else { first=false; } StyleSpan boldSpan=new StyleSpan(Typeface.BOLD); SpannableString label=new SpannableString(additionalHeader.label + ": "); label.setSpan(boldSpan,0,label.length(),0); sb.append(label); sb.append(MimeUtility.unfoldAndDecode(additionalHeader.value)); } mAdditionalHeadersView.setText(sb); }
Example 88
From project KeyboardTerm, under directory /src/tw/kenshinn/keyboardTerm/.
Source file: GestureView.java

public GestureView(Context c,AttributeSet attrs){ super(c,attrs); mMovePaint=new Paint(); mMovePaint.setColor(Color.argb(128,0,255,0)); footprintPaint=new Paint(); footprintPaint.setAntiAlias(true); footprintPaint.setColor(footprintColor); footprintPaint.setStyle(Paint.Style.STROKE); footprintPaint.setStrokeWidth(footprintWidth); textPaint=new Paint(); textPaint.setAntiAlias(true); textPaint.setTextSize(15); textPaint.setTypeface(Typeface.MONOSPACE); setOnLongClickListener(this); setOnClickListener(this); SharedPreferences pref=PreferenceManager.getDefaultSharedPreferences(this.getContext()); String send_key_in_list=pref.getString("settings_send_key_in_list","ENTER"); String send_key_in_reading=pref.getString("settings_send_key_in_reading","SPACE"); mSend_inList=ArrowKeyView.getKeyTag(send_key_in_list); mSend_inReading=ArrowKeyView.getKeyTag(send_key_in_reading); }
Example 89
From project lastfm-android, under directory /app/src/fm/last/android/widget/.
Source file: TagLayout.java

/** * Sharable code between constructors * @param context */ private void init(Context context){ mTagButtons=new TreeMap<String,TagButton>(); mPadding=5; mAnimationEnabled=false; mAnimating=false; mAnimations=new ArrayList<Animation>(); mAreaHint=new TextView(context); LayoutParams params=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); mAreaHint.setVisibility(View.GONE); mAreaHint.setTextColor(0xff666666); mAreaHint.setGravity(Gravity.CENTER); mAreaHint.setTextSize(16); mAreaHint.setTypeface(mAreaHint.getTypeface(),Typeface.BOLD); this.addView(mAreaHint,params); }
Example 90
From project LitHub, under directory /LitHub-Android/src/us/lithub/ui/activity/.
Source file: MainMenu.java

private void newInstall(){ final Dialog homeSetup=new Dialog(mContext); homeSetup.setContentView(R.layout.dialog_home_setup); homeSetup.setTitle("Initial Setup"); homeSetup.show(); final Handler muniHandler=new Handler(){ TextView status=(TextView)homeSetup.findViewById(R.id.status); ProgressBar progress=(ProgressBar)homeSetup.findViewById(R.id.progressBar); int mStatus; public void handleMessage( Message msg){ if (mStatus == Util.PENDING) { mStatus=Util.IN_PROGRESS; status.setTypeface(null,Typeface.BOLD); status.setText("In Progress"); progress.setProgress(0); progress.setMax(msg.arg1); } else { progress.setProgress(msg.arg2); if (msg.arg1 == msg.arg2) { mStatus=Util.COMPLETE; status.setTypeface(null,Typeface.NORMAL); status.setTextColor(Color.GREEN); status.setText("Complete"); homeSetup.dismiss(); } } } } ; new Thread(new Runnable(){ public void run(){ new UserDb(mContext).initialize(); new GlobalDb(mContext).downloadDatabase(muniHandler); } } ).start(); ; }
Example 91
From project Locale-MWM, under directory /src/org/metawatch/manager/locale/receiver/.
Source file: FireReceiver.java

private static void createAndSendWidget(Context context,String icon,String id,String label){ Log.d(Constants.LOG_TAG,"widget: icon:" + icon + " id:"+ id+ " label:"+ label); if (typeface == null) { typeface=Typeface.createFromAsset(context.getAssets(),"metawatch_8pt_5pxl_CAPS.ttf"); } TextPaint paintSmall=new TextPaint(); paintSmall.setColor(Color.BLACK); paintSmall.setTextSize(8); paintSmall.setTypeface(typeface); paintSmall.setTextAlign(Align.CENTER); label=label.trim(); { Bitmap iconBmp=loadBitmapFromAssets(context,icon + "_10.bmp"); Bitmap bitmap=Bitmap.createBitmap(16,16,Bitmap.Config.RGB_565); Canvas canvas=new Canvas(bitmap); canvas.drawColor(Color.WHITE); int y=label.length() == 0 ? 3 : 0; canvas.drawBitmap(iconBmp,2,y,null); canvas.drawText(label,8,16,paintSmall); Intent i=createUpdateIntent(bitmap,"localeMWM_" + id + "_16_16","Locale Plugin Widget (16x16)",1); context.sendBroadcast(i); } { Bitmap iconBmp=loadBitmapFromAssets(context,icon + ".bmp"); Bitmap bitmap=Bitmap.createBitmap(24,32,Bitmap.Config.RGB_565); Canvas canvas=new Canvas(bitmap); canvas.drawColor(Color.WHITE); int y=label.length() == 0 ? 7 : 3; canvas.drawBitmap(iconBmp,0,y,null); canvas.drawText(label,12,30,paintSmall); Intent i=createUpdateIntent(bitmap,"localeMWM_" + id + "_24_32","Locale Plugin Widget (24x32)",1); context.sendBroadcast(i); } }
Example 92
public GestureView(Context c,AttributeSet attrs){ super(c,attrs); footprintPaint=new Paint(); footprintPaint.setAntiAlias(true); footprintPaint.setColor(footprintColor); footprintPaint.setStyle(Paint.Style.STROKE); footprintPaint.setStrokeWidth(footprintWidth); textPaint=new Paint(); textPaint.setAntiAlias(true); textPaint.setTextSize(15); textPaint.setTypeface(Typeface.MONOSPACE); setOnLongClickListener(this); }
Example 93
From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/text/.
Source file: Link.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.link); TextView t2=(TextView)findViewById(R.id.text2); t2.setMovementMethod(LinkMovementMethod.getInstance()); TextView t3=(TextView)findViewById(R.id.text3); t3.setText(Html.fromHtml("<b>text3:</b> Text with a " + "<a href=\"http://www.google.com\">link</a> " + "created in the Java source code using HTML.")); t3.setMovementMethod(LinkMovementMethod.getInstance()); SpannableString ss=new SpannableString("text4: Click here to dial the phone."); ss.setSpan(new StyleSpan(Typeface.BOLD),0,6,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ss.setSpan(new URLSpan("tel:4155551212"),13,17,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); TextView t4=(TextView)findViewById(R.id.text4); t4.setText(ss); t4.setMovementMethod(LinkMovementMethod.getInstance()); }
Example 94
From project MIT-Mobile-for-Android, under directory /src/edu/mit/mitmobile2/libraries/.
Source file: LibrariesHoldingsSliderActivity.java

@Override public void updateView(Availability item,View view){ TwoLineActionRow row=(TwoLineActionRow)view; row.setTitle(item.callNumber); Spannable status=Spannable.Factory.getInstance().newSpannable(item.status); StyleSpan boldMarker=new StyleSpan(Typeface.BOLD); if (item.available) { status.setSpan(boldMarker,0,status.length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE); } row.setSubtitle(status); }
Example 95
From project Mobile-Tour-Guide, under directory /zxing-2.0/android/src/com/google/zxing/client/android/book/.
Source file: SearchBookContentsListItem.java

public void set(SearchBookContentsResult result){ pageNumberView.setText(result.getPageNumber()); String snippet=result.getSnippet(); if (snippet.length() > 0) { if (result.getValidSnippet()) { String lowerQuery=SearchBookContentsResult.getQuery().toLowerCase(Locale.getDefault()); String lowerSnippet=snippet.toLowerCase(Locale.getDefault()); Spannable styledSnippet=new SpannableString(snippet); StyleSpan boldSpan=new StyleSpan(Typeface.BOLD); int queryLength=lowerQuery.length(); int offset=0; while (true) { int pos=lowerSnippet.indexOf(lowerQuery,offset); if (pos < 0) { break; } styledSnippet.setSpan(boldSpan,pos,pos + queryLength,0); offset=pos + queryLength; } snippetView.setText(styledSnippet); } else { snippetView.setText(snippet); } } else { snippetView.setText(""); } }
Example 96
From project mobilis, under directory /MobilisXHunt/MobilisXHunt_Android/src/de/tudresden/inf/rn/mobilis/android/xhunt/activity/.
Source file: LobbyActivity.java

/** * Insert a new player row in the list of players. * @param player the player to be insert * @return true, if successful */ private boolean insertNewPlayerRow(XHuntPlayer player){ ImageView icon=new ImageView(LobbyActivity.this); if (player.isReady()) { icon.setImageResource(player.getPlayerIconID()); } else { icon.setImageResource(player.getPlayerIconID()); icon.setAlpha(150); } icon.setPadding(3,0,0,10); TextView tv_player=new TextView(LobbyActivity.this); tv_player.setText(player.getName()); tv_player.setTextSize(20); tv_player.setTypeface(Typeface.DEFAULT_BOLD); tv_player.setPadding(3,0,0,10); TextView tv_role=new TextView(LobbyActivity.this); tv_role.setText(player.getPlayerRoleToString()); tv_role.setGravity(Gravity.RIGHT); tv_role.setPadding(3,0,0,10); TableRow tr=new TableRow(LobbyActivity.this); tr.setTag(player.getJid()); tr.addView(icon); tr.addView(tv_player); tr.addView(tv_role); registerForContextMenu(tr); tbl_lobby.addView(tr); return true; }
Example 97
From project multi-translator, under directory /src/com/robtheis/translator/.
Source file: TranslateApertiumAsyncTask.java

@Override protected synchronized void onPreExecute(){ super.onPreExecute(); textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL),Typeface.NORMAL); textView.setTextSize(14); textView.setText("Translating..."); }
Example 98
From project ohmagePhone, under directory /src/org/ohmage/fragments/.
Source file: ResponseHistoryCalendarFragment.java

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle args){ View view=inflater.inflate(R.layout.calendar_view,container,false); mTextSwitcher=(TextSwitcher)view.findViewById(R.id.summary_text_switcher); mTextSwitcher.setFactory(new ViewSwitcher.ViewFactory(){ @Override public View makeView(){ TextView textview=new TextView(getActivity()); textview.setTextColor(Color.WHITE); textview.setBackgroundColor(Color.DKGRAY); textview.setTextSize(TypedValue.COMPLEX_UNIT_DIP,16); textview.setTypeface(null,Typeface.ITALIC); textview.setGravity(Gravity.CENTER); int padding_in_dp=3; final float scale=getResources().getDisplayMetrics().density; int padding_in_px=(int)(padding_in_dp * scale + 0.5f); textview.setPadding(0,0,0,padding_in_px); return textview; } } ); mTextSwitcher.setInAnimation(getActivity(),android.R.anim.fade_in); mTextSwitcher.setOutAnimation(getActivity(),android.R.anim.fade_out); mCalendarView=(GridView)view.findViewById(R.id.calendar); mCalendarView.setAdapter(mAdapter); return view; }