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
#!/bin/bash | |
export LANG=en_US.UTF-8 | |
export LANGUAGE=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
# Check if -man option is passed | |
if [ -f "version-properties.gradle" ]; then | |
APP_VERSION_RAW=$(grep "appVersion *=" version-properties.gradle) | |
else |
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.lang.ref.WeakReference | |
import kotlin.reflect.KProperty | |
inline fun <reified T> weak() = WeakReferenceDelegate<T>() | |
inline fun <reified T> weak(value: T) = WeakReferenceDelegate(value) | |
/** | |
* e.g. var x by weak<Context?>(activity) |
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
// val activity = LocalContext.current.findActivity() | |
tailrec fun Context.findActivity(): AppCompatActivity? = when (this) { | |
is AppCompatActivity -> this | |
is ContextWrapper -> baseContext.findActivity() | |
else -> null | |
} |
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
// based on https://github.com/ferPrieto/steps-app-gallery-deploy/blob/main/step.sh | |
import groovy.json.JsonSlurper | |
ext { | |
def properties = project.gradle.startParameter.projectProperties | |
println(properties) | |
// https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-getstarted-0000001111845114 | |
// IMPORTANT: when creating api key: 'N/A' as Project |
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
/** | |
* Generates a text file containing dependencies for different build variants | |
* and saves them into the respective variant asset folder. | |
* Also deletes files on clean. | |
* | |
* Can be safely used with <code>org.gradle.unsafe.configuration-cache=true</code> | |
*/ | |
android.applicationVariants.all { variant -> | |
def name = variant.name |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<!-- google's material design colours from | |
http://www.google.com/design/spec/style/color.html#color-ui-color-palette --> | |
<!--reds--> | |
<color name="md_red_50">#FFEBEE</color> | |
<color name="md_red_100">#FFCDD2</color> | |
<color name="md_red_200">#EF9A9A</color> |
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
// implementation "com.github.kibotu:AndroidAnimationsActions:2.0.1" | |
// maven { url 'https://jitpack.io' } | |
fun ViewGroup.woobleEVERYTHING() = children.forEach { it.startWobbling() } | |
fun View.startWobbling() { | |
val minDuration = 1f | |
val maxDuration = 1.5f | |
val duration: Float = randomRange(minDuration, maxDuration) | |
play( |
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
@OptIn(ExperimentalCoroutinesApi::class) | |
suspend fun Lifecycle.waitForLifecycleEvent(event: Lifecycle.Event) = suspendCancellableCoroutine<Unit> { continuation -> | |
val observer = object : DefaultLifecycleObserver { | |
override fun onCreate(owner: LifecycleOwner) { | |
super.onCreate(owner) | |
if (event != Lifecycle.Event.ON_CREATE) return | |
continuationResume() | |
} |
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
#!/usr/bin/env bash | |
set -e | |
set -x | |
find . -type f -name "*.json" -print0 | xargs -0 -I {} sh -c "echo Validating \"{}\"; cat \"{}\" | jq ." |
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.view.View | |
/** | |
* An OnClickListener that sends only the first click of a given Time Interval | |
* | |
* @param defaultInterval time frame to skip until next click is send | |
* @param onThrottleFirstClick callback | |
*/ | |
class ThrottleFirstClickListener( | |
private var defaultInterval: Int = 100, |