Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kyhule's full-sized avatar

Kyle Lehman kyhule

  • Comcast
  • VT, USA
  • 09:46 (UTC -04:00)
  • X @kyhule
View GitHub Profile
@kyhule
kyhule / ReactiveAccessibilityManager
Last active October 31, 2019 15:44
Reactive Android System callbacks #android #rxjava
Observable.create<Boolean> { emitter ->
val listener = AccessibilityStateChangeListener { enabled ->
if (emitter.isDisposed) return@AccessibilityStateChangeListener
emitter.onNext(enabled)
}
accessibilityManager.addAccessibilityStateChangeListener(listener)
emitter.setCancellable {
accessibilityManager.removeAccessibilityStateChangeListener(listener)
}
}
@kyhule
kyhule / keep-awake
Last active October 24, 2020 04:11
ADB Snippets #android #adb
# Set the 'keep awake while plugged in' setting
# usage: svc power stayon [true|false|usb|ac|wireless]
adb shell svc power stayon usb
@kyhule
kyhule / commit-msg
Created December 3, 2015 12:27
Git hook for verify Jira ticket in commit message
#!/usr/bin/env bash
# set this to your active development branch
current_branch="$(git rev-parse --abbrev-ref HEAD)"
# regex to validate in commit msg
commit_regex='(DEMO-\d+|merge)'
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('DEMO-1111') or 'Merge'"
if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
@kyhule
kyhule / README.md
Last active August 29, 2015 14:26 — forked from shekibobo/README.md
Android: Base Styles for Button (not provided by AppCompat)

How to create custom button styles using Android's AppCompat-v7:21

Introduction

AppCompat is an Android support library to provide backwards-compatible functionality for Material design patterns. It currently comes bundled with a set of styles in the Theme.AppCompat and Widget.AppCompat namespaces. However, there is a critical component missing which I would have thought essential to provide the a default from which we could inherit our styles: Widget.AppCompat.Button. Sure, there's Widget.AppCompat.Light.ActionButton, but that doesn't actually inherit from Widget.ActionButton, which does not inherit from Widget.Button, so we might get some unexpected behavior using that as our base button style, mainly because Widget.ActionButton strictly belongs in the ActionBar.

So, if we want to have a decently normal default button style related to AppCompat, we need to make it ourselves. Let's start by digging into the Android SDK to see how it's doing default styles.

Digging In