com.huami.watch.watchface.util.Util Java Examples
The following examples show how to use
com.huami.watch.watchface.util.Util.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BatteryWidget.java From GreatFit with MIT License | 6 votes |
public void onDataUpdate(DataType type, Object value) { // Battery class this.batteryData = (Battery) value; if(this.batteryData == null){ return; } // Bar angle if(settings.batteryProg>0 && settings.batteryProgType==0) { this.batterySweepAngle = this.angleLength * (this.batteryData.getLevel() / (float) this.batteryData.getScale()); } // Battery Image if( this.tempBattery == this.batteryData.getLevel()/10 || !(settings.batteryProg>0 && settings.batteryProgType==1)){ return; } this.tempBattery = this.batteryData.getLevel()/10; this.batteryIcon = Util.decodeImage(mService.getResources(),"battery/battery"+this.tempBattery+".png"); }
Example #2
Source File: StepsWidget.java From GreatFit with MIT License | 6 votes |
public void init(Service service) { this.mService = service; if(settings.steps>0){ this.stepsPaint = new Paint(Paint.ANTI_ALIAS_FLAG); this.stepsPaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.stepsPaint.setTextSize(settings.stepsFontSize); this.stepsPaint.setColor(settings.stepsColor); this.stepsPaint.setTextAlign( (settings.stepsAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); if(settings.stepsIcon){ this.icon = Util.decodeImage(mService.getResources(),"icons/"+settings.is_white_bg+"steps.png"); } } if(settings.stepsProg>0 && settings.stepsProgType==0){ this.ring = new Paint(Paint.ANTI_ALIAS_FLAG); this.ring.setStrokeCap(Paint.Cap.ROUND); this.ring.setStyle(Paint.Style.STROKE); this.ring.setStrokeWidth(settings.stepsProgThickness); } }
Example #3
Source File: HugeDigitClock.java From AmazfitAPKs with Apache License 2.0 | 6 votes |
@Override public void onDrawDigital(Canvas canvas, float width, float height, float centerX, float centerY, int seconds, int minutes, int hours, int year, int month, int day, int week, int ampm) { canvas.drawColor(background); //Calendar rightNow = Calendar.getInstance(); int hh = hours/10; int hl = hours%10; int mh = minutes/10; int ml = minutes%10; float halfWidth = width / 2; float halfHeight = height / 2; canvas.drawBitmap(Util.drawableToBitmap(digits[hh]), img_offset+offset, img_offset+offset, null); canvas.drawBitmap(Util.drawableToBitmap(digits[hl]), halfWidth-offset, offset+img_offset, null); canvas.drawBitmap(Util.drawableToBitmap(digits[mh]), offset+img_offset, halfHeight-offset, null); canvas.drawBitmap(Util.drawableToBitmap(digits[ml]), halfWidth-offset, halfHeight-offset, null); }
Example #4
Source File: HeartRateWidget.java From GreatFit with MIT License | 6 votes |
@Override public void init(Service service) { this.mService = service; this.textPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.textPaint.setColor(settings.heart_rateColor); this.textPaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.textPaint.setTextSize(settings.heart_rateFontSize); this.textPaint.setTextAlign( (settings.heart_rateAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); if(settings.heart_rateIcon){ this.heart_rateIcon = Util.decodeImage(service.getResources(),"icons/"+settings.is_white_bg+"heart_rate.png"); this.heart_rate_flashingIcon = Util.decodeImage(service.getResources(),"icons/"+settings.is_white_bg+"heart_rate_flashing.png"); } // Progress Bar Circle if(settings.heart_rateProg>0 && settings.heart_rateProgType==0){ this.ring = new Paint(Paint.ANTI_ALIAS_FLAG); this.ring.setStrokeCap(Paint.Cap.ROUND); this.ring.setStyle(Paint.Style.STROKE); this.ring.setStrokeWidth(settings.heart_rateProgThickness); } }
Example #5
Source File: SportTodayDistanceWidget.java From GreatFit with MIT License | 6 votes |
public void init(Service service) { this.mService = service; if(settings.today_distance>0){ this.today_distancePaint = new Paint(Paint.ANTI_ALIAS_FLAG); this.today_distancePaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.today_distancePaint.setTextSize(settings.today_distanceFontSize); this.today_distancePaint.setColor(settings.today_distanceColor); this.today_distancePaint.setTextAlign( (settings.today_distanceAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); if(settings.today_distanceIcon){ this.today_distanceIcon = Util.decodeImage(service.getResources(),"icons/"+settings.is_white_bg+"today_distance.png"); } } if(settings.today_distanceProg>0 && settings.today_distanceProgType==0){ this.ring = new Paint(Paint.ANTI_ALIAS_FLAG); this.ring.setStrokeCap(Paint.Cap.ROUND); this.ring.setStyle(Paint.Style.STROKE); this.ring.setStrokeWidth(settings.today_distanceProgThickness); } }
Example #6
Source File: CaloriesWidget.java From GreatFit with MIT License | 6 votes |
@Override public void init(Service service) { this.mService = service; if(settings.calories>0) { // Font this.textPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.textPaint.setColor(settings.caloriesColor); this.textPaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.textPaint.setTextSize(settings.caloriesFontSize); this.textPaint.setTextAlign((settings.caloriesAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER); if (settings.caloriesIcon) { this.icon = Util.decodeImage(service.getResources(), "icons/"+settings.is_white_bg+"calories.png"); } } // Progress Bar Circle if(settings.caloriesProg>0 && settings.caloriesProgType==0){ this.ring = new Paint(Paint.ANTI_ALIAS_FLAG); this.ring.setStrokeCap(Paint.Cap.ROUND); this.ring.setStyle(Paint.Style.STROKE); this.ring.setStrokeWidth(settings.caloriesProgThickness); } }
Example #7
Source File: MainClock.java From AmazfitAPKs with Apache License 2.0 | 6 votes |
@Override public void onDrawDigital(Canvas canvas, float width, float height, float centerX, float centerY, int seconds, int minutes, int hours, int year, int month, int day, int week, int ampm) { this.background.draw(canvas); canvas.drawText(Util.formatTime(hours), this.leftHour, this.topHour, this.hourFont); canvas.drawText(Util.formatTime(minutes), this.leftMinute, this.topMinute, this.timeFont); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, week); String date = String.format("%02d.%02d.%02d", day, month, year); canvas.drawText(date, leftDate, topDate, this.dateFont); String weekday = String.format("%S", new SimpleDateFormat("EE").format(calendar.getTime())); canvas.drawText(weekday, leftWeekday, topWeekday, this.weekdayFont); int nSecond = calendar.get(13); String segundero = String.format(":"); if(nSecond%2 ==0 ) { canvas.drawText(segundero, 160, 190, this.hourFont); } }
Example #8
Source File: MainClock.java From AmazfitAPKs with Apache License 2.0 | 6 votes |
@Override public void onDrawDigital(Canvas canvas, float width, float height, float centerX, float centerY, int seconds, int minutes, int hours, int year, int month, int day, int week, int ampm) { this.background.draw(canvas); canvas.drawText(Util.formatTime(hours), this.leftHour, this.topHour, this.hourFont); canvas.drawText(Util.formatTime(minutes), this.leftMinute, this.topMinute, this.timeFont); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, week); String date = String.format("%02d - %02d", day, month); canvas.drawText(date, leftDate, topDate, this.dateFont); String weekday = String.format("%S", new SimpleDateFormat("EE").format(calendar.getTime())); canvas.drawText(weekday, leftWeekday, topWeekday, this.weekdayFont); }
Example #9
Source File: GreatFitSlpt.java From GreatFit with MIT License | 5 votes |
@Override public boolean isClockPeriodSecond() { Context context = this.getApplicationContext(); boolean needRefreshSecond = Util.needSlptRefreshSecond(context); if (needRefreshSecond) { this.setClockPeriodSecond(true); } return needRefreshSecond; }
Example #10
Source File: MalvarezClock.java From malvarez-watchface with Apache License 2.0 | 5 votes |
@Override public void onDrawDigital(Canvas canvas, float width, float height, float centerX, float centerY, int seconds, int minutes, int hours, int year, int month, int day, int week, int ampm) { canvas.drawColor(background); canvas.drawText(Util.formatTime(hours), this.leftHour, this.topHour, this.hourFont); canvas.drawText(Util.formatTime(minutes), this.leftMinute, this.topMinute, this.timeFont); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, week); String date = String.format("%02d / %02d %s", day, month, new SimpleDateFormat("EE").format(calendar.getTime())); canvas.drawText(date, leftDate, topDate, this.dateFont); }
Example #11
Source File: MalvarezClock.java From AmazfitAPKs with Apache License 2.0 | 5 votes |
@Override public void onDrawDigital(Canvas canvas, float width, float height, float centerX, float centerY, int seconds, int minutes, int hours, int year, int month, int day, int week, int ampm) { canvas.drawColor(background); canvas.drawText(Util.formatTime(hours), this.leftHour, this.topHour, this.hourFont); canvas.drawText(Util.formatTime(minutes), this.leftMinute, this.topMinute, this.timeFont); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, week); String date = String.format("%02d / %02d %s", day, month, new SimpleDateFormat("EE").format(calendar.getTime())); canvas.drawText(date, leftDate, topDate, this.dateFont); }
Example #12
Source File: BigImageWeather.java From AmazfitAPKs with Apache License 2.0 | 5 votes |
@Override public void draw(Canvas canvas, float width, float height, float centerX, float centerY) { if(weather!=null && weather.weatherType<22){ //int idx = ThreadLocalRandom.current().nextInt(0,weatherIcons.length); int idx = weather.weatherType; Drawable weatherIcon = weatherIcons[idx]; float y = verticalOffset; //160 + 16;//160 - 120; float x = 160 - 175/2; canvas.drawBitmap(Util.drawableToBitmap(weatherIcon), x, y, null); } }
Example #13
Source File: ThreeLines.java From AmazfitAPKs with Apache License 2.0 | 5 votes |
@Override public void onDrawDigital(Canvas canvas, float width, float height, float centerX, float centerY, int seconds, int minutes, int hours, int year, int month, int day, int week, int ampm) { canvas.drawColor(background); String sDate = String.format("%02d/%02d", day, month); String sTime = Util.formatTime(hours) + ":" + Util.formatTime(minutes); final float totalHeight = fontHeight * (nLines - 1) - verticalOffset; final float x = width / 2; float y = globalVerticalOffset + fontHeight / 2 + height / 2 - totalHeight / 2 - nLines*4 + 2; canvas.drawText(sDate, x, y, this.dateFont); y += fontHeight; canvas.drawText(sTime, x, y, this.timeFont); }
Example #14
Source File: CirclesWidget.java From AmazfitAPKs with Apache License 2.0 | 5 votes |
@Override public List<SlptViewComponent> buildSlptViewComponent(Service service) { Typeface timeTypeFace = ResourceManager.getTypeFace(service.getResources(), ResourceManager.Font.BEBAS_NEUE); SlptLinearLayout steps = new SlptLinearLayout(); steps.alignX = 2; steps.alignY = 2; steps.add(new SlptTodayStepNumView()); steps.setTextAttrForAll( service.getResources().getDimension(R.dimen.circles_font_size_slpt), -16777216 , timeTypeFace ); SlptPowerArcAnglePicView powerArcView = new SlptPowerArcAnglePicView(); powerArcView.setImagePicture(Util.assetToBytes(service, "battery_splt.png")); powerArcView.start_angle = (int) startAngleBattery + 180 - 3; powerArcView.full_angle = (int) arcSizeBattery + 6; SlptTodayStepArcAnglePicView stepArcPicView = new SlptTodayStepArcAnglePicView(); stepArcPicView.setImagePicture(Util.assetToBytes(service, "steps_splt.png")); stepArcPicView.start_angle = (int) startAngleSteps + 180 - 3; stepArcPicView.full_angle = (int) arcSizeSteps + 6; return Arrays.asList(steps, stepArcPicView, powerArcView); }
Example #15
Source File: FloorWidget.java From AmazfitAPKs with Apache License 2.0 | 5 votes |
@Override public List<SlptViewComponent> buildSlptViewComponent(Service service) { byte[] num0 = Util.assetToBytes(service.getApplicationContext(), "num0.png"); byte[] num1 = Util.assetToBytes(service.getApplicationContext(), "num1.png"); byte[] num2 = Util.assetToBytes(service.getApplicationContext(), "num2.png"); byte[] num3 = Util.assetToBytes(service.getApplicationContext(), "num3.png"); byte[] num4 = Util.assetToBytes(service.getApplicationContext(), "num4.png"); byte[] num5 = Util.assetToBytes(service.getApplicationContext(), "num5.png"); byte[] num6 = Util.assetToBytes(service.getApplicationContext(), "num6.png"); byte[] num7 = Util.assetToBytes(service.getApplicationContext(), "num7.png"); byte[] num8 = Util.assetToBytes(service.getApplicationContext(), "num8.png"); byte[] num9 = Util.assetToBytes(service.getApplicationContext(), "num9.png"); byte[][] SlptNumArray = new byte[][]{num0, num1, num2, num3, num4, num5, num6, num7, num8, num9}; SlptLinearLayout floors = new SlptLinearLayout(); SlptTodayFloorNumView floorsnum = new SlptTodayFloorNumView(); SlptPictureView floorsunit = new SlptPictureView(); floors.add(new SlptTodayFloorNumView()); floors.setImagePictureArrayForAll(SlptNumArray); floors.setStart( (int) service.getResources().getDimension(R.dimen.floors_text_left_slpt), (int) service.getResources().getDimension(R.dimen.floors_text_top_slpt)); floors.alignX = 2; floors.alignY=0; floors.setRect(28,21); return Arrays.asList(new SlptViewComponent[]{floors}); }
Example #16
Source File: BatteryWidget.java From AmazfitAPKs with Apache License 2.0 | 5 votes |
public List<SlptViewComponent> buildSlptViewComponent(Service service) { byte[] SlptBlank = Util.assetToBytes(service.getApplicationContext(), "blank.png"); byte[] SlptZero = Util.assetToBytes(service.getApplicationContext(), "zero.png"); byte[] SlptBatteryIcon100 = Util.assetToBytes(service.getApplicationContext(), "battery100.png"); byte[] SlptBatteryIcon90 = Util.assetToBytes(service.getApplicationContext(), "battery90.png"); byte[] SlptBatteryIcon80 = Util.assetToBytes(service.getApplicationContext(), "battery80.png"); byte[] SlptBatteryIcon70 = Util.assetToBytes(service.getApplicationContext(), "battery70.png"); byte[] SlptBatteryIcon60 = Util.assetToBytes(service.getApplicationContext(), "battery60.png"); byte[] SlptBatteryIcon50 = Util.assetToBytes(service.getApplicationContext(), "battery50.png"); byte[] SlptBatteryIcon40 = Util.assetToBytes(service.getApplicationContext(), "battery40.png"); byte[] SlptBatteryIcon30 = Util.assetToBytes(service.getApplicationContext(), "battery30.png"); byte[] SlptBatteryIcon20 = Util.assetToBytes(service.getApplicationContext(), "battery20.png"); byte[] SlptBatteryIcon10 = Util.assetToBytes(service.getApplicationContext(), "battery10.png"); byte[] SlptBatteryIcon0 = Util.assetToBytes(service.getApplicationContext(), "battery0.png"); byte[][] SlptBatteryArray = new byte[][]{SlptBatteryIcon0, SlptBatteryIcon10, SlptBatteryIcon20, SlptBatteryIcon30, SlptBatteryIcon40, SlptBatteryIcon50, SlptBatteryIcon60, SlptBatteryIcon70, SlptBatteryIcon80, SlptBatteryIcon90}; byte[][] SlptBatteryArray100 = new byte[][]{SlptZero, SlptBatteryIcon100, SlptBlank, SlptBlank, SlptBlank, SlptBlank, SlptBlank, SlptBlank, SlptBlank, SlptBlank}; SlptLinearLayout BatteryIcon10 = new SlptLinearLayout(); BatteryIcon10.add(new SlptPowerNumView()); BatteryIcon10.setImagePictureArrayForAll(SlptBatteryArray); BatteryIcon10.setStart(-17, 17); SlptLinearLayout BatteryIcon100 = new SlptLinearLayout(); BatteryIcon100.add(new SlptPowerNumView()); BatteryIcon100.setImagePictureArrayForAll(SlptBatteryArray100); BatteryIcon100.setStart(-17, 17); BatteryIcon100.alignX = (byte) 1; BatteryIcon100.alignY = (byte) 0; BatteryIcon100.setRect(960, 320); return Arrays.asList(new SlptViewComponent[]{BatteryIcon100, BatteryIcon10}); }
Example #17
Source File: SportTotalDistanceWidget.java From GreatFit with MIT License | 5 votes |
public void init(Service service) { this.mService = service; this.total_distancePaint = new Paint(Paint.ANTI_ALIAS_FLAG); this.total_distancePaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.total_distancePaint.setTextSize(settings.total_distanceFontSize); this.total_distancePaint.setColor(settings.total_distanceColor); this.total_distancePaint.setTextAlign( (settings.total_distanceAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); if(settings.total_distanceIcon){ this.total_distanceIcon = Util.decodeImage(service.getResources(),"icons/"+settings.is_white_bg+"total_distance.png"); } }
Example #18
Source File: FloorWidget.java From GreatFit with MIT License | 5 votes |
@Override public void init(Service service) { // Font this.textPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.textPaint.setColor(settings.floorsColor); this.textPaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.textPaint.setTextSize(settings.floorsFontSize); this.textPaint.setTextAlign( (settings.floorsAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); if(settings.floorsIcon){ this.icon = Util.decodeImage(service.getResources(),"icons/"+settings.is_white_bg+"floors.png"); } }
Example #19
Source File: BatteryWidget.java From GreatFit with MIT License | 5 votes |
public void init(Service service) { this.mService = service; // Battery percent element if(settings.battery_percent>0){ if(settings.battery_percentIcon){ this.icon = Util.decodeImage(mService.getResources(),"icons/"+settings.is_white_bg+"battery.png"); } this.batteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG); this.batteryPaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.batteryPaint.setTextSize(settings.battery_percentFontSize); this.batteryPaint.setColor(settings.battery_percentColor); this.batteryPaint.setTextAlign( (settings.battery_percentAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); } // Battery as images if(settings.batteryProg>0 && settings.batteryProgType==1) { this.batteryIcon = Util.decodeImage(mService.getResources(),"battery/battery0.png"); } // Progress Bar Circle if(settings.batteryProg>0 && settings.batteryProgType==0){ this.ring = new Paint(Paint.ANTI_ALIAS_FLAG); this.ring.setStrokeCap(Paint.Cap.ROUND); this.ring.setStyle(Paint.Style.STROKE); this.ring.setStrokeWidth(settings.batteryProgThickness); } }
Example #20
Source File: ResourceManager.java From GreatFit with MIT License | 5 votes |
public static byte[] getVergeImageFromAssets(Boolean verge, Context var0, String var1) { byte[] file; if(!verge) { file = SimpleFile.readFileFromAssets(var0, var1); }else{ Bitmap image = Util.decodeImage(var0.getResources(),"background.png"); image = Bitmap.createScaledBitmap(image, 360, 360, false); file = getBytesFromBitmap(image); } return file; }
Example #21
Source File: MainClock.java From AmazfitAPKs with Apache License 2.0 | 4 votes |
@Override public List<SlptViewComponent> buildSlptViewComponent(Service service) { SlptPictureView background = new SlptPictureView(); background.setImagePicture(Util.assetToBytes(service, "background_heart_splt.png")); SlptLinearLayout hourLayout = new SlptLinearLayout(); hourLayout.add(new SlptHourHView()); hourLayout.add(new SlptHourLView()); hourLayout.setStringPictureArrayForAll(this.digitalNums); SlptLinearLayout minuteLayout = new SlptLinearLayout(); minuteLayout.add(new SlptMinuteHView()); minuteLayout.add(new SlptMinuteLView()); minuteLayout.setStringPictureArrayForAll(this.digitalNums); Typeface timeTypeFace = ResourceManager.getTypeFace(service.getResources(), ResourceManager.Font.BEBAS_NEUE); hourLayout.setTextAttrForAll( service.getResources().getDimension(R.dimen.time_font_size), -16777216, timeTypeFace); minuteLayout.setTextAttrForAll( service.getResources().getDimension(R.dimen.time_font_size), -65536, timeTypeFace); hourLayout.setStart( (int) service.getResources().getDimension(R.dimen.time_hour_left_slpt), (int) service.getResources().getDimension(R.dimen.time_hour_top_slpt)); hourLayout.alignX = 2; hourLayout.alignY = 0; hourLayout.setRect(320,160); minuteLayout.setStart( (int) service.getResources().getDimension(R.dimen.time_minute_left_slpt), (int) service.getResources().getDimension(R.dimen.time_minute_top_slpt)); minuteLayout.alignX=2; minuteLayout.alignY=0; minuteLayout.setRect(320,160); SlptPictureView dash = new SlptPictureView(); dash.setStringPicture(" -"); SlptLinearLayout dayLayout = new SlptLinearLayout(); dayLayout.add(new SlptDayHView()); dayLayout.add(new SlptDayLView()); dayLayout.add(dash); SlptLinearLayout monthLayout = new SlptLinearLayout(); monthLayout.add(new SlptMonthHView()); monthLayout.add(new SlptMonthLView()); for (SlptLayout component : Arrays.asList(monthLayout, dayLayout)) { component.setTextAttrForAll( service.getResources().getDimension(R.dimen.date_font_size), -16777216, timeTypeFace ); } dayLayout.setStart( (int) service.getResources().getDimension(R.dimen.date_left_slpt), (int) service.getResources().getDimension(R.dimen.date_top_slpt)); monthLayout.setStart( (int) service.getResources().getDimension(R.dimen.month_left_slpt), (int) service.getResources().getDimension(R.dimen.month_top_slpt)); SlptLinearLayout WeekdayLayout = new SlptLinearLayout(); WeekdayLayout.add(new SlptWeekView()); WeekdayLayout.setStart( (int) service.getResources().getDimension(R.dimen.week_left_slpt), (int) service.getResources().getDimension(R.dimen.week_top_slpt)); WeekdayLayout.setTextAttrForAll(service.getResources().getDimension(R.dimen.date_font_size), -16777216, timeTypeFace ); WeekdayLayout.alignX = (byte) 2; WeekdayLayout.alignY = (byte) 0; WeekdayLayout.setRect(50, 40); return Arrays.asList(background, hourLayout, minuteLayout, dayLayout, monthLayout, WeekdayLayout); }
Example #22
Source File: MoonPhaseWidget.java From GreatFit with MIT License | 4 votes |
private Bitmap getMoonphaseImageIcon(int i) { String name = "moon/moon"+Integer.toString(i)+".png"; return Util.decodeImage(mService.getResources(),name); }
Example #23
Source File: MainClock.java From GreatFit with MIT License | 4 votes |
@Override public void init(Service service) { //this.background = service.getResources().getDrawable(R.drawable.background); //todo //this.background.setBounds(0, 0, 320, 300); this.background = Util.decodeImage(service.getResources(),settings.is_white_bg+"background.png"); if(settings.isVerge()) this.background = Bitmap.createScaledBitmap(this.background, 360, 360, true); if(settings.digital_clock) { this.hourFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.hourFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.hourFont.setTextSize(settings.hoursFontSize); this.hourFont.setColor(settings.hoursColor); this.hourFont.setTextAlign((settings.hoursAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER); this.minutesFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.minutesFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.minutesFont.setTextSize(settings.minutesFontSize); this.minutesFont.setColor(settings.minutesColor); this.minutesFont.setTextAlign((settings.minutesAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER); this.secondsFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.secondsFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.secondsFont.setTextSize(settings.secondsFontSize); this.secondsFont.setColor(settings.secondsColor); this.secondsFont.setTextAlign((settings.secondsAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER); this.indicatorFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.indicatorFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.indicatorFont.setTextSize(settings.indicatorFontSize); this.indicatorFont.setColor(settings.indicatorColor); this.indicatorFont.setTextAlign((settings.indicatorAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER); this.ampmFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.ampmFont.setColor(settings.am_pmColor); this.ampmFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.ampmFont.setTextSize(settings.am_pmFontSize); this.ampmFont.setTextAlign((settings.am_pmAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER); } if(settings.analog_clock) { this.hourHand = Util.decodeImage(service.getResources(),"timehand/hour"+ ((settings.isVerge())?"_verge":"") +".png"); this.minuteHand = Util.decodeImage(service.getResources(),"timehand/minute"+ ((settings.isVerge())?"_verge":"") +".png"); this.secondsHand = Util.decodeImage(service.getResources(),"timehand/seconds"+ ((settings.isVerge())?"_verge":"") +".png"); } if(settings.date>0) { this.dateFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.dateFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.dateFont.setTextSize(settings.dateFontSize); this.dateFont.setColor(settings.dateColor); this.dateFont.setTextAlign((settings.dateAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER); if (settings.dateIcon) { this.dateIcon = Util.decodeImage(service.getResources(), "icons/"+settings.is_white_bg+"date.png"); } } this.weekdayFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.weekdayFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.weekdayFont.setTextSize(settings.weekdayFontSize); this.weekdayFont.setColor(settings.weekdayColor); this.weekdayFont.setTextAlign( (settings.weekdayAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); this.dayFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.dayFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.dayFont.setTextSize(settings.dayFontSize); this.dayFont.setColor(settings.dayColor); this.dayFont.setTextAlign( (settings.dayAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); this.monthFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.monthFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.monthFont.setTextSize(settings.monthFontSize); this.monthFont.setColor(settings.monthColor); this.monthFont.setTextAlign( (settings.monthAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); this.yearFont = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); this.yearFont.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font)); this.yearFont.setTextSize(settings.yearFontSize); this.yearFont.setColor(settings.yearColor); this.yearFont.setTextAlign( (settings.yearAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER ); }
Example #24
Source File: MainClock.java From xDrip-Watchface with Apache License 2.0 | 4 votes |
@Override public void onDrawDigital(Canvas canvas, float width, float height, float centerX, float centerY, int seconds, int minutes, int hours, int year, int month, int day, int week, int ampm) { // Draw background image this.background.draw(canvas); // Draw hours //canvas.drawText( (this.no_0_on_hour_first_digit)?hours+"":Util.formatTime(hours), this.leftHour, this.topHour, this.hourFont); // Draw minutes //canvas.drawText(Util.formatTime(minutes), this.leftMinute, this.topMinute, this.minutesFont); // JAVA calendar get/show time library Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, week); // Draw Date if(this.dateBool) { String date = Util.formatTime(day)+"."+Util.formatTime(month)+"."+Integer.toString(year);//String.format("%02d.%02d.%02d", day, month, year); canvas.drawText(date, leftDate, topDate, this.dateFont); } // Draw Day if(this.dayBool) { String dayText = Util.formatTime(day); canvas.drawText(dayText, leftDay, topDay, this.dayFont); } // Get + Draw WeekDay (using JAVA) if(this.weekdayBool) { //String weekday = String.format("%S", new SimpleDateFormat("EE").format(calendar.getTime())); int weekdaynum = calendar.get(Calendar.DAY_OF_WEEK)-1; String weekday = (this.three_letters_day_if_textBool)? days_3let[this.language][weekdaynum] : days[this.language][weekdaynum] ; canvas.drawText(weekday, leftWeekday, topWeekday, this.weekdayFont); } // Draw Month if(this.monthBool) { String monthText = (this.month_as_textBool)? ( (this.three_letters_month_if_textBool)? months_3let[this.language][month] : months[this.language][month] ) : String.format("%02d", month) ; canvas.drawText(monthText, leftMonth, topMonth, this.monthFont); } // Draw Year if(this.yearBool) { canvas.drawText(Integer.toString(year), leftYear, topYear, this.yearFont); } // Draw Seconds if(this.secondsBool) { canvas.drawText(Util.formatTime(seconds), leftSeconds, topSeconds, this.secondsFont); } // : indicator Draw + Flashing if(this.indicatorBool) { String indicator = ":"; if (seconds % 2 == 0 || !this.indicatorFlashBool) { // Draw only on even seconds (flashing : symbol) canvas.drawText(indicator, this.leftIndicator, this.topIndicator, this.indicatorFont); } } }
Example #25
Source File: CirclesWidget.java From malvarez-watchface with Apache License 2.0 | 4 votes |
@Override public List<SlptViewComponent> buildSlptViewComponent(Service service) { Typeface timeTypeFace = ResourceManager.getTypeFace(service.getResources(), ResourceManager.Font.BEBAS_NEUE); SlptLinearLayout power = new SlptLinearLayout(); power.alignX = 2; power.alignY = 2; power.add(new SlptPowerNumView()); power.setTextAttrForAll( service.getResources().getDimension(R.dimen.malvarez_circles_font_size_slpt), -1, timeTypeFace ); power.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_battery_text_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_battery_text_top_slpt)); SlptLinearLayout steps = new SlptLinearLayout(); steps.alignX = 2; steps.alignY = 2; steps.add(new SlptTodayStepNumView()); steps.setTextAttrForAll( service.getResources().getDimension(R.dimen.malvarez_circles_font_size_slpt), -1, timeTypeFace ); steps.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_steps_text_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_steps_text_top_slpt)); SlptLinearLayout sport = new SlptLinearLayout(); sport.add(new SlptTodaySportDistanceLView()); sport.setTextAttrForAll( service.getResources().getDimension(R.dimen.malvarez_circles_font_size_slpt), -1, timeTypeFace ); sport.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_sport_text_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_sport_text_top_slpt)); SlptPowerArcAnglePicView powerArcView = new SlptPowerArcAnglePicView(); powerArcView.setImagePicture(Util.assetToBytes(service, "battery_splt.png")); powerArcView.start_angle = (int) startAngleBattery + 180 - 3; powerArcView.full_angle = (int) arcSizeBattery + 6; SlptTodayStepArcAnglePicView stepArcPicView = new SlptTodayStepArcAnglePicView(); stepArcPicView.setImagePicture(Util.assetToBytes(service, "steps_splt.png")); stepArcPicView.start_angle = (int) startAngleSteps + 180 - 3; stepArcPicView.full_angle = (int) arcSizeSteps + 6; SlptTodayDistanceArcAnglePicView distanceArcPicView = new SlptTodayDistanceArcAnglePicView(); distanceArcPicView.setImagePicture(Util.assetToBytes(service, "sports_splt.png")); distanceArcPicView.start_angle = (int) startAngleSport + 180 - 3; distanceArcPicView.full_angle = (int) arcSizeSport + 6; return Arrays.asList(power, steps, sport, powerArcView, stepArcPicView, distanceArcPicView); }
Example #26
Source File: MalvarezClock.java From malvarez-watchface with Apache License 2.0 | 4 votes |
@Override public List<SlptViewComponent> buildSlptViewComponent(Service service) { SlptPictureView background = new SlptPictureView(); background.setImagePicture(Util.assetToBytes(service, "background_splt.png")); SlptLinearLayout hourLayout = new SlptLinearLayout(); hourLayout.add(new SlptHourHView()); hourLayout.add(new SlptHourLView()); hourLayout.setStringPictureArrayForAll(this.digitalNums); SlptLinearLayout minuteLayout = new SlptLinearLayout(); minuteLayout.add(new SlptMinuteHView()); minuteLayout.add(new SlptMinuteLView()); minuteLayout.setStringPictureArrayForAll(this.digitalNums); Typeface timeTypeFace = ResourceManager.getTypeFace(service.getResources(), ResourceManager.Font.BEBAS_NEUE); hourLayout.setTextAttrForAll( service.getResources().getDimension(R.dimen.malvarez_time_font_size), -1, timeTypeFace); minuteLayout.setTextAttrForAll( service.getResources().getDimension(R.dimen.malvarez_time_font_size), -65536, timeTypeFace); hourLayout.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_time_hour_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_time_hour_top_slpt)); minuteLayout.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_time_minute_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_time_minute_top_slpt)); SlptLinearLayout dayLayout = new SlptLinearLayout(); dayLayout.add(new SlptDayHView()); dayLayout.add(new SlptDayLView()); SlptLinearLayout monthLayout = new SlptLinearLayout(); monthLayout.add(new SlptMonthHView()); monthLayout.add(new SlptMonthLView()); SlptWeekView weekView = new SlptWeekView(); for (SlptLayout component : Arrays.asList(monthLayout, dayLayout)) { component.setTextAttrForAll( service.getResources().getDimension(R.dimen.malvarez_date_font_size), -1, timeTypeFace ); } weekView.setTextAttr( service.getResources().getDimension(R.dimen.malvarez_date_font_size), -1, timeTypeFace ); dayLayout.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_date_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_date_top_slpt)); monthLayout.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_month_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_month_top_slpt)); weekView.setStart( (int) service.getResources().getDimension(R.dimen.malvarez_week_left_slpt), (int) service.getResources().getDimension(R.dimen.malvarez_week_top_slpt)); return Arrays.asList(background, hourLayout, minuteLayout, dayLayout, monthLayout, weekView); }