Skip to content

Instantly share code, notes, and snippets.

View mlc's full-sized avatar

mike castleman mlc

View GitHub Profile
@mlc
mlc / gist:6768769
Created September 30, 2013 19:22
workaround for android bug 58192
/**
* Work around a bug in Android 4.3
*/
public static CharSequence fixFontColor(CharSequence seq, int color) {
if (Build.VERSION.SDK_INT < 18 || !(seq instanceof Spanned))
return seq;
Spannable txt = (seq instanceof Spannable ? (Spannable)seq : new SpannableString(seq));
for (ForegroundColorSpan ann : txt.getSpans(0, txt.length(), ForegroundColorSpan.class)) {
if (ann.getForegroundColor() != color) {
int start = txt.getSpanStart(ann), end = txt.getSpanEnd(ann), flags = txt.getSpanFlags(ann);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed(); // OMG THIS IS SO WRONG BUT ALSO SO RIGHT
return true;
// other cases...
}
}
@mlc
mlc / gist:5897951
Created July 1, 2013 02:14
necessary change to ConnectedDevice.java to get things to compile
diff --git a/builder/src/main/java/com/android/builder/testing/ConnectedDevice.java b/builder/src/main/java/com/android/builder/testing/ConnectedDevice.java
index 8a1aa64..edfe30a 100644
--- a/builder/src/main/java/com/android/builder/testing/ConnectedDevice.java
+++ b/builder/src/main/java/com/android/builder/testing/ConnectedDevice.java
@@ -28,7 +28,6 @@ import com.android.utils.ILogger;
import java.io.File;
import java.io.IOException;
-import java.util.concurrent.TimeUnit;
@mlc
mlc / gist:5897934
Last active December 19, 2015 04:29
proposed changes to android build system to support aapt's -c option
diff --git a/builder-model/src/main/java/com/android/builder/model/AaptOptions.java b/builder-model/src/main/java/com/android/builder/model/AaptOptions.java
index 86192e0..6b42479 100644
--- a/builder-model/src/main/java/com/android/builder/model/AaptOptions.java
+++ b/builder-model/src/main/java/com/android/builder/model/AaptOptions.java
@@ -31,4 +31,9 @@ public interface AaptOptions {
* Returns the list of values for the -0 (disabled compression) option, or null
*/
List<String> getNoCompress();
+
+ /**
public class DateUtils {
// ...
/**
* This constant is actually the length of 364 days, not of a year!
*/
public static final long YEAR_IN_MILLIS = WEEK_IN_MILLIS * 52;
}
@mlc
mlc / gist:5625204
Created May 22, 2013 04:15
reading my new citibike key
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<InfoDump application="NFC TagInfo" version="1.09c">
<Tag rfTechnology="Type V (ISO/IEC 15693 / Vicinity)">
<GeneralInformation>
<Value name="uid" description="UID">e0XXXXXXXXXXXXXX</Value>
<Value name="rfTechnology" description="RF technology">Type V (ISO/IEC 15693 / Vicinity)</Value>
<Value name="tagType" description="Tag type">SL2 ICS2001 (ICODE SLI)</Value>
<Value name="manufacturer" description="Manufacturer">NXP Semiconductors (Germany)</Value>
<Value name="afiString" description="Application family identifier (AFI)">all families and sub-families</Value>
<Value name="afi" description="AFI (numeric)">00</Value>
@mlc
mlc / calendarprovidersample.java
Last active December 15, 2015 02:39
HOWTO inhibit display of the "Attending?" line in the Android calendar app when your application inserts rows into the Calendar Provider.
import android.content.ContentValues;
import android.database.Cursor;
import android.provider.CalendarContract.Calendars;
import android.provider.CalendarContract.Events;
Cursor calendarCursor;
// query the Calendars provider, and position to the desired row
long calendarId = calendarCursor.getLong(calendarCursor.getColumnIndex(Calendars._ID));
String calendarOwner = calendarCursor.getString(calendarCursor.getColumnIndex(Calendars.OWNER_ACCOUNT));
@mlc
mlc / NfcUtils.java
Last active December 12, 2015 04:08
nfc sample
package com.meetup.utils;
import android.annotation.TargetApi;
import android.app.Activity;
import android.net.Uri;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.NfcEvent;
import android.os.Build;
import com.google.android.gms.maps.model.LatLng;
import com.google.common.collect.Lists;
import java.util.List;
import static java.lang.Math.*;
public class CircleMaker {
private static final double EARTH_RADIUS = 6371000.0; /* meters */
private static final int CIRCLE_PRECISION = 48;
@mlc
mlc / gist:4614375
Created January 23, 2013 22:02
Is it still art if you have to explain it?
__̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡̡.___
U+005F LOW LINE
UTF-8: 5f UTF-16BE: 005f Decimal: &#95;
_
Category: Pc (Punctuation, Connector)
Bidi: ON (Other Neutrals)
U+005F LOW LINE
UTF-8: 5f UTF-16BE: 005f Decimal: &#95;