@ -185,22 +185,15 @@ public class HybridHRWatchfaceFactory {
} catch ( IOException e ) {
LOG . warn ( "Unable to read asset file" , e ) ;
}
LinkedHashMap < String , String > layout = new LinkedHashMap < > ( ) ;
try {
layout . put ( "complication_layout" , getComplicationLayout ( ) ) ;
} catch ( JSONException e ) {
LOG . warn ( "Could not generate complication_layout" , e ) ;
}
try {
layout . put ( "image_layout" , getImageLayout ( ) ) ;
} catch ( JSONException e ) {
LOG . warn ( "Could not generate image_layout" , e ) ;
}
try {
if ( includeWidget ( "widgetBattery" ) > 0 ) layout . put ( "battery_layout" , getBatteryLayout ( ) ) ;
} catch ( JSONException e ) {
LOG . warn ( "Could not generate battery_layout" , e ) ;
LinkedHashMap < String , InputStream > layout = new LinkedHashMap < > ( ) ;
layout . put ( "complication_layout" , context . getAssets ( ) . open ( "fossil_hr/complication_layout.json" ) ) ;
layout . put ( "image_layout" , context . getAssets ( ) . open ( "fossil_hr/image_layout.json" ) ) ;
layout . put ( "menu_layout" , context . getAssets ( ) . open ( "fossil_hr/menu_layout.json" ) ) ;
if ( includeWidget ( "widgetBattery" ) > 0 ) {
layout . put ( "battery_layout" , context . getAssets ( ) . open ( "fossil_hr/battery_layout.json" ) ) ;
}
LinkedHashMap < String , String > displayName = new LinkedHashMap < > ( ) ;
displayName . put ( "display_name" , watchfaceName ) ;
displayName . put ( "theme_class" , "complications" ) ;
@ -214,184 +207,6 @@ public class HybridHRWatchfaceFactory {
return appWriter . getWapp ( ) ;
}
private String getBatteryLayout ( ) throws JSONException {
JSONArray batteryLayout = new JSONArray ( ) ;
JSONObject complicationBackground = new JSONObject ( ) ;
complicationBackground . put ( "id" , 0 ) ;
complicationBackground . put ( "type" , "complication_background" ) ;
complicationBackground . put ( "background" , "#background" ) ;
complicationBackground . put ( "visible" , true ) ;
complicationBackground . put ( "inversion" , false ) ;
JSONObject goalRing = new JSONObject ( ) ;
goalRing . put ( "is_enable" , "#goal_ring" ) ;
goalRing . put ( "end_angle" , "#fi" ) ;
goalRing . put ( "is_invert" , "#$e" ) ;
complicationBackground . put ( "goal_ring" , goalRing ) ;
JSONObject dimension = new JSONObject ( ) ;
dimension . put ( "type" , "rigid" ) ;
dimension . put ( "width" , "#size.w" ) ;
dimension . put ( "height" , "#size.h" ) ;
complicationBackground . put ( "dimension" , dimension ) ;
JSONObject placement = new JSONObject ( ) ;
placement . put ( "type" , "absolute" ) ;
placement . put ( "left" , "#pos.Ue" ) ;
placement . put ( "top" , "#pos.Qe" ) ;
complicationBackground . put ( "placement" , placement ) ;
batteryLayout . put ( complicationBackground ) ;
JSONObject complicationContent = new JSONObject ( ) ;
complicationContent . put ( "id" , 1 ) ;
complicationContent . put ( "parent_id" , 0 ) ;
complicationContent . put ( "type" , "complication_content" ) ;
complicationContent . put ( "icon" , "icBattery" ) ;
complicationContent . put ( "text_low" , "#ci" ) ;
complicationContent . put ( "visible" , true ) ;
complicationContent . put ( "inversion" , "#$e" ) ;
dimension = new JSONObject ( ) ;
dimension . put ( "type" , "rigid" ) ;
dimension . put ( "width" , 76 ) ;
dimension . put ( "height" , 76 ) ;
complicationContent . put ( "dimension" , dimension ) ;
placement = new JSONObject ( ) ;
placement . put ( "type" , "relative" ) ;
complicationContent . put ( "placement" , placement ) ;
batteryLayout . put ( complicationContent ) ;
JSONObject chargingStatus = new JSONObject ( ) ;
chargingStatus . put ( "id" , 2 ) ;
chargingStatus . put ( "parent_id" , 1 ) ;
chargingStatus . put ( "type" , "solid" ) ;
chargingStatus . put ( "color" , "#nt" ) ;
chargingStatus . put ( "visible" , true ) ;
chargingStatus . put ( "inversion" , false ) ;
dimension = new JSONObject ( ) ;
dimension . put ( "type" , "rigid" ) ;
dimension . put ( "width" , "#it" ) ;
dimension . put ( "height" , 6 ) ;
chargingStatus . put ( "dimension" , dimension ) ;
placement = new JSONObject ( ) ;
placement . put ( "type" , "absolute" ) ;
placement . put ( "left" , 29 ) ;
placement . put ( "top" , 23 ) ;
chargingStatus . put ( "placement" , placement ) ;
batteryLayout . put ( chargingStatus ) ;
JSONObject image = new JSONObject ( ) ;
image . put ( "id" , 3 ) ;
image . put ( "parent_id" , 1 ) ;
image . put ( "type" , "image" ) ;
image . put ( "image_name" , "icBattCharging" ) ;
image . put ( "draw_mode" , 1 ) ;
image . put ( "visible" , "#et" ) ;
image . put ( "inversion" , false ) ;
placement = new JSONObject ( ) ;
placement . put ( "type" , "absolute" ) ;
placement . put ( "left" , 34 ) ;
placement . put ( "top" , 21 ) ;
image . put ( "placement" , placement ) ;
dimension = new JSONObject ( ) ;
dimension . put ( "width" , 6 ) ;
dimension . put ( "height" , 9 ) ;
image . put ( "dimension" , dimension ) ;
batteryLayout . put ( image ) ;
return batteryLayout . toString ( ) ;
}
private String getComplicationLayout ( ) throws JSONException {
JSONArray complicationLayout = new JSONArray ( ) ;
JSONObject complicationBackground = new JSONObject ( ) ;
complicationBackground . put ( "id" , 0 ) ;
complicationBackground . put ( "type" , "complication_background" ) ;
complicationBackground . put ( "background" , "#background" ) ;
complicationBackground . put ( "visible" , true ) ;
complicationBackground . put ( "inversion" , false ) ;
JSONObject goalRing = new JSONObject ( ) ;
goalRing . put ( "is_enable" , "#goal_ring" ) ;
goalRing . put ( "end_angle" , "#fi" ) ;
goalRing . put ( "is_invert" , "#$e" ) ;
complicationBackground . put ( "goal_ring" , goalRing ) ;
JSONObject dimension = new JSONObject ( ) ;
dimension . put ( "type" , "rigid" ) ;
dimension . put ( "width" , "#size.w" ) ;
dimension . put ( "height" , "#size.h" ) ;
complicationBackground . put ( "dimension" , dimension ) ;
JSONObject placement = new JSONObject ( ) ;
placement . put ( "type" , "absolute" ) ;
placement . put ( "left" , "#pos.Ue" ) ;
placement . put ( "top" , "#pos.Qe" ) ;
complicationBackground . put ( "placement" , placement ) ;
complicationLayout . put ( complicationBackground ) ;
JSONObject complicationContent = new JSONObject ( ) ;
complicationContent . put ( "id" , 1 ) ;
complicationContent . put ( "parent_id" , 0 ) ;
complicationContent . put ( "type" , "complication_content" ) ;
complicationContent . put ( "icon" , "#icon" ) ;
complicationContent . put ( "text_high" , "#dt" ) ;
complicationContent . put ( "text_low" , "#ci" ) ;
complicationContent . put ( "visible" , true ) ;
complicationContent . put ( "inversion" , "#$e" ) ;
dimension = new JSONObject ( ) ;
dimension . put ( "type" , "rigid" ) ;
dimension . put ( "width" , "#size.w" ) ;
dimension . put ( "height" , "#size.h" ) ;
complicationContent . put ( "dimension" , dimension ) ;
placement = new JSONObject ( ) ;
placement . put ( "type" , "relative" ) ;
complicationContent . put ( "placement" , placement ) ;
complicationLayout . put ( complicationContent ) ;
return complicationLayout . toString ( ) ;
}
private String getImageLayout ( ) throws JSONException {
JSONArray imageLayout = new JSONArray ( ) ;
JSONObject container = new JSONObject ( ) ;
container . put ( "id" , 0 ) ;
container . put ( "type" , "container" ) ;
container . put ( "direction" , 1 ) ;
container . put ( "main_alignment" , 1 ) ;
container . put ( "cross_alignment" , 1 ) ;
container . put ( "visible" , true ) ;
container . put ( "inversion" , false ) ;
JSONObject dimension = new JSONObject ( ) ;
dimension . put ( "type" , "rigid" ) ;
dimension . put ( "width" , 240 ) ;
dimension . put ( "height" , 240 ) ;
container . put ( "dimension" , dimension ) ;
JSONObject placement = new JSONObject ( ) ;
placement . put ( "type" , "absolute" ) ;
placement . put ( "left" , 0 ) ;
placement . put ( "top" , 0 ) ;
container . put ( "placement" , placement ) ;
imageLayout . put ( container ) ;
JSONObject image = new JSONObject ( ) ;
image . put ( "id" , 1 ) ;
image . put ( "parent_id" , 0 ) ;
image . put ( "type" , "image" ) ;
image . put ( "image_name" , "#name" ) ;
image . put ( "draw_mode" , 1 ) ;
image . put ( "visible" , true ) ;
image . put ( "inversion" , false ) ;
placement = new JSONObject ( ) ;
placement . put ( "type" , "absolute" ) ;
placement . put ( "left" , "#pos.Ue" ) ;
placement . put ( "top" , "#pos.Qe" ) ;
image . put ( "placement" , placement ) ;
dimension = new JSONObject ( ) ;
dimension . put ( "width" , "#size.w" ) ;
dimension . put ( "height" , "#size.h" ) ;
image . put ( "dimension" , dimension ) ;
imageLayout . put ( image ) ;
return imageLayout . toString ( ) ;
}
private String getConfiguration ( ) throws JSONException {
JSONObject configuration = new JSONObject ( ) ;
@ -432,6 +247,7 @@ public class HybridHRWatchfaceFactory {
config . put ( "wrist_flick_duration" , settings . getWristFlickDuration ( ) ) ;
config . put ( "wrist_flick_move_hour" , settings . getWristFlickMoveHour ( ) ) ;
config . put ( "wrist_flick_move_minute" , settings . getWristFlickMoveMinute ( ) ) ;
config . put ( "light_up_on_notification" , settings . getLightUpOnNotification ( ) ) ;
config . put ( "powersave_display" , settings . getPowersaveDisplay ( ) ) ;
config . put ( "powersave_hands" , settings . getPowersaveHands ( ) ) ;
configuration . put ( "config" , config ) ;