yashsingh1/xdaforums huggingface dataset:
[Amazfit] chidav77:
You probably are right but... The hours.getColor(i++,0) how works?

I didnt remove any element from the array.

I mean... Hours is a typed array, but the getColor method what does it get?

I dont know if im clear in the explanation...

Sorry again...
[Amazfit] GreatApo:
The getColor gets whatever it finds :p but you indicate that a color is at that point of the array.

The getColor function is defined as:

public int getColor(int index, int defValue) {...}

The first parameter is the index of the array (eg. color is at 3rd position in the hours array, but i use the i++ to avoid numbering them) and the second parameter if the default value (i guess if not color is found or sth like that).

Ps. The hours.getColor(i++,0) tries to read the item beneath:

<array name="hours">
<item name="font_size">190px</item>
<item name="left">108px</item>
<item name="top">226px</item>
<item name="color">#ff0000</item> <!-- THIS ITEM -->
<item name="align_left">false</item>
</array>

It is the same as hours.getColor(3,0/*this is the default value*/)

If you change the getColor with getString it will take the hex color string, but then you need to pass it through Color.parseColor() to get the color number equivalent (this is how android works).
[Amazfit] chidav77:
Thanks boss. Now I have understood how it works...

See you at the next question! ?

Thanks again!
[Amazfit] chidav77:
Hi boss, still me asking questions...

I need your help.

I have drawn a circle and a rounded rectangle with canvas and is all fine.

Now I have to replicate the same layout while in sleep mode... Unfortunately I dont understand how have you done to draw on sleep mode.

Could you please give me some hint on how to draw images in sleep mode?

I know that to work on buildSlptViewComponent but I have no idea on how draw something... seems that there is no canvas...

thanks again
[Amazfit] GreatApo:
Unlike canvas where you can "draw" text or geometric shapes, sleep mode (slpt) works 100% with images. Even when you define a text to be displayed, the code actually converts it to an image, that is why the position you assigns on your test is relevant to its top right corner and not font's base line like in canvas mode.

Now back to your specific question. There are 2 ways to create a progress bar in slpt mode. The first way is by defining an array of images of different states of the progress bar (for example many battery icons with different level of battery each). The second way (that you are probably interested in) is by drawing part of an image that is cropped in a rotation way. If you draw a circle in an image, you can set the starting angle of a bar and the ending of a bar and the libraries would automatically crop and display only that part of the image in your SLPT mode. Like the other auto-updated elements in SLPT, different predefined elements are used to display batter, daily steps (etc) progress circles.

At the bottom of the battery widget you will find both progress bar ways coded (search for "Battery as images" and "Battery bar"). Mind that in the case of the battery bar, the "Draw background image" part of the code just prints the grey circle behind the actual progress bar (to make it like it is empty on the cropped part).

Have a look at the code, don't get frustrated on the calculation each property of the bar (setImagePicture, setStart, start_angle, len_angle, full_angle, draw_clockwise) they do what it is indicated by their names, the parametric design of greatfit makes is complex. As always, you can directly customize the progress-bar from the value/*.xml files.
[Amazfit] chidav77:
Wow... Really complex...

Im doing something easier than a progress bar dynamic... I have static images for now...

So if i understood i have to create images of what I have done with canvas... Right?

By the way... How do you update (progress bar for example) the draw based on a value? (for example the battery value)

Is there some specific method to call?
[Amazfit] GreatApo:
Then you need to use the first way I mention. You can't manually update the values in SLPT mode. You use different element (that are supported) and the values are auto updated by the system. For the battery, you have to use the "SlptBatteryView" element. The only way to manually update the SLPT mode (as for now) is to restart the whole SLPT service. This is how all the custom stuff I have coded work (btw in the last couple of versions the refresh don't work when screen is off).

Again, have a look at the end of the battery widget, this is the code you need:

int battery_steps = 11;
byte[][] arrayOfByte = new byte[battery_steps][];
for (int i = 0; i < arrayOfByte.length; i++) {
arrayOfByte[i] = SimpleFile.readFileFromAssets(service, String.format(((better_resolution) ? "" : "slpt_") + "battery/battery%d.png", i));
}
SlptBatteryView localSlptBatteryView = new SlptBatteryView(battery_steps);
localSlptBatteryView.setImagePictureArray(arrayOfByte);
localSlptBatteryView.setStart((int) settings.batteryProgLeft, (int) settings.batteryProgTop);
slpt_objects.add(localSlptBatteryView);

