Skip to content

Instantly share code, notes, and snippets.

View danybony's full-sized avatar

Daniele Bonaldo danybony

View GitHub Profile
@romannurik
romannurik / DrawInsetsFrameLayout.java
Created February 10, 2014 16:28
DrawInsetsFrameLayout — adding additional background protection for system UI chrome when using KitKat’s translucent decor flags.
/*
* Copyright 2014 Google Inc.
*
* 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
@gabrielemariotti
gabrielemariotti / GridActivity.java
Created July 27, 2014 21:38
Android Wear: How to use a simple a GridViewPager with a FragmentGridPagerAdapter.
public class GridActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid);
final GridViewPager mGridPager = (GridViewPager) findViewById(R.id.pager);
mGridPager.setAdapter(new SampleGridPagerAdapter(this, getFragmentManager()));
}
@dlew
dlew / themes-debug.xml
Last active March 1, 2024 15:46
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>
@rock3r
rock3r / ColorUtils.java
Last active February 25, 2020 09:06
ColorUtils: utilities for manipulating colours
package net.frakbot.util.color;
import android.graphics.Color;
/**
* The MIT License (MIT)
* <p/>
* Copyright (c) 2014 Sebastiano Poggi
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
@chrisbanes
chrisbanes / CollapsingTitleLayout.java
Last active March 26, 2023 11:58
CollapsingTitleLayout
/*
* Copyright 2014 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
@PomepuyN
PomepuyN / SettingsAdapter.java
Last active June 5, 2018 09:02
Functional example of WearableListView
public class SettingsAdapter extends WearableListView.Adapter {
private final Context context;
private final List<SettingsItems> items;
public SettingsAdapter(Context context, List<SettingsItems> items) {
this.context = context;
this.items = items;
}
@JakeWharton
JakeWharton / gist:f50f3b4d87e57d8e96e9
Created February 7, 2015 01:59
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
@frapontillo
frapontillo / make-gif.sh
Created March 18, 2015 22:31
Make (good) GIFs w/ ffmpeg
#!/bin/sh
# originally from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
palette="palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
rm $palette
@rock3r
rock3r / boot-into-cwm.sh
Created June 4, 2015 13:42
Root script for Asus Zenfone 2 for *NIX
#! /bin/bash
# How to use: save this in the folder where you extract the contents of this zip:
# http://click.xda-developers.com/api/click?format=go&jsonp=vglnk_14334252799608&key=f0a7f91912ae2b52e0700f73990eb321&libId=iai8ebh401000n4o000DAb9a6aa9o&loc=http%3A%2F%2Fforum.xda-developers.com%2Fzenfone2%2Fgeneral%2Fasus-zenfone-2-flashing-recovery-mode-t3096596&v=1&out=http%3A%2F%2Fwww.mediafire.com%2Fdownload%2Fv6m7n9j0gqins9b%2FCWM_Zenfone_2_Intel.zip&ref=http%3A%2F%2Fforum.xda-developers.com%2Fzenfone2%2Fgeneral&title=Asus%20Zenfone%202%20%7C%20Resources%20all%20in%20one%20thread%20%7C%20Asus%20ZenFone%202%20%7C%20XDA%20Forums&txt=%3Cb%3EDownload%20the%20Asus%20Zenfone%20temporary%20CWM%20package%3C%2Fb%3E
# Then chmod a+x it, and run it. Have your phone attached to the USB port with USB debugging enabled before starting.
# Setup
WORKINGDIR=$(pwd)
LAUNCHER="$WORKINGDIR/FB_RecoveryLauncher/recovery.launcher"
RECOVERY="$WORKINGDIR/FB_RecoveryLauncher/recovery.zip"
@rock3r
rock3r / giffify.py
Last active January 14, 2022 09:00
Giffify - easily create optimised GIFs from a video
#!/usr/bin/python
# License for any modification to the original (linked below):
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# Sebastiano Poggi and Daniele Conti wrote this file. As long as you retain
# this notice you can do whatever you want with this stuff. If we meet some day,
# and you think this stuff is worth it, you can buy us a beer in return.
import argparse, sys, subprocess, tempfile