Skip to content

Instantly share code, notes, and snippets.

View jaredrummler's full-sized avatar

Jared Rummler jaredrummler

View GitHub Profile

Cyanea

A theme engine for Android.
Themes are immutable, possibilities are beautiful.

License

@jaredrummler
jaredrummler / ANDROID_RESOURCE_HACK.md
Last active June 25, 2019 20:49
Hackity hack hack hack; Android resource attack
fun Resources.getValue(id: Int, resolveRefs: Boolean = true) = TypedValue().also {
  try {
    (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
      Resources::class.java.getDeclaredField("mResourcesImpl").apply {
        isAccessible = true
      }.get(this)
    } else this)?.run obj@{
      this::class.java.getDeclaredMethod("getValue",
 Int::class.java, TypedValue::class.java, Boolean::class.java).apply {
@jaredrummler
jaredrummler / artifactory-push.gradle
Last active June 25, 2019 21:58
Helper to upload Gradle Android Artifacts to Maven repositories — https://github.com/chrisbanes/gradle-mvn-push
/*
* Copyright 2013 Chris Banes
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.jaredrummler.usagestatsperm">
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions"/>
<application
android:allowBackup="true"
@jaredrummler
jaredrummler / Prefs.kt
Created May 15, 2018 05:20
Yet another SharedPreference helper written in Kotlin
import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
class Prefs(
private val preferences: SharedPreferences,
private val encryptor: StringEncryptor? = null,
private val obfuscator: Obfuscator? = null
) {
@jaredrummler
jaredrummler / AndroidManifest.xml
Last active June 25, 2019 21:01
Setup a FileProvider for Android with paths for root, external storage, and internal app files
<manifest package="com.jaredrummler.android.common"
xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<provider
android:name="com.jaredrummler.android.files.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
@jaredrummler
jaredrummler / MOCK_INJECT.md
Created April 13, 2018 06:31
Mock lazy injection using reflection

Method to set all @Inject fields in a class to mocks:

fun mockInjectables(obj: Any) {
    obj::class.java.declaredFields.forEach { field ->
        field.getAnnotation(Inject::class.java)?.apply {
            if (field.type.isAssignableFrom(dagger.Lazy::class.java)) {
                if (!field.isAccessible) field.isAccessible = true

                val type = field.genericType as ParameterizedType
@jaredrummler
jaredrummler / ROOT_BROWSER_STORAGE_PERMISSIONS.md
Last active June 25, 2019 22:01
Root Browser Permissions

Root Browser File Manager allows users to copy, move, delete and modify files on internal, external, root and cloud storages. To accomplish this Root Browser requires various permssions as explained below:

Internal Storage Permission:

The Internal Storage on an Android device is often referred to as the SD card. This is not a removable storage.

Root Browser needs the user to grant the WRITE_EXTERNAL_STORAGE permission to work properly. The permission is requested when the app is first launched on Android 6.0+. For previous versions of Android, the permission is granted when the app is downloaded from the Google Play Store.

@jaredrummler
jaredrummler / boot2gif.sh
Last active February 1, 2023 23:08
Convert an Android boot animation to an animated GIF
#!/bin/bash
################################################################################
#
# boot2gif.sh
#
# DESCRIPTION: Convert an Android boot animation to a GIF
# You will need ImageMagick to run this script.
#
# USAGE:
#
@jaredrummler
jaredrummler / FizzBuzz.kt
Created February 24, 2017 12:43
Kotlin FizzBuzz
fun main(args: Array<String>) {
for (i in 1..100) {
println(if (i % 15 == 0) "FizzBuzz" else if (i % 3 == 0) "Fizz" else if (i % 5 == 0) "Buzz" else i)
}
}