• Vivoactive 5 Now Available on Connect IQ SDK Manager

    Know the real you with the vívoactive® 5 smartwatch, the ultimate on-wrist coach designed to support your goals — whatever they may be. Featuring a bright, colorful display and up to 11 days of battery life, this GPS smartwatch is purpose-built with essential health and fitness features to help you better understand your body.

    You’ll find vívoactive 5 support available today from the Connect IQ SDK manager. Update your apps today. 

    • Sep 20, 2023
  • Connect IQ 6.3.0 SDK Release

    We have just released Connect IQ SDK version 6.3.0, which introduces the wheelchair API, increase sampling rates for accelerometer, gyroscope and magnetometer, and the addition of the Venu 3/3s devices. There are also a handful of bug fixes that were addressed from previous SDKs.  Here is the full list of updates and changes:

    General Changes

    • Update the Primates sample to use the native page indicator.
    • Add a new sample, TrueTypeFonts, to highlight the new vector font APIs.
    • Add the wheelchair API usages to the ActivityTracking sample.
    • Add non-binary gender to the UserProfile sample.
    • Allow the FPS to be set higher than 10 in the MonkeyMotion app.
    • Fix a bug where PNG images were not accurately decoded for non-GPU enabled devices in the simulator
    • Fix a bug where a deadlock could sometimes occur when installing new apps
    • Fix a bug in API level 4.x products where makeImageRequest() would return a bitmap resource instead of a resource reference.
    • Fix a bug where loading images from application storage would temporarily use app memory instead of allocating from the shared resource pool.
    • Fix a bug where getRegisteredSensors() would not return the correct enabled states for onboard hear-rate and onboard pulse-ox sensors.
    • Fix a bug where setEnabledSensors() did not work correctly for onboard heart-rate and onboard pulse-ox sensors.
    • Add a more useful error string when encountering an illegal access error on accessing an invalid class member by providing the class name and context.
    • Fix a bug where duplicate app listings could be seen after firmware updates.
    • Fix a bug where DCs were not properly invalidated after onUpdate() was called. If an app saved a reference to this DC and attempted to use it while in an invalid state, a device crash could occur.
    • Add support for setting sampling frequency to 100hz for real-time accelerometer data.
    • Add APIs for getting real-time gyroscope and magnetometer data. Gyroscope supports sampling rates up to 100hz, whereas magnetometer supports up to 50hz.

    Simulator Changes

    • Add support for enhanced readability mode.
    • Add support for Archery, Mixed Martial Arts, Motor and Water sports in the activity profile dialog.
    • Add support for Overland and Trolling Motor sub sports in the activity profile dialog.
    • Add support for higher frequency sensor sampling rates.
    • Add support for wheelchair mode.
    • Add support for triggering calls to AppBase.onActive() and AppBase.onInactive().
    • Add support for non-binary gender in the user profile editor.
    • Fix issue where the touch screen could be disabled for touch only devices after running a touch and button device.
    • Fix several issues with the Menu2 implementation.
    • Adjust the toast page to better match the fr965 and fr265 implementation.
    • Allow float input for the battery remaining in days dialog.
    • Allow ANT HR sensors to connect.
    • Fix issue where the user profile editor wouldn’t allow entry for some values.
    • Wrap text in confirmation page if needed.
    • Display the device’s API level in the title bar.
    • Prevent double counting of an object’s memory in the memory viewer.
    • Fix transparent pixels being rendered as black when drawing a bitmap on 16 color palette devices.
    • Fix rendering Thai characters on certain devices.
    • Fix log in issue when trying to login to a Connect account on Windows.
    • Fix issue seen with some OAuth providers when using makeOAuthRequest() on Windows.
    • Fix simulator crash when editing app settings.

    Compiler Changes

    • Fix incorrect ‘Value may not be initialized’ error after a return statement.
    • Add error message indicating that the entry point must have a module as a parent.
    • Change the error message when the optimizer fails.
    • Fix bitmap scaling to be relative to the screen size, as documented, and not the image size.
    • Fix incorrect type checking error when using Array.addAll().
    • Fix type checker incorrectly stating a value could be null after retrieving a value from a dictionary and checking that it does not equal null.
    • Add message indicating that compilation was successful.
    • Adjust the ‘Typedef Summary’ and ‘Method Summary’ sections to match the rest of the documentation when using monkeydoc.
    • Fix type casting with certain l-values.
    • Fix symbol not found error when calling an object’s instance method from within a static function of the same class.
    • Fix constant folding between char and number types.
    • Update type checker error messages to not remove duplicate types from a dictionary.
    • Apply scope checking for the background and glance portions of an app when the entire app is loaded into these processes.
    • Allow setting an equal or greater dependency on a barrel version in the manifest file.
    • Allow resource IDs to start with an underscore.
    • Fix bug when the exporting and the output path didn’t include a directory.
    • Fix incorrectly allowing a non-null class member to be set to null by assigning it to itself in initialize().
    • Fix typecheck error when using an enum that is assigned to null.
    • Fix incorrect code generation when removing the Test.assert calls from a release build.
    • Fix value being returned inside a try/catch block being modified in the finally statement.
    • Prevent a stack overflow error when returning from a finally statement.
    • Aug 30, 2023
  • Venu 3 Now Available on Connect IQ SDK Manager

    Today marks the arrival of the new Venu® series smartwatch, the ultimate on-wrist coaches designed to support your goals. With up to 14 days of battery life, these GPS smartwatches are purpose-built with advanced health and fitness features to help you better understand your body. Plus, when paired with your smartphone, they allow you to easily make and take calls right from your wrist.

    With the launch of the Venu 3, we are also excited to introduce several new Connect IQ APIs that are outlined below:

    Multitasking

    The Venu 3 introduces a new task switcher that makes it easy to switch between activities and apps on the device. To take full advantage of the task switcher, you need to utilize the full app lifecycle.

    State

     Description

    Launched

    AppBase.onStart() is called when the app is launched or when transitioning from the suspended state. If the app is being resumed, the :resume symbol is in the state argument, and you should restore your application state.

    Active

    AppBase.onActive() is called when your app is transitioning from the inactive to active state. Active apps have access defined by the app type.

    When transitioning from inactive to active, access to sensors, ANT/BLE, will be restored.

    Inactive

    AppBase.onInactive() is called when transitioning from the active to inactive state.

    Suspended

    AppBase.onStop() is called when entering the terminated or suspended state. If the app is being suspended, the :suspend key will be in the state dictionary.

     Based on the state your app is running in, you will have different levels of access to system resources:

     

    Active

    Inactive

    Activity Recording

    With permission, you may be allowed to start and stop activity recording.

    If the app is recording an activity, recording will continue. If the app is not recording, it is not allowed to start or stop activity recording.

    GPS

    GPS access may be denied if another app is recording an activity.

    If the app is recording an activity and receiving position events, it will continue to receive events in the inactive state. If the app is not recording an activity, it is blocked from modifying the GPS state.

    ANT

    ANT access may be denied if another app is recording an activity.

    If the app is recording an activity, ANT access is permitted. If the app is not recording an activity, all open channels will be closed and will be reopened when transitioning from inactive to active.

    High Frequency Sensors (Accelerometer, Magnetometer, Gyro)

    If the app is recording an activity, access is permitted. If the app is not recording an activity, access may fail in a non-fatal way.

    If the app is recording an activity, access will be permitted. Otherwise, measurements can be retrieved at a maximum of 10 hz.

    Sensors

    If the app is recording an activity, access is permitted. If the app is not recording an activity, access may fail in a non-fatal way.

    If the app is recording an activity, access will be permitted. Otherwise, sensor access will be limited.

    Attention

    Access is allowed.

    Access is denied.

     

    Activities and Apps

    The app launcher of the Venu 3 provides separation between activities and apps. If your app has the Fit permission, it will show in the Activities list.

    Enhanced Readability Mode

    Venu 3 has a new setting that enlarges the sizes of fonts in menus, glances and application pages to enhance readability.

    To add support for enhanced readability mode, check DeviceSettings.isEnhancedReadabilityMode at runtime to see if you should be using larger fonts. Implementing AppBase.onEnhancedReadabilityModeChanged() will let you know if the setting changed while the app was running.

    Wheelchair Mode

    The Venu 3 adds support for users with wheelchairs. When this is enabled, step tracking is replaced with push tracking, and new activities are available to the user.

    When wheelchair mode is enabled, ActivityMonitor.Info will have zeroes for steps, stepGoal, floorsClimbed, floorsDescended and floorsClimbedGoal and will instead have values in pushes and pushGoal. Wheelchair mode will also remove COMPLICATION_TYPE_STEPS and COMPLICATION_TYPE_FLOORS_CLIMBED and enable COMPLICATION_TYPE_WHEELCHAIR_PUSHES.

    Try It Today

    The Venu 3 series is now available from the Connect IQ SDK manager. Update your apps to support them today.

    • Aug 28, 2023
  • Watch Face Low- and High-Power Modes

    Connect IQ watch faces typically operate in a low-power state where the system requests updates every minute. When the user gestures to look at the watch, the system will request the watch face enter a high-power state. During this period, typically 10 seconds, the watch face can enable timers and play animations. Use this time to add some action to your watch faces.

    Always Active

    MIP watch faces by default update once a minute. High-power mode does allow drawing seconds or a second hand for a period, but sometimes the user wants that kind of information available the moment their eyes focus on the watch.

    Always-active watch faces can perform a partial update of the screen every second. The update must operate under a 20-millisecond time frame, which does not allow updating the whole screen but can allow for an update on a small portion. For example, the seconds area of this watch face (highlighted in pink) could be updated once a second:

    Always On (AMOLED)

    Devices with AMOLED displays typically disable the display when not in use to save power, but they do allow the user to enable an always-on mode. Because long-term display use affects the battery life and can wear down the display, Connect IQ has special rules for AMOLED always-on mode. When the watch face enters always-on mode, the watch face will only update every minute, and each update is limited to using 10% of the available pixels of the display. In addition, a burn-in prevention mechanism will further guide the use of the display on some devices.

    Many AMOLED devices have a setting to disable the gesture that returns the watch face to high power mode to save power. To avoid a poor user experience, it is expected that Connect IQ watch faces for AMOLED devices support always-on mode and keep the watch face visible in these cases.

    Get the SDK

    Get the SDK and update your watch faces today.

    • Aug 22, 2023
  • Elipse Plug-in Deprecation

    The Connect IQ Eclipse Plug-in has technically been unsupported since the release of the Visual Studio Code Monkey C Extension, but we've kept it available to allow developers time to transition from Eclipse to Visual Studio Code. As of August 28, the Eclipse plug-in will no longer be available for download. If you haven't already had the chance to shift your Connect IQ development environment to Visual Studio Code, now is a good time!

    Thanks

    - The Connect IQ Team

    • Aug 14, 2023
  • Connect IQ 6.2.2 SDK Release

    We have released Connect IQ SDK version 6.2.2, which contains some fixes for issues found in 6.2.1. Here is the list of changes and updates:

    General Changes

    • No changes

    Simulator Changes

    • Fix symbol not found error when calling WatchUi.makeReviewTokenRequest() on 3.4 devices.
    • Match the on-device page indicator for the Venu 2 family.
    • Fix issue preventing hitting breakpoints in Application.onStart().
    • Keep the communication open with debugger when a background app stops or the running app is restarted.

    Compiler Changes

    • Fix incorrect optimization of static constants that would lead to a runtime crash.
    • Fix the type checker to use the correct type for Array.removeAll().
    • Revert a change from 4.2.1 that caused an issue where a parent class’s member function isn’t called in some cases.
    • Aug 2, 2023
  • Connect IQ 6.2.1 SDK Release

    We've released Connect IQ SDK version 6.2.1, which contains a few small fixes for issues found in 6.2.0. Here is a list of the changes and updates:

    General Changes

    • No Changes

    Simulator Changes

    • Fix steps complication being returned as an int once steps reach 10000.
    • Fix transparency when displaying toasts on some devices.

    Compiler Changes

    • Fix issue with byte arrays that could prevent an app from exporting if byte array usage is surrounded by a has check.
    • Improve the too many members in module error when using Rez.Styles by suggesting a solution.
    • Fix complication icon scaling when the source image size does not match the complication icon size.
    • Jun 27, 2023
  • New Connect IQ For You in System 6.2

    In the second quarterly maintenance release of 2023, System 6 is getting some exciting new features that you can take advantage of in your Connect IQ apps.

    Wait, 6.2.0?

    You might be wondering about the new system number. After years of matching the SDK version with the Connect IQ API version, the SDK is getting a new versioning scheme:

    Version Digit

    Meaning

    Value

    Major

    The current system level of the Connect IQ platform

    6 (For System 6)

    Minor

    The current annual quarterly maintenance release

    2 (For quarter two)

    Micro

    SDK release within a quarter

    0 (First release in quarter two)

     Make sense? Good. Now here is what's new.

    Scalable Fonts

    Font support for Garmin devices can vary from device to device. All devices support Unicode bitmap fonts, but some devices support scalable fonts. If a device supports scalable fonts, the supported fonts are published in the Reference Guide as Scalable Font entries in the font list.

    To access a scalable font, you can call Graphics.getVectorFont() using the name from the device reference as the :face argument. The :face argument also will take an array of face names. This allows you to specify backup font faces that are acceptable for your needs in case the device doesn’t support your preferred choice. You can also specify the font size in pixels.

    Scalable fonts work with Dc.drawText() but can also be used with the Dc.drawAngledText() and Dc.drawRadialText(). These APIs only support scalable fonts and do not support custom fonts loaded as resources.

    We have new syntax for layouts. In layout definitions, there are three ways to refer to fonts:

    Reference

    Description

    Example

    System font reference

    Reference the standard FONT enumeration in the Graphics module.

    Graphics.FONT_SMALL

    Custom font reference

    Reference a font in application resources.

    @Rez.Fonts.MySmallFont

    Scalable font reference

    Reference a system scalable font. This is the font name and the pixel size separated by a colon. Additional font names can optionally be added separated by a comma.

    "#BionicBold:12,Roboto"

    Bitmap Transformation

    API level 4.2.2 introduces Dc.drawBitmap2() with some powerful new features.

    Connect IQ allows you to create two-dimensional affine transforms using the Graphics.AffineTransform class. AffineTransform provides access to the underlying transformation matrix and common operations like rotationscaling and shearing.

    To apply the transform, pass the AffineTransform into Dc.drawBitmap2() as the :transform argument in the options dictionary.

    Sometimes you want the color of an asset, like an icon, to be user-definable. For example, you may want the complication icons on a watch face to match a user-defined theme color. One of the features of Dc.drawBitmap2() is the ability to apply a tint color to an asset. The :tintColor option can be used to specify a color to apply to a white asset.

    Requesting Reviews

    As a developer, you want your users to review your apps after they’ve had positive experiences. Ideally, this would be a low-friction experience to maximize the number of users who leave positive reviews.

    For compatible devices, the steps to leave a review are as follows:

    • Request a review token
    • Receive a token from the store
    • Initiate the review process

    To prevent user harassment, apps must request permission from the app store to perform a review request. The app store validates a number of factors, including if you have recently requested a review from a user and if the user is using the most recent version of the app. The token request can be made with the WatchUi.makeReviewTokenRequest() call. This call is asynchronous, and you must provide this call with a Lang.Method callback.

    When the server responds to your review request, your callback will be invoked with the server response code and optionally the review tokens. The response codes are as follows:

    Response Description API Level
    REVIEW_REQUEST_STATUS_GRANTED Request is granted, and token has been provided 4.2.0
    REVIEW_REQUEST_STATUS_DENIED User does not meet review requirements 4.2.0
    REVIEW_REQUEST_STATUS_FAILED Cannot make review request at this time 4.2.0

    If you receive a token it should be valid for the current day. When you are ready for the user to review the app, you can use WatchUi.startUserReview() with the valid token from a token response.

    Red Shift

    The epixTm (gen 2) Pro series introduced a new feature called Red Shift that makes the watch easier to read in low light conditions. The Connect IQ simulator will now let you simulate red shift for testing purposes.

    Try It Today

    These System 6 features are now available for the following devices:

    Scalable Fonts

    Bitmap Transformation

    On-Device Reviews

    epix(gen 2)
    fēnix® 7 Series
    Forerunner® 265 Series
    Forerunner 955
    Forerunner 965
    MARQ® (Gen 2) Series

    Epix (gen 2)
    fēnix 7 Series
    Forerunner 255 Series
    Forerunner 265 Series
    Forerunner 955
    Forerunner 965
    MARQ (Gen 2) Series
    Venu® 2 Series
    Venu 2 Plus
    Venu Sq 2 Series

    Edge® 540
    Edge 840
    Edge 1040
    fēnix 6 Series
    fēnix6 Pro Series
    fēnix7 Series
    Forerunner 255 Series
    Forerunner 265 Series
    Forerunner 955
    Forerunner 965
    MARQ Series
    MARQ 2 Series
    Venu 2 Series
    Venu 2 Plus
    Venu Sq 2 Series

    Get the Connect IQ 6.2.0 SDK with the SDK manager today to update your apps with these exciting features.

    • Jun 15, 2023
  • fēnix 7 Pro and epix Pro Now Available on Connect IQ SDK Manager

    Designed to perform all day, every day — fēnix 7 Pro series and epix Pro series take smartwatches to the next level. Offering solar charging, an always-on display and premium materials, fēnix 7 Pro is made for those who measure adventure in weeks, not hours. With always-on, bright AMOLED display, three new sizes and built-in flashlights on all models epix Pro is made for the best of the best. 

    The fēnix 7 Pro series and epix Pro series are now available from the Connect IQ SDK manager. Update your apps to support them today.

    • May 31, 2023
  • Adding Personality to Your Application with Personality UI

    In the first few months of 2023, Garmin has released (among other products) the Forerunner 265 series, the Forerunner® 965, the Instinct® 2X, the Edge® 540 series and Edge 840 series. In addition to being a testament to the hardworking product teams, that is a lot of new products that will require Connect IQ support for your apps. And if you think that’s the last of the new products for 2023, well, you must be new to Connect IQ.

    System 6 adds Personality UI, a new design system for Connect IQ meant to simplify writing user interfaces across Connect IQ products. Personality UI combines a style language with a design library to better facilitate separation of view and business logic.

    Authentication

    When a Connect IQ app interfaces with a cloud service, one of the first steps the user will have to do is enter their user credentials. This involves asking the user to open an app on their phone. To give the user a sense of control, it’s best to make this a two-step process:

    1. Tell the user to perform an action to begin authentication.
    2. Direct the user to the phone to complete the authentication process.

    For step one, you’ll want to create a prompt with the action to perform. Step two will be a prompt with no action. It should be clear and progress when the user completes authentication on their phone.

    To get started, you’ll create a new Watch App project. In manifest.xml, set the minApiLevel to 3.4.0. Summon the command palette and enter the command Monkey C : Edit Products. Select all of the products in the list, and click okay to add them to the project.

    Define some strings for the prompts in resources/strings/strings.xml:

    <string id="authenticationPrompt">Press to log in</string>
    <string id="openCIQStore">Open the Connect IQ Store to complete login</string>
    

    The authenticationPrompt will go with the first page of the flow, which asks the user to perform the action, and openCIQStore will be the second page of the flow.

    To define these pages, let’s open up the Personality Library on developer.garmin.com. The Personality Library defines the components modeled in Personality UI. Go to the Prompts page and then the Prompts with No Title section. 

    Copy the XML example below into your resources/layouts.xml. Make sure the <layouts> tag wraps everything:

    <layouts>
        <!-- Informational Prompt -->
        <layout id="AuthPrompt" >
    
            <!-- Prompt Body -->
            <text-area text="@Strings.authenticationPrompt" id="mainLabel" personality="
                system_color_dark__text
                prompt_size__body_no_title
                prompt_loc__body_no_title
                prompt_font__body_no_title
            " />
        </layout>
    </layouts>

    If you’ve written layouts before, the personality attribute may be new. We’ll explain these selectors in a little bit, as they are an important part of Personality UI.

    Now let’s create a Monkey C view to display our new layout. Create a new source file source/AuthView.mc that loads the layout:

    import Toybox.Lang;
    import Toybox.Graphics;
    import Toybox.WatchUi;
    
    class AuthView extends WatchUi.View {
    
        function initialize() {
            View.initialize();
        }
    
        // Load your resources here
        function onLayout(dc as Dc) as Void {
            setLayout(Rez.Layouts.AuthPrompt(dc));
        }
    }

    For now, create an empty delegate for your view in source/AuthDelegate.mc:

    import Toybox.Lang;
    import Toybox.WatchUi;
    
    import Rez.Styles;
    
    class AuthDelegate extends WatchUi.BehaviorDelegate {
    }

    In your application source file, load the AuthView as the application initial view by editing the getInitialView() function:

        // Return the initial view of your application here
        function getInitialView() as Array<Views or InputDelegates>? {
            return [ new AuthView(), new AuthDelegate() ] as Array<Views or InputDelegates>;
        }
    

    If you haven’t already created a launch.json create one in the Run and Debug section of VS Code:

    Let’s run this app on the fēnix® 7. Hit F5 and select the fēnix 7 to launch the app in the simulator:

    We specified the string in the XML, but how did the text become centered horizontally and vertically? This is where the personality selectors come into play. Let’s look at them individually:

    Selector

    Meaning

    prompt_color_dark__body

    The text color for the body text of prompts with light-on-dark shading

    prompt_size__body_no_title

    The size of the body text of a prompt when a title is not involved

    prompt_loc__body_no_title

    The starting location of the body text of a prompt when a title is not involved

    prompt_font__body_no_title

    The font used for the body text of a prompt without a title

    Importantly, these definitions exist per-product. For the Instinct 2, the body text begins below the sub-window and is aligned vertically with the top to prevent interference between the body text and the sub-window:

    This is all well and good, but it’s just a text prompt. We’re not really indicating to the user what to press. Let’s fix that.

    Action Hints

    We’re going to co-opt the action menu button hint as our action indicator. Go to the Action Views chapter of the Personality Library, copy the Action Menu Hint XML, and paste into your AuthPrompt layout:

    <!-- Informational Prompt -->
    <layout id="AuthPrompt" >
    
        <!-- ActionMenu hint -->
        <bitmap id="actionMenu" personality="
            system_icon_dark__hint_action_menu
            system_loc__hint_action_menu
        " />
    
        <text-area text="@Strings.authenticationPrompt" id="mainLabel" personality="
            system_color_dark__text
            prompt_size__body_no_title
            prompt_loc__body_no_title
            prompt_font__body_no_title
        " />
    </layout>

    Now when we run the app on the fēnix  7, we’ll get the action hint for the start button:

    If you run the app for Instinct 2, you’ll get the hint, as well:

    Adding the Login Prompt and Button Input

    Let’s create the second prompt in our flow. We need another title-less prompt to direct the user to the phone. Add the following to resources/layouts.xml:

    <!-- Login Prompt -->
    <layout id="LoginPrompt" >
    
        <!-- Prompt Body -->
        <text-area id="mainLabel" text="@Strings.openCIQStore" personality="
            system_color_dark__text
            prompt_size__body_no_title
            prompt_loc__body_no_title
            prompt_font__body_no_title
        " />
    </layout>
    

    Now create source/LoginView.mc. Once again, it will be a wrapper around the layout:

    import Toybox.Graphics;
    import Toybox.WatchUi;
    
    class LoginView extends WatchUi.View {
    
        function initialize() {
            View.initialize();
        }
    
        // Load your resources here
        function onLayout(dc as Dc) as Void {
            setLayout(Rez.Layouts.LoginPrompt(dc));
        }
    }

    Now we want to handle the button associated with the action menu. Most of the time, this is the start button, but that isn’t guaranteed. Thankfully, Personality UI documents the inputs used in common components, as well.

    Create a new source file source/helpers.mc and add the following function:

    import Toybox.Lang;
    import Toybox.WatchUi;
    
    import Rez.Styles;
    
    (:typecheck(false))
    function isActionButton(button as WatchUi.Key) as Boolean {
        if (Styles.system_input__action_menu has :button &&
            button == Styles.system_input__action_menu.button) {
                return true;
        }
        return false;
    }

    Let’s look at this function. The Personality UI selectors we used in the resource XML earlier are accessible in the Monkey C code space via the Rez.Styles module. In this case, we are checking to see if the system_input__action_menu selector has the button symbol, and we’re referencing it if it does. This is because some products like the Venu® 2 series have a touch area for the action menu. We’ll get to that in a moment.

    Personality selector references are replaced with constants at compile time, so adding selectors should not take up precious run time heap.

    Let’s add the key handler into our AuthDelegate:

        function onKey(evt as KeyEvent) as Boolean {
            if ($.isActionButton(evt.getKey())) {
                onAction();
                return true;
            }
            return false;
        }
    
        function onAction() {
            WatchUi.switchToView(
                new LoginView(),
                new BehaviorDelegate(),
                WatchUi.SLIDE_IMMEDIATE
            );
        }
    

    Our onAction() now advances the flow from the first page to the second based on what button triggers the action menu:

    Venu 2 Has Entered the Chat

    Remember how we said mere paragraphs ago that the Venu 2 doesn’t have button input? Well, when you run on that device, the experience seems… off:

    If you’re familiar with Venu 2, you know the action menu button at the bottom typically shows a menu and is not used for advancing flows. Rather than writing a completely separate flow for the Venu 2, let’s make some small modifications:

    1. Rather than “Press to log in”, we want the action to be “Tap the screen to begin”
    2. Because the Venu 2 has an AMOLED display, let’s add some background imagery.
    3. Since the screen tap will trigger the flow, we want to remove the hint.

    Add the new string to resources/strings.xml:

    <string id="touchAuthenticationPrompt">Tap screen to log in</string>

    Now, we’re going to create our own personality selectors. Create a new file named resources/personality.mss:

    view_auth__action_hint {
    
    }
    
    view_auth__prompt_text {
        text: "@Strings.authenticationPrompt";
    }
    
    view_auth__background {
        exclude: true;
    }
    

    This is a new Monkey Style Sheet. It uses a CSS-like syntax to define properties. The resource compiler can read the properties from the selectors, with later selectors able to override earlier ones. One property never seen before is exclude. This is a new resource compiler option to eliminate a resource element.

    Now we are going to make the following changes to AuthPrompt in resources/layouts.xml:

    1. Add a background bitmap reference
    2. Remove the text="@Strings.authenticationPrompt" from the mainLabel
    3. Add view_auth__action_hint to actionMenu
    4. Add view_auth__prompt_text to mainLabel

    <!-- Informational Prompt -->
    <layout id="AuthPrompt" >
        <bitmap id="background" personality="
            view_auth__background
        "/>
    
        <!-- ActionMenu hint -->
        <bitmap id="actionMenu" personality="
            system_icon_dark__hint_action_menu
            system_loc__hint_action_menu
            view_auth__action_hint
        " />
    
        <!-- Prompt Body -->
        <text-area id="mainLabel" personality="
            system_color_dark__text
            prompt_size__body_no_title
            prompt_loc__body_no_title
            prompt_font__body_no_title
            view_auth__prompt_text
        " />
    </layout>
    

    If you run the application now on the fēnix 7 or Instinct 2, it should function the same way as before. We created a new background image, only to request it be eliminated by default using the exclude property.

    Now create a new directory resources-venu2022. Copy the image below (original available here) and save it as resources-venu2022/background.jpg:

    Now create resources-venu2022/personality.mss and add the following:

    view_auth__action_hint {
        exclude: true;
    }
    
    view_auth__prompt_text {
        text: "@Strings.touchAuthenticationPrompt";
        color: #FFFFFF;
    }
    
    view_auth__background {
        filename: "background.jpg";
        scaleX:  100%;
        scaleRelativeTo: "screen";
        packingFormat: "jpg";
    }

    Quick look at what’s going on:

    1. We are telling the resource compiler not to include the action hint.
    2. We are switching the string and color of the prompt.
    3. We are providing the image, scaling options and packing format for the background.

    We need to update our AuthDelegate.mc to handle touch input:

        function onTap(clickEvent as ClickEvent) {
            onAction();
            return true;
        }
    

    Finally, we need to tell the build system to look in our new folder for the following products:

    • Venu 2
    • Venu 2s
    • Venu 2 Plus
    • Venu Sq 2
    • Venu Sq 2 Music

    Open the monkey.jungle file and add the following:

    venu2.personality=$(venu2.personality);resources-venu2022
    venu2s.personality=$(venu2s.personality);resources-venu2022
    venu2plus.personality=$(venu2plus.personality);resources-venu2022
    venusq2.personality=$(venusq2.personality);resources-venu2022
    venusq2m.personality=$(venusq2m.personality);resources-venu2022
    

    For these products, we’re creating a new centralized location to look for the adapted personality information.

    When we run this on the Venu 2, it now looks completely different:

    Wrapping Up

    This just scratches the surface of Personality UI, but hopefully you can see its power. Personality UI provides a new component library to use as the foundation for your applications. Using monkey style sheets and jungles, you have new flexibility to separate view component definition from your source.

    • Apr 26, 2023