Of course you can manually define the "arrayOfByte" array like this:

byte[][] arrayOfByte = new byte[11][];
arrayOfByte[0] = SimpleFile.readFileFromAssets(service, "battery/battery0.png");
...
arrayOfByte[10] = SimpleFile.readFileFromAssets(service, "battery/battery10.png");
[Amazfit] chidav77:
Sorry another question.

In your code I see SlptBatteryView. I suppose is an object of the "watch".

Which kind of view are available?
[Amazfit] GreatApo:
These objects:

SlptPowerArcAnglePicView
SlptTodayDistanceArcAnglePicView
SlptTodayStepArcAnglePicView
[Amazfit] chidav77:
Hi master

could you please explain or tell me where to find documentation for the following code?

hourLayout.setTextAttrForAll(
settings.hoursFontSize,
settings.hoursColor,
timeTypeFace
);
// Position based on screen on
hourLayout.alignX = 2;
hourLayout.alignY = 0;
hourLayout.setRect(
(int) (2 * settings.hoursLeft + 640),
(int) (((float) settings.font_ratio / 100) * settings.hoursFontSize)
);
hourLayout.setStart(
-320,
(int) (settings.hoursTop - ((float) settings.font_ratio / 100) * settings.hoursFontSize)
);

In particular methods "setTextAttrForAll", "setRect" and "setStart"...

I cannot find anything on google....

Thanks again... and again sorry to disturb
[Amazfit] GreatApo:
There is no proper documentation :P. You look at ingenic's api documentation but it really is just a cheap list of the classes. The best thing you can to is shift+click on the objects and read the code and how they are defined.

"setStart" just sets the location of the element (distance from top and distance form left). GreatFit's code is complex because it relates the location of the screen on to the location of the screen off (the picture problem is mentioned in a previous post, read this).

"setRect" limits the layout in a rectangular space. GreatFit uses this property because you can align texts but again it is complex, I define a width 2 times the screen width and then calculate the left position so that the element is centered.

"setTextAttrForAll" is used to style all the text elements in the layout (color, font, size etc)
[Amazfit] chidav77:
sorry boss.... I'm going crazy..

I changed the font, but in the sleep view it shows hours "cutted" on the top... I tried to change every param (font ratio, rect x, rect y) but I can only move the hours... always cutted on top.

please... give me help if you can
[Amazfit] GreatApo:
Remove the setRect command completely (or increase its height). It is because of the font ratio, the height of the box is not perfectly calculated.
[Amazfit] chidav77:
unfortunately does not work.

I hardcoded the dimension of the rect and even if I increase height, the hours are cutted on top. It seems aligned on top.

does the alignY is an enumeration?

removing setRect, removes all...
[Amazfit] GreatApo:
Removing setRect should work, you probably didn't also commented the "tmp_left= -320;" value and you text is moved out of the screen.
[Amazfit] chidav77:
the strange thing is that if I low the font size, is always cutted... could it be the font? very strange.. at screen on is perfect....

really I have no idea...

Sorry for my english ;)
[Amazfit] GreatApo:
It is because of the text to image conversion and the font ratio I introduced in the code. I recently found that the base line of the font is a property that is available so I may fix the code in the future.

There is a way to fix the current code but it will be easier for you to just disable the align center on that element. That will avoid the cropping problem.
[Amazfit] chidav77:
Sorry last message for today... How to disable the algn center?

Thanks for your patience
[Amazfit] GreatApo:
GO to the arrays.xml and set all "align_left" items to true.
[Amazfit] chidav77:
Ah... I was thinking a vertical align... Beacause is cutted on top...

By the way, i will try and let you know...
[Amazfit] chidav77:
Hi master, I'm going crazy....

I will try to show my problem

Attached you can find a picture of the issue.

The red square is the "setRect" method.

Inside the square is the hour.

this is the code (please note that is all hardcoded for test purpose)

// Set font
Typeface timeTypeFace = ResourceManager.getTypeFace(service.getResources(), settings.font);
SlptLinearLayout hourLayout = new SlptLinearLayout();
SlptHourHView hourHView = new SlptHourHView();
SlptHourLView hourLView = new SlptHourLView();

hourLayout.add(hourHView);
hourLayout.add(hourLView);

hourLayout.setStringPictureArrayForAll(this.digitalNums);
hourLayout.setTextAttrForAll(
settings.hoursFontSize,
settings.hoursColor,
timeTypeFace
);
hourLayout.alignX = 2;
hourLayout.alignY = 2;
SlptViewComponent.Background background1 = new SlptViewComponent.Background();
background1.color = -65536;
hourLayout.background = background1;
hourLayout.setRect(
100,
100
);

