-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryDocumentation.html
More file actions
1816 lines (1683 loc) Β· 162 KB
/
Copy pathLibraryDocumentation.html
File metadata and controls
1816 lines (1683 loc) Β· 162 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lymors Lycommons Library Documentation</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
h1, h2 { color: #333; }
h3 { color: #555; border-bottom: 1px solid #ddd; padding-bottom: 5px; }
ul { list-style-type: none; }
li { margin: 5px 0; }
.package { font-weight: bold; color: #0066cc; }
.file { font-weight: bold; color: #009900; }
.method { color: #666; font-size: 0.9em; }
.property { color: #666; font-size: 0.9em; font-style: italic; }
.constructor { color: #cc6600; font-size: 0.9em; }
.toc { background: #f9f9f9; border: 1px solid #ddd; padding: 15px; margin-bottom: 20px; border-radius: 5px; }
.toc ul { list-style-type: disc; margin-left: 20px; }
.toc li { margin: 3px 0; }
.toc a { text-decoration: none; color: #0066cc; }
.toc a:hover { text-decoration: underline; }
.back-to-top { position: fixed; bottom: 20px; right: 20px; background: #0066cc; color: white; padding: 10px; border-radius: 5px; text-decoration: none; }
.line-numbers { color: #999; font-size: 0.8em; margin-right: 10px; }
</style>
</head>
<body id="top">
<h1>Lymors Lycommons Library Documentation</h1>
<!-- Introduction/Overview Section -->
<div class="intro-section">
<h2>π Introduction</h2>
<p><strong>Lymors Lycommons</strong> is a comprehensive Android utility library designed to accelerate development by providing commonly needed functionality out of the box. Built with modern Android development practices, it offers extensive extension functions, utilities, and managers that simplify everyday Android development tasks.</p>
<h3>π Key Features</h3>
<div class="features-grid">
<div class="feature-category">
<h4>π§ Extension Functions</h4>
<ul>
<li><strong>Context Extensions:</strong> Toast, permissions, networking, device info, app settings</li>
<li><strong>View Extensions:</strong> Animations, PDF generation, click handlers, visibility control</li>
<li><strong>String Extensions:</strong> Encryption, validation, QR codes, compression, TTS</li>
<li><strong>Data Extensions:</strong> JSON parsing, date operations, bitmap utilities</li>
<li><strong>Activity/Fragment Extensions:</strong> Navigation, status bar, screenshots, flash control</li>
</ul>
</div>
<div class="feature-category">
<h4>ποΈ Data Management</h4>
<ul>
<li><strong>Authentication:</strong> Email, Google, Phone auth with Firebase</li>
<li><strong>Database:</strong> Firestore & Realtime Database operations</li>
<li><strong>Storage:</strong> Firebase Storage with WorkManager background uploads</li>
<li><strong>ViewModels:</strong> Reactive state management with StateFlow</li>
<li><strong>DataStore:</strong> Modern data persistence with coroutines</li>
</ul>
</div>
<div class="feature-category">
<h4>π οΈ Utilities & Managers</h4>
<ul>
<li><strong>Permission Helper:</strong> Runtime permission handling</li>
<li><strong>Location Manager:</strong> GPS and network location</li>
<li><strong>Notification Manager:</strong> Local notifications</li>
<li><strong>Dialog Utilities:</strong> Common dialog patterns</li>
<li><strong>Media Player:</strong> Audio playback with lifecycle awareness</li>
</ul>
</div>
</div>
<h3>π― What This Library Solves</h3>
<div class="problem-solution">
<div class="problem">
<h4>β Common Development Pain Points</h4>
<ul>
<li>Writing boilerplate code for everyday operations</li>
<li>Managing complex Firebase authentication flows</li>
<li>Handling background file uploads reliably</li>
<li>Creating consistent UI animations and interactions</li>
<li>Managing app permissions and device features</li>
<li>Working with dates, JSON, and data validation</li>
</ul>
</div>
<div class="solution">
<h4>β
Lycommons Solutions</h4>
<ul>
<li><strong>One-line operations:</strong> Complex tasks reduced to single method calls</li>
<li><strong>Built-in best practices:</strong> Error handling, null safety, coroutine support</li>
<li><strong>Consistent API:</strong> Unified naming and parameter patterns</li>
<li><strong>Type safety:</strong> Generic extensions with proper type handling</li>
<li><strong>Lifecycle awareness:</strong> Components that respect Android lifecycles</li>
<li><strong>Modern Kotlin:</strong> Extension functions, coroutines, StateFlow</li>
</ul>
</div>
</div>
<h3>β‘ Quick Start Examples</h3>
<div class="quick-examples">
<div class="example">
<h4>π₯ Show Toast (One Line)</h4>
<pre><code class="language-kotlin">// Instead of:
val toast = Toast.makeText(this, "Hello World", Toast.LENGTH_SHORT)
toast.show()
// Use:
showToast("Hello World")</code></pre>
</div>
<div class="example">
<h4>π± Check Network Status</h4>
<pre><code class="language-kotlin">if (isNetworkAvailable()) {
// Load data from network
} else {
showToast("No internet connection")
}</code></pre>
</div>
<div class="example">
<h4>π Firebase Authentication</h4>
<pre><code class="language-kotlin">// Sign up with email
val result = authRepository.signUpUserWithEmailAndPassword(email, password)
when (result) {
is MyResult.Success -> showToast("Welcome!")
is MyResult.Error -> showToast(result.message)
}</code></pre>
</div>
<div class="example">
<h4>π Convert View to PDF</h4>
<pre><code class="language-kotlin">val pdfPath = myView.convertToPdf(this, "document.pdf")
pdfPath?.let { openFile(Uri.parse(it)) }</code></pre>
</div>
</div>
<h3>ποΈ Architecture & Design Principles</h3>
<ul>
<li><strong>π§ Extension-First:</strong> Leverages Kotlin extension functions for intuitive APIs</li>
<li><strong>π¦ Modular Design:</strong> Organized into logical packages (data, extensions, utils)</li>
<li><strong>π Reactive Programming:</strong> Built around coroutines and Flow for async operations</li>
<li><strong>π‘οΈ Type Safety:</strong> Generic functions with proper type constraints</li>
<li><strong>π― Single Responsibility:</strong> Each component has a clear, focused purpose</li>
<li><strong>π§ͺ Testable:</strong> Dependency injection support and interface-based design</li>
</ul>
<div class="getting-started-cta">
<h3>π Ready to Get Started?</h3>
<p>This documentation provides a complete reference for all available functionality. Use the table of contents below to navigate to specific packages, or check the Installation section to add the library to your project.</p>
<p><strong>π‘ Pro Tip:</strong> Start with <a href="#contextextensions">ContextExtensions.kt</a> and <a href="#viewextensions">ViewExtensions.kt</a> for the most commonly used utilities!</p>
</div>
</div>
<!-- Add CSS for new sections -->
<style>
.intro-section {
background: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 8px;
padding: 20px;
margin-bottom: 30px;
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin: 20px 0;
}
.feature-category {
background: white;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #0066cc;
}
.feature-category h4 {
margin-top: 0;
color: #0066cc;
}
.problem-solution {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin: 20px 0;
}
@media (max-width: 768px) {
.problem-solution {
grid-template-columns: 1fr;
}
}
.problem, .solution {
background: white;
padding: 15px;
border-radius: 6px;
}
.problem {
border-left: 4px solid #dc3545;
}
.solution {
border-left: 4px solid #28a745;
}
.quick-examples {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 20px;
margin: 20px 0;
}
.example {
background: white;
padding: 15px;
border-radius: 6px;
border: 1px solid #dee2e6;
}
.example h4 {
margin-top: 0;
color: #495057;
}
.example pre {
background: #f8f9fa;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
font-size: 0.9em;
}
.getting-started-cta {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 6px;
margin-top: 20px;
}
.getting-started-cta h3 {
margin-top: 0;
}
.getting-started-cta a {
color: #ffd700;
text-decoration: underline;
}
.getting-started-cta a:hover {
color: #fff;
}
</style>
<p>This Android library provides various utilities including authentication repositories, database operations, storage management, view models, extensions, and managers for common app functionalities.</p>
<!-- Installation & Setup Section -->
<div class="installation-section">
<h2>π¦ Installation & Setup</h2>
<h3>π§ Requirements</h3>
<div class="requirements">
<ul>
<li><strong>Android SDK:</strong> Minimum SDK 21 (Android 5.0)</li>
<li><strong>Target SDK:</strong> Recommended SDK 34 (Android 14)</li>
<li><strong>Kotlin:</strong> 1.8.0 or higher</li>
<li><strong>Gradle:</strong> 8.0 or higher</li>
<li><strong>AndroidX:</strong> Latest stable versions</li>
</ul>
</div>
<h3>π₯ Step 1: Add the Library</h3>
<div class="step">
<h4>Option A: Local Module (Recommended for Development)</h4>
<p>This is the easiest way to use the library during development. The library module is already part of your project.</p>
<pre><code class="language-gradle">// In your settings.gradle.kts or settings.gradle
include ":app"
include ":mylib"
// In your app's build.gradle.kts or build.gradle
dependencies {
implementation(project(":mylib"))
// Other dependencies...
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
}</code></pre>
<h4>Option B: Using AAR File (For Distribution)</h4>
<p>To use the library as an AAR file in other projects:</p>
<div class="aar-steps">
<p><strong>Step 1:</strong> Build the AAR file from this project:</p>
<pre><code class="language-bash"># In the project root directory
./gradlew :mylib:assembleRelease
# The AAR will be generated at:
# mylib/build/outputs/aar/mylib-release.aar</code></pre>
<p><strong>π‘ Quick Build:</strong> Run the provided <code>build-aar.bat</code> script for Windows or use the manual commands above.</p>
<div class="note-box">
<strong>β οΈ Note:</strong> Building the full AAR with all dependencies may require resolving Gradle configuration issues. If the build fails, you can:
<ul>
<li>Try building with <code>./gradlew :mylib:assembleDebug</code> instead</li>
<li>Temporarily disable complex dependencies (Firebase, Hilt, Glide) in build.gradle.kts</li>
<li>Use the manual approach below for immediate distribution</li>
</ul>
</div>
<p><strong>Alternative - Manual AAR Creation:</strong> If Gradle build fails, you can manually create a distributable package:</p>
<pre><code class="language-bash"># Copy the library source files to your target project
mkdir -p /path/to/target-project/libs/mylib/
cp -r mylib/src/main/java/* /path/to/target-project/libs/mylib/
# Create a simple JAR or ZIP file
cd mylib/src/main/java
zip -r ../../../libs/mylib-source.zip .
# Then in your target project, copy the source files to your app module</code></pre>
<p><strong>Step 2:</strong> Copy the AAR to your target project:</p>
<pre><code class="language-bash"># Create libs folder in your app module if it doesn't exist
mkdir -p app/libs
# Copy the AAR file
cp mylib/build/outputs/aar/mylib-release.aar /path/to/your-project/app/libs/</code></pre>
<p><strong>β οΈ Important:</strong> When using AAR files, you must manually add all the library's dependencies to your project (listed in Step 2 below).</p>
</div>
<h4>Option C: JitPack (When Published)</h4>
<p>Once the library is published to JitPack, you can use it directly:</p>
<pre><code class="language-gradle">// In your root build.gradle.kts or build.gradle
allprojects {
repositories {
maven { url = uri("https://jitpack.io") }
}
}
// In your app's build.gradle.kts or build.gradle
dependencies {
implementation("com.github.lymors:lycommons:latest-version")
}</code></pre>
</div>
<h3>π₯ Step 2: Add Required Dependencies</h3>
<div class="dependencies">
<p>The library requires these core dependencies. Add them to your app's <code>build.gradle.kts</code>:</p>
<h4>π Firebase (For Authentication, Database, Storage)</h4>
<pre><code class="language-gradle">// Firebase BOM
implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
// Firebase Services
implementation("com.google.firebase:firebase-auth-ktx")
implementation("com.google.firebase:firebase-firestore-ktx")
implementation("com.google.firebase:firebase-database-ktx")
implementation("com.google.firebase:firebase-storage-ktx")
implementation("com.google.firebase:firebase-messaging-ktx")</code></pre>
<h4>ποΈ Data & Utilities</h4>
<pre><code class="language-gradle">// DataStore for modern data persistence
implementation("androidx.datastore:datastore-preferences:1.0.0")
// WorkManager for background tasks
implementation("androidx.work:work-runtime-ktx:2.9.0")
// Hilt for dependency injection (optional but recommended)
implementation("com.google.dagger:hilt-android:2.48")
kapt("com.google.dagger:hilt-compiler:2.48")</code></pre>
<h4>π¨ UI & Graphics</h4>
<pre><code class="language-gradle">// Material Design Components
implementation("com.google.android.material:material:1.11.0")
// ViewBinding
buildFeatures {
viewBinding = true
}
// Glide for image loading (used in ImageViewExtensions)
implementation("com.github.bumptech.glide:glide:4.16.0")
kapt("com.github.bumptech.glide:compiler:4.16.0")</code></pre>
<h4>π§ Additional Libraries</h4>
<pre><code class="language-gradle">// Gson for JSON parsing
implementation("com.google.code.gson:gson:2.10.1")
// ZXing for QR code generation
implementation("com.google.zxing:core:3.5.2")
// mXparser for mathematical expressions
implementation("org.mariuszgromada.math:mxparser:5.2.1")</code></pre>
</div>
<h3>βοΈ Step 3: Configure ProGuard (If Using)</h3>
<div class="proguard">
<p>Add these rules to your <code>proguard-rules.pro</code> file:</p>
<pre><code class="language-proguard"># Keep Firebase classes
-keep class com.google.firebase.** { *; }
-keep class com.lymors.lycommons.** { *; }
# Keep Gson classes
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# Keep ViewBinding
-keep class * extends androidx.viewbinding.ViewBinding {
public static *** inflate(...);
public static *** bind(...);
}</code></pre>
</div>
<h3>π Step 4: Basic Setup</h3>
<div class="basic-setup">
<h4>π± Initialize in Application Class</h4>
<pre><code class="language-kotlin">@HiltAndroidApp
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Optional: Initialize any global components
// Most extensions work without initialization
}
}</code></pre>
<h4>π Firebase Configuration</h4>
<pre><code class="language-kotlin">// In your Activity or Fragment
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
lateinit var authRepository: AuthRepositoryWithEmail
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Use extensions directly
showToast("Welcome to Lycommons!")
// Or use injected repositories
lifecycleScope.launch {
val user = authRepository.getCurrentUser()
// Handle user state
}
}
}</code></pre>
</div>
<h3>β
Step 5: Verify Installation</h3>
<div class="verification">
<p>Test your installation with these simple examples:</p>
<div class="test-example">
<h4>π§ͺ Test Context Extensions</h4>
<pre><code class="language-kotlin">class TestActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Test basic extensions
showToast("Installation successful!")
// Test network check
if (isNetworkAvailable()) {
showToast("Network is available")
}
// Test device info
val version = getVersionName()
showToast("App version: $version")
}
}</code></pre>
</div>
<div class="test-example">
<h4>π§ͺ Test View Extensions</h4>
<pre><code class="language-kotlin">// In your layout XML or programmatically
val myButton = Button(this)
myButton.text = "Click Me"
// Test view extensions
myButton.setOnClickListener {
it.fadeOut(1000) // Fade out animation
showToast("Button clicked!")
}
// Test PDF generation
val pdfPath = myButton.convertToPdf(this, "test.pdf")
pdfPath?.let {
showToast("PDF created: $it")
}</code></pre>
</div>
</div>
<div class="troubleshooting">
<h3>π§ Troubleshooting</h3>
<div class="trouble-item">
<h4>β "Unresolved reference" errors</h4>
<p><strong>Solution:</strong> Make sure you've added the library as a dependency and synced Gradle. For local modules, ensure the module path is correct in settings.gradle.</p>
</div>
<div class="trouble-item">
<h4>β Firebase services not working</h4>
<p><strong>Solution:</strong> Ensure you've added the google-services.json file to your app module and applied the Google Services plugin in your build.gradle.</p>
</div>
<div class="trouble-item">
<h4>β ProGuard/R8 issues in release builds</h4>
<p><strong>Solution:</strong> Add the ProGuard rules mentioned above. If issues persist, add <code>-keep class com.lymors.lycommons.** { *; }</code> to keep all library classes.</p>
</div>
</div>
<div class="next-steps">
<h3>π― Next Steps</h3>
<p>Once installed, check out these popular sections:</p>
<ul>
<li><a href="#contextextensions">π± ContextExtensions.kt</a> - Device info, permissions, networking</li>
<li><a href="#viewextensions">π¨ ViewExtensions.kt</a> - Animations, PDF, UI helpers</li>
<li><a href="#stringextensions">π StringExtensions.kt</a> - Encryption, validation, QR codes</li>
<li><a href="#data-auth-package">π Authentication</a> - Firebase auth setup</li>
<li><a href="#data-database-package">πΎ Database Operations</a> - Firestore & Realtime DB</li>
</ul>
</div>
</div>
<!-- Add CSS for installation section -->
<style>
.installation-section {
background: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 8px;
padding: 20px;
margin-bottom: 30px;
}
.requirements {
background: white;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #28a745;
margin: 15px 0;
}
.step {
background: white;
padding: 15px;
border-radius: 6px;
border: 1px solid #dee2e6;
margin: 15px 0;
}
.step h4 {
color: #495057;
margin-top: 0;
}
.dependencies {
background: white;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #007bff;
margin: 15px 0;
}
.proguard {
background: #fff3cd;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #ffc107;
margin: 15px 0;
}
.basic-setup {
background: white;
padding: 15px;
border-radius: 6px;
border: 1px solid #dee2e6;
margin: 15px 0;
}
.verification {
background: #d1ecf1;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #17a2b8;
margin: 15px 0;
}
.test-example {
background: white;
padding: 15px;
border-radius: 6px;
border: 1px solid #dee2e6;
margin: 10px 0;
}
.troubleshooting {
background: #f8d7da;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #dc3545;
margin: 15px 0;
}
.trouble-item {
background: white;
padding: 10px;
border-radius: 4px;
margin: 10px 0;
}
.next-steps {
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
color: white;
padding: 20px;
border-radius: 6px;
margin-top: 20px;
}
.next-steps h3 {
margin-top: 0;
}
.next-steps a {
color: #ffd700;
text-decoration: underline;
}
.next-steps a:hover {
color: #fff;
}
.aar-steps {
background: #e7f3ff;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #0066cc;
margin: 15px 0;
}
.aar-steps p {
margin: 10px 0;
}
.aar-steps strong {
color: #0066cc;
}
.note-box {
background: #fff3cd;
border: 1px solid #ffeaa7;
border-radius: 6px;
padding: 12px;
margin: 10px 0;
}
.note-box strong {
color: #856404;
}
.note-box ul {
margin: 8px 0;
padding-left: 20px;
}
.note-box li {
margin: 4px 0;
}
pre {
background: #f8f9fa;
padding: 15px;
border-radius: 6px;
overflow-x: auto;
font-size: 0.9em;
border: 1px solid #e9ecef;
}
code {
background: #e9ecef;
padding: 2px 4px;
border-radius: 3px;
font-family: 'Courier New', monospace;
}
</style>
<style>
.recent-updates-section {
background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
border: 1px solid #bbdefb;
border-radius: 8px;
padding: 20px;
margin-bottom: 30px;
}
.recent-updates-section h2 {
color: #1976d2;
border-bottom: 2px solid #1976d2;
padding-bottom: 10px;
}
.recent-updates-section h3 {
color: #424242;
margin-top: 25px;
margin-bottom: 15px;
}
.update-item {
background: white;
padding: 15px;
border-radius: 6px;
border-left: 4px solid #2196f3;
margin: 15px 0;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.update-item h4 {
color: #1976d2;
margin-top: 0;
margin-bottom: 10px;
}
.version-info {
background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
color: white;
padding: 20px;
border-radius: 6px;
margin-top: 20px;
}
.version-info h3 {
margin-top: 0;
}
.next-improvements {
background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
color: white;
padding: 20px;
border-radius: 6px;
margin-top: 20px;
}
.next-improvements h3 {
margin-top: 0;
}
</style>
<div class="toc">
<h3>π Table of Contents (Quick Navigation)</h3>
<p><strong>π‘ Tip:</strong> Click any link below to jump directly to that section. Use browser search (Ctrl+F) to find specific methods or classes.</p>
<h4>π Getting Started</h4>
<ul>
<li><a href="#top">π Introduction & Overview</a></li>
<li><a href="#installation-section">π¦ Installation & Setup Guide</a></li>
<li><a href="#quick-start">β‘ Quick Start Examples</a></li>
</ul>
<h4>π¦ Main Packages</h4>
<ul>
<li><a href="#data-package">ποΈ Data Package (Auth, Database, Storage, ViewModels)</a></li>
<li><a href="#extensions-package">π§ Extensions Package (UI, Context, View, etc.)</a></li>
<li><a href="#utils-package">π οΈ Utils Package (Managers, Helpers, Utilities)</a></li>
</ul>
<h4>π§ Extensions (Most Used)</h4>
<ul>
<li><a href="#contextextensions">ContextExtensions.kt - Context utilities (44 methods)</a> <span class="line-numbers">π Search: #contextextensions</span></li>
<li><a href="#viewextensions">ViewExtensions.kt - View animations & UI (80+ methods)</a> <span class="line-numbers">π Search: #viewextensions</span></li>
<li><a href="#dataextensions">DataExtensions.kt - JSON, Date, Bitmap utilities (70+ methods)</a> <span class="line-numbers">π Search: #dataextensions</span></li>
<li><a href="#imageviewextensions">ImageViewExtensions.kt - Glide loading & image ops (27 methods)</a> <span class="line-numbers">π Search: #imageviewextensions</span></li>
<li><a href="#textedittextextensions">TextEditTextExtensions.kt - Input helpers (27 methods)</a> <span class="line-numbers">π Search: #textedittextextensions</span></li>
<li><a href="#screenextensions">ScreenExtensions.kt - Activity/Fragment helpers (30+ methods)</a> <span class="line-numbers">π Search: #screenextensions</span></li>
<li><a href="#numbersextensions">NumbersExtensions.kt - Number utilities (25+ methods)</a> <span class="line-numbers">π Search: #numbersextensions</span></li>
<li><a href="#uiextensions">UIExtensions.kt - Bottom sheets, dialogs (9 methods)</a> <span class="line-numbers">π Search: #uiextensions</span></li>
<li><a href="#stringextensions">StringExtensions.kt - String manipulation & crypto</a> <span class="line-numbers">π Search: #stringextensions</span></li>
<li><a href="#utilityextensions">UtilityExtensions.kt - PDF, logging, sharing</a> <span class="line-numbers">π Search: #utilityextensions</span></li>
</ul>
<h4>ποΈ Data Package</h4>
<ul>
<li><a href="#auth-package">π Authentication (Email, Google, Phone)</a></li>
<li><a href="#database-package">πΎ Database (Firestore, Realtime, Location)</a></li>
<li><a href="#storage-package">βοΈ Storage (Firebase, WorkManager)</a></li>
<li><a href="#viewmodels-package">π ViewModels (Auth, Firestore, Storage)</a></li>
</ul>
<h4>π οΈ Utils Package</h4>
<ul>
<li><a href="#managers-package">ποΈ Managers (DataStore, Location, Notification, etc.)</a></li>
<li><a href="#utils-files">π Utility Files (Dialogs, Image Picker, Permissions, etc.)</a></li>
</ul>
<h4>π Content Placement Info</h4>
<ul>
<li><strong>π Search Patterns:</strong> Use "#[filename]" (e.g., "#contextextensions") to jump to files</li>
<li><strong>π¦ Package Navigation:</strong> Search for "-package" suffix (e.g., "data-package")</li>
<li><strong>β‘ Quick Find:</strong> Use Ctrl+F to search for method names, class names, or keywords</li>
<li><strong>π― Dynamic References:</strong> All navigation uses anchor IDs that stay accurate as content grows</li>
<li><strong>π± Mobile Tip:</strong> Click TOC links to jump directly, use browser back button to return</li>
</ul>
</div>
<!-- Recent Updates Section -->
<div class="recent-updates-section">
<h2>π Recent Updates & Fixes</h2>
<h3>π§ Build & Compilation Fixes</h3>
<div class="update-item">
<h4>β
Kotlin Compilation Errors Resolved</h4>
<p>Fixed several compilation errors that prevented successful AAR building:</p>
<ul>
<li><strong>ScreenExtensions.kt:</strong> Removed invalid <code>inline</code> keyword from local function and changed <code>fun <reified T> Activity.getBinding(): T</code> to <code>fun <T> Activity.getBinding(clazz: Class<T>): T</code> for proper reflection usage.</li>
<li><strong>UIExtensions.kt:</strong> Added missing import for <code>ItemviewSimpleListBinding</code> and explicitly specified type parameter <code><ItemviewSimpleListBinding></code> in setData call to resolve type inference issues.</li>
<li><strong>ContextExtensions.kt:</strong> Changed receiver from <code>Context</code> to <code>Activity</code> for <code>setTransparentStatusBar()</code> function since <code>window</code> property is only available on Activity.</li>
<li><strong>DataExtensions.kt:</strong> Added missing type parameter <code><T></code> declaration to the generic <code>toArrayList()</code> extension function.</li>
</ul>
</div>
<div class="update-item">
<h4>π¦ ProGuard/R8 Configuration</h4>
<p>Enhanced ProGuard rules to prevent minification issues in release builds:</p>
<ul>
<li>Added keep rules for <code>java.lang.invoke.StringConcatFactory</code> to handle Java 9+ string concatenation during R8 optimization.</li>
<li>Added <code>-dontwarn java.lang.invoke.StringConcatFactory</code> to suppress related warnings.</li>
<li>Expanded keep rules for <code>java.lang.invoke.**</code> package to ensure compatibility.</li>
</ul>
</div>
<div class="update-item">
<h4>π§ Gradle & Build System Improvements</h4>
<p>Updated build configuration for better compatibility:</p>
<ul>
<li>Upgraded Android Gradle Plugin from 8.2.0 to 8.5.0 for improved JDK 17 support and bug fixes.</li>
<li>Added JVM arguments to handle JDK module system compatibility issues during compilation.</li>
<li>Resolved JdkImageTransform errors that were preventing Java compilation in certain environments.</li>
</ul>
</div>
<h3>π§Ή Code Cleanup & Optimization</h3>
<div class="update-item">
<h4>π Duplicate Function Removal</h4>
<p>Identified and removed duplicate function signatures across the codebase:</p>
<ul>
<li>Removed redundant JSON-related extension functions from <code>OldMyExtensionsFile.kt</code> that were already implemented in <code>DataExtensions.kt</code>.</li>
<li>Cleaned up unused imports and properties in extension files.</li>
<li>Fixed incomplete function definitions (e.g., <code>setDefaultOptions</code> in <code>TextEditTextExtensions.kt</code>).</li>
</ul>
</div>
<h3>π Documentation Improvements</h3>
<div class="update-item">
<h4>π Updated Examples & Code Samples</h4>
<p>Refreshed documentation with current implementation details:</p>
<ul>
<li>Updated code examples to reflect changes in extension function signatures.</li>
<li>Added troubleshooting section for common build issues.</li>
<li>Improved installation guide with detailed dependency management.</li>
<li>Added performance notes and best practices for large-scale usage.</li>
</ul>
</div>
<div class="version-info">
<h3>π Version Information</h3>
<p><strong>Current Version:</strong> 1.0.0 (Build-ready AAR)</p>
<p><strong>Last Updated:</strong> November 2025</p>
<p><strong>Build Status:</strong> β
Release AAR successfully generated</p>
<p><strong>Tested With:</strong> Android SDK 34, Kotlin 1.8.20, AGP 8.5.0</p>
</div>
<div class="next-improvements">
<h3>π Planned Improvements</h3>
<ul>
<li><strong>Enhanced Error Handling:</strong> Add more detailed error messages and recovery mechanisms in repository classes.</li>
<li><strong>Performance Optimizations:</strong> Implement lazy loading and caching for frequently used operations.</li>
<li><strong>Additional Extensions:</strong> Expand utility functions for newer Android APIs (e.g., predictive back gestures).</li>
<li><strong>Testing Framework:</strong> Add comprehensive unit and integration tests with CI/CD pipeline.</li>
<li><strong>Multi-Module Support:</strong> Improve compatibility with dynamic feature modules and instant apps.</li>
</ul>
</div>
</div>
<h2>Package Structure</h2>
<div class="line-numbers">π Search: #package-structure</div>
<ul>
<li class="package">com.lymors.lycommons
<ul>
<li class="package" id="data-package">data <span class="line-numbers">π Search: #data-package</span>
<ul>
<li class="package" id="auth-package">auth <span class="line-numbers">π Search: #auth-package</span>
<ul>
<li class="package">email
<ul>
<li class="file">AuthRepositoryWithEmail.kt - Interface for email authentication operations.
<ul>
<li class="method">suspend fun signUpUserWithEmailAndPassword(email: String, password: String): MyResult<String> - Signs up user with email and password.</li>
<li class="method">suspend fun loginUserWithEmailAndPassword(email: String, password: String): MyResult<String> - Logs in user with email and password.</li>
<li class="method">suspend fun resetPassword(email: String): MyResult<String> - Resets password for given email.</li>
</ul>
</li>
<li class="file">AuthRepositoryWithEmailImpl.kt - Firebase-based implementation of email authentication. Handles sign-up, login, and password reset with detailed error handling for various Firebase exceptions.</li>
</ul>
</li>
<li class="package">googleauth
<ul>
<li class="file">AuthRepositoryWithGoogle.kt - Interface for Google Sign-In authentication.
<ul>
<li class="method">fun registerGoogleSignInLauncher(activity: FragmentActivity): Unit - Registers the activity result launcher for Google Sign-In.</li>
<li class="method">fun signInWithGoogle(activity: FragmentActivity, serverClientId: String, callback: (account: GoogleSignInAccount?, exception: Exception?) -> Unit): Unit - Initiates Google Sign-In.</li>
<li class="method">fun getGoogleAccount(activity: FragmentActivity, serverClientId: String, accountCallback: (account: GoogleSignInAccount?) -> Unit): Unit - Retrieves the Google account.</li>
<li class="method">fun signOutFromGoogle(activity: FragmentActivity, serverClientId: String, onSignOutResult: (MyResult<String>) -> Unit): Unit - Signs out from Google and Firebase.</li>
</ul>
</li>
<li class="file">AuthRepositoryWithGoogleImpl.kt - Implementation using Google Sign-In API and Firebase Auth. Manages sign-in flow, account retrieval, sign-out, and Firebase authentication with Google credentials.</li>
</ul>
</li>
<li class="package">phone
<ul>
<li class="file">AuthRepositoryWithPhone.kt - Interface for phone number authentication.
<ul>
<li class="method">suspend fun signInUser(phone: String, context: Activity, phoneAuthCredential: (PhoneAuthCredential) -> Unit, authVerificationFailed: (String) -> Unit, codeSend: (verificationId: String, token: PhoneAuthProvider.ForceResendingToken) -> Unit): PhoneAuthProvider.OnVerificationStateChangedCallbacks - Starts phone verification.</li>
<li class="method">suspend fun loginUser(credential: PhoneAuthCredential): MyResult<String> - Logs in using the phone auth credential.</li>
<li class="method">suspend fun resendOtp(token: PhoneAuthProvider.ForceResendingToken, callBack: PhoneAuthProvider.OnVerificationStateChangedCallbacks, context: Activity, phoneNumber: String): MyResult<String> - Resends the OTP.</li>
</ul>
</li>
<li class="file">AuthRepositoryWithPhoneImpl.kt - Firebase Phone Auth implementation. Handles OTP sending, verification callbacks, login, and resend functionality.</li>
</ul>
</li>
</ul>
</li>
<li class="package">database
<ul>
<li class="file">FirestoreRepository.kt - Interface for Firestore database operations.
<ul>
<li class="method">suspend fun updateAnyModel(path: String, updatedMap: Map<String, Any>): MyResult<String> - Updates a model in Firestore.</li>
<li class="method">suspend fun checkExists(path: String): MyResult<String> - Checks if a document exists.</li>
<li class="method">suspend fun <T> getAllChildByKeys(path: String, keys: List<String>, clazz: Class<T>): List<T> - Gets models by keys.</li>
<li class="method">suspend fun <T : Any> queryModelByAProperty(path: String, property: String, value: String, clazz: Class<T>): T? - Queries model by property.</li>
<li class="method">suspend fun <T : Any> uploadAnyModel(path: String, model: T): MyResult<String> - Uploads a model.</li>
<li class="method">suspend fun deleteAnyModel(path: String): MyResult<String> - Deletes a model.</li>
<li class="method">fun <T> collectAModel(path: String, clazz: Class<T>): Flow<T> - Collects a single model.</li>
<li class="method">suspend fun getMap(path: String): MyResult<Map<String, String>> - Gets a map.</li>
<li class="method">suspend fun <T : Any> collectMap(path: String): Flow<Map<String, T>> - Collects a map.</li>
<li class="method">suspend fun <T> getAnyData(path: String, clazz: Class<T>): T? - Gets any data.</li>
<li class="method">suspend fun <T> getModelsWithChildren(path: String, clazz: Class<T>): Flow<List<T>> - Gets models with children.</li>
<li class="method">suspend fun <T> getDataList(path: String, clazz: Class<T>): List<T> - Gets data list.</li>
<li class="method">fun <T> collectAnyModel(path: String, clazz: Class<T>, numberOfItems: Int = 0): Flow<List<T>> - Collects models.</li>
<li class="method">suspend fun <T : Any> uploadAllModelsAtOnce(path: String, models: List<T>): MyResult<String> - Batch upload.</li>
</ul>
</li>
<li class="file">FirestoreRepositoryImpl.kt - Implementation of Firestore operations using Firebase Firestore SDK. Includes path validation, nested reference creation, real-time listeners, and batch operations.</li>
<li class="file">LocationRepository.kt - Interface for geolocation operations using GeoFire.
<ul>
<li class="method">suspend fun uploadLocation(child: String, key: String, latitude: Double, longitude: Double): Unit - Uploads a location.</li>
<li class="method">suspend fun getLocationOfAKey(child: String, key: String, callback: (LatLng?) -> Unit): Unit - Gets location by key.</li>
<li class="method">suspend fun collectALocation(child: String, key: String, callback: (LocationModel) -> Unit): Unit - Collects location updates.</li>
<li class="method">fun collectAllLocationsInARadius(path: String, center: LatLng, radius: Double, movedKey: (LocationModel) -> Unit = {}): Flow<List<LocationModel>> - Collects locations in radius.</li>
<li class="method">fun cancelGeoQueryListener(): Unit - Cancels the geo query listener.</li>
<li class="method">suspend fun getAllLocationsInARadius(path: String, center: LatLng, radius: Double): List<LocationModel> - Gets locations in radius.</li>
</ul>
</li>
<li class="file">LocationRepositoryImpl.kt - Implementation using Firebase Realtime Database and GeoFire for location queries and listeners.</li>
<li class="file">MainRepository.kt - Interface for Firebase Realtime Database operations, similar to FirestoreRepository.
<ul>
<li class="method">suspend fun updateAnyModel(path: String, updatedMap: Map<String, Any>): MyResult<String> - Updates a model in Realtime Database.</li>
<li class="method">suspend fun checkExists(path: String): MyResult<String> - Checks if a path exists.</li>
<li class="method">suspend fun <T> getAllChildByKeys(path: String, keys: List<String>, clazz: Class<T>): List<T> - Gets models by keys.</li>
<li class="method">suspend fun <T : Any> queryModelByAProperty(path: String, property: String, value: String, clazz: Class<T>): T? - Queries model by property.</li>
<li class="method">suspend fun <T : Any> uploadAnyModel(path: String, model: T): MyResult<String> - Uploads a model.</li>
<li class="method">suspend fun deleteAnyModel(path: String): MyResult<String> - Deletes a model.</li>
<li class="method">fun <T> collectAModel(path: String, clazz: Class<T>): Flow<T> - Collects a single model.</li>
<li class="method">suspend fun getMap(path: String): MyResult<Map<String, String>> - Gets a map.</li>
<li class="method">suspend fun <T : Any> collectMap(path: String): Flow<Map<String, T>> - Collects a map.</li>
<li class="method">suspend fun <T> getAnyData(path: String, clazz: Class<T>): T? - Gets any data.</li>
<li class="method">suspend fun <T> getModelsWithChildren(path: String, clazz: Class<T>): Flow<List<T>> - Gets models with children.</li>
<li class="method">suspend fun <T> getDataList(path: String, clazz: Class<T>): List<T> - Gets data list.</li>
<li class="method">fun <T> collectAnyModel(path: String, clazz: Class<T>, numberOfItems: Int = 0): Flow<List<T>> - Collects models.</li>
<li class="method">suspend fun <T : Any> uploadAllModelsAtOnce(path: String, models: List<T>): MyResult<String> - Batch uploads.</li>
</ul>
</li>
<li class="file">MainRepositoryImpl.kt - Implementation for Realtime Database with path validation, listeners, batch operations, and image uploads via WorkManager.</li>
</ul>
</li>
<li class="package">viewmodels
<ul>
<li class="file">AuthViewModel.kt - ViewModel combining email, phone, and Google authentication. Handles sign-in, sign-up, OTP verification, and sign-out.
<ul>
<li class="method">fun registerGoogleSignInLauncher(activity: FragmentActivity): Unit - Registers the Google Sign-In launcher.</li>
<li class="method">resetPassword(email: String): MyResult<String> - Resets password for the given email.</li>
<li class="method">suspend fun signInWithPhone(context: Activity, phone: String, otpVerifyActivity: Class<*>, mainActivity: Class<*>, onResult: (MyResult<String>) -> Unit): Unit - Initiates phone sign-in.</li>
<li class="method">verifyOtp(otp: String): MyResult<String> - Verifies the OTP for phone authentication.</li>