[G3 General] yoavst:
How to create a watchface for Quick Circle

General info

The app that is responsible for the watchface is LGAlarmClock.apk from /system/priv-apps .

This guide will learn you how to create an xposed module to switch those files.

Requirements

To know how to compile source to apk

Android Stuio / gradle project / To know how to reference a jar on a regular project on eclipse

Tutorial:

Create the new watchfaces.

Since we doesn't edit the functionallity of the clock, your image should be compatible with the layout of the original watchface.

The original watchfaces are stored on raw-xxxhdpi folder on the apk. You can decompoile the apk by yourself, or take a look at this.

save the edited image in the same name as the original

Create new android project in your IDE.

add the edited file to raw-xxxhdpi folder inside res folder.

Download the xposed-bridge jar from here.

Reference the jar to your project. In a gradle project you need to add to the dependencies:

provided files('path to jar')

Note: you don't need to add to jar to the classpath, only reference since it already exists on the firmware.

Create a module class that implements IXposedHookZygoteInit and IXposedHookInitPackageResources. It should look like:

package com.yoavst.quickcirclemod;

import android.content.res.XModuleResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;

public class Module implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
// Required for resources
private static String MODULE_PATH = null;
[MENTION=439709]override[/MENTION]
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}

[MENTION=439709]override[/MENTION]
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resParam) throws Throwable {
// Only if it is the clock package, continue.
if (!resParam.packageName.equals("com.lge.clock")) return;
// Here we will put or modifications.
}
}

Now you need to replace the resources. for example, let's say you edited those files: b2_quickcircle_digital_bg and b2_quickcircle_analog_style01_hour.

[MENTION=439709]override[/MENTION]
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resParam) throws Throwable {
// Only if it is the clock package, continue.
if (!resParam.packageName.equals("com.lge.clock")) return;
// Create a reference to our resources
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resParam.res);
// Replace the raw resources with hour resources
resParam.res.setReplacement("com.lge.clock", "raw", "b2_quickcircle_analog_style01_hour", modRes.fwd(R.raw.b2_quickcircle_analog_style01_hour));
resParam.res.setReplacement("com.lge.clock", "raw", "b2_quickcircle_digital_bg", modRes.fwd(R.raw.b2_quickcircle_digital_bg));
}

add an assets folder (in gradle, it is under the "main" folder). add an xposed_init file, this file contain the full classname for your module class. in the example it is: com.yoavst.quickcirclemod.Module

Compile it and see it works (need to be applied in xposed and reboot)

You can check for the source here - https://github.com/yoavst/rolexquickcircle