List of usage examples for android.graphics Typeface createFromAsset
public static Typeface createFromAsset(AssetManager mgr, String path)
From source file:com.projecty.sleepgroundbox.activity.HomeActivity.java
private void setupTopButton() { List<Button> buttons = new ArrayList<Button>(); buttons.add((Button) findViewById(R.id.settingButton)); buttons.add((Button) findViewById(R.id.inviteButton)); // buttons.add((Button) findViewById(R.id.readButton)); buttons.add((Button) findViewById(R.id.homeButton)); buttons.add((Button) findViewById(R.id.favoriteButton)); buttons.add((Button) findViewById(R.id.featuredButton)); buttons.add((Button) findViewById(R.id.bjlogButton)); buttons.add((Button) findViewById(R.id.communityButton)); buttons.add((Button) findViewById(R.id.playlistButton)); buttons.add((Button) findViewById(R.id.bj1)); buttons.add((Button) findViewById(R.id.bj2)); buttons.add((Button) findViewById(R.id.bj3)); buttons.add((Button) findViewById(R.id.bj4)); buttons.add((Button) findViewById(R.id.bj5)); buttons.add((Button) findViewById(R.id.bj6)); buttons.add((Button) findViewById(R.id.bj7)); Typeface font = Typeface.createFromAsset(getAssets(), "NotoSans.otf"); for (Button btn : buttons) { btn.setOnClickListener(this); btn.setTypeface(font);//from w w w . j a v a 2s. c o m } }
From source file:co.dilaver.quoter.activities.ShareActivity.java
private void showFontSelectionDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setAdapter(textFontAdapter, new DialogInterface.OnClickListener() { @Override//from w w w.j av a 2 s. c o m public void onClick(DialogInterface dialog, int which) { String textFontString = ""; switch (which) { case Fonts.ALEXBRUSH_REGULAR: textFontString = "AlexBrush-Regular.ttf"; break; case Fonts.ALLER_LT: textFontString = "Aller_Lt.ttf"; break; case Fonts.ALLURA_REGULAR: textFontString = "Allura-Regular.otf"; break; case Fonts.AMATICSC_REGULAR: textFontString = "AmaticSC-Regular.ttf"; break; case Fonts.ANTONIO_REGULAR: textFontString = "Antonio-Regular.ttf"; break; case Fonts.ARIZONIA_REGULAR: textFontString = "Arizonia-Regular.ttf"; break; case Fonts.BEBAS___: textFontString = "BEBAS___.ttf"; break; case Fonts.CAPTURE_IT: textFontString = "Capture_it.ttf"; break; case Fonts.CAVIARDREAMS: textFontString = "CaviarDreams.ttf"; break; case Fonts.CHUNKFIVE: textFontString = "Chunkfive.otf"; break; case Fonts.DANCINGSCRIPT_REGULAR: textFontString = "DancingScript-Regular.otf"; break; case Fonts.DOSIS_REGULAR: textFontString = "Dosis-Regular.otf"; break; case Fonts.EXO_REGULAR: textFontString = "Exo-Regular.otf"; break; case Fonts.FFF_TUSJ: textFontString = "FFF_Tusj.ttf"; break; case Fonts.GOODDOG: textFontString = "GoodDog.otf"; break; case Fonts.GRANDHOTEL_REGULAR: textFontString = "GrandHotel-Regular.otf"; break; case Fonts.GREATVIBES_REGULAR: textFontString = "GreatVibes-Regular.otf"; break; case Fonts.KAUSHANSCRIPT_REGULAR: textFontString = "KaushanScript-Regular.otf"; break; case Fonts.LATO_REGULAR: textFontString = "Lato-Regular.ttf"; break; case Fonts.LEAGUEGOTHIC_REGULAR: textFontString = "LeagueGothic-Regular.otf"; break; case Fonts.LEARNINGCURVE_OT: textFontString = "LearningCurve_OT.otf"; break; case Fonts.LOBSTERTWO_REGULAR: textFontString = "LobsterTwo-Regular.otf"; break; case Fonts.LOBSTER: textFontString = "Lobster.otf"; break; case Fonts.MATHLETE_BULKY: textFontString = "Mathlete-Bulky.otf"; break; case Fonts.MONTSERRAT_REGULAR: textFontString = "Montserrat-Regular.otf"; break; case Fonts.OPENSANS_REGULAR: textFontString = "OpenSans-Regular.ttf"; break; case Fonts.OSWALD_REGULAR: textFontString = "Oswald-Regular.ttf"; break; case Fonts.PACIFICO: textFontString = "Pacifico.ttf"; break; case Fonts.PLAYFAIRDISPLAYSC_REGULAR: textFontString = "PlayfairDisplaySC-Regular.ttf"; break; case Fonts.QUICKSAND_REGULAR: textFontString = "Quicksand-Regular.otf"; break; case Fonts.RALEWAY_REGULAR: textFontString = "Raleway-Regular.ttf"; break; case Fonts.ROBOTO_REGULAR: textFontString = "Roboto-Regular.ttf"; break; case Fonts.ROBOTOSLAB_REGULAR: textFontString = "RobotoSlab-Regular.ttf"; break; case Fonts.SEASRN__: textFontString = "SEASRN__.ttf"; break; case Fonts.SOFIA_REGULAR: textFontString = "Sofia-Regular.otf"; break; case Fonts.SOURCESANSPRO_REGULAR: textFontString = "SourceSansPro-Regular.otf"; break; case Fonts.TITILLIUM_REGULAR: textFontString = "Titillium-Regular.otf"; break; case Fonts.WALKWAY_BOLD: textFontString = "Walkway_Bold.ttf"; break; case Fonts.WINDSONG: textFontString = "Windsong.ttf"; break; case Fonts.BLACK_JACK: textFontString = "black_jack.ttf"; break; case Fonts.CAC_CHAMPAGNE: textFontString = "cac_champagne.ttf"; break; case Fonts.OSTRICH_REGULAR: textFontString = "ostrich-regular.ttf"; break; } Typeface typeface = Typeface.createFromAsset(getAssets(), textFontString); chooseTextFont.setTypeface(typeface); previewQuote.setTypeface(typeface); previewAuthor.setTypeface(typeface); } }); builder.setTitle(getString(R.string.str_ChooseTextFont)); builder.setCancelable(true); builder.show(); }
From source file:ua.southwall.screenpicker.app.Fragments.BarFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.fragment_bargraph, container, false); final Resources resources = getResources(); ArrayList<Bar> points = new ArrayList<Bar>(); ArrayList<Bar> pointsNew = new ArrayList<Bar>(); ArrayList<Bar> pointsNewer = new ArrayList<Bar>(); ArrayList<Bar> pointsEvenNewer = new ArrayList<Bar>(); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(getActivity().getApplicationContext()); prefValue = prefs.getString("prefSyncFrequency", prefValue); try {// w ww . j a v a2 s . c om deviceModel = ResultsActivity.getJSON("deviceModel"); deviceHeight = ResultsActivity.getJSON("height"); deviceWidth = ResultsActivity.getJSON("width"); devicePpi = ResultsActivity.getJSON("ppi"); deviceDiagonal = ResultsActivity.getJSON("diagonal"); } catch (JSONException e) { e.printStackTrace(); } numberOfDevices = deviceModel.length; // if(numberOfDevices>10) numberOfDevices=10; //T // for(int i=1;i<numberOfDevices;i++){ // if (devicePpi[i].equals("(None)")||devicePpi[i].equals("(None)")) // } //double resolutionDistanceIdeal = 1 / (2 * Float.parseFloat(devicePpi[1]) * tangens_ideal); resolutionDistanceAverage = new Double[deviceModel.length]; //////Log.e(devicePpi) resolutionDistanceAverage[1] = 1 / (2 * Float.parseFloat(devicePpi[1]) * tangens_average); for (int i = 0; i < numberOfDevices; i++) { } d = new Bar[numberOfDevices]; for (int i = 0; i < numberOfDevices; i++) { d[i] = new Bar(); } b = new Bar[numberOfDevices]; for (int i = 0; i < numberOfDevices; i++) { b[i] = new Bar(); } c = new Bar[numberOfDevices]; for (int i = 0; i < numberOfDevices; i++) { c[i] = new Bar(); } e = new Bar[numberOfDevices]; for (int i = 0; i < numberOfDevices; i++) { e[i] = new Bar(); } //d[1].setColor(resources.getColor(colors[1])); //d[1].setSelectedColor(resources.getColor(colors[1])); //d[1].setName(deviceModel[1]); pixelsBasis = Integer.parseInt(deviceHeight[1]) * Integer.parseInt(deviceWidth[1]); //d[1].setValueString(String.valueOf(100)); //points.add(d[1]); numberOfPixels = new Integer[numberOfDevices]; for (int i = 1; i < numberOfDevices; i++) { d[i].setColor(resources.getColor(colors[i - 1])); d[i].setSelectedColor(resources.getColor(colors[i - 1])); d[i].setName(deviceModel[i]); numberOfPixels[i] = Integer.parseInt(deviceHeight[i]) * Integer.parseInt(deviceWidth[i]); d[i].setValue((float) numberOfPixels[i]); d[i].setValueString(String.valueOf(Math.round((numberOfPixels[i] / 1000.0f)) / 1000.0f)); if (i != 0) points.add(d[i]); } BarGraph g = (BarGraph) v.findViewById(R.id.bargraph); g.setBars(points); g.setOnBarClickedListener(new OnBarClickedListener() { @Override public void onClick(int index) { Toast.makeText(getActivity(), deviceModel[index + 1] + " " + getString(R.string.bar_value) + " " + numberOfPixels[index + 1], Toast.LENGTH_SHORT).show(); //recalculate to view percentages if (clickedFirst != index) { d[index + 1].setValueString("100%"); for (int i = 1; i < numberOfDevices; i++) { if (i != index + 1) d[i].setValueString( String.valueOf(Math.round(numberOfPixels[i] * 100 / numberOfPixels[index + 1])) + "%"); } clickedFirst = index; } else { for (int i = 1; i < numberOfDevices; i++) { d[i].setValueString(String.valueOf(Math.round((numberOfPixels[i] / 1000.0f)) / 1000.0f)); } clickedFirst = -10; } } }); // b[1].setColor(resources.getColor(colors[1])); // b[1].setSelectedColor(resources.getColor(colors[1])); // b[1].setName(deviceModel[1]); //pixelsBasis=Integer.parseInt(deviceHeight[1]) * Integer.parseInt(deviceWidth[1]); // b[1].setValueString(String.valueOf(resolutionDistanceAverage) + ""); for (int i = 1; i < numberOfDevices; i++) { b[i].setColor(resources.getColor(colors[i - 1])); b[i].setSelectedColor(resources.getColor(colors[i - 1])); b[i].setName(deviceModel[i]); percentage = Integer.parseInt(deviceHeight[i]) * Integer.parseInt(deviceWidth[i]) * 100 / pixelsBasis; resolutionDistanceAverage[i] = 1 / (2 * Float.parseFloat(devicePpi[i]) * tangens_average); if (prefValue.equals("cm")) resolutionDistanceAverage[i] = resolutionDistanceAverage[i] * 2.54f; resolutionDistanceAverage[i] = (Math.round(resolutionDistanceAverage[i] * 10.0)) / 10.0; b[i].setValue((float) (resolutionDistanceAverage[i] * 1.0f)); b[i].setValueString(String.valueOf(resolutionDistanceAverage[i])); if (i != 0) pointsNew.add(b[i]); } BarGraph g1 = (BarGraph) v.findViewById(R.id.bargraph_distance); g1.setBars(pointsNew); g1.setOnBarClickedListener(new OnBarClickedListener() { @Override public void onClick(int index) { Toast.makeText(getActivity(), deviceModel[index + 1] + " " + getString(R.string.bar_value) + " " + resolutionDistanceAverage[index + 1], Toast.LENGTH_SHORT).show(); if (clickedSecond != index) { b[index + 1].setValueString("100%"); for (int i = 1; i < numberOfDevices; i++) { if (i != index + 1) b[i].setValueString(String.valueOf(Math.round( resolutionDistanceAverage[i] * 100 / resolutionDistanceAverage[index + 1])) + "%"); } clickedSecond = index; } else { for (int i = 1; i < numberOfDevices; i++) { b[i].setValueString(String.valueOf(resolutionDistanceAverage[i])); } clickedSecond = -10; } } }); thirdGraph = new Double[numberOfDevices]; for (int i = 1; i < numberOfDevices; i++) { c[i].setColor(resources.getColor(colors[i - 1])); c[i].setSelectedColor(resources.getColor(colors[i - 1])); c[i].setName(deviceModel[i]); //(float)Math.pow(1/Float.parseFloat(devicePpi[1]),2) thirdGraph[i] = Math.pow(1 / Float.parseFloat(devicePpi[i]), 2); if (prefValue.equals("cm")) thirdGraph[i] = thirdGraph[i] * 2.54 * 2.54; thirdGraph[i] = ((float) Math.round(thirdGraph[i] * 1000000 * 100)) / 100.0; c[i].setValue((float) (thirdGraph[i] * 1.0f)); c[i].setValueString(String.valueOf(thirdGraph[i])); if (i != 0) pointsNewer.add(c[i]); } BarGraph g2 = (BarGraph) v.findViewById(R.id.bargraph_size); g2.setBars(pointsNewer); g2.setOnBarClickedListener(new OnBarClickedListener() { @Override public void onClick(int index) { Toast.makeText(getActivity(), deviceModel[index + 1] + " " + getString(R.string.bar_value) + " " + thirdGraph[index + 1], Toast.LENGTH_SHORT).show(); if (clickedThird != index) { c[index + 1].setValueString("100%"); for (int i = 1; i < numberOfDevices; i++) { if (i != index + 1) c[i].setValueString( String.valueOf(Math.round(thirdGraph[i] * 100 / thirdGraph[index + 1])) + "%"); } clickedThird = index; } else { for (int i = 1; i < numberOfDevices; i++) { c[i].setValueString(String.valueOf(thirdGraph[i])); } clickedThird = -10; } } }); final Double[] forthGraph = new Double[numberOfDevices]; for (int i = 1; i < numberOfDevices; i++) { e[i].setColor(resources.getColor(colors[i - 1])); e[i].setSelectedColor(resources.getColor(colors[i - 1])); e[i].setName(deviceModel[i]); //(float)Math.pow(1/Float.parseFloat(devicePpi[1]),2) forthGraph[i] = (Double.valueOf(deviceHeight[i]) / Double.valueOf(devicePpi[i])) * (Double.valueOf(deviceWidth[i]) / Double.valueOf(devicePpi[i])); if (prefValue.equals("cm")) forthGraph[i] = forthGraph[i] * 2.54 * 2.54; forthGraph[i] = ((float) Math.round(forthGraph[i] * 100)) / 100.0; e[i].setValue((float) (forthGraph[i] * 1.0f)); e[i].setValueString(String.valueOf(forthGraph[i])); if (i != 0) pointsEvenNewer.add(e[i]); } BarGraph g3 = (BarGraph) v.findViewById(R.id.bargraph_area); g3.setBars(pointsEvenNewer); g3.setOnBarClickedListener(new OnBarClickedListener() { @Override public void onClick(int index) { Toast.makeText(getActivity(), deviceModel[index + 1] + " " + getString(R.string.bar_value) + " " + forthGraph[index + 1], Toast.LENGTH_SHORT).show(); if (clickedForth != index) { e[index + 1].setValueString("100%"); for (int i = 1; i < numberOfDevices; i++) { if (i != index + 1) e[i].setValueString( String.valueOf(Math.round(forthGraph[i] * 100 / forthGraph[index + 1])) + "%"); } clickedForth = index; } else { for (int i = 1; i < numberOfDevices; i++) { e[i].setValueString(String.valueOf(forthGraph[i])); } clickedForth = -10; } } }); Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Light.ttf"); TextView firstBarView = (TextView) v.findViewById(R.id.bar_title_textview); TextView secondBarView = (TextView) v.findViewById(R.id.bar_title_textview_distance); TextView thirdBarView = (TextView) v.findViewById(R.id.bar_title_); TextView forthBarView = (TextView) v.findViewById(R.id.bar_title_textview_area); if (prefValue.equals("in")) { secondBarView.setText(R.string.distance_bargraph); thirdBarView.setText(R.string.textview_bargraph_size); forthBarView.setText(R.string.area_bargraph); } else if (prefValue.equals("cm")) { secondBarView.setText(R.string.distance_bargraph_cm); thirdBarView.setText(R.string.textview_bargraph_size_cm); forthBarView.setText(R.string.area_bargraph_cm); } firstBarView.setTypeface(typeface); secondBarView.setTypeface(typeface); thirdBarView.setTypeface(typeface); forthBarView.setTypeface(typeface); return v; }
From source file:baasi.hackathon.sja.TalkActivity.java
/** * ?/*from w ww . j a va 2 s. c om*/ */ private void setTypeFaces() { Typeface font = Typeface.createFromAsset(getApplicationContext().getAssets(), "BPG_GEL_Excelsior.ttf"); helpTextView.setTypeface(font); resetButton.setTypeface(font); }
From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java
private void drawGaugeTitle(Canvas canvas, String Title) { Paint titlePaint = new Paint(); titlePaint.setStyle(Paint.Style.FILL_AND_STROKE); titlePaint.setColor(Color.LTGRAY);//0x9f004d0f titlePaint.setStrokeWidth(1);//0.005f titlePaint.setAntiAlias(true);// w ww . j av a 2 s . c om titlePaint.setTextSize(14); titlePaint.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/chivo.ttf")); /*Path titlePath = new Path(); titlePath.addArc(new RectF(40, 90, 196, 155), -180.0f, -180.0f); canvas.drawTextOnPath(Title, titlePath, 0.0f,0.0f, titlePaint);*/ canvas.drawText(Title, 60, 160, titlePaint); }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
@Override protected void onServiceBound() { T.UI();// w w w . j a va2 s .c o m if (mNotYetProcessedIntent != null) { processIntent(mNotYetProcessedIntent); mNotYetProcessedIntent = null; } setContentView(R.layout.registration2); //Apply Fonts TextUtils.overrideFonts(this, findViewById(android.R.id.content)); final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf"); final int[] visibleLogos; final int[] goneLogos; if (AppConstants.FULL_WIDTH_HEADERS) { visibleLogos = FULL_WIDTH_ROGERTHAT_LOGOS; goneLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS; View viewFlipper = findViewById(R.id.registration_viewFlipper); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) viewFlipper.getLayoutParams(); params.setMargins(0, 0, 0, 0); } else { visibleLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS; goneLogos = FULL_WIDTH_ROGERTHAT_LOGOS; } for (int id : visibleLogos) findViewById(id).setVisibility(View.VISIBLE); for (int id : goneLogos) findViewById(id).setVisibility(View.GONE); handleScreenOrientation(getResources().getConfiguration().orientation); ScrollView rc = (ScrollView) findViewById(R.id.registration_container); Resources resources = getResources(); if (CloudConstants.isRogerthatApp()) { rc.setBackgroundColor(resources.getColor(R.color.mc_page_dark)); } else { rc.setBackgroundColor(resources.getColor(R.color.mc_homescreen_background)); } TextView rogerthatWelcomeTextView = (TextView) findViewById(R.id.rogerthat_welcome); TextView tosTextView = (TextView) findViewById(R.id.registration_tos); Typeface FONT_THIN_ITALIC = Typeface.createFromAsset(getAssets(), "fonts/lato_light_italic.ttf"); tosTextView.setTypeface(FONT_THIN_ITALIC); tosTextView.setTextColor(ContextCompat.getColor(RegistrationActivity2.this, R.color.mc_words_color)); Button agreeBtn = (Button) findViewById(R.id.registration_agree_tos); TextView tvRegistration = (TextView) findViewById(R.id.registration); tvRegistration.setText(getString(R.string.registration_city_app_sign_up, getString(R.string.app_name))); mEnterEmailAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.registration_enter_email); if (CloudConstants.isEnterpriseApp()) { rogerthatWelcomeTextView .setText(getString(R.string.rogerthat_welcome_enterprise, getString(R.string.app_name))); tosTextView.setVisibility(View.GONE); agreeBtn.setText(R.string.start_registration); mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint_enterprise); } else { rogerthatWelcomeTextView .setText(getString(R.string.registration_welcome_text, getString(R.string.app_name))); tosTextView.setText(Html.fromHtml( "<a href=\"" + CloudConstants.TERMS_OF_SERVICE_URL + "\">" + tosTextView.getText() + "</a>")); tosTextView.setMovementMethod(LinkMovementMethod.getInstance()); agreeBtn.setText(R.string.registration_btn_agree_tos); mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint); } agreeBtn.getBackground().setColorFilter(Message.GREEN_BUTTON_COLOR, PorterDuff.Mode.MULTIPLY); agreeBtn.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_AGREED_TOS); mWiz.proceedToNextPage(); } }); initLocationUsageStep(faTypeFace); View.OnClickListener emailLoginListener = new View.OnClickListener() { @Override public void onClick(View v) { sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_EMAIL_LOGIN); mWiz.proceedToNextPage(); } }; findViewById(R.id.login_via_email).setOnClickListener(emailLoginListener); Button facebookButton = (Button) findViewById(R.id.login_via_fb); View.OnClickListener facebookLoginListener = new View.OnClickListener() { @Override public void onClick(View v) { // Check network connectivity if (!mService.getNetworkConnectivityManager().isConnected()) { UIUtils.showNoNetworkDialog(RegistrationActivity2.this); return; } sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_FACEBOOK_LOGIN); FacebookUtils.ensureOpenSession(RegistrationActivity2.this, AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE ? Arrays.asList("email", "user_friends", "user_birthday") : Arrays.asList("email", "user_friends"), PermissionType.READ, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { if (session != Session.getActiveSession()) { session.removeCallback(this); return; } if (exception != null) { session.removeCallback(this); if (!(exception instanceof FacebookOperationCanceledException)) { L.bug("Facebook SDK error during registration", exception); AlertDialog.Builder builder = new AlertDialog.Builder( RegistrationActivity2.this); builder.setMessage(R.string.error_please_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } else if (session.isOpened()) { session.removeCallback(this); if (session.getPermissions().contains("email")) { registerWithAccessToken(session.getAccessToken()); } else { AlertDialog.Builder builder = new AlertDialog.Builder( RegistrationActivity2.this); builder.setMessage(R.string.facebook_registration_email_missing); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } } }, false); } ; }; facebookButton.setOnClickListener(facebookLoginListener); final Button getAccountsButton = (Button) findViewById(R.id.get_accounts); if (configureEmailAutoComplete()) { // GET_ACCOUNTS permission is granted getAccountsButton.setVisibility(View.GONE); } else { getAccountsButton.setTypeface(faTypeFace); getAccountsButton.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { ActivityCompat.requestPermissions(RegistrationActivity2.this, new String[] { Manifest.permission.GET_ACCOUNTS }, PERMISSION_REQUEST_GET_ACCOUNTS); } }); } mEnterPinEditText = (EditText) findViewById(R.id.registration_enter_pin); mEnterPinEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (s.length() == PIN_LENGTH) onPinEntered(); } }); Button requestNewPinButton = (Button) findViewById(R.id.registration_request_new_pin); requestNewPinButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mWiz.setEmail(null); hideNotification(); mWiz.reInit(); mWiz.goBackToPrevious(); mEnterEmailAutoCompleteTextView.setText(""); } }); mWiz = RegistrationWizard2.getWizard(mService); mWiz.setFlipper((ViewFlipper) findViewById(R.id.registration_viewFlipper)); setFinishHandler(); addAgreeTOSHandler(); addIBeaconUsageHandler(); addChooseLoginMethodHandler(); addEnterPinHandler(); mWiz.run(); mWiz.setDeviceId(Installation.id(this)); handleEnterEmail(); if (mWiz.getBeaconRegions() != null && mBeaconManager == null) { bindBeaconManager(); } if (CloudConstants.USE_GCM_KICK_CHANNEL && GoogleServicesUtils.checkPlayServices(this, true)) { GoogleServicesUtils.registerGCMRegistrationId(mService, new GCMRegistrationIdFoundCallback() { @Override public void idFound(String registrationId) { mGCMRegistrationId = registrationId; } }); } }
From source file:com.deliciousdroid.fragment.ViewBookmarkFragment.java
@Override public void onResume() { super.onResume(); readView.setBackgroundColor(Integer.parseInt(base.readingBackground)); readTitle.setBackgroundColor(Integer.parseInt(base.readingBackground)); if (Integer.parseInt(base.readingBackground) == Color.BLACK) { readView.setTextColor(Color.parseColor("#999999")); readTitle.setTextColor(Color.parseColor("#999999")); } else {//from ww w.ja va2 s . c o m readView.setTextColor(Color.parseColor("#222222")); readTitle.setTextColor(Color.parseColor("#222222")); } readView.setPadding(Integer.parseInt(base.readingMargins), 15, Integer.parseInt(base.readingMargins), 15); Typeface tf = Typeface.createFromAsset(base.getAssets(), "fonts/" + base.readingFont + ".ttf"); readView.setTypeface(tf); readView.setTextSize(Float.parseFloat(base.readingFontSize)); readView.setLineSpacing(Float.parseFloat(base.readingLineSpace), 1); }
From source file:kr.wdream.storyshop.AndroidUtilities.java
public static Typeface getTypeface(String assetPath) { synchronized (typefaceCache) { if (!typefaceCache.containsKey(assetPath)) { try { Typeface t = Typeface.createFromAsset(ApplicationLoader.applicationContext.getAssets(), assetPath);/*from www . ja va 2s.com*/ typefaceCache.put(assetPath, t); } catch (Exception e) { FileLog.e("Typefaces", "Could not get typeface '" + assetPath + "' because " + e.getMessage()); return null; } } return typefaceCache.get(assetPath); } }
From source file:org.akop.crosswords.view.CrosswordView.java
public CrosswordView(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { setLayerType(View.LAYER_TYPE_HARDWARE, null); }/*from w ww. j a va 2s . c o m*/ // Set drawing defaults Resources r = context.getResources(); DisplayMetrics dm = r.getDisplayMetrics(); int cellFillColor = NORMAL_CELL_FILL_COLOR; int cheatedCellFillColor = CHEATED_CELL_FILL_COLOR; int mistakeCellFillColor = MISTAKE_CELL_FILL_COLOR; int selectedWordFillColor = SELECTED_WORD_FILL_COLOR; int selectedCellFillColor = SELECTED_CELL_FILL_COLOR; int textColor = TEXT_COLOR; int cellStrokeColor = CELL_STROKE_COLOR; int circleStrokeColor = CIRCLE_STROKE_COLOR; float numberTextSize = NUMBER_TEXT_SIZE * dm.scaledDensity; float answerTextSize = ANSWER_TEXT_SIZE * dm.scaledDensity; mCellSize = CELL_SIZE * dm.density; mNumberTextPadding = NUMBER_TEXT_PADDING * dm.density; mAnswerTextPadding = ANSWER_TEXT_PADDING * dm.density; // Read supplied attributes if (attrs != null) { Resources.Theme theme = context.getTheme(); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.Crossword, 0, 0); mCellSize = a.getDimension(R.styleable.Crossword_cellSize, mCellSize); mNumberTextPadding = a.getDimension(R.styleable.Crossword_numberTextPadding, mNumberTextPadding); numberTextSize = a.getDimension(R.styleable.Crossword_numberTextSize, numberTextSize); mAnswerTextPadding = a.getDimension(R.styleable.Crossword_answerTextPadding, mAnswerTextPadding); answerTextSize = a.getDimension(R.styleable.Crossword_answerTextSize, answerTextSize); cellFillColor = a.getColor(R.styleable.Crossword_defaultCellFillColor, cellFillColor); cheatedCellFillColor = a.getColor(R.styleable.Crossword_cheatedCellFillColor, cheatedCellFillColor); mistakeCellFillColor = a.getColor(R.styleable.Crossword_mistakeCellFillColor, mistakeCellFillColor); selectedWordFillColor = a.getColor(R.styleable.Crossword_selectedWordFillColor, selectedWordFillColor); selectedCellFillColor = a.getColor(R.styleable.Crossword_selectedCellFillColor, selectedCellFillColor); cellStrokeColor = a.getColor(R.styleable.Crossword_cellStrokeColor, cellStrokeColor); circleStrokeColor = a.getColor(R.styleable.Crossword_circleStrokeColor, circleStrokeColor); textColor = a.getColor(R.styleable.Crossword_textColor, textColor); a.recycle(); } mMarkerSideLength = mCellSize * MARKER_TRIANGLE_LENGTH_FRACTION; // Init paints mCellFillPaint = new Paint(); mCellFillPaint.setColor(cellFillColor); mCellFillPaint.setStyle(Paint.Style.FILL); mCheatedCellFillPaint = new Paint(); mCheatedCellFillPaint.setColor(cheatedCellFillColor); mCheatedCellFillPaint.setStyle(Paint.Style.FILL); mMistakeCellFillPaint = new Paint(); mMistakeCellFillPaint.setColor(mistakeCellFillColor); mMistakeCellFillPaint.setStyle(Paint.Style.FILL); mSelectedWordFillPaint = new Paint(); mSelectedWordFillPaint.setColor(selectedWordFillColor); mSelectedWordFillPaint.setStyle(Paint.Style.FILL); mSelectedCellFillPaint = new Paint(); mSelectedCellFillPaint.setColor(selectedCellFillColor); mSelectedCellFillPaint.setStyle(Paint.Style.FILL); mCellStrokePaint = new Paint(); mCellStrokePaint.setColor(cellStrokeColor); mCellStrokePaint.setStyle(Paint.Style.STROKE); // mCellStrokePaint.setStrokeWidth(1); mCircleStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCircleStrokePaint.setColor(circleStrokeColor); mCircleStrokePaint.setStyle(Paint.Style.STROKE); mCircleStrokePaint.setStrokeWidth(1); mNumberTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mNumberTextPaint.setColor(textColor); mNumberTextPaint.setTextAlign(Paint.Align.CENTER); mNumberTextPaint.setTextSize(numberTextSize); mNumberStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mNumberStrokePaint.setColor(cellFillColor); mNumberStrokePaint.setTextAlign(Paint.Align.CENTER); mNumberStrokePaint.setTextSize(numberTextSize); mNumberStrokePaint.setStyle(Paint.Style.STROKE); mNumberStrokePaint.setStrokeWidth(NUMBER_TEXT_STROKE_WIDTH * dm.scaledDensity); mAnswerTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mAnswerTextPaint.setColor(textColor); mAnswerTextPaint.setTextSize(answerTextSize); mAnswerTextPaint.setTextAlign(Paint.Align.CENTER); // http://www.google.com/fonts/specimen/Kalam Typeface typeface = Typeface.createFromAsset(context.getAssets(), "kalam-regular.ttf"); mAnswerTextPaint.setTypeface(typeface); // Init rest of the values mCircleRadius = (mCellSize / 2) - mCircleStrokePaint.getStrokeWidth(); mPuzzleCells = EMPTY_CELLS; mPuzzleWidth = 0; mPuzzleHeight = 0; mAllowedChars = EMPTY_CHARS; mRenderScale = 0; mBitmapOffset = new PointF(); mCenteredOffset = new PointF(); mTranslationBounds = new RectF(); mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); mContentRect = new RectF(); mPuzzleRect = new RectF(); mBitmapPaint = new Paint(Paint.FILTER_BITMAP_FLAG); mScroller = new Scroller(context, null, true); mZoomer = new Zoomer(context); setFocusableInTouchMode(true); setOnKeyListener(this); }
From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java
private void drawScale(Canvas canvas, Boolean Colors, int Count, int Max) { RectF faceRect = new RectF(); faceRect.set(10, 10, 190, 190);/*from w w w . ja v a 2s . co m*/ Paint scalePaint = new Paint(); scalePaint.setStyle(Paint.Style.STROKE); scalePaint.setColor(getResources().getColor(R.color.WarningGreen)); scalePaint.setStrokeWidth(1); scalePaint.setAntiAlias(true); scalePaint.setTextSize(12); scalePaint.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/chivo.ttf")); scalePaint.setTextAlign(Paint.Align.CENTER); float scalePosition = 10; RectF scaleRect = new RectF(); scaleRect.set(faceRect.left + scalePosition, faceRect.top + scalePosition, faceRect.right - scalePosition, faceRect.bottom - scalePosition); if (!Colors) scalePaint.setColor(Color.WHITE); scalePaint.setStrokeWidth(2); canvas.save(Canvas.MATRIX_SAVE_FLAG); for (int i = 0; i < Max; ++i) { if (Colors) { if (i > 20) scalePaint.setColor(getResources().getColor(R.color.WarningYellow)); if (i > 40) scalePaint.setColor(getResources().getColor(R.color.WarningOrange)); if (i > 60) scalePaint.setColor(getResources().getColor(R.color.WarningRed)); } canvas.drawLine(100, 20, 100, 18, scalePaint); int divisor = 5; if (Max > 100) divisor = 25; if (i % divisor == 0) { canvas.drawText(Integer.toString(i), 100, 16, scalePaint); } canvas.rotate((360.0f / Max), 100, 100); } canvas.restore(); }