📘 AppUtilX Documentation
Examples: Gradle KTS, Gradle (Groovy), and Kotlin — (No Java examples)
🔹 Download & Setup (Gradle KTS & Groovy)
Kotlin DSL (build.gradle.kts)
repositories {
google()
mavenCentral()
maven {
maven { url = uri("https://jitpack.io") }
}
}
dependencies {
implementation("com.github.mohamed-zaitoon:apputilx:1.0.3")
}
🔹 Initialize Utils (Kotlin)
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Utils.initialize(this)
registerActivityLifecycleCallbacks(Utils.activityTracker)
}
}
🔹 Toast (Kotlin)
Utils.showToast("Hello World")
Utils.showToast("Long Toast", long = true)
🔹 Connectivity (Kotlin)
val connected = Utils.isConnected
Utils.addConnectionListener { isOnline ->
Utils.showToast("Network changed: $isOnline")
}
🔹 Clipboard (Kotlin)
Utils.copyText("Copied text")
val copied = Utils.getCopiedText()
🔹 Device Info (Kotlin)
val model = Utils.getDeviceModel()
val version = Utils.getAndroidVersion()
🔹 Permissions (Kotlin)
Utils.requestPermission(this, Manifest.permission.CAMERA, 1001)
🔹 Keyboard (Kotlin)
/* Hide keyboard (auto-detects Activity / Context) */
Utils.hideKeyboard()
/* Hide keyboard with Context */
Utils.hideKeyboard(this)
/* Hide keyboard from View */
Utils.hideKeyboard(editText)
/* Show keyboard for a View */
Utils.showKeyboard(editText)
/* Toggle keyboard state */
Utils.toggleKeyboard()
/* Check keyboard state */
if (Utils.isKeyboardOpen(editText)) {
Utils.hideKeyboard(editText)
}
🔹 Sharing (Kotlin)
Utils.shareText(this, "Hello from Utils!")
🔹 Intent Utilities (Kotlin)
/* Open WhatsApp chat */
Utils.openWhatsApp("201234567890", "Hello!")
/* Open phone dialer */
Utils.dial("201234567890")
/* Send email */
Utils.sendEmail(
email = "test@example.com",
subject = "Hello",
body = "Message body"
)
/* Share text */
Utils.shareText("Shared from Utils")
🔹 Storage (Kotlin)
val free = Utils.getFreeStorage()
val total = Utils.getTotalStorage()
val cacheSize = Utils.getCacheSize()
Utils.clearCache()
🔹 File Utilities (Kotlin)
Utils.writeFile("test.txt", "Hello World")
val text = Utils.readFile("test.txt")
val exists = Utils.fileExists("test.txt")
Utils.deleteFile("test.txt")
🔹 Encryption & Encoding (Kotlin)
val hash = Utils.sha256("password123")
val encoded = Utils.base64Encode("Hello")
val decoded = Utils.base64Decode(encoded)
🔹 App State (Kotlin)
val isForeground = Utils.isAppInForeground()
val isScreenOn = Utils.isScreenOn()
🔹 Permission Helpers (Kotlin)
if (!Utils.isPermissionGranted(Manifest.permission.CAMERA)) {
Utils.requestPermission(
this,
Manifest.permission.CAMERA,
1001
)
}
🔹 Vibration (Kotlin)
Utils.vibrate(300)
Utils.vibratePattern(longArrayOf(0,200,100,300), -1)
🔹 Open URL (Kotlin)
Utils.openUrl(this, "https://google.com")
🔹 Screen Capture (Kotlin)
Utils.blockCapture()
Utils.unblockCapture()
🔹 Notification (Kotlin)
val intent = Intent(this, ExampleActivity::class.java)
val pendingIntent = PendingIntent.getActivity(
this,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)Utils.showNotification( channelId = "default_channel", title = "Hello", text = "This is a notification", iconResId = R.drawable.ic_launcher, intent = pendingIntent )
🔹 App Signature (Kotlin)
val signatures = Utils.getAppSignatures()
val primarySha1 = Utils.getPrimarySignatureSHA1()
val valid = Utils.validateAppSignature("AA:BB:CC:DD")
🔹 Logger (AlertDialog + Logcat)
/* Normal log */
Utils.log("Main", "App started successfully")
/* Warning log */
Utils.logWarning("Network", "Internet connection is slow")
/* Error log */
Utils.logError("API", "Request failed")
/* Error log with Exception */
try {
riskyCall()
} catch (e: Exception) {
Utils.logError("Crash", "Unexpected error", e)
}
🔹 License
Copyright (c) 2025 Mohamed Zaitoon