Skip to content

Instantly share code, notes, and snippets.

View tprochazka's full-sized avatar

Tomáš Procházka tprochazka

View GitHub Profile
@tprochazka
tprochazka / TypedArrayUtils.kt
Created May 30, 2021 21:42
Access to XML based textAppearance styles from Jetpack Compose
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tprochazka
tprochazka / ScaleToFitLayout.kt
Created September 6, 2021 01:39
Layout manager that will simply render everything inside in requested size and then scale down it to fit the parent size.
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import androidx.core.view.children
import kotlin.math.roundToInt
/**
* Layout manager that will simply render everything inside in requested size
* and then scale down it to fit the parent size.
@tprochazka
tprochazka / build.gradle.kts
Created April 3, 2024 22:55
Android Library module: Copy one localication to another during build time
androidComponents.onVariants { variant ->
generateCopyValuesTask(variant, "values-sr-rRS", "values-b+sr+Latn", "copySerbianValuesTaskFor")
generateCopyValuesTask(variant, "values-es", "values-ca", "copySpanishValuesTaskFor")
generateCopyValuesTask(variant, "values-iw", "values-he", "copyHebrewValuesTaskFor")
}
fun generateCopyValuesTask(variant: LibraryVariant, sourceLocale: String, targetLocale: String, taskName: String) {
variant.sources.res?.let { source: SourceDirectories.Layered ->
val assetCreationTask =
project.tasks.register<CopyLocalizedResTask>("$taskName${variant.name}") {