Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Gilfelt jgilfelt

  • readyState Software Ltd
  • London, United Kingdom
View GitHub Profile
@jgilfelt
jgilfelt / install_jdk
Created May 2, 2014
Install Oracle JDK on the Funky Android AOSP build environment VirtualBox image
View install_jdk
# add the webupd8team java PPA
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
# install oracle java 6
sudo apt-get install oracle-java6-installer
@jgilfelt
jgilfelt / gist:1755312
Created Feb 6, 2012
Android - Managing single MapView Fragment state across multiple Activities
View gist:1755312
private GeoPoint center;
private int zoomLevel = -1;
@Override
public void onPause() {
super.onPause();
center = mapView.getMapCenter();
zoomLevel = mapView.getZoomLevel();
}
@jgilfelt
jgilfelt / mapimports.sh
Created Sep 13, 2012
Toggle Google/Amazon Android map imports
View mapimports.sh
#!/bin/bash
A_IMPORT="import com.amazon.geo.maps"
G_IMPORT="import com.google.android.maps"
A_VIEW="com.amazon.geo.maps.MapView"
G_VIEW="com.google.android.maps.MapView"
if [ "$1" = "a" ]; then
FR=$G_IMPORT
@jgilfelt
jgilfelt / styles.xml
Created Oct 28, 2012
Kindle Fire typeface fix
View styles.xml
<!-- fixes for broken Holo text appearances on Kindle Fire 2/HD -->
<style name="TextAppearance.KindleFix.Small" parent="android:TextAppearance" >
<item name="android:textSize">14sp</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="TextAppearance.KindleFix.Small.Inverse" >
<item name="android:textColor">?android:attr/textColorSecondaryInverse</item>
<item name="android:textColorHint">?android:attr/textColorHintInverse</item>
@jgilfelt
jgilfelt / main.xml
Created Dec 17, 2012
"fix" for black surface artefact left by MapFragment when transitioned in a ViewPager on old API versions
View main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
@jgilfelt
jgilfelt / FittingLinearLayout.java
Last active Dec 10, 2015
Custom LinearLayout needed for fullscreen YouTube player when using SYSTEM_UI_FLAG_HIDE_NAVIGATION
View FittingLinearLayout.java
package com.readystatesoftware.views;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class FittingLinearLayout extends LinearLayout {
public FittingLinearLayout(Context context, AttributeSet attrs, int defStyle) {
@jgilfelt
jgilfelt / CacheableImageView.java
Created Jan 30, 2013
Android-BitmapCache (https://github.com/chrisbanes/Android-BitmapCache) CacheableImageView with a fade-in transition display option.
View CacheableImageView.java
/*******************************************************************************
* Copyright 2011, 2012 Chris Banes. 2013 readyState Software Ltd.
*
* 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
@jgilfelt
jgilfelt / DrawerSafeViewPager.java
Last active Dec 19, 2015
DrawerLayout friendly ViewPager that will ignore rogue touch events from the bezel swipe gesture.
View DrawerSafeViewPager.java
/*
* Copyright (C) 2013 readyState Software Ltd
*
* 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
@jgilfelt
jgilfelt / gist:8105b5ca07776a4359c2
Created Nov 28, 2014
Notification whose content is partially redacted on API 21 secure lockscreens
View gist:8105b5ca07776a4359c2
private Notification buildNotification() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setCategory(NotificationCompat.CATEGORY_EVENT)
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) // default
.setContentTitle(title)
.setContentText(shortText)
.setStyle(new NotificationCompat.BigTextStyle().bigText(fullText))
.setSmallIcon(R.drawable.ic_stat_notification)
.setColor(context.getResources().getColor(R.color.my_color))
.setContentIntent(intent);
@jgilfelt
jgilfelt / ExpandingListView.java
Created Nov 6, 2013
Fixes for Daniel Olshansky's DevByte example "ListView Expanding Cells Animation" (lines 130-132), also adds compatibility back to API 11. http://www.youtube.com/watch?v=mwE61B56pVQ http://developer.android.com/shareables/devbytes/ListViewExpandingCells.zip
View ExpandingListView.java
/*
* Copyright (C) 2013 The Android Open Source Project
*
* 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
You can’t perform that action at this time.