Help with Resource Folder

I've set up resource folder's for multiple devices such as 390x390, 280x280, etc.

I am trying to customize the code for heart rate, date and other texts but I do not see any change whatsoever. 

In the View.mc folder, the following code works perfectly to draw the hr:

      dc.setColor(Application.getApp().getProperty("ForegroundColor"),Gfc.COLOR_TRANSPARENT);

      dc.drawText(0,0,Gfx.FONT_SMALL, hr,Gfx.TEXT_JUSTIFY_LEFT);

In order to customize the draw on other devices, I've tested the string listed below in the respective layout folder and the resources folder similar to the "PluralsightTribute" SDK. Does anyone know what is the best way to display these in multiple devices?

The below codes are the ones I've tried using in the layout or resource file, but I have seen no change when I select the appropriate device... What am I missing?

Any help would be appreciated!

<layout id="WatchFace">

    <label id="ShowHeartRateLabel" x="0" y="0" font="Graphics.FONT_SMALL" justification="Graphics.TEXT_JUSTIFY_LEFT" />

    <label id="HeartrateDisplay" text="000" x="0" y="0" font="@Fonts.smallFont" justification="Gfx.TEXT_JUSTIFY_CENTER" color="Gfx.COLOR_WHITE" />    

</layout> 

  • I've tried to reproduce and I'm seeing weird things with the resources not applying correctly for devices. If I modify the resource file the change will take effect, but if I then switch devices the old xml will be used.

    Are you using the vscode plugin or eclipse?

  • What I see is you are using dc.drawText() so the layout you posted isn't even used for anything.

    I'm confused.

  • I’ve tried many ways to shift the heart rate on devices based on their size by using dc or without dc callout and I get the same results irrespective of what I use. 

    The dc.drawText works well on all the devices. The problem is the HR or any other text doesn’t shift when I recode on a resource folder for a device such as round-390x390 or 280x280. 

  • one simple solution with dc.drawText() is that you make use of dc.getWidth()/dc.getHeight() and set the x,y for the draw based on that.

    it could be as simple is setting "x" at width*.1. (10% of the width)

  • correct. I have  dc.drawText "x" and "y" in the view.mc file. That x,y is applied across the board to all devices.

    But when I try to code different x,y on every resource folder screen respectively, they do not work. Not sure why it is not working

    I have attached an example of the code I have used in the resources-rectangle-205x148>layouts>layout.xml file.

    .

    <layout id="WatchFace">
        <drawable class="Background" />
        <label id="TimeLabel" x="center" y="center" font="Graphics.FONT_LARGE" justification="Graphics.TEXT_JUSTIFY_CENTER" color="Graphics.COLOR_BLUE" />
        <label id="showHeartRate" x="1" y="15" font="Graphics.FONT_SMALL" justification="Graphics.TEXT_JUSTIFY_LEFT" />
    </layout>

  • Okay but where's your Monkey C code that actually calls setLayout(Rez.Layouts.WatchFace, dc) ? Where's the code in onUpdate() that assigns text values to TimeLabel and showHeartRate? Right now these are just labels whose text is empty, so it's natural that nothing is displayed, even if the layout is being used.

    If you think that the layout is already used by your code but isn't being picked up, what happens if you change the layout id to something invalid like "_WatchFace"? Do you get a compile error? This is the kind of sanity check you can use to see if your code is even being used at all.

  • I currently have the code in the onLayout portion as written below. The TimeLabel and HR are listed in onUpdate in the class extends WatchUi.WatchFace file (view.mc).

        function onLayout(dc) {setLayout(Rez.Layouts.WatchFace(dc));

    I tried the "_WatchFace" for one of the screen types (ex.resources-round-218x218) and I did get an error. I kept that same invalid code and ran the sim for another device screen (ex.resources-round-240x240) and the sim ran well.

    I have tried using the "PluralsightTribute" SDK as a guide throughout the process...

  • You can use the same "invalid id" technique to verify that the SDK isn't picking up your resources for a given screen size (e.g. 390x390), by changing the layout IDs for all devices except the 390x390 layout to an invalid ID.

    Or even easier, just temporarily move all the non 390-390 resource folders (except for the common resource folder) somewhere else, and build for your 390x390 device. You should get a compile time error. If that happens, you're probably seeing some variant of the bug that Travis is seeing.

  • I have used the "invalid id" technique for all the folders and I did get an error on each folder except the main folder. This is the build error I received each time on each folder:

    "BUILD: ERROR: Invalid resource '_WatchFace' in attribute 'id'. Please use a valid Monkey C identifier."

    I also tried all the "id" I can think of in thoughts I was doing something wrong...So yeah maybe Travis' observation is correct?

    on another note...any thoughts how to modify the analog arms on difference screens? For example the 240x240 arms are too small for the 309x309 and too big for the 205 x 148 screens.