Skip to content

Instantly share code, notes, and snippets.

View AaronRietschlin's full-sized avatar

Aaron Rietschlin AaronRietschlin

  • Disney Streaming Services
  • Columbus, OH
View GitHub Profile
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
@AaronRietschlin
AaronRietschlin / MyUtils
Created March 31, 2015 22:01
A simple way to use ArrayLists within Parcelable while keeping the array null if not present.
public class MyUtils {
private static final int PARCEL_LIST_NULL = 1151;
private static final int PARCEL_LIST_NOTNULL = 1152;
public static <T extends Parcelable> void appendListToParcel(Parcel out, @Nullable ArrayList<T> list) {
if (list == null) {
out.writeInt(PARCEL_LIST_NULL);
} else {
out.writeInt(PARCEL_LIST_NOTNULL);
out.writeList(list);

Android Cheat Sheet

Styles

Font family

android:fontFamily="sans-serif"                 // roboto regular
android:fontFamily="sans-serif-light"           // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
@AaronRietschlin
AaronRietschlin / themes-debug.xml
Last active August 27, 2015 21:35 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
@AaronRietschlin
AaronRietschlin / file.md
Created December 22, 2015 17:55 — forked from dlew/file.md
Android permissions library proliferation
@AaronRietschlin
AaronRietschlin / Android Lollipop Widget Tinting Guide
Created April 27, 2016 20:47 — forked from seanKenkeremath/Android Lollipop Widget Tinting Guide
How base colors in Lollipop apply to different UI elements
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
* ripple effect (Lollipop only) -- "colorControlHighlight"
Status Bar:
------------
* background (Lollipop only) - "colorPrimaryDark"
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2016 30xi, LLC
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON
@AaronRietschlin
AaronRietschlin / commit-msg
Last active February 15, 2017 15:53
Pre Commit Hook for running tests prior to pushing to the Android repos
#!/bin/bash
CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
COMMIT_MESSAGE=$(head -n 1 $1)
REGEX_TICKET_NUMBER="\APPS-*[0-9]*"
[[ "$CURRENT_BRANCH" =~ $REGEX_TICKET_NUMBER ]] && echo ${BASH_REMATCH[1]}
TICKET_NUMBER=$BASH_REMATCH
REGEX_CHECK_FOR_COMMIT_MESSAGE="(^""$TICKET_NUMBER""|Merge)"
AppCompat-v7:21 provides a very useful way of dealing with pressed/focused/activated states maintaining backwards compatibility downto API-7, but there's a small issue (big for some) with the default selectableItemBackground: It uses some PNGs and/or default values for API<21.
The main reason is that android drawable resource definitions (prior API 21) CANNOT use theme attributes at all, so there's no way of making something like:
<shape android:shape="rectangle">
<solid android:color="?attr/colorControlHighlight" />
</shape>
For this, I've put this simple mockup on how to give your app better drawables that the appcompat defaults.