5. Custom Dial

V1.15.0 supports Dynamic Album Dial and Video Dial. Both belong to custom dial backgrounds. You need to confirm device capabilities through the dial expansion parameters, transcode the resource into a device-supported format, insert it into the device, and bind it to the current watch face.

Resource Types

Resource Type

File Prefix

Description

Image dial

BGP_W

Static image

Dynamic album dial

BGG_W

GIF dynamic dial composed of multiple images

Video dial

BGV_W

Video dial in ANI/AVI format

Important

  1. Read the dial expansion parameters before use; refer to Dial Expansion Parameters

  2. Whether the device supports dynamic dials and which formats are supported depends on the values returned by DialExpandInfo

  3. The transcoded resource must be inserted into the device through createWatchFile and then bound through enableCustomWatchBg

5.1. Capability Check

WatchManager watchManager = WatchManager.getInstance();
WatchConfigure watchConfigure = watchManager.getWatchConfigure(watchManager.getConnectedDevice());
if (null == watchConfigure) return;
//Whether dial expansion information is supported
boolean isSupportDialExpandInfo = null != watchConfigure.getFunctionOption()
        && watchConfigure.getFunctionOption().isSupportDialExpandInfo();
if (!isSupportDialExpandInfo) return;
DialExpandInfo dialExpandInfo = watchConfigure.getDialExpandInfo();
if (null == dialExpandInfo) return;

//Master switch for dynamic dial
boolean isSupportDynamicDial = dialExpandInfo.isSupportDynamicDial();
//Supported dynamic dial formats
boolean isSupportGif = dialExpandInfo.isSupportGifFile();    //Dynamic album
boolean isSupportAni = dialExpandInfo.isSupportAniFile();    //Video (ANI)
boolean isSupportAvi = dialExpandInfo.isSupportAviFile();    //Video (AVI)
//Material limits
int maxFrameRate = dialExpandInfo.getMaxFrameRate();
int maxDuration = dialExpandInfo.getMaxDuration();
int width = dialExpandInfo.getScreeWidth();
int height = dialExpandInfo.getScreenHeight();

5.2. Dynamic Album Dial

The user selects multiple images, which are combined in order into a GIF dynamic dial.

Support Conditions

  1. FunctionOption.isSupportDialExpandInfo() is true

  2. DialExpandInfo.isSupportDynamicDial() is true

  3. DialExpandInfo.isSupportGifFile() is true

Material Requirements

  1. The image resolution is recommended to match screeWidth / screenHeight to avoid stretching or cropping

  2. The frame rate cannot exceed maxFrameRate

  3. The playback duration cannot exceed maxDuration

  4. The number of images and the size of each image must be controlled within the available device space

Implementation Flow

//Step1. Check device capabilities
if (!dialExpandInfo.isSupportDynamicDial() || !dialExpandInfo.isSupportGifFile()) return;

//Step2. Compose a GIF and transcode it into a device-recognizable bin file
//GifConverter comes from the GifConvert library
GifConverter converter = GifConverter.getInstance();
String inputGifPath = "Path of the composed GIF file";
String outputBinPath = "Transcoding output path";
int chip = GifConverter.CHIP_707N; //Select based on chip: CHIP_707N / CHIP_701N
converter.gif2BinAsync(inputGifPath, outputBinPath, GifConverter.MODE_LOW_COMPRESSION_RATE, chip,
        new GifConverter.ResultCallback<GifBin>() {
            @Override
            public void onSuccess(GifBin gifBin) {
                //Step3. Insert the watch face
                insertCustomDial(gifBin.getPath());
            }

            @Override
            public void onError(int code, String message) {
                //Transcoding failed
            }
        });


/**
 * Insert the watch face and bind it as the custom background of the current watch face
 */