hourLayout.setStart(
50,
153
);

slpt_objects.add(hourLayout);

Basically is your code without variables.

as you can see, the top of the hour are cropped. Every param I move (padding, margin, align) I have always the same results.

do you have any suggestion?

thanks
[Amazfit] GreatApo:
Completely remove the layout.setRect(100,100);

It the hours still cropped?
[Amazfit] chidav77:
If I remove the setRect, nothing appears...
[Amazfit] chidav77:
By the way...

I changed font and I have no more issue... Dont ask me why...
[Amazfit] chidav77:
Hi greatApo, I would like a little explanation on your code because there's something I dont understand....

When load settings for example, I see this code

this.am_pm_always = sharedPreferences.getBoolean( "am_pm_always", context.getResources().getBoolean(R.bool.am_pm_always));

That let me think that the default value is taken from

<bool name="am_pm_always">false</bool> <!-- Show am/pm always (not only when 12h time format) -->

Thats the question...

If I put the false value on the xml, clear data of the package, uninstall and install, the start value is always "true".

Is there another default value that I'm missing?

seems that xml files are not considered...

thanks!
[Amazfit] GreatApo:
Sorry for the delay,

Sounds very strange... it may be the font after all...

Really? You are doing it the correct way, and the code is clear, if you set it to true, it should be true when no preference is found. Are you sure all data are cleared? amazfit works in a strange way...
[Amazfit] chidav77:
I tried to clean as per instruction in the first post...

For example, after cleaning and reinstall, even if the value is false in the xml, the radiobutton in the preferences is checked...

I dont know why, but if you have time to check... Let me know...

Probably im doing something wrong

Thanks
[Amazfit] GreatApo:
The AM/PM is always true is you have the 12h time system.
[Amazfit] chidav77:
Of course but i have 24h setted.

By the way, this is a behaviour not related only to the am pm param. Every value taken from xml seems to be ignored.

Once again... Probably is my fault, but I actually dont know where is the problem
[Amazfit] GreatApo:
So, I went through AM/PM code again. The code and the default value works correctly, however, I found some holes and potential crashes that can arise when you change the time format. I have updated GreatFit's code, what I would propose you to do to is change the LoadSettings.java and use only the am_pm_always values only (and not am_pmBool) like they are on/off.
[Amazfit] GreatApo:
Version 4.1 BETA

Version 4.1 (BETA)
Improvements:
- New Walked distance widget (based on height, imperial/metric, thanks to alvaroDigio)
- New max/min temperatures widget (thanks to lfom)
- Option to show pressure in mmHg added
- Settings seekbars where changed to buttons
- Low battery mode icon added
- World time widget changed to GMT zone based
Fixes:
- SLPT update now works as it should (thanks to lfom)
- Pressure & Altitude improvements/fixes
- Verge white bg flat tire fix
- If white bg: Clock only slpt on verge is now black
- Clock only slpt default true on verge
- AM/PM improvements
- 0 floor fix
- Moonphase white bg slpt icons fix
- libs updated with missing receiver folder (fixes some crashes)
- World Time +30min fix for slpt
- Notifications number font fix
- Crashes related to weather widget

Please report back with problems either here or on GitHub.

Edit: Beta 2 released as version 4.1
[Amazfit] uvys:
Thank you for fixing moonphase icon!
[Amazfit] Santi_SAZ:
Thanks@GreatApo for this awesome watchface.

Walked distance is not shown on screen, I tried in every single widget, but it doesn't show anything.

Do I have to set something? I set my height

Forget it, now works. Unistalled and installed again

Many thanks again
[Amazfit] GreatApo:
It is supposed to work out of the box (there is a default height). I can't think of a way why it didn't...
[Amazfit] Santi_SAZ:
Thanks for the reply.

If I set off always AM/PM and widget 5 is different to Notifications, walked distance is not shown.

If I set always AM/PM ON, widget 5 can be whatever you want, walked distance is shown

That's weird. I can try more configuration if you want
[Amazfit] GreatApo:
Hm... i will look into it. I think that configuration will help :good:
[Amazfit] kwet:
Me too don't work : Walked distance widget... i don't use format AM /PM.
[Amazfit] chidav77:
Hi boss, I have a strange thing.....

I have tried to install your watchface and the one I am developing to a pace of a friend and I receive this error.

