Skip to content

Instantly share code, notes, and snippets.

View JakeSteam's full-sized avatar
🤖

Jake Lee JakeSteam

🤖
View GitHub Profile
@JakeSteam
JakeSteam / SettingsFragment.kt
Created March 18, 2019 22:06
Automatically adding build time to your Android app
private fun setupVersionInfo() {
findPreference(getString(R.string.pref_version)).title = "V${BuildConfig.VERSION_NAME}"
findPreference(getString(R.string.pref_version)).summary = String.format(
getString(R.string.version_summary),
BuildConfig.VERSION_CODE,
SimpleDateFormat("dd MMM yyy", Locale.US).format(BuildConfig.BUILD_TIME)
)
}
@JakeSteam
JakeSteam / AndroidManifest.xml
Created April 28, 2019 21:13
"How to programmatically change your Android app icon and name" for http://blog.jakelee.co.uk/programmatically-changing-app-icon
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.jakelee.dynamiciconchanging">
<application
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.jakelee.updatelistener">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
@JakeSteam
JakeSteam / .travis.yml
Last active December 15, 2020 10:27
Creating app bundles and APKs on Travis CI (for https://wp.me/paoKlI-Gk)
# Overall config
dist: xenial
language: android
# Android version config
android:
components:
- build-tools-28.0.3
- android-28
# Overall config
dist: xenial
language: android
# Android version config
android:
components:
- build-tools-28.0.3
- android-28
# Overall config
dist: xenial
language: android
# Android version config
android:
components:
- build-tools-28.0.3
- android-28
@JakeSteam
JakeSteam / build.sh
Created April 26, 2020 20:14
Posting a Slack message from Travis CI
# Environment variables
REPO=${TRAVIS_REPO_SLUG}
BRANCH=${TRAVIS_BRANCH}
COMMIT_HASH=${TRAVIS_COMMIT}
COMMIT_HASH_SHORT=${COMMIT_HASH:0:7}
COMMIT_MESSAGE=${TRAVIS_COMMIT_MESSAGE}
IS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}
BUILD_DIR=${TRAVIS_BUILD_DIR}
BUILD_NUMBER=${TRAVIS_BUILD_NUMBER}
BUILD_URL=${TRAVIS_BUILD_WEB_URL}
private var animatorSet: AnimatorSet? = null
private fun startAnimation(target: ImageView) {
val animationLayers = target.drawable as LayerDrawable
val moveImageViewLeft = ObjectAnimator.ofFloat(target, View.TRANSLATION_X, -200f).setDuration(6000)
val moveImageViewRight = ObjectAnimator.ofFloat(target, View.TRANSLATION_X, 0f).setDuration(6000)
val redCircle = animationLayers.findDrawableByLayerId(R.id.red_circle) as GradientDrawable
val redCircleFadeOut = ObjectAnimator.ofInt(redCircle, "alpha", 255, 100).setDuration(1000)
val redCircleFadeIn = ObjectAnimator.ofInt(redCircle, "alpha", 100, 255).setDuration(100)
@JakeSteam
JakeSteam / MyClass.kt
Last active March 23, 2024 19:24
Accessing Android app secrets from GitHub Actions using Gradle (https://blog.jakelee.co.uk/accessing-android-app-secret-from-github-actions-using-gradle/)
package uk.co.jakelee.apodwallpaper.example
import uk.co.jakelee.apodwallpaper.BuildConfig
class MyClass() {
val key = BuildConfig.APOD_API_KEY
}
@JakeSteam
JakeSteam / ItemAdapter.kt
Last active April 22, 2024 09:56
Creating a grid RecyclerView with quick drag and drop item swapping, Room / LiveData support, and more!
class ItemAdapter(
private val itemClickListener: (OwnedItem) -> Unit,
private val itemSaver: (List<OwnedItem>) -> Unit
) : RecyclerView.Adapter<ItemViewHolder>() {
val items = ArrayList<OwnedItem>()
fun setItems(newItems: List<OwnedItem>) {
val result = calculateDiff(newItems)
items.clear()