appcompat v21 で material design pre-Lollipop の サンプル を動かして

「v21」!

ちと, 確認.

Android_SDK_Manager

Screenshot_10_20_14__16_21

どんどん上がっていきますAPIバージョン.

Android Lollipop | Android Developers

フラットなカードな雰囲気なんだ...

Android_5_0_Lollipop__Material_Design_in_pictures_and_video___Android_Central

Android 5.0 Lollipop: Material Design in pictures and video | Android Central

サンプルコードを.

dependencies {
  ...
  compile 'com.android.support:appcompat-v7:21.+'
  ...
}

なんかあちこちサンプルあるので

Material Design Everywhere: Using AppCompat 21

appcompat v21: material design for pre-Lollipop devices! - Chris Banes

入れたりしてみる.

20141020-163315

20141020-163340

と, API19 (Android 4.4) にいれてみたが,

まあフツー.

values-v21_themes_xml_-__app__-_MaterialEverywhere-master_-____Desktop_MaterialEverywhere-master__-_Android_Studio__Beta__0_8_13

あ, そうか...

API21 に入れないとか.

AndroidStudio で見れるのかな...

activity_home_xml_-__app__-_MaterialEverywhere-master_-____Desktop_MaterialEverywhere-master__-_Android_Studio__Beta__0_8_13

残るは, エミュレータか.

Recent_Changes_-_Android_Tools_Project_Site

Android Studio 0.8.13 Released - Android Tools Project Site

もういいか...(笑)

appcompat v21: material design for pre-Lollipop devices! : androiddev


Docker コンテナと Mac OSX で ファイルを共有する

コンテナ内のディレクトリ /root を ホストのディレクトリ /tmp にマウントする.

docker run -v /tmp:/root myImage

dotcloud - Mounting directory from parent system to container in docker - Stack Overflow

コンテナ内から見えない...

This definitely does not work on OSX using boot2docker.

Mac OSX ではできない?

Docker を boot2docker で使う場合,

ファイルシステムでいうところの

コンテナとホストの間に dockerサーバ が存在する.

はじめてのDocker_on_Mac_OS_X_|_Developers_IO

はじめてのDocker on Mac OS X | Developers.IO

なので, 共有が2段階になっている.

docker_share_osx

以下の方法を試す.

How to share folders with docker containers on OSX

1. OSX と dockerサーバ(VM) 間の共有

sshfs-fuse を使う.

Filesystem in Userspace - Browse /sshfs-fuse at SourceForge.net

まず, OSX のリモートログイン機能を開始する.

System_Preferences

Sharing

Docker サーバに入って OSXのユーザディレクトリをマウントする.

$username と $ipadress は, OSX設定で許可した それぞれ.

$ boot2docker ssh
docker@boot2docker:~$ tce-load -wi sshfs-fuse
docker@boot2docker:~$ mkdir ~/osx
docker@boot2docker:~$ sudo sshfs $username@$ipaddress:/Users/$username/ /home/docker/osx/

2. dockerサーバ(VM) とコンテナ間の共有

通常の docker オプション -v による共有しながらのイメージ起動.

$ docker run -it -v /home/docker/osx/somefolder:/opt/somefolder ubuntu bash

これで,
コンテナ内 /opt/somefolder が
OSX の /Users/$username/somefolder と
共有されている.

追記:

とかいう話もバージョンアップで解消された.

docker 1.3 で MacOSX でもフツーに共有できようになった


Google API を利用するときの 認証トークン の取得

ネット上で調べていると混乱する.

android_-_In_a_nutshell_what_s_the_difference_from_using_OAuth2_request_getAuthToken_and_getToken_-_Stack_Overflow

 /**
   * Gets the google account credential.
   * 
   * @param context the context
   * @param accountName the account name
   * @param scope the scope
   */
  public static GoogleAccountCredential getGoogleAccountCredential(
      Context context, String accountName, String scope) throws IOException, GoogleAuthException {
    GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(context, scope);
    credential.setSelectedAccountName(accountName);
    credential.getToken();
    return credential;
  }

  /**
   * Gets the OAuth2 token.
   * 
   * @param context the context
   * @param accountName the account name
   * @param scope the scope
   */
  public static String getToken(Context context, String accountName, String scope)
      throws IOException, GoogleAuthException {
    GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(context, scope);
    credential.setSelectedAccountName(accountName);
    return credential.getToken();
  }

以下, StackOverflowからの抜粋.

The Google APIs Client Library for Java is as the name suggests a library for accessing Google APIs and it is available for several platforms such as Java (in general) and Android while the Google Play Services and GoogleAuthUtil is only available on Android.

Google APIs Client Library
→ 汎用的 Java向け (Androidも含む)

GoogleAuthUtil(Google Play services)
→ Android向け専用

However if you dig into the code and their issue tracker a bit you can see that the tasks sample you linked actually uses GoogleAuthUtil since version 1.12.0 of the Google APIs Client Library when support for GoogleAuthUtil was added.

Google APIs Client Library バージョン 1.12.0 移行 は GoogleAuthUtil が追加されている.

AccountManager.getAuthToken

良いとこ:
- OS 2.0+ から使える.
- Android自体に含まれていて,別SDKを必要としない.
- 認証をもつすべてのアカウント(Google以外でも)で使える.

悪いとこ:
- トークンが期限切れなら再度新しいトークンを取得.
- GET_ACCOUNTS と USE_CREDENTIALS のパーミッションを必要とする.
- 認証要求画面が 2.x でダサい.

GoogleAuthUtil.getToken

良いとこ:
- 常に使えるトークンを返す.
- パーミッションは GET_ACCOUNTS のみ.
- 認証要求画面がダサくない
- Google が推奨している.

悪いとこ:
- 2.2+ の GooglePlay利用のデバイスに限る.
- Google Play services SDK が必要.
- Google API Console からアプリ登録が必要.
- Google services での OAuth 2.0 のみ.

android - Access to Google API - GoogleAccountCredential.usingOAuth2 vs GoogleAuthUtil.getToken() - Stack Overflow

android - In a nutshell what's the difference from using OAuth2 request getAuthToken and getToken - Stack Overflow