08-29 14:03:38.897 1207-1207/? E/CrashHandler: FATAL: watch face crashed
08-29 14:03:38.897 1207-1207/? W/System.err: java.lang.NoSuchMethodError: No virtual method getSportCalories()F in class Lcom/huami/watch/sensor/SensorDataInfo; or its super classes (declaration of 'com.huami.watch.sensor.SensorDataInfo' appears in /system/framework/android.policy.jar)
08-29 14:03:38.898 1207-1207/? W/System.err: at com.huami.watch.watchface.util.SingletonWrapper.getSportCalories(Unknown Source)
08-29 14:03:38.898 1207-1207/? W/System.err: at com.huami.watch.watchface.AbstractWatchFace$BaseEngine$CaloriesDataProvider.requestData(Unknown Source)
08-29 14:03:38.898 1207-1207/? W/System.err: at com.huami.watch.watchface.AbstractWatchFace$BaseEngine.requestWatchData(Unknown Source)
08-29 14:03:38.898 1207-1207/? W/System.err: at com.huami.watch.watchface.AbstractWatchFace$BaseEngine.registerWatchDataListener(Unknown Source)
08-29 14:03:38.898 1207-1207/? W/System.err: at com.cicteam.cicwatchface.AbstractWatchFace$DigitalEngine.onPrepareResources(AbstractWatchFace.java:42)
08-29 14:03:38.898 1207-1207/? W/System.err: at com.huami.watch.watchface.AbstractWatchFace$BaseEngine.onCreate(Unknown Source)
08-29 14:03:38.898 1207-1207/? W/System.err: at android.service.wallpaper.WallpaperService$Engine.attach(WallpaperService.java:873)
08-29 14:03:38.898 1207-1207/? W/System.err: at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:1164)
08-29 14:03:38.899 1207-1207/? W/System.err: at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:37)
08-29 14:03:38.899 1207-1207/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
08-29 14:03:38.899 1207-1207/? W/System.err: at android.os.Looper.loop(Looper.java:135)
08-29 14:03:38.899 1207-1207/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5254)
08-29 14:03:38.899 1207-1207/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
08-29 14:03:38.899 1207-1207/? W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
08-29 14:03:38.899 1207-1207/? W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-29 14:03:38.899 1207-1207/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Please note that.

1) is the version 4.1, not the latest one.

2) the watch is on 2.8.3.0

Have you ever seen this error?

Thanks
[Amazfit] GreatApo:
I will check it out guys, thanks for the feedback

Update the libraries file ;)
[Amazfit] chidav77:
Sorry boss...

Im a newbie... How and which library to update?
[Amazfit] GreatApo:
Close android studio and update this file: https://github.com/GreatApo/GreatFit/blob/master/app/libs/advanced_minified-20190822-universal.jar

(Just delete the one you have and use this one)
[Amazfit] thra1982:
Hi there.

Did you include the Danish translations I posted on the Calendar Widget thread? And if any missing strings let me know. I would really like to see Danish language on this ?
[Amazfit] GreatApo:
I can't replicate the problem... Re-applying the watchface doesn't fix it?

Oh, I forgot it! So sorry! If I haven't included it until next Wednesday, spam my mailbox!
[Amazfit] chidav77:
Hi GreatApo.

I'm trying to work on the widgets.

Is really all clear to me, but I have a strange issue, only on my watchface.

When I change a widget value (from steps to heart for example), is all fine when the screen is on, but in slept mode it keeps both old and new value. The result is an overlap of the 2 values. only in slept mode.

All the flags are correctly evaluated.

If I reboot the watch, the values are correctly displayed in slept mode.

If I change watchface and back to mine, the problem is still present.

Do I miss something? The code is still untouched for widgets....
[Amazfit] kwet:
[MENTION=3668555]GreatApo[/MENTION]

For me, it's good today, but I think against that it lacks a space between the image and the Walked distance on widget...
[Amazfit] GreatApo:
No it's a bug related to the libraries, re-apply the watchface when it happens
[Amazfit] kamild_:
Somehow I cannot find any information about it, but how do I enable ADB on my Amazfit Pace? When I plug the watch into my PC and run 'adb devices', the device isn't there, and drivers are installed.
[Amazfit] GreatApo:
ADB is enabled by default. Just to make it clear, don't expect to see a name "Pace" or sth, it would just be a digits-letters device name. If the watch is not shown up there is a problem with your watch's connection either physically (does the device show up connected) or in terms of the drivers used.
[Amazfit] kamild_:
Ok I just realized there's a physical connection problem, no matter what cable I try, I have to push the cable into the dock really hard to make a connection. Is this common, or is it just my dock being damaged out of the box?

