-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTweak.xm
759 lines (691 loc) · 32 KB
/
Tweak.xm
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
#import "version.h"
#import <sys/utsname.h>
static NSDate *lastLocked; // Static variable that holds the NSDate of the last locked time
static NSTimer *updateEverySecond;
static NSUserDefaults *dontationAlertSettings;
static NSString *language = [[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2];
@interface NZ9TimeFormat : NSObject
+ (NSString *)nz9_lastLockedTimeFormat; // Class method that will be used to format the time string
@end
@implementation NZ9TimeFormat : NSObject
+ (NSString *)nz9_lastLockedTimeFormat {
NSInteger secondCount = 0; // Initialize the secondCount to 0
if(lastLocked) {
secondCount = ceil(lastLocked.timeIntervalSinceNow*(-1)); // If the lastLocked date exists, set the secondCount to the total number of seconds passed
}
NSInteger minuteCount = floor(secondCount / 60); // Calculate number of minutes
NSInteger hourCount = floor(minuteCount / 60); // Calculate number of hours
NSInteger dayCount = floor(hourCount / 24); // Calculate number of days
NSInteger monthCount = floor(dayCount / 30.42); // Calculate number of months
NSInteger yearCount = floor(monthCount / 12); // Calculate number of years
secondCount = secondCount % 60; // Calculate the number of actual seconds (between 0 and 60 seconds)
minuteCount = minuteCount % 60; // Calculate the number of actual minutes
hourCount = hourCount % 24; // Calculate the number of actual hours
dayCount = dayCount % 30; // Calculate the number of actual days
monthCount = monthCount % 12; // Calculate the number of actual months
NSString *formattedString = @"LastLocked: Language not supported.";
if([language isEqualToString: @"nl"]) { // Dutch format
formattedString = @"Vergrendeld"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld jr", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld jr", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld maand", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld mdn", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld dg", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld dgn", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld uur", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld u", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld sec", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld sec", (long)secondCount];
formattedString = [formattedString stringByAppendingFormat: @" geleden"]; // Append "ago" to the string
}
else if([language isEqualToString: @"he"]) { // Hebrew format
formattedString = @"ננעל לפני"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld שנה", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld שנים", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld חודש", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld חודשים", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld יום", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld ימים", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld שעה", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld שעות", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld דקה", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld דקות", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld שנייה", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld שניות", (long)secondCount];
}
else if([language isEqualToString: @"sv"]) { // Swedish format
formattedString = @"Låst"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld år", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld år", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld mån", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld månader", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld dag", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld dagar", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld tim", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld tim", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
}
if(yearCount > 0 || monthCount > 0 || dayCount > 0 || hourCount > 0 || minuteCount > 0) {
formattedString = [formattedString stringByAppendingFormat: @" och"];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld sek", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld sek", (long)secondCount];
formattedString = [formattedString stringByAppendingFormat: @" sedan"]; // Append "ago" to the string
}
else if([language isEqualToString: @"ja"]) { // Japanese format
formattedString = @"最後のロック :"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld 年", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld 年", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld ヶ月", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld ヶ月", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld 日", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld 日", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld 時間", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld 時間", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld 分", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld 分", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld 秒", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld 秒", (long)secondCount];
formattedString = [formattedString stringByAppendingFormat: @" 前"]; // Append "ago" to the string
}
else if([language isEqualToString: @"ar"]) { // Arabic format
formattedString = @"مغلق منذ"; // Begin formatting string
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
NSLocale *arLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"ar"] autorelease];
[formatter setLocale:arLocale];
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %@ سنة", [formatter stringFromNumber:@(yearCount)]];
else
formattedString = [formattedString stringByAppendingFormat: @" %@ سنين", [formatter stringFromNumber:@(yearCount)]];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %@ شهر", [formatter stringFromNumber:@(monthCount)]];
else
formattedString = [formattedString stringByAppendingFormat: @" %@ شهور", [formatter stringFromNumber:@(monthCount)]];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %@ يوم", [formatter stringFromNumber:@(dayCount)]];
else
formattedString = [formattedString stringByAppendingFormat: @" %@ أيام", [formatter stringFromNumber:@(dayCount)]];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %@ ساعة", [formatter stringFromNumber:@(hourCount)]];
else
formattedString = [formattedString stringByAppendingFormat: @" %@ ساعات", [formatter stringFromNumber:@(hourCount)]];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %@ دقيقة", [formatter stringFromNumber:@(minuteCount)]];
else
formattedString = [formattedString stringByAppendingFormat: @" %@ دقائق", [formatter stringFromNumber:@(minuteCount)]];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %@ ثانية", [formatter stringFromNumber:@(secondCount)]];
else
formattedString = [formattedString stringByAppendingFormat: @" %@ ثواني", [formatter stringFromNumber:@(secondCount)]];
}
else if([language isEqualToString: @"tr"]) { // Turkish format
formattedString = @""; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld yıl", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld yıl", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld ay", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld ay", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld gün", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld gün", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld saat", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld saat", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld dakika", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld dakika", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld saniye", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld saniye", (long)secondCount];
formattedString = [formattedString stringByAppendingFormat: @" önce kilitlendi"]; // Append "ago" to the string
}
else if([language isEqualToString: @"fr"]) { // French format
formattedString = @"Verrouillé depuis"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld an", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld ans", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld mois", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld mois", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld jour", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld jours", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld heure", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld heures", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld minute", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld minutes", (long)minuteCount];
}
if(yearCount > 0 || monthCount > 0 || dayCount > 0 || hourCount > 0 || minuteCount > 0) {
formattedString = [formattedString stringByAppendingFormat: @" et"];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld seconde", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld secondes", (long)secondCount];
}
else if([language isEqualToString: @"de"]) { // German format
formattedString = @"Gesperrt vor"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld Jahr", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld Jahren", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld Monat", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld Monaten", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld Tag", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld Tagen", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld Stunde", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld Stunden", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld Minute", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld Minuten", (long)minuteCount];
}
if(yearCount > 0 || monthCount > 0 || dayCount > 0 || hourCount > 0 || minuteCount > 0) {
formattedString = [formattedString stringByAppendingFormat: @" und"];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld Sekunde", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld Sekunden", (long)secondCount];
}
else if([language isEqualToString: @"es"]) { // Spanish format
formattedString = @"Bloqueado hace"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld año", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld años", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld mes", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld meses", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld día", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld días", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld hora", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld horas", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld mins", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld seg", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld segs", (long)secondCount];
}
else if([language isEqualToString: @"pt"]) { // Portuguese format
formattedString = @"Bloqueado há"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld ano", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld anos", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld mês", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld meses", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld dia", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld dias", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld hora", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld horas", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld mins", (long)minuteCount];
}
if(yearCount > 0 || monthCount > 0 || dayCount > 0 || hourCount > 0 || minuteCount > 0) {
formattedString = [formattedString stringByAppendingFormat: @" e"];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld seg", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld segs", (long)secondCount];
formattedString = [formattedString stringByAppendingFormat: @" atrás"]; // Append "ago" to the string
}
else if([language isEqualToString: @"nb"]) { // Norwegian format
formattedString = @"Låst"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld år", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld år", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld mnd", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld mnd", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld dag", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld dager", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld time", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld timer", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld sek", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld sek", (long)secondCount];
formattedString = [formattedString stringByAppendingFormat: @" siden"]; // Append "ago" to the string
}
else if([language isEqualToString: @"zh"]) { // Traditional Chinese format
formattedString = @"已鎖了"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld年", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld年份", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld月", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld個月", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld天", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld天", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld小時", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld小時", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld分鐘", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld分鐘", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld秒", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld秒", (long)secondCount];
}
else if([language isEqualToString: @"cn"]) { // Simplified Chinese format
formattedString = @"已锁了"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld年", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld年", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld个月", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld个月", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld天", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld天", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld小时", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld小时", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld分", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld分", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld秒", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld秒", (long)secondCount];
}
else { // English format (default)
formattedString = @"Locked"; // Begin formatting string
// Do all of the formatting stuff by appending the string
if(yearCount > 0) {
if(yearCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld yr", (long)yearCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld yrs", (long)yearCount];
}
if(monthCount > 0) {
if(monthCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld mon", (long)monthCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld mons", (long)monthCount];
}
if(dayCount > 0) {
if(dayCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld day", (long)dayCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld days", (long)dayCount];
}
if(hourCount > 0) {
if(hourCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld hr", (long)hourCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld hrs", (long)hourCount];
}
if(minuteCount > 0) {
if(minuteCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld min", (long)minuteCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld mins", (long)minuteCount];
}
if(secondCount == 0 || secondCount == 1)
formattedString = [formattedString stringByAppendingFormat: @" %ld sec", (long)secondCount];
else
formattedString = [formattedString stringByAppendingFormat: @" %ld secs", (long)secondCount];
formattedString = [formattedString stringByAppendingFormat: @" ago"]; // Append "ago" to the string
}
return formattedString; // Return the formatted string
}
@end
%group iOS11X
@interface SBUILegibilityLabel : UIView
@property (nonatomic, assign, readwrite) NSString *string;
@end
@interface SBDashBoardTeachableMomentsContainerView
@property (nonatomic, assign, readwrite) SBUILegibilityLabel *callToActionLabel;
@end
%hook SBDashBoardTeachableMomentsContainerView
- (id)init {
%orig;
updateEverySecond = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateLastLocked) userInfo:nil repeats:YES];
return self;
}
%new
- (void)updateLastLocked {
NSString *newString = [NZ9TimeFormat nz9_lastLockedTimeFormat];
self.callToActionLabel.string = newString; //Gang
CGRect frame = self.callToActionLabel.frame;
self.callToActionLabel.frame = CGRectMake(frame.origin.x, frame.origin.y, [UIScreen mainScreen].bounds.size.width, frame.size.height); //Set frame so you can actually see stuff
self.callToActionLabel.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, self.callToActionLabel.center.y); //Center text
}
%end
%end
%group iOS10
%hook SBUICallToActionLabel // "Hook" the SBUICallToActionLabel class to change pre-existing methods
- (id)init {
%orig;
updateEverySecond = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(setText:) userInfo:nil repeats:YES];
return self;
}
- (void)setText:(id)arg1 {
NSString *newString = [NZ9TimeFormat nz9_lastLockedTimeFormat]; // Get formatted string
%orig(newString); // Call the original method with the formatted string
}
- (void)setText:(id)arg1 forLanguage:(id)language animated:(BOOL)animated {
NSString *newString = [NZ9TimeFormat nz9_lastLockedTimeFormat]; // Get formatted string
%orig(newString, language, animated); // Call the original method with the formatted string
}
%end
@interface SBDashBoardViewController : UIViewController <UIAlertViewDelegate>
@end
%hook SBDashBoardViewController
- (void)viewDidAppear:(BOOL)animated {
%orig(); // Call original "viewDidAppear:" method
lastLocked = [[NSDate date] retain]; // Set the lastLocked NSDate to the current date
if([dontationAlertSettings integerForKey: @"unlockCount"] == 15) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Enjoying my tweak, LastLocked?" message:@"Please consider donating so I can continue to develop tweaks like this! -NeinZedd9 <3" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Donate", nil];
[alert show];
[alert release];
}
[dontationAlertSettings setInteger: ([dontationAlertSettings integerForKey: @"unlockCount"] + 1) forKey: @"unlockCount"];
}
%new - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [alertView cancelButtonIndex]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://paypal.me/neinzedd"]];
}
}
%end
%end
%group iOS9
@interface SBLockScreenView : UIView <UIAlertViewDelegate>
@end
%hook SBLockScreenView
- (void)didMoveToWindow {
%orig;
lastLocked = [[NSDate date] retain]; // Set the lastLocked NSDate to the current date
updateEverySecond = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(setCustomSlideToUnlockText:) userInfo:nil repeats:YES];
if([dontationAlertSettings integerForKey: @"unlockCount"] == 15) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Enjoying my tweak, LastLocked?" message:@"Please consider donating so I can continue to develop tweaks like this! -NeinZedd9 <3" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Donate", nil];
[alert show];
[alert release];
}
[dontationAlertSettings setInteger: ([dontationAlertSettings integerForKey: @"unlockCount"] + 1) forKey: @"unlockCount"];
}
- (void)setCustomSlideToUnlockText:(NSString *)text {
NSString *newString = [NZ9TimeFormat nz9_lastLockedTimeFormat]; // Get formatted string
%orig(newString); // Call the original method with the formatted string
}
- (void)setCustomSlideToUnlockText:(NSString *)text animated:(BOOL)arg2 {
NSString *newString = [NZ9TimeFormat nz9_lastLockedTimeFormat]; // Get formatted string
%orig(newString, arg2); // Call the original method with the formatted string
}
%new - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [alertView cancelButtonIndex]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://paypal.me/neinzedd"]];
}
}
%end
%end
%ctor {
dontationAlertSettings = [[NSUserDefaults alloc] initWithSuiteName: @"com.neinzedd9.LastLocked"];
[dontationAlertSettings registerDefaults:@{
@"unlockCount": @0
}];
struct utsname systemInfo;
uname(&systemInfo);
NSString *device = @(systemInfo.machine);
// X Devices
if([device isEqualToString:@"iPhone10,3"] || [device isEqualToString:@"iPhone11,2"] || [device isEqualToString:@"iPhone11,4"] || [device isEqualToString:@"iPhone11,8"]) {
%init(iOS11X);
}
if(IS_IOS_OR_NEWER(iOS_10_0)) {
%init(iOS10);
}
else {
%init(iOS9);
}
}