Skip to content

Instantly share code, notes, and snippets.

View brainail's full-sized avatar
🦊
What Does The Fox Say?

Yegor brainail

🦊
What Does The Fox Say?
View GitHub Profile
@brainail
brainail / README.md
Last active August 29, 2015 14:09 — forked from roottony/README.md

README

Allows running Robolectric tests directly from the Android Studio.

Supported versions

This script works with com.android.tools.build:gradle:0.14.0 and Android Studio v0.9.1

Instructions

Robolectric setup

@brainail
brainail / build.gradle
Created April 7, 2015 21:44
Drive REST API libraries, build.gradle
dependencies {
// Libs folder
compile fileTree(dir: 'libs', include: ['*.jar'])
// ...
// Google auth, drive, etc
compile 'com.google.code.gson:gson:2.3'
compile 'com.google.api-client:google-api-client:1.19.0'
compile 'com.google.api-client:google-api-client-android:1.19.0'
@brainail
brainail / SettingsActivityWithAuthorizationButton.java
Created April 7, 2015 22:27
Drive REST API, Settings Activity, Authorization button
public class ActivityWithAuthorizationButton
extends ActionBarActivity
implements AuthorizationFlow.Callback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display the fragment as the main content
initSettingsBox();
@brainail
brainail / stdc++.h
Created October 27, 2015 20:26 — forked from velicast/stdc++.h
Linux GCC 4.8.0 /bits/stdc++.h header definition.
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
{
"cmd": ["/usr/local/Cellar/gcc49/4.9.3/bin/g++-4.9", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
@brainail
brainail / CustomTabsKeepAliveService.java
Created November 22, 2015 10:44
Empty service used by the custom tab to bind to, raising the application's importance
public final class CustomTabsKeepAliveService extends Service {
private static final Binder sBinder = new Binder ();
@Override public IBinder onBind (Intent intent) {
return sBinder;
}
}
@brainail
brainail / CustomTabsHelper.java
Created November 22, 2015 11:37
Helper class for Custom Tabs
public final class CustomTabsHelper {
public static abstract class ChromePackages {
public static final String STABLE_PACKAGE = "com.android.chrome";
public static final String BETA_PACKAGE = "com.chrome.beta";
public static final String DEV_PACKAGE = "com.chrome.dev";
public static final String LOCAL_PACKAGE = "com.google.android.apps.chrome";
}
public static String sPackageNameToUse;
public class CustomTabsSceneHelper {
/**
* A Callback for when the service is connected or disconnected. Use those callbacks to
* handle UI changes when the service is connected or disconnected
*/
public static interface ConnectionCallback {
public void onCustomTabsConnected ();
public void onCustomTabsDisconnected ();
}
public class FragmentChromeCustomTabs
extends Fragment
implements CustomTabsSceneHelper.ConnectionCallback {
public static enum CustomTabsAction {
GOOGLE_PLUS ("Open Google+", "https://plus.google.com/+ЕгорМалышев"),
MEDIUM ("Open Medium", "https://medium.com/@brainail"),
ABOUT_ME ("Open About.Me", "https://about.me/brainail");
private final String mActionDescription;
@brainail
brainail / build.gradle
Created November 25, 2015 12:38
Chrome custom Tabs
dependencies {
...
compile 'com.android.support:customtabs:23.1.0'
}