private void insertCustomDial(String binFilePath) {
    WatchManager watchManager = WatchManager.getInstance();
    //Insert the watch face; isNoNeedCheck = true means skip version verification
    watchManager.insertWatch(binFilePath, true, new OnFatFileProgressListener() {
        @Override
        public void onStart(String filePath) {
        }

        @Override
        public void onProgress(float progress) {
            //Insertion progress
        }

        @Override
        public void onStop(int result) {
            if (result != FatFsErrCode.RES_OK) return; //Insertion failed
            //Step4. Bind as the custom background of the current watch face
            String fatFilePath = FatUtil.getFatFilePath(binFilePath);
            watchManager.enableWatchCustomBg(fatFilePath, new OnWatchOpCallback<FatFile>() {
                @Override
                public void onSuccess(FatFile result) {
                    //Binding succeeded
                }

                @Override
                public void onFailed(BaseError error) {
                    //Binding failed
                }
            });
        }
    });
}

Note

  1. Insert Dial

  2. Enable Dial Custom Background

  3. For sample code, refer to com.jieli.healthaide.tool.customdial.CustomDialManager#transcodingGif

Important

The dynamic album dial depends on the GIF transcoding algorithm library. You need to integrate GifConvert_Vxxx.aar (current version GifConvert_V1.3.0_42-release.aar). For the GIF transcoding interface and chip algorithm selection, refer to GIF File Conversion.

5.3. Video Dial

The user selects a video file, which is transcoded into a device-supported ANI/AVI format and used as the dial background.

Support Conditions

  1. FunctionOption.isSupportDialExpandInfo() is true

  2. DialExpandInfo.isSupportDynamicDial() is true

  3. DialExpandInfo.isSupportAniFile() or DialExpandInfo.isSupportAviFile() is true

Format Selection

  • If ANI is supported, prefer ANI output

  • If only AVI is supported, output AVI

  • The actual format depends on the values returned by DialExpandInfo

Material Requirements

  1. Set the video resolution according to screeWidth / screenHeight

  2. The frame rate cannot exceed maxFrameRate

  3. The duration cannot exceed maxDuration

Implementation Flow

//Step1. Check device capabilities
if (!dialExpandInfo.isSupportDynamicDial()) return;
boolean isSupportAni = dialExpandInfo.isSupportAniFile();
boolean isSupportAvi = dialExpandInfo.isSupportAviFile();
if (!isSupportAni && !isSupportAvi) return;

//Step2. Select the output format
OutputType outType = isSupportAni ? OutputType.ANI : OutputType.AVI;

//Step3. Transcode the video
//VideoTool comes from the video transcoding library
VideoTool videoTool = new VideoTool(context);
videoTool.setOnConversionListener((resultCode, message) -> {
    if (resultCode == ResultCode.Success) {
        //Step4. Insert the watch face and bind it
        insertCustomDial(outputPath);
    } else {
        //Transcoding failed
    }
});
boolean ret = videoTool.tryToConvert(new InputOption()
        .setInPath(videoPath)
        .setOutPath(outputPath)
        .setOutputType(outType)
        .setWidth(dialExpandInfo.getScreeWidth())
        .setHeight(dialExpandInfo.getScreenHeight())
        .setQuality(8)
        .setFrameRate(dialExpandInfo.getMaxFrameRate()));
if (!ret) {
    //Failed to start transcoding
    videoTool.release();
}

Note

  1. For the insertion and binding flow, refer to insertCustomDial in Dynamic Album Dial

  2. For sample code, refer to com.jieli.healthaide.tool.customdial.CustomDialManager#transcodingVideo

Important

The video dial depends on the video transcoding tool library. You need to integrate jl_vtool_vxxx.aar (current version jl_vtool_v1.0.0_3-release.aar). The video transcoding interface is provided by VideoTool, and the output format is ANI/AVI.

5.4. Notes

Important

  1. Dynamic dial files are large; check the remaining device space before transfer; refer to Get Remaining Space Size of Watch System

  2. Transferring watch faces during a call is not recommended; refer to WatchError.ERR_DEVICE_IN_CALLING

  3. Do not initiate repeated operations during transfer to avoid overwriting resource files