E: OK mystery solved, found a cable that works but ADB would still refuse to work. I've been using an universal ADB driver from ClockworkMod, which doesn't seem like it works with this watch, so I changed the driver to the in-built one ("USB Composite Device") and it popped right up.
[Amazfit] kamild_:
About the app though, thank you, I'm loving the customizability and the overall look, but if I were to nitpick on a few things, i would mention:

- Jagged edges, tough to notice from afar but up close its very visible, would it be possible to implement some sort of antialiasing or smoothing to make them look better? I'm aware there are resolution constraints but maybe...? (EDIT: I only just noticed the edges look like that only when the watch is in stand by)

- With font set to regular (thin IMO looks pretty bad) spacing between certain elements is uneven, for example the charge level indicators look fine but the weather icon not so much, the icon is too close to the percentage. See photo.

Even with those issues in mind I really like Greatfit and I'd rather use this than any other of Xiaomi's watchfaces. :)
[Amazfit] GreatApo:
Yeah, it's due to the limitations of the reflective screen (screen off=slpt mode). That is why when you raise your hand things are slightly better (more colours).

Weather icons are a little bigger than the other icons (24x24 vs 21x21) that's why the spacing is different. Two different position parameters are assigned on each widget (widget as a place on the watchface), one for the icon and one for the text. Thus changing the spacing to "fix" the weather will increase the spacing for the rest of the elements when chosen in that widget.

There are some problems like this because of the wider customization range, for example, you can also show days as full text (not only 3 letters) but that will mesh GreatFit's design (but other devs can use that option in different designs).

And now after all my excuses, I have think of an easy way to fix the weather spacing :p, thanks for the feedback
[Amazfit] kamild_:
Speaking of spacing issues, here's another one with 24h time format.
[Amazfit] GreatApo:
That is because the watch is design based on the thin font and 12h system, thus such complications will exist.
[Amazfit] Adramel:
How do I change the font size?

Is there any possibility of a watchface layout view on the computer?
[Amazfit] GreatApo:
From the arrays.xml file. Just change the "font_size" attributes. Is screen on and screen off have difference positions, you also need to change the "font ratio" number from the integer.xml (in the first post you will find links with more information over this).
[Amazfit] Adramel:
I have one more problem. In 8c mode (off ) the clock flies down.

Is it because I don't change the "font ratio"?

EDIT: The 8c watch doesn't work. Nothing changes on the watchface. Seconds and minutes stand;((((
[Amazfit] GreatApo:
Yes. When you fix that, if you the digits are still cropped, then you need to disable the center alignment and manually fix the left positions.
[Amazfit] Adramel:
But how do you calculate that? I use the IONA-Black.otf font.

https://dafonttop.com/iona-black.font

I switched

Regular ("fonts/IONA-Black.otf"),

the rest without changing. But even on the standard Thin font the clock in Slpt stands - the numbers of the clock do not change.

EDIT:

I rebooted my watch. It works;)

100 was a wanted value.
[Amazfit] darkvoid_66:
I'm glad to see that my code for max/min temp and for walked distance has been integrated in GreatFit. :good:

I was hopping that you could have fixed the fact that it does not refresh walked distance while in SLPT mode.:angel:
[Amazfit] Adramel:
One more thing. I can't find the widget position.

Where is the date (the one under minutes)?
[Amazfit] GreatApo:
Yeah, I will code it to be calculated automatically in the future.

It is suppose to be updated, however, I didn't finish/testing it (I had to release it at that time). So I will improve it more.

Arrays.xml :P
[Amazfit] no2:
Altitude and Air pressure solved

Excellent work,

Widgets with altitude and air pressure are perfectly working now.

Only one question: seconds are available for Amazfit Stratos 2?, I saw some photos in Pace, but I do not how to activate in my Stratos...

One possible future improvement: watchface of Greatfit Apo could be in the watchfaces of Amazfit app.

Congratulations
[Amazfit] GreatApo:
Thanks.

Seconds are automatically enabled when you enable "second hand" option in watch's settings (not GreatFit's settings).

Just re-apply the watchface after changing that setting.
[Amazfit] Adramel:
Is there any way to view the position of the target elements on my computer?

Without having to upload a watchface every time?
[Amazfit] GreatApo:
Nope...

You could make a layout and add some images and text if that will help you, but it will just be a representation.