/
LoadSettings.java
1834 lines (1755 loc) · 107 KB
/
LoadSettings.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package com.dinodevs.greatfitwatchface.settings;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.StyleableRes;
import android.util.Log;
import com.dinodevs.greatfitwatchface.R;
import com.dinodevs.greatfitwatchface.resource.ResourceManager;
import com.huami.watch.watchface.util.Util;
import java.util.Arrays;
import java.util.List;
public class LoadSettings {
private Context context;
public SharedPreferences sharedPreferences;
private int versionCode;
private Resources res;
private final static String TAG = "DinoDevs-GreatFit";
public LoadSettings(Context context){
this.context = context;
this.res = context.getResources();
this.sharedPreferences = context.getSharedPreferences(context.getPackageName()+"_settings", Context.MODE_PRIVATE);
// Default Parameters
defaultParameters();
}
// GENERAL
public int font_ratio;
public boolean better_resolution_when_raising_hand;
public String watchface;
public String author;
public int language;
public int color;
public boolean white_bg;
public String is_white_bg;
public int font_no;
public Integer[] colorCodes;
public boolean flashing_indicator;
public boolean month_as_text;
public boolean three_letters_month_if_text;
public boolean three_letters_day_if_text;
public boolean no_0_on_hour_first_digit;
public boolean wind_direction_as_arrows;
public boolean status_bar;
public float status_barLeft;
public float status_barTop;
public boolean low_power;
public float low_powerLeft;
public float low_powerTop;
public boolean flashing_heart_rate_icon;
public float target_calories;
public int custom_refresh_rate;
public int temp_heart_rate;
public int temp_calories;
public boolean am_pm_always;
public float world_time_zone;
public boolean pressure_to_mmhg;
public Paint mGPaint;
public List widgets_list;
public List circle_bars_list;
public boolean isMetric;
// Hours
public boolean hoursBool;
public float hoursFontSize;
public float hoursLeft;
public float hoursTop;
public int hoursColor;
public boolean hoursAlignLeft;
// Indicator
public float indicatorFontSize;
public float indicatorLeft;
public float indicatorTop;
public int indicatorColor;
public boolean indicatorAlignLeft;
public boolean indicatorBool;
// Minutes
public float minutesFontSize;
public float minutesLeft;
public float minutesTop;
public int minutesColor;
public boolean minutesAlignLeft;
public boolean minutesBool;
// Seconds
public float secondsFontSize;
public float secondsLeft;
public float secondsTop;
public int secondsColor;
public boolean secondsAlignLeft;
public boolean secondsBool;
// am_pm
public float am_pmFontSize;
public float am_pmLeft;
public float am_pmTop;
public int am_pmColor;
public boolean am_pmAlignLeft;
// weekday
public float weekdayFontSize;
public float weekdayLeft;
public float weekdayTop;
public int weekdayColor;
public boolean weekdayAlignLeft;
public boolean weekdayBool;
// month
public float monthFontSize;
public float monthLeft;
public float monthTop;
public int monthColor;
public boolean monthAlignLeft;
public boolean monthBool;
// day
public float dayFontSize;
public float dayLeft;
public float dayTop;
public int dayColor;
public boolean dayAlignLeft;
public boolean dayBool;
// year
public float yearFontSize;
public float yearLeft;
public float yearTop;
public int yearColor;
public boolean yearAlignLeft;
public boolean yearBool;
//WIDGETS
// date
public int date;
public float dateFontSize;
public float dateLeft;
public float dateTop;
public int dateColor;
public boolean dateAlignLeft;
public boolean dateUnits;
public boolean dateIcon;
public float dateIconLeft;
public float dateIconTop;
// calories
public int calories;
public float caloriesFontSize;
public float caloriesLeft;
public float caloriesTop;
public int caloriesColor;
public boolean caloriesAlignLeft;
public boolean caloriesUnits;
public boolean caloriesIcon;
public float caloriesIconLeft;
public float caloriesIconTop;
// Steps
public int steps;
public float stepsFontSize;
public float stepsLeft;
public float stepsTop;
public int stepsColor;
public boolean stepsAlignLeft;
public boolean stepsUnits;
public boolean stepsIcon;
public float stepsIconLeft;
public float stepsIconTop;
// heart_rate
public int heart_rate;
public float heart_rateFontSize;
public float heart_rateLeft;
public float heart_rateTop;
public int heart_rateColor;
public boolean heart_rateAlignLeft;
public boolean heart_rateUnits;
public boolean heart_rateIcon;
public float heart_rateIconLeft;
public float heart_rateIconTop;
// total_distance
public int total_distance;
public float total_distanceFontSize;
public float total_distanceLeft;
public float total_distanceTop;
public int total_distanceColor;
public boolean total_distanceAlignLeft;
public boolean total_distanceUnits;
public boolean total_distanceIcon;
public float total_distanceIconLeft;
public float total_distanceIconTop;
// today_distance
public int today_distance;
public float today_distanceFontSize;
public float today_distanceLeft;
public float today_distanceTop;
public int today_distanceColor;
public boolean today_distanceAlignLeft;
public boolean today_distanceUnits;
public boolean today_distanceIcon;
public float today_distanceIconLeft;
public float today_distanceIconTop;
// walked_distance
public int step_length;
public int walked_distance;
public float walked_distanceFontSize;
public float walked_distanceLeft;
public float walked_distanceTop;
public int walked_distanceColor;
public boolean walked_distanceAlignLeft;
public boolean walked_distanceUnits;
public boolean walked_distanceIcon;
public float walked_distanceIconLeft;
public float walked_distanceIconTop;
// floors
public int floors;
public float floorsFontSize;
public float floorsLeft;
public float floorsTop;
public int floorsColor;
public boolean floorsAlignLeft;
public boolean floorsUnits;
public boolean floorsIcon;
public float floorsIconLeft;
public float floorsIconTop;
// battery_percent
public int battery_percent;
public float battery_percentFontSize;
public float battery_percentLeft;
public float battery_percentTop;
public int battery_percentColor;
public boolean battery_percentAlignLeft;
public boolean battery_percentUnits;
public boolean battery_percentIcon;
public float battery_percentIconLeft;
public float battery_percentIconTop;
// temperature
public int temperature;
public float temperatureFontSize;
public float temperatureLeft;
public float temperatureTop;
public int temperatureColor;
public boolean temperatureAlignLeft;
public boolean temperatureUnits;
public boolean temperatureIcon;
public float temperatureIconLeft;
public float temperatureIconTop;
// city
public int city;
public float cityFontSize;
public float cityLeft;
public float cityTop;
public int cityColor;
public boolean cityAlignLeft;
public boolean cityUnits;
public boolean cityIcon;
public float cityIconLeft;
public float cityIconTop;
// watch_alarm
public int watch_alarm;
public float watch_alarmFontSize;
public float watch_alarmLeft;
public float watch_alarmTop;
public int watch_alarmColor;
public boolean watch_alarmAlignLeft;
public boolean watch_alarmUnits;
public boolean watch_alarmIcon;
public float watch_alarmIconLeft;
public float watch_alarmIconTop;
// humidity
public int humidity;
public float humidityFontSize;
public float humidityLeft;
public float humidityTop;
public int humidityColor;
public boolean humidityAlignLeft;
public boolean humidityUnits;
public boolean humidityIcon;
public float humidityIconLeft;
public float humidityIconTop;
// uv
public int uv;
public float uvFontSize;
public float uvLeft;
public float uvTop;
public int uvColor;
public boolean uvAlignLeft;
public boolean uvUnits;
public boolean uvIcon;
public float uvIconLeft;
public float uvIconTop;
// wind_direction
public int wind_direction;
public float wind_directionFontSize;
public float wind_directionLeft;
public float wind_directionTop;
public int wind_directionColor;
public boolean wind_directionAlignLeft;
public boolean wind_directionUnits;
public boolean wind_directionIcon;
public float wind_directionIconLeft;
public float wind_directionIconTop;
// wind_strength
public int wind_strength;
public float wind_strengthFontSize;
public float wind_strengthLeft;
public float wind_strengthTop;
public int wind_strengthColor;
public boolean wind_strengthAlignLeft;
public boolean wind_strengthUnits;
public boolean wind_strengthIcon;
public float wind_strengthIconLeft;
public float wind_strengthIconTop;
// min_max_temperatures
public int min_max_temperatures;
public float min_max_temperaturesFontSize;
public float min_max_temperaturesLeft;
public float min_max_temperaturesTop;
public int min_max_temperaturesColor;
public boolean min_max_temperaturesAlignLeft;
public boolean min_max_temperaturesUnits;
public boolean min_max_temperaturesIcon;
public float min_max_temperaturesIconLeft;
public float min_max_temperaturesIconTop;
// sunset
public int sunset;
public float sunsetFontSize;
public float sunsetLeft;
public float sunsetTop;
public int sunsetColor;
public boolean sunsetAlignLeft;
public boolean sunsetUnits;
public boolean sunsetIcon;
public float sunsetIconLeft;
public float sunsetIconTop;
// sunrise
public int sunrise;
public float sunriseFontSize;
public float sunriseLeft;
public float sunriseTop;
public int sunriseColor;
public boolean sunriseAlignLeft;
public boolean sunriseUnits;
public boolean sunriseIcon;
public float sunriseIconLeft;
public float sunriseIconTop;
// visibility
public int visibility;
public float visibilityFontSize;
public float visibilityLeft;
public float visibilityTop;
public int visibilityColor;
public boolean visibilityAlignLeft;
public boolean visibilityUnits;
public boolean visibilityIcon;
public float visibilityIconLeft;
public float visibilityIconTop;
// clouds
public int clouds;
public float cloudsFontSize;
public float cloudsLeft;
public float cloudsTop;
public int cloudsColor;
public boolean cloudsAlignLeft;
public boolean cloudsUnits;
public boolean cloudsIcon;
public float cloudsIconLeft;
public float cloudsIconTop;
// air_pressure
public int air_pressure;
public float air_pressureFontSize;
public float air_pressureLeft;
public float air_pressureTop;
public int air_pressureColor;
public boolean air_pressureAlignLeft;
public boolean air_pressureUnits;
public boolean air_pressureIcon;
public float air_pressureIconLeft;
public float air_pressureIconTop;
// altitude
public int altitude;
public float altitudeFontSize;
public float altitudeLeft;
public float altitudeTop;
public int altitudeColor;
public boolean altitudeAlignLeft;
public boolean altitudeUnits;
public boolean altitudeIcon;
public float altitudeIconLeft;
public float altitudeIconTop;
// phone_battery
public int phone_battery;
public float phone_batteryFontSize;
public float phone_batteryLeft;
public float phone_batteryTop;
public int phone_batteryColor;
public boolean phone_batteryAlignLeft;
public boolean phone_batteryUnits;
public boolean phone_batteryIcon;
public float phone_batteryIconLeft;
public float phone_batteryIconTop;
// phone_alarm
public int phone_alarm;
public float phone_alarmFontSize;
public float phone_alarmLeft;
public float phone_alarmTop;
public int phone_alarmColor;
public boolean phone_alarmAlignLeft;
public boolean phone_alarmUnits;
public boolean phone_alarmIcon;
public float phone_alarmIconLeft;
public float phone_alarmIconTop;
// xdrip
public int xdrip;
public float xdripFontSize;
public float xdripLeft;
public float xdripTop;
public int xdripColor;
public boolean xdripAlignLeft;
public boolean xdripUnits;
public boolean xdripIcon;
public float xdripIconLeft;
public float xdripIconTop;
// Weather
public int weather_img;
public float weather_imgFontSize;
public float weather_imgLeft;
public float weather_imgTop;
public int weather_imgColor;
public boolean weather_imgAlignLeft;
public boolean weather_imgUnits;
public boolean weather_imgIcon;
public float weather_imgIconLeft;
public float weather_imgIconTop;
// world_time
public int world_time;
public float world_timeFontSize;
public float world_timeLeft;
public float world_timeTop;
public int world_timeColor;
public boolean world_timeAlignLeft;
public boolean world_timeUnits;
public boolean world_timeIcon;
public float world_timeIconLeft;
public float world_timeIconTop;
// phone_alarm
public int notifications;
public float notificationsFontSize;
public float notificationsLeft;
public float notificationsTop;
public int notificationsColor;
public boolean notificationsAlignLeft;
public boolean notificationsUnits;
public boolean notificationsIcon;
public float notificationsIconLeft;
public float notificationsIconTop;
//moonphase
public int moonphase;
public float moonphaseFontSize;
public float moonphaseLeft;
public float moonphaseTop;
public int moonphaseColor;
public boolean moonphaseAlignLeft;
public boolean moonphaseIcon;
public float moonphaseIconLeft;
public float moonphaseIconTop;
// PROGRESS ELEMENTS
// Steps
public int stepsProg;
public float stepsProgLeft;
public float stepsProgTop;
public int stepsProgType;
public float stepsProgRadius;
public float stepsProgThickness;
public int stepsProgStartAngle;
public int stepsProgEndAngle;
public int stepsProgClockwise;
public int stepsProgColorIndex;
public boolean stepsProgBgBool;
public int stepsProgBgColor;
public String stepsProgBgImage;
public String stepsProgSlptImage;
// today distance
public int today_distanceProg;
public float today_distanceProgLeft;
public float today_distanceProgTop;
public int today_distanceProgType;
public float today_distanceProgRadius;
public float today_distanceProgThickness;
public int today_distanceProgStartAngle;
public int today_distanceProgEndAngle;
public int today_distanceProgClockwise;
public int today_distanceProgColorIndex;
public boolean today_distanceProgBgBool;
public int today_distanceProgBgColor;
public String today_distanceProgBgImage;
public String today_distanceProgSlptImage;
// Battery
public int batteryProg;
public float batteryProgLeft;
public float batteryProgTop;
public int batteryProgType;
public float batteryProgRadius;
public float batteryProgThickness;
public int batteryProgStartAngle;
public int batteryProgEndAngle;
public int batteryProgClockwise;
public int batteryProgColorIndex;
public boolean batteryProgBgBool;
public int batteryProgBgColor;
public String batteryProgBgImage;
public String batteryProgSlptImage;
// Calories
public int caloriesProg;
public float caloriesProgLeft;
public float caloriesProgTop;
public int caloriesProgType;
public float caloriesProgRadius;
public float caloriesProgThickness;
public int caloriesProgStartAngle;
public int caloriesProgEndAngle;
public int caloriesProgClockwise;
public int caloriesProgColorIndex;
public boolean caloriesProgBgBool;
public int caloriesProgBgColor;
public String caloriesProgBgImage;
public String caloriesProgSlptImage;
// Heart rate
public int heart_rateProg;
public float heart_rateProgLeft;
public float heart_rateProgTop;
public int heart_rateProgType;
public float heart_rateProgRadius;
public float heart_rateProgThickness;
public int heart_rateProgStartAngle;
public int heart_rateProgEndAngle;
public int heart_rateProgClockwise;
public int heart_rateProgColorIndex;
public boolean heart_rateProgBgBool;
public int heart_rateProgBgColor;
public String heart_rateProgBgImage;
public String heart_rateProgSlptImage;
// Phone Battery
public int phone_batteryProg;
public float phone_batteryProgLeft;
public float phone_batteryProgTop;
public int phone_batteryProgType;
public float phone_batteryProgRadius;
public float phone_batteryProgThickness;
public int phone_batteryProgStartAngle;
public int phone_batteryProgEndAngle;
public int phone_batteryProgClockwise;
public int phone_batteryProgColorIndex;
public boolean phone_batteryProgBgBool;
public int phone_batteryProgBgColor;
public String phone_batteryProgBgImage;
public String phone_batteryProgSlptImage;
// Clock
public boolean analog_clock;
public boolean digital_clock;
public boolean clock_only_slpt;
public float scale;
public ResourceManager.Font font;
// Build.PRODUCT = Amazfit Verge or Amazfit Smartwatch
public final String[] BUILD_VERGE_MODELS = {"qogir", "qogirUS"};
public boolean isVerge(){
return Arrays.asList(BUILD_VERGE_MODELS).contains(Build.PRODUCT);
}
// Default Parameters
private void defaultParameters(){
// Verge scale
this.scale = (isVerge())? 1.125f : 1f; // 360/320 = 1.125
int inverted_text_color = Color.parseColor("#000000");
//Log.d(TAG,"Scale: "+scale);
// All
this.watchface = context.getResources().getString(R.string.watch_face);
this.author = context.getResources().getString(R.string.author);
this.language = sharedPreferences.getInt( "language", 0);
this.color = sharedPreferences.getInt( "color", -1);
this.white_bg = sharedPreferences.getBoolean( "white_bg", context.getResources().getBoolean(R.bool.white_bg));
this.is_white_bg = (this.white_bg?"inv-":"");
this.font_no = sharedPreferences.getInt( "font", 0);
this.better_resolution_when_raising_hand = sharedPreferences.getBoolean( "better_resolution_when_raising_hand", context.getResources().getBoolean(R.bool.better_resolution_when_raising_hand));
this.flashing_indicator = sharedPreferences.getBoolean( "flashing_indicator", context.getResources().getBoolean(R.bool.flashing_indicator));
this.month_as_text = sharedPreferences.getBoolean( "month_as_text", context.getResources().getBoolean(R.bool.month_as_text));
this.three_letters_month_if_text = sharedPreferences.getBoolean( "three_letters_month_if_text", context.getResources().getBoolean(R.bool.three_letters_month_if_text));
this.three_letters_day_if_text = sharedPreferences.getBoolean( "three_letters_day_if_text", context.getResources().getBoolean(R.bool.three_letters_day_if_text));
this.no_0_on_hour_first_digit = sharedPreferences.getBoolean( "no_0_on_hour_first_digit", context.getResources().getBoolean(R.bool.no_0_on_hour_first_digit));
this.wind_direction_as_arrows = sharedPreferences.getBoolean( "wind_direction_as_arrows", context.getResources().getBoolean(R.bool.wind_direction_as_arrows));
this.status_bar = sharedPreferences.getBoolean( "status_bar", context.getResources().getBoolean(R.bool.status_bar));
this.status_barLeft = scale*sharedPreferences.getInt( "status_barLeft", context.getResources().getInteger(R.integer.status_left));
this.status_barTop = scale*sharedPreferences.getInt( "status_barTop", context.getResources().getInteger(R.integer.status_top));
this.low_power = sharedPreferences.getBoolean( "low_power", context.getResources().getBoolean(R.bool.low_power));
this.low_powerLeft = scale*sharedPreferences.getInt( "low_powerLeft", context.getResources().getInteger(R.integer.low_power_left));
this.low_powerTop = scale*sharedPreferences.getInt( "low_powerTop", context.getResources().getInteger(R.integer.low_power_top));
this.flashing_heart_rate_icon = sharedPreferences.getBoolean( "flashing_heart_rate_icon", context.getResources().getBoolean(R.bool.flashing_heart_rate_icon));
this.target_calories = sharedPreferences.getInt( "target_calories", 1000);
this.custom_refresh_rate = sharedPreferences.getInt( "custom_refresh_rate", context.getResources().getInteger(R.integer.custom_refresh_rate)*1000);
this.temp_heart_rate = sharedPreferences.getInt( "temp_heart_rate", 0);
this.temp_calories = sharedPreferences.getInt( "temp_calories", 0);
this.am_pm_always = sharedPreferences.getBoolean( "am_pm_always", context.getResources().getBoolean(R.bool.am_pm_always));
this.world_time_zone = sharedPreferences.getFloat( "world_time_zone", -1f);
this.pressure_to_mmhg = sharedPreferences.getBoolean( "pressure_to_mmhg", context.getResources().getBoolean(R.bool.pressure_to_mmhg));
this.analog_clock = sharedPreferences.getBoolean( "analog_clock", context.getResources().getBoolean(R.bool.analog_clock));
this.digital_clock = sharedPreferences.getBoolean( "digital_clock", context.getResources().getBoolean(R.bool.digital_clock));
this.clock_only_slpt = sharedPreferences.getBoolean( "clock_only_slpt", isVerge() || context.getResources().getBoolean(R.bool.clock_only_slpt));
this.isMetric = (Settings.Secure.getInt(context.getContentResolver(), "measurement", 0) == 0);
// Populate color codes
String[] colorCodes = context.getResources().getStringArray(R.array.color_codes);
int x = 0;
this.colorCodes = new Integer[colorCodes.length];
for(String color : colorCodes){
this.colorCodes[x] = Color.parseColor(color);
x++;
}
// Select Font
this.font = ResourceManager.Font.values()[font_no];
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTextSize(100);// 100 to get the 100% value
paint.setTypeface(ResourceManager.getTypeFace(context.getResources(), this.font));
this.font_ratio = (int) -paint.ascent(); // ascent() is negative
// Icon paint
this.mGPaint = new Paint();
mGPaint.setAntiAlias(false);
mGPaint.setFilterBitmap(false);
List theme_elements = Arrays.asList(context.getResources().getStringArray(R.array.theme_elements));
String[] color_codes = context.getResources().getStringArray(R.array.color_codes);
//Log.d(TAG, "Language: "+this.language );
@StyleableRes int i = 0;
// Hours
this.hoursBool = sharedPreferences.getBoolean("hoursBool", true);
if(this.hoursBool) {
TypedArray hours = res.obtainTypedArray(R.array.hours);
this.hoursFontSize = scale*sharedPreferences.getFloat("hoursFontSize", hours.getDimension(i++, 0));
this.hoursLeft = scale*sharedPreferences.getFloat("hoursLeft", hours.getDimension(i++, 0));
this.hoursTop = scale*sharedPreferences.getFloat("hoursTop", hours.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("hours")>-1){
this.hoursColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.hoursColor = sharedPreferences.getInt("hoursColor", hours.getColor(i++, 0));
}
this.hoursAlignLeft = sharedPreferences.getBoolean("hoursAlignLeft", hours.getBoolean(i, true));
hours.recycle();
}
// Indicator
this.indicatorBool = sharedPreferences.getBoolean("indicatorBool", res.getIdentifier("indicator", "array", context.getPackageName())!=0);
if(this.indicatorBool) {
TypedArray indicator = res.obtainTypedArray(res.getIdentifier("indicator", "array", context.getPackageName()));
i = 0;
this.indicatorFontSize = scale*sharedPreferences.getFloat("indicatorFontSize", indicator.getDimension(i++, 0));
this.indicatorLeft = scale*sharedPreferences.getFloat("indicatorLeft", indicator.getDimension(i++, 0));
this.indicatorTop = scale*sharedPreferences.getFloat("indicatorTop", indicator.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("indicator")>-1){
this.indicatorColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.indicatorColor = sharedPreferences.getInt("indicatorColor", indicator.getColor(i++, 0));
}
if(this.white_bg) this.indicatorColor = inverted_text_color;
this.indicatorAlignLeft = sharedPreferences.getBoolean("indicatorAlignLeft", indicator.getBoolean(i, true));
indicator.recycle();
}
// Minutes
this.minutesBool = sharedPreferences.getBoolean("minutesBool", true);
if(this.minutesBool) {
TypedArray minutes = res.obtainTypedArray(R.array.minutes);
i = 0;
this.minutesFontSize = scale*sharedPreferences.getFloat("minutesFontSize", minutes.getDimension(i++, 0));
this.minutesLeft = scale*sharedPreferences.getFloat("minutesLeft", minutes.getDimension(i++, 0));
this.minutesTop = scale*sharedPreferences.getFloat("minutesTop", minutes.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("minutes")>-1) {
this.minutesColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.minutesColor = sharedPreferences.getInt("minutesColor", minutes.getColor(i++, 0));
}
if(this.white_bg) this.minutesColor = inverted_text_color;
this.minutesAlignLeft = sharedPreferences.getBoolean("minutesAlignLeft", minutes.getBoolean(i, true));
minutes.recycle();
}
// Seconds
this.secondsBool = sharedPreferences.getBoolean("secondsBool", res.getIdentifier("seconds", "array", context.getPackageName())!=0) && Util.needSlptRefreshSecond(context);
//if(this.secondsBool) { (Always draw seconds with unlocked screen as for stock watchface)
TypedArray seconds = res.obtainTypedArray(res.getIdentifier("seconds", "array", context.getPackageName()));
i = 0;
this.secondsFontSize = scale*sharedPreferences.getFloat("secondsFontSize", seconds.getDimension(i++, 0));
this.secondsLeft = scale*sharedPreferences.getFloat("secondsLeft", seconds.getDimension(i++, 0));
this.secondsTop = scale*sharedPreferences.getFloat("secondsTop", seconds.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("seconds")>-1){
this.secondsColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.secondsColor = sharedPreferences.getInt("secondsColor", seconds.getColor(i++, 0));
}
if(this.white_bg) this.secondsColor = inverted_text_color;
this.secondsAlignLeft = sharedPreferences.getBoolean("secondsAlignLeft", seconds.getBoolean(i, false));
seconds.recycle();
//}
// am_pm
/*
String time_format = Settings.System.getString(context.getContentResolver(), "time_12_24");
if(time_format.equals("24") && !this.am_pm_always){
this.am_pmBool = false;//Hide on 24 if am/pm not always shown
}else {
this.am_pmBool = sharedPreferences.getBoolean("am_pmBool", res.getIdentifier("am_pm", "array", context.getPackageName()) != 0);
}
//Log.d("DinoDevs-GreatFit", "AM-PM: "+am_pmBool+", share-pref:"+this.am_pm_always+", xml:"+context.getResources().getBoolean(R.bool.am_pm_always)+", time-format:"+time_format);
*/
//if(this.am_pmBool) {
TypedArray am_pm = res.obtainTypedArray(res.getIdentifier("am_pm", "array", context.getPackageName()));
i = 0;
this.am_pmFontSize = scale*sharedPreferences.getFloat("am_pmFontSize", am_pm.getDimension(i++, 0));
this.am_pmLeft = scale*sharedPreferences.getFloat("am_pmLeft", am_pm.getDimension(i++, 0));
this.am_pmTop = scale*sharedPreferences.getFloat("am_pmTop", am_pm.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("am_pm")>-1){
this.am_pmColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.am_pmColor = sharedPreferences.getInt("am_pmColor", am_pm.getColor(i++, 0));
}
if(this.white_bg) this.am_pmColor = inverted_text_color;
this.am_pmAlignLeft = sharedPreferences.getBoolean("am_pmAlignLeft", am_pm.getBoolean(i, false));
am_pm.recycle();
//}
// weekday
this.weekdayBool = sharedPreferences.getBoolean("weekdayBool", res.getIdentifier("weekday", "array", context.getPackageName())!=0);
if(this.weekdayBool) {
TypedArray weekday = res.obtainTypedArray(res.getIdentifier("weekday", "array", context.getPackageName()));
i = 0;
this.weekdayFontSize = scale*sharedPreferences.getFloat("weekdayFontSize", weekday.getDimension(i++, 0));
this.weekdayLeft = scale*sharedPreferences.getFloat("weekdayLeft", weekday.getDimension(i++, 0));
this.weekdayTop = scale*sharedPreferences.getFloat("weekdayTop", weekday.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("weekday")>-1){
this.weekdayColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.weekdayColor = sharedPreferences.getInt("weekdayColor", weekday.getColor(i++, 0));
}
if(this.white_bg) this.weekdayColor = inverted_text_color;
this.weekdayAlignLeft = sharedPreferences.getBoolean("weekdayAlignLeft", weekday.getBoolean(i, false));
weekday.recycle();
}
// month
this.monthBool = sharedPreferences.getBoolean("monthBool", res.getIdentifier("month", "array", context.getPackageName())!=0);
if(this.monthBool) {
TypedArray month = res.obtainTypedArray(res.getIdentifier("month", "array", context.getPackageName()));
i = 0;
this.monthFontSize = scale*sharedPreferences.getFloat("monthFontSize", month.getDimension(i++, 0));
this.monthLeft = scale*sharedPreferences.getFloat("monthLeft", month.getDimension(i++, 0));
this.monthTop = scale*sharedPreferences.getFloat("monthTop", month.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("month")>-1){
this.monthColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.monthColor = sharedPreferences.getInt("monthColor", month.getColor(i++, 0));
}
if(this.white_bg) this.monthColor = inverted_text_color;
this.monthAlignLeft = sharedPreferences.getBoolean("monthAlignLeft", month.getBoolean(i, false));
month.recycle();
}
// day
this.dayBool = sharedPreferences.getBoolean("dayBool", res.getIdentifier("day", "array", context.getPackageName())!=0);
if(this.dayBool) {
TypedArray day = res.obtainTypedArray(res.getIdentifier("day", "array", context.getPackageName()));
i = 0;
this.dayFontSize = scale*sharedPreferences.getFloat("dayFontSize", day.getDimension(i++, 0));
this.dayLeft = scale*sharedPreferences.getFloat("dayLeft", day.getDimension(i++, 0));
this.dayTop = scale*sharedPreferences.getFloat("dayTop", day.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("day")>-1){
this.dayColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.dayColor = sharedPreferences.getInt("dayColor", day.getColor(i++, 0));
}
if(this.white_bg) this.dayColor = inverted_text_color;
this.dayAlignLeft = sharedPreferences.getBoolean("dayAlignLeft", day.getBoolean(i, false));
day.recycle();
}
// Year
this.yearBool = sharedPreferences.getBoolean("yearBool", res.getIdentifier("year", "array", context.getPackageName())!=0);
if(this.yearBool) {
TypedArray year = res.obtainTypedArray(res.getIdentifier("year", "array", context.getPackageName()));
i = 0;
this.yearFontSize = scale*sharedPreferences.getFloat("yearFontSize", year.getDimension(i++, 0));
this.yearLeft = scale*sharedPreferences.getFloat("yearLeft", year.getDimension(i++, 0));
this.yearTop = scale*sharedPreferences.getFloat("yearTop", year.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("year")>-1){
this.yearColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.yearColor = sharedPreferences.getInt("yearColor", year.getColor(i++, 0));
}
if(this.white_bg) this.yearColor = inverted_text_color;
this.yearAlignLeft = sharedPreferences.getBoolean("yearAlignLeft", year.getBoolean(i, false));
year.recycle();
}
// Get Widgets
String widgetsAsText = sharedPreferences.getString("widgets", null);
if(widgetsAsText==null) {
int[] widgets_as_num = context.getResources().getIntArray(R.array.widgets);
String[] supported_widgets = context.getResources().getStringArray(R.array.supported_widgets);
String[] widgets = new String[widgets_as_num.length];
for (int j = 0; j < widgets_as_num.length; j++) {
widgets[j] = supported_widgets[widgets_as_num[j]];
}
this.widgets_list = Arrays.asList(widgets);
}else{
String text = widgetsAsText.replaceAll("(\\[|\\]| )",""); // Replace "[", "]" and "spaces"
this.widgets_list = Arrays.asList(text.split(","));
}
//Log.d(TAG, "Widgets: "+ widgets_list.toString());
// Date
this.date = sharedPreferences.getInt("date", widgets_list.indexOf("date")+1);
if(this.date>0){
TypedArray widgetN = res.obtainTypedArray(res.getIdentifier("widget"+this.date, "array", context.getPackageName()));
i = 0;
this.dateFontSize = scale*sharedPreferences.getFloat("dateFontSize", widgetN.getDimension(i++, 0));
this.dateLeft = scale*sharedPreferences.getFloat("dateLeft", widgetN.getDimension(i++, 0));
this.dateTop = scale*sharedPreferences.getFloat("dateTop", widgetN.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("widget"+this.date)>-1){
this.dateColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.dateColor = sharedPreferences.getInt("dateColor", widgetN.getColor(i++, 0));
}
if(this.white_bg) this.dateColor = inverted_text_color;
this.dateAlignLeft = sharedPreferences.getBoolean("dateAlignLeft", widgetN.getBoolean(i++, false));
this.dateUnits = sharedPreferences.getBoolean("dateUnits", widgetN.getBoolean(i++, true));
this.dateIcon = sharedPreferences.getBoolean("dateIcon", widgetN.getBoolean(i++, true));
if(dateIcon) {
this.dateIconLeft = scale*sharedPreferences.getFloat("dateIconLeft", widgetN.getDimension(i++, 0));
this.dateIconTop = scale*sharedPreferences.getFloat("dateIconTop", widgetN.getDimension(i, 0));
}
widgetN.recycle();
}
// Calories
this.calories = sharedPreferences.getInt("calories", widgets_list.indexOf("calories")+1);
if(this.calories>0){
TypedArray widgetN = res.obtainTypedArray(res.getIdentifier("widget"+this.calories, "array", context.getPackageName()));
i = 0;
this.caloriesFontSize = scale*sharedPreferences.getFloat("caloriesFontSize", widgetN.getDimension(i++, 0));
this.caloriesLeft = scale*sharedPreferences.getFloat("caloriesLeft", widgetN.getDimension(i++, 0));
this.caloriesTop = scale*sharedPreferences.getFloat("caloriesTop", widgetN.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("widget"+this.calories)>-1){
this.caloriesColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.caloriesColor = sharedPreferences.getInt("caloriesColor", widgetN.getColor(i++, 0));
}
if(this.white_bg) this.caloriesColor = inverted_text_color;
this.caloriesAlignLeft = sharedPreferences.getBoolean("caloriesAlignLeft", widgetN.getBoolean(i++, false));
this.caloriesUnits = sharedPreferences.getBoolean("caloriesUnits", widgetN.getBoolean(i++, true));
this.caloriesIcon = sharedPreferences.getBoolean("caloriesIcon", widgetN.getBoolean(i++, true));
if(caloriesIcon){
this.caloriesIconLeft = scale*sharedPreferences.getFloat("caloriesIconLeft", widgetN.getDimension(i++, 0));
this.caloriesIconTop = scale*sharedPreferences.getFloat("caloriesIconTop", widgetN.getDimension(i, 0));
}
widgetN.recycle();
}
// steps
this.steps = sharedPreferences.getInt("steps", widgets_list.indexOf("steps")+1);
if(this.steps>0){
TypedArray widgetN = res.obtainTypedArray(res.getIdentifier("widget"+this.steps, "array", context.getPackageName()));
i = 0;
this.stepsFontSize = scale*sharedPreferences.getFloat("stepsFontSize", widgetN.getDimension(i++, 0));
this.stepsLeft = scale*sharedPreferences.getFloat("stepsLeft", widgetN.getDimension(i++, 0));
this.stepsTop = scale*sharedPreferences.getFloat("stepsTop", widgetN.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("widget"+this.steps)>-1){
this.stepsColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.stepsColor = sharedPreferences.getInt("stepsColor", widgetN.getColor(i++, 0));
}
if(this.white_bg) this.stepsColor = inverted_text_color;
this.stepsAlignLeft = sharedPreferences.getBoolean("stepsAlignLeft", widgetN.getBoolean(i++, false));
this.stepsUnits = sharedPreferences.getBoolean("stepsUnits", widgetN.getBoolean(i++, true));
this.stepsIcon = sharedPreferences.getBoolean("stepsIcon", widgetN.getBoolean(i++, true));
if(stepsIcon){
this.stepsIconLeft = scale*sharedPreferences.getFloat("stepsIconLeft", widgetN.getDimension(i++, 0));
this.stepsIconTop = scale*sharedPreferences.getFloat("stepsIconTop", widgetN.getDimension(i, 0));
}
widgetN.recycle();
}
// heart_rate
this.heart_rate = sharedPreferences.getInt("heart_rate", widgets_list.indexOf("heart_rate")+1);
if(this.heart_rate>0){
TypedArray widgetN = res.obtainTypedArray(res.getIdentifier("widget"+this.heart_rate, "array", context.getPackageName()));
i = 0;
this.heart_rateFontSize = scale*sharedPreferences.getFloat("heart_rateFontSize", widgetN.getDimension(i++, 0));
this.heart_rateLeft = scale*sharedPreferences.getFloat("heart_rateLeft", widgetN.getDimension(i++, 0));
this.heart_rateTop = scale*sharedPreferences.getFloat("heart_rateTop", widgetN.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("widget"+this.heart_rate)>-1){
this.heart_rateColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.heart_rateColor = sharedPreferences.getInt("heart_rateColor", widgetN.getColor(i++, 0));
}
if(this.white_bg) this.heart_rateColor = inverted_text_color;
this.heart_rateAlignLeft = sharedPreferences.getBoolean("heart_rateAlignLeft", widgetN.getBoolean(i++, false));
this.heart_rateUnits = sharedPreferences.getBoolean("heart_rateUnits", widgetN.getBoolean(i++, true));
this.heart_rateIcon = sharedPreferences.getBoolean("heart_rateIcon", widgetN.getBoolean(i++, true));
if(heart_rateIcon) {
this.heart_rateIconLeft = scale*sharedPreferences.getFloat("heart_rateIconLeft", widgetN.getDimension(i++, 0));
this.heart_rateIconTop = scale*sharedPreferences.getFloat("heart_rateIconTop", widgetN.getDimension(i, 0));
}
widgetN.recycle();
}
// total_distance
this.total_distance = sharedPreferences.getInt("total_distance", widgets_list.indexOf("total_distance")+1);
if(this.total_distance>0){
TypedArray widgetN = res.obtainTypedArray(res.getIdentifier("widget"+this.total_distance, "array", context.getPackageName()));
i = 0;
this.total_distanceFontSize = scale*sharedPreferences.getFloat("total_distanceFontSize", widgetN.getDimension(i++, 0));
this.total_distanceLeft = scale*sharedPreferences.getFloat("total_distanceLeft", widgetN.getDimension(i++, 0));
this.total_distanceTop = scale*sharedPreferences.getFloat("total_distanceTop", widgetN.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("widget"+this.total_distance)>-1){
this.total_distanceColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.total_distanceColor = sharedPreferences.getInt("total_distanceColor", widgetN.getColor(i++, 0));
}
if(this.white_bg) this.total_distanceColor = inverted_text_color;
this.total_distanceAlignLeft = sharedPreferences.getBoolean("total_distanceAlignLeft", widgetN.getBoolean(i++, false));
this.total_distanceUnits = sharedPreferences.getBoolean("total_distanceUnits", widgetN.getBoolean(i++, true));
this.total_distanceIcon = sharedPreferences.getBoolean("total_distanceIcon", widgetN.getBoolean(i++, true));
if(total_distanceIcon) {
this.total_distanceIconLeft = scale*sharedPreferences.getFloat("total_distanceIconLeft", widgetN.getDimension(i++, 0));
this.total_distanceIconTop = scale*sharedPreferences.getFloat("total_distanceIconTop", widgetN.getDimension(i, 0));
}
widgetN.recycle();
}
// today_distance
this.today_distance = sharedPreferences.getInt("today_distance", widgets_list.indexOf("today_distance")+1);
if(this.today_distance>0){
TypedArray widgetN = res.obtainTypedArray(res.getIdentifier("widget"+this.today_distance, "array", context.getPackageName()));
i = 0;
this.today_distanceFontSize = scale*sharedPreferences.getFloat("today_distanceFontSize", widgetN.getDimension(i++, 0));
this.today_distanceLeft = scale*sharedPreferences.getFloat("today_distanceLeft", widgetN.getDimension(i++, 0));
this.today_distanceTop = scale*sharedPreferences.getFloat("today_distanceTop", widgetN.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("widget"+this.today_distance)>-1){
this.today_distanceColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.today_distanceColor = sharedPreferences.getInt("today_distanceColor", widgetN.getColor(i++, 0));
}
if(this.white_bg) this.today_distanceColor = inverted_text_color;
this.today_distanceAlignLeft = sharedPreferences.getBoolean("today_distanceAlignLeft", widgetN.getBoolean(i++, false));
this.today_distanceUnits = sharedPreferences.getBoolean("today_distanceUnits", widgetN.getBoolean(i++, true));
this.today_distanceIcon = sharedPreferences.getBoolean("today_distanceIcon", widgetN.getBoolean(i++, true));
if(today_distanceIcon) {
this.today_distanceIconLeft = scale*sharedPreferences.getFloat("today_distanceIconLeft", widgetN.getDimension(i++, 0));
this.today_distanceIconTop = scale*sharedPreferences.getFloat("today_distanceIconTop", widgetN.getDimension(i, 0));
}
widgetN.recycle();
}
// walked_distance
this.step_length = Math.round((float) sharedPreferences.getInt("height", 175)*0.414f);
this.walked_distance = sharedPreferences.getInt("walked_distance", widgets_list.indexOf("walked_distance")+1);
if(this.walked_distance>0){
TypedArray widgetN = res.obtainTypedArray(res.getIdentifier("widget"+this.walked_distance, "array", context.getPackageName()));
i = 0;
this.walked_distanceFontSize = scale*sharedPreferences.getFloat("walked_distanceFontSize", widgetN.getDimension(i++, 0));
this.walked_distanceLeft = scale*sharedPreferences.getFloat("walked_distanceLeft", widgetN.getDimension(i++, 0));
this.walked_distanceTop = scale*sharedPreferences.getFloat("walked_distanceTop", widgetN.getDimension(i++, 0));
if(this.color>-1 && theme_elements.indexOf("widget"+this.walked_distance)>-1){
this.walked_distanceColor = Color.parseColor(color_codes[this.color]);
i++;
}else{
this.walked_distanceColor = sharedPreferences.getInt("walked_distanceColor", widgetN.getColor(i++, 0));
}
if(this.white_bg) this.walked_distanceColor = inverted_text_color;
this.walked_distanceAlignLeft = sharedPreferences.getBoolean("walked_distanceAlignLeft", widgetN.getBoolean(i++, false));
this.walked_distanceUnits = sharedPreferences.getBoolean("walked_distanceUnits", widgetN.getBoolean(i++, true));
this.walked_distanceIcon = sharedPreferences.getBoolean("walked_distanceIcon", widgetN.getBoolean(i++, true));
if(walked_distanceIcon) {
this.walked_distanceIconLeft = scale*sharedPreferences.getFloat("walked_distanceIconLeft", widgetN.getDimension(i++, 0));
this.walked_distanceIconTop = scale*sharedPreferences.getFloat("walked_distanceIconTop", widgetN.getDimension(i, 0));