Java Code Examples for com.huami.watch.watchface.util.Util#decodeImage()

The following examples show how to use com.huami.watch.watchface.util.Util#decodeImage() . 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 vote down vote up
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 vote down vote up
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: HeartRateWidget.java    From GreatFit with MIT License 6 votes vote down vote up
@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 4
Source File: SportTodayDistanceWidget.java    From GreatFit with MIT License 6 votes vote down vote up
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 5
Source File: CaloriesWidget.java    From GreatFit with MIT License 6 votes vote down vote up
@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 6
Source File: ResourceManager.java    From GreatFit with MIT License 5 votes vote down vote up
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 7
Source File: BatteryWidget.java    From GreatFit with MIT License 5 votes vote down vote up
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 8
Source File: FloorWidget.java    From GreatFit with MIT License 5 votes vote down vote up
@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 9
Source File: SportTotalDistanceWidget.java    From GreatFit with MIT License 5 votes vote down vote up
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 10
Source File: MainClock.java    From GreatFit with MIT License 4 votes vote down vote up
@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 11
Source File: MoonPhaseWidget.java    From GreatFit with MIT License 4 votes vote down vote up
private Bitmap getMoonphaseImageIcon(int i) {
    String name = "moon/moon"+Integer.toString(i)+".png";
    return Util.decodeImage(mService.getResources(),name);
}