This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.firezenk | |
import androidx.navigation.NavGraphBuilder | |
import androidx.navigation.NavHostController | |
import androidx.navigation.NavType | |
import androidx.navigation.compose.composable | |
import com.github.firezenk.Route | |
import com.github.firezenk.exampleRoute2 | |
internal val exampleRoute1 = Route("ExampleRoute1", linkedMapOf( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun OnLifecycleEvent(onEvent: (owner: LifecycleOwner, event: Lifecycle.Event) -> Unit) { | |
val eventHandler = rememberUpdatedState(onEvent) | |
val lifecycleOwner = rememberUpdatedState(LocalLifecycleOwner.current) | |
DisposableEffect(lifecycleOwner.value) { | |
val lifecycle = lifecycleOwner.value.lifecycle | |
val observer = LifecycleEventObserver { owner, event -> | |
eventHandler.value(owner, event) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ActivateBluetooth(launcher: (() -> Unit) -> Unit, isRequestingActivation: (Boolean) -> Unit, | |
onActivated: () -> Unit) { | |
val bluetoothActivationLauncher = | |
rememberLauncherForActivityResult(RequestBluetoothActivation()) { | |
if (it) { | |
isRequestingActivation(false) | |
onActivated() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ActivateLocationServices() { | |
val context = LocalContext.current | |
val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager | |
if (!LocationManagerCompat.isLocationEnabled(lm)) | |
context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalPermissionsApi | |
@Composable | |
fun CheckPermissions(permissions: List<String>, launcher: (() -> Unit) -> Unit, | |
onAllGranted: () -> Unit, onPermissionsNeeded: () -> Unit, ) { | |
val multiplePermissionsState = rememberMultiplePermissionsState(permissions) | |
val isAlreadyGranted = remember { mutableStateOf(false) } | |
launcher { multiplePermissionsState.launchMultiplePermissionRequest() } | |
val allGranted = multiplePermissionsState.allPermissionsGranted | |
if (allGranted && !isAlreadyGranted.value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import proguard.gradle.ProGuardTask | |
import java.nio.file.Paths | |
dependencies { | |
[...] | |
// Required by @task::obfuscate | |
compileOnly 'org.jetbrains:annotations:13.0' | |
} | |
def jarNameWithoutExtension = jar.archiveName.with { it.take(it.lastIndexOf(".")) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class Action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Intent | |
import timber.log.Timber | |
fun dumpIntent(intent: Intent) { | |
val bundle = intent.extras | |
if (bundle != null) { | |
val keys = bundle.keySet() | |
val it = keys.iterator() | |
Timber.e("------->>> Dumping Intent start") | |
while (it.hasNext()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.text.Spanned | |
import android.text.style.ImageSpan | |
import android.graphics.drawable.ColorDrawable | |
import android.text.SpannableString | |
import android.text.SpannableStringBuilder | |
import android.widget.TextView | |
import java.util.concurrent.atomic.AtomicBoolean | |
fun TextView.justify() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayOutputStream | |
import java.io.File | |
import java.nio.charset.StandardCharsets.UTF_8 | |
import java.util.zip.GZIPInputStream | |
import java.util.zip.GZIPOutputStream | |
fun String.gzip(): ByteArray { | |
val bos = ByteArrayOutputStream() | |
GZIPOutputStream(bos).bufferedWriter(UTF_8).use { it.write(this) } | |
return bos.toByteArray() |
NewerOlder