Skip to content

Instantly share code, notes, and snippets.

View maxirosson's full-sized avatar

Maxi Rosson maxirosson

View GitHub Profile
@maxirosson
maxirosson / build.gradle
Last active December 28, 2022 12:02
Versioning Android apps
apply plugin: 'com.android.application'
ext.versionMajor = 1
ext.versionMinor = 2
ext.versionPatch = 3
ext.versionClassifier = null
ext.isSnapshot = true
ext.minimumSdkVersion = 19
android {
@maxirosson
maxirosson / build.gradle
Created June 27, 2017 15:29
Versioning Android apps + Feature Branches
apply plugin: 'com.android.application'
ext.versionMajor = 1
ext.versionMinor = 2
ext.versionPatch = 3
ext.versionClassifier = null
ext.isSnapshot = true
ext.minimumSdkVersion = 15
ext.featureBranchPrefix = "feature/"
@maxirosson
maxirosson / RemoteConfigFetcherWorker.kt
Last active March 24, 2021 18:16
RemoteConfigFetcherWorker
class RemoteConfigFetcherWorker(appContext: Context, workerParams: WorkerParameters) : Worker(appContext, workerParams) {
companion object {
fun enqueue(context: Context) {
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val workRequestBuilder = OneTimeWorkRequestBuilder<RemoteConfigFetcherWorker>().setConstraints(constraints)
@maxirosson
maxirosson / index.js
Last active September 29, 2021 18:29
Firebase Cloud Function to send an FCM ping on Remote Config events
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
exports.pushConfig = functions.remoteConfig.onUpdate((versionMetadata) => {
// Create FCM payload to send data message to REMOTE_CONFIG_PUSH topic.
const payload = {
topic: "REMOTE_CONFIG_PUSH",
data: {
"REMOTE_CONFIG_STATUS": "STALE",
Firebase.remoteConfig.apply {
setConfigSettingsAsync(remoteConfigSettings {
val sharedPreferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)
if (BuildConfig.DEBUG || sharedPreferences.getBoolean("remote_config_stale", false)) {
minimumFetchIntervalInSeconds = 0
}
})
}
override fun onMessageReceived(remoteMessage: RemoteMessage) {
if (remoteMessage.getData().containsKey("REMOTE_CONFIG_STATUS")) {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
sharedPreferences.edit().putBoolean("remote_config_stale", true).apply()
}
}
override fun onNewToken(newPushToken: String) {
FirebaseMessaging.getInstance().subscribeToTopic("REMOTE_CONFIG_PUSH")
}
package com.dipien.gradle
enum class GradleProperty(val defaultValue: Any?) {
BYE_BYE_JETIFIER_ENABLED(false)
}
package com.dipien.gradle
import com.dipien.gradle.GradleProperty
import org.gradle.api.Project
class PropertyResolver(private val project: Project) {
fun getBooleanProp(gradleProperty: GradleProperty): Boolean {
return getBooleanProp(gradleProperty, gradleProperty.defaultValue as Boolean)
}
buildscript {
dependencies {
classpath("com.dipien:bye-bye-jetifier:1.1.2")
}
}
ext {
propertyResolver = new PropertyResolver(project)
}