2012年3月25日日曜日

AnotherBrowser(Androidアプリ)

Androidアプリ:AnotherBrowser
package:jp.blogspot.tsukinihinikeni.AnotherBrowser
対象:Android1.6+ (DONUT以上)

AnotherBrowser"はAndroid用ブラウザアプリの共有機能から、今見ているページを別のブラウザアプリで表示するアプリです。
また、ローカルに保存しているHTMLファイルをブラウザアプリで表示することができます。

・アプリの概要
1.ブラウザの"ページを共有"等からこのアプリを選択すると、今見ているページを別のブラウザアプリで表示することができます。
例えば、普段使用しているブラウザアプリはflashをサポートしていないので、
このページを他のブラウザで表示したい

"ページを共有"等のメニューから、"AnotherBrowser"を選択する

今見ているページを、どのブラウザで開くかの選択肢が表示される
※設定で、この選択を経ずに、常に特定のアプリで表示することもできます

2.ファイル管理ソフト等でローカルに保存しているHTMLファイルにアクセスした時、そのファイルをどのアプリで表示するかのダイアログが現れます。
しかし、標準のブラウザを含む多くのブラウザはローカルファイルの表示(file://へのアクセス)に対して候補に現れず、HTMLファイルを直接ブラウザアプリで開くことができません。
"AnotherBrowser"を経由することで、好きなブラウザアプリでHTMLファイルを表示することができるようになります。
"AnotherBrowser"を選択すると、ブラウザアプリの一覧が現れるので、ファイルを表示したいブラウザを選択して下さい。
また、設定で常に特定のブラウザで開くようにすることもできます。

3.設定画面
共有機能等からではなく、アプリ一覧の中からこのアプリを起動すると、設定画面が表示されます。

設定画面
Web Pages
http://、https://で接続するときの設定です。
「毎回ブラウザを選択する」のチェックを外すと、常に設定したアプリで開きます。どのアプリで開くかの設定は、「ブラウザの変更」から行なって下さい。

ブラウザの変更
Local Files
file://で接続するときの設定です。
Web Pagesとは異なるブラウザを設定することができます。


・使用時の要件
無料、広告なし、権限(permission)不要です。
その他も特別な要件は必要としませんが、以下のことに気をつけて下さい。

・"ページの共有"の仕様はブラウザアプリによって異なるため、このアプリがうまく機能しないアプリもあるかもしれません。
・ローカルファイルを開くときの仕様もファイル管理アプリ等によって異なるため、このアプリがうまく機能しないアプリもあるかもしれません。また、ローカルのHTMLファイルを読み込む際の挙動が、意図しないものとなるブラウザアプリもあるかもしれません。

これらについては、個別に対処できることもありますので、このアプリがうまく動作しない場合などは詳細をご連絡いただければ、なんとかできるようがんばろうと思っています。


・その他

アプリのダウンロード(Google play)
https://play.google.com/store/apps/details?id=jp.blogspot.tsukinihinikeni.AnotherBrowser

類似の既存のアプリ
ブラウザアプリの共有機能から、今見ているページを別のブラウザアプリで表示するアプリとしては、既に以下のようなものもマーケットに公開されています。

・Browser Switch ( https://play.google.com/store/apps/details?id=com.nkj.app.browserswitch )
クリップボードの内容からブラウザを開いたり、ステータスバーにアイコンを置いたりもできます。

・Choose Browser ( https://play.google.com/store/apps/details?id=com.benhirashima.choosebrowser )
共有機能で受けたURLを暗黙的インテントで他のブラウザに飛ばす、この発想のアプリとしては最も基本的なロジックになっています。

2者とも、ローカルファイルを開くということについては特に意識して作られていないようですので、「ローカルのHTMLファイルをブラウザで開きたい」というややマイナーな趣向をお持ちの方については、"AnotherBrowser"が一番お役に立てる気がします。

更新
(2012/7/14 ver1.1)
設定したブラウザが見つからない時のエラー処理の方法を変更しました。
(旧:標準のブラウザで開く→新:ブラウザ設定画面)

連絡先
何かありましたら、この記事のコメント欄、あるいはメール( d.kondo.android@gmail.com )でお問い合わせください。

2012年3月16日金曜日

PlusOne(Androidアプリ)

Androidアプリ:PlusOne
package:com.blogspot.tsukinihinikeni.plusone
対象:Android1.6+ (DONUT以上)

"PlusOne"はAndroid用ブラウザアプリの共有機能から、今見ているページを+1することができるようになるアプリです。

・アプリの概要
ブラウザの"ページを共有"等からこのアプリを選択すると、今見ているページを+1するボタンをブラウザで表示します。

このページを+1したいが、+1ボタンが設置されていない

"ページを共有"を選択

"PlusOne"(このアプリ)を選択

先ほどのページを+1するためのボタンが表示されます。
ボタンの上に書かれているアドレスが、いま+1しようとしているアドレスです。

ボタンをクリックすることで+1ができます。
もう一度クリックすれば+1を取り消すこともできます。

・使用時の要件
+1を行うためには、Google+のアカウントが必要です。また、+1ボタンを表示するブラウザでGoogleアカウントにログインしている必要があります。

+1ボタンはJavaScriptで動いているため、ブラウザのJavaScriptがオフになっているとボタンが使用できません。

・その他

アプリのダウンロード(Google play)
https://play.google.com/store/apps/details?id=com.blogspot.tsukinihinikeni.plusone

セキュリティ
"PlusOne"は、権限やGoogleアカウントの情報を必要としません。Googleアカウントへのアクセスなどはブラウザアプリ任せのため、このアプリはユーザーの個人データには一切アクセスしません。

+1ボタンが表示されない
このアプリにもブラウザアプリにもアップデートが行われていないにもかかわらず、+1ボタンが表示されなくなった時期がありました。原因は私には分かりませんでした。また同様のことが起こるかもしれません。
表示されなくなった時期には、マーケットからこのアプリを削除するつもりでいましたが、原因は分かりませんがまた機能するようになったので、当分は機能する/しないに関わらずとりあえずマーケットに公開しておくことにします。ご迷惑をおかけすることもあるかと思いますが宜しくお願いいたします。

更新
(2012/7/14 ver1.3)
設定したブラウザが見つからない時のエラー処理の方法を変更しました。
(旧:標準のブラウザで開く→新:ブラウザの選択ダイアログ)

(2012/4/12 ver1.2)
標準のブラウザ以外でも+1ボタンを表示できるようにしました。
+1ボタン表示用のHTMLを若干変更しました。

(ver1.1)
+1ボタン表示用のHTMLを若干変更しましたが、このバージョンはマーケットに公開しませんでした。

連絡先
何かありましたら、この記事のコメント欄、あるいはメール( d.kondo.android@gmail.com )でお問い合わせください。

2012年2月25日土曜日

入力ボックス(Androidアプリ)

Androidアプリ:入力ボックス
package:com.blogspot.tsukinihinikeni.InputBox
対象:Android2.2+ (FROYO以上)

"入力ボックス"はマッシュルームアプリです。
Simejiのマッシュルーム呼び出し機能、ATOKのATOKダイレクトなどから呼び出してご使用下さい。

・アプリの概要
"入力ボックス"をマッシュルームとして呼び出すと、文字入力用のボックスが現れます。

・どんな時に役に立つか
1.Gmailアプリの宛先入力時

現在、Galaxy NEXUSでは、標準のGmailアプリの宛先欄にうまく日本語が入力できません。
2012年4月8日追記:2012年4月4日のGmailアプリのアップデートで、この件の不具合は解消されたようです。


(ATOKの場合1)一文字ごとに確定してしまう (ATOKの場合2)文字が2つ入力されてしまう

入力一文字ごとに電話帳の検索が入るためのバグと思いますが、漢字変換等もできないので、日本人名の入力ができない状態です。


このアプリを使えば、漢字変換等を行った後の文字を宛先欄に入力することができます。

入力ボックスに文字を入力

宛先欄に反映



 2.入力文字が隠されてしまう時

パスワードの入力フォームなど、入力文字が***や・・・のようにマスクされてしまい、何を入力したか分からなくなる時があります。
また、入力フォームのフォントが小さすぎて読みづらい、入力フォームが1行分しか表示されなくて入力した文字が表示されきらない、といったこともあるかもしれません。

このアプリを使えば、入力文字を確認後にフォームに反映させることができます。


パスワードを入力

反映
スクリーンショットをとっておけば、パスワードとして何を設定したかの簡易なメモにもなります。


3.アクションボタン

ver.2.0(2012/8/5-)にて、アクションボタンの機能を追加しました。


ボリュームダウンキーを押すと、入力ボックスの下に4つのアイコンが表示されます。

ボタンの機能は、左から、
・入力した番号に電話をかけます
・入力したアドレス宛にメールを作成します
・入力した内容を共有します
・入力ボックスの表示位置を移動します

ボリュームアップキーを押すとアクションボタンの表示をやめます。
また、メニューキーによってもアクションボタンの表示/非表示を切り替えることができます。

この機能によって、(マッシュルームの本来の使い方からは外れますが、)ブラウジング中でもメール作成中でも、IMEさえ立ち上げられる(あるいはマッシュルームを起動できる)状態であれば、画面を見ながら電話番号やメールアドレスを入力することができます。


・その他
アプリのダウンロード(Google play)
https://play.google.com/store/apps/details?id=com.blogspot.tsukinihinikeni.InputBox

更新
(2012/8/5 ver.2.0)
アクションボタン機能を追加しました。


(2012/2/27 ver.1.1)
対象OSを「Android4.0+(Ice Cream Sandwich以上)」から「Android2.2以上(FROYO以上)」に広げました。

(2012/2/29 ver.1.2)
入力ボックスが複数行を表示するように修正しました。


連絡先
何かありましたら、この記事のコメント欄、あるいはメール( d.kondo.android@gmail.com )でお問い合わせください。


2012年2月9日木曜日

BouncingBalls

API Demosに入っているBouncingBalls (http://goo.gl/HuQSf)を自分でも書いてみた。

ただし、勉強のため

・背景色は静的なものとし、AnimatorUpdateListenerによってinvalidateの処理を行うこととした。(オリジナルのBouncingBallsは背景色を変化させることで自動的にinvalidateの処理をおこなっている)

・オリジナルにあるShapeHolderクラスを使用しない。つまり、メインのBouncingBallsクラスの中で全て完結させる。また、ObjectAnimatorは使用せず、全てValueAnimatorで処理する。

という制限をつけて行った。

上手いコードにはなっていないが、とりあえずできたので貼りつけておく。



import java.util.ArrayList;

import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator.AnimatorUpdateListener;

public class BouncingBallsActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((LinearLayout) findViewById(R.id.container)).addView(new MyView(this));
}

public class MyView extends View implements AnimatorUpdateListener {

int i = 0;
ArrayList<Integer> rgb = new ArrayList<Integer>();
ArrayList<AnimatorSet> animatorSet = new ArrayList<AnimatorSet>();

ArrayList<ValueAnimator> animLeft1 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animTop1 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animRight1 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animBottom1 = new ArrayList<ValueAnimator>();
ArrayList<AnimatorSet> animatorSet1 = new ArrayList<AnimatorSet>();

ArrayList<ValueAnimator> animLeft2 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animTop2 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animRight2 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animBottom2 = new ArrayList<ValueAnimator>();
ArrayList<AnimatorSet> animatorSet2 = new ArrayList<AnimatorSet>();

ArrayList<ValueAnimator> animLeft3 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animTop3 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animRight3 = new ArrayList<ValueAnimator>();
ArrayList<ValueAnimator> animBottom3 = new ArrayList<ValueAnimator>();
ArrayList<AnimatorSet> animatorSet3 = new ArrayList<AnimatorSet>();

public MyView(Context context) {
super(context);
}

@Override
public void onAnimationUpdate(ValueAnimator anim) {
invalidate();
}

@Override
public boolean onTouchEvent(MotionEvent event) {

if (event.getAction() != MotionEvent.ACTION_DOWN
&& event.getAction() != MotionEvent.ACTION_MOVE) {
return false;
}

float h = (float) getHeight();
float endY = h - 50f;
float X = event.getX();
float startY = event.getY();
int duration = (int) (500 * ((h - startY) / h));

// color
rgb.add(i, Color.rgb((int) (Math.random() * 255),
(int) (Math.random() * 255), (int) (Math.random() * 255)));

// down
animLeft1.add(i, ValueAnimator.ofFloat(X - 25f, X - 25f));
animLeft1.get(i).setDuration(duration);

animRight1.add(i, ValueAnimator.ofFloat(X + 25f, X + 25f));
animRight1.get(i).setDuration(duration);

animTop1.add(i, ValueAnimator.ofFloat(startY - 25f, endY - 25f));
animTop1.get(i).setDuration(duration);
animTop1.get(i).setInterpolator(new AccelerateInterpolator());
animTop1.get(i).addUpdateListener(this);

animBottom1.add(i, ValueAnimator.ofFloat(startY + 25f, endY + 25f));
animBottom1.get(i).setDuration(duration);
animBottom1.get(i).setInterpolator(new AccelerateInterpolator());

animatorSet1.add(i, new AnimatorSet());
animatorSet1.get(i).play(animTop1.get(i)).with(animBottom1.get(i));
animatorSet1.get(i).play(animTop1.get(i)).with(animLeft1.get(i));
animatorSet1.get(i).play(animTop1.get(i)).with(animRight1.get(i));

// skew
animLeft2.add(i, ValueAnimator.ofFloat(X - 25f, X - 25f * 2f));
animLeft2.get(i).setDuration(duration / 4);
animLeft2.get(i).setInterpolator(new DecelerateInterpolator());
animLeft2.get(i).setRepeatCount(1);
animLeft2.get(i).setRepeatMode(ValueAnimator.REVERSE);

animRight2.add(i, ValueAnimator.ofFloat(X + 25f, X + 25f * 2f));
animRight2.get(i).setDuration(duration / 4);
animRight2.get(i).setInterpolator(new DecelerateInterpolator());
animRight2.get(i).setRepeatCount(1);
animRight2.get(i).setRepeatMode(ValueAnimator.REVERSE);

animTop2.add(i, ValueAnimator.ofFloat(endY - 25f, endY - 25f * 0f));
animTop2.get(i).setDuration(duration / 4);
animTop2.get(i).setInterpolator(new DecelerateInterpolator());
animTop2.get(i).setRepeatCount(1);
animTop2.get(i).setRepeatMode(ValueAnimator.REVERSE);
animTop2.get(i).addUpdateListener(this);

animBottom2.add(i, ValueAnimator.ofFloat(endY + 25f, endY + 25f));
animBottom2.get(i).setDuration(duration / 4);
animBottom2.get(i).setRepeatCount(1);
animBottom2.get(i).setRepeatMode(ValueAnimator.REVERSE);

animatorSet2.add(i, new AnimatorSet());
animatorSet2.get(i).play(animTop2.get(i)).with(animBottom2.get(i));
animatorSet2.get(i).play(animTop2.get(i)).with(animLeft2.get(i));
animatorSet2.get(i).play(animTop2.get(i)).with(animRight2.get(i));

// up
animLeft3.add(i, ValueAnimator.ofFloat(X - 25f, X - 25f));
animLeft3.get(i).setDuration(duration);

animRight3.add(i, ValueAnimator.ofFloat(X + 25f, X + 25f));
animRight3.get(i).setDuration(duration);

animTop3.add(i, ValueAnimator.ofFloat(endY - 25f, startY - 25f));
animTop3.get(i).setDuration(duration);
animTop3.get(i).setInterpolator(new DecelerateInterpolator());
animTop3.get(i).addUpdateListener(this);

animBottom3.add(i, ValueAnimator.ofFloat(endY + 25f, startY + 25f));
animBottom3.get(i).setDuration(duration);
animBottom3.get(i).setInterpolator(new DecelerateInterpolator());

animatorSet3.add(i, new AnimatorSet());
animatorSet3.get(i).play(animTop3.get(i)).with(animBottom3.get(i));
animatorSet3.get(i).play(animTop3.get(i)).with(animLeft3.get(i));
animatorSet3.get(i).play(animTop3.get(i)).with(animRight3.get(i));

animatorSet.add(i, new AnimatorSet());
animatorSet.get(i).play(animatorSet2.get(i))
.after(animatorSet1.get(i));
animatorSet.get(i).play(animatorSet3.get(i))
.after(animatorSet2.get(i));
animatorSet.get(i).start();

i++;

return true;
}

@Override
public void onDraw(Canvas canvas) {
if (i > 0) {
for (int j = 0; j < animatorSet.size(); ++j) {
if (animatorSet1.get(j) != null
&& animatorSet1.get(j).isRunning()) {
Paint paint = new Paint();
paint.setColor(rgb.get(j));
paint.setStyle(Paint.Style.FILL);
RectF oval = new RectF((Float) animLeft1.get(j)
.getAnimatedValue(), (Float) animTop1.get(j)
.getAnimatedValue(), (Float) animRight1.get(j)
.getAnimatedValue(), (Float) animBottom1.get(j)
.getAnimatedValue());
canvas.drawOval(oval, paint);
} else if (animatorSet2.get(j) != null
&& animatorSet2.get(j).isRunning()) {
Paint paint = new Paint();
paint.setColor(rgb.get(j));
paint.setStyle(Paint.Style.FILL);
RectF oval = new RectF((Float) animLeft2.get(j)
.getAnimatedValue(), (Float) animTop2.get(j)
.getAnimatedValue(), (Float) animRight2.get(j)
.getAnimatedValue(), (Float) animBottom2.get(j)
.getAnimatedValue());
canvas.drawOval(oval, paint);
} else if (animatorSet3.get(j) != null
&& animatorSet3.get(j).isRunning()) {
Paint paint = new Paint();
paint.setColor(rgb.get(j));
paint.setStyle(Paint.Style.FILL);
RectF oval = new RectF((Float) animLeft3.get(j)
.getAnimatedValue(), (Float) animTop3.get(j)
.getAnimatedValue(), (Float) animRight3.get(j)
.getAnimatedValue(), (Float) animBottom3.get(j)
.getAnimatedValue());
canvas.drawOval(oval, paint);
}
}
}
}
}
}



なお、R.layout.mainは以下のようになっている。

<?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"
    android:id="@+id/container"
    android:background="#ffffffff">
</LinearLayout>

android:id="@+id/container"を定義している以外は、特に何もしていない。

2012年2月6日月曜日

(Animator)図形を動かす

図形を動かすには、OS3.0から導入された"Property Animation"という方法と、以前からある"View Animation"という方法がある。
Property Animationの方が汎用性が高く推奨される方法とのこと。
(http://developer.android.com/intl/ja/guide/topics/graphics/animation.html)

現在の端末は2.xが主流であるため、あまり使用されていないようだが、この記事の内容はProperty Animationについてである。


Property Animationでは、動きの描写は、ValueAnimatorオブジェクト、および、このオブジェクトに関するリスナーを使って記述される。

ValueAnimatorオブジェクト(android.animation.ValueAnimator)は、単にタイマー的な計算機であり、
「値Aから値BまでをT秒かけて変化していく」
という動作を基本とする。
この値の変化について、一定のスピードで変化するのか、あるいは後半加速するのかといった補間の仕方(InterPoletor)や、この動作を一度でやめるのか繰り返すのかなどといった、様々な設定を施すことができる。

ValueAnimatorの値の変化はAnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener)で感知することができる。
このクラスのonAnimationUpdateメソッドをオーバーライドしてinvalidateメソッドを実行することで、ValueAnimatorに連動して、適時onDrawを呼び出すことができる。

最後に、図形を描画するCanvas側では、図形の位置や大きさなどのプロパティをValueAnimatorの計算値から取得するようにする。

以下のコードは、円が画面上部から下方へ並行移動する。

import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.animation.ValueAnimator.AnimatorUpdateListener;

public class CanvasSampleActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((LinearLayout) findViewById(R.id.container)).addView(new MyView(this));
}

public class MyView extends View implements AnimatorUpdateListener {

ValueAnimator anim = null;

public MyView(Context context) {
super(context);
anim = ValueAnimator.ofFloat(100f, 500f);
anim.setDuration(3000);
anim.addUpdateListener(this);
anim.start();
}

@Override
public void onAnimationUpdate(ValueAnimator anim) {
invalidate();
}

@Override
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(0xff0000ff);
paint.setStyle(Paint.Style.STROKE);
canvas.drawCircle(200f, (Float) anim.getAnimatedValue(), 50f, paint);
}

}

}


なお、R.layout.mainは以下のようになっている。

<?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"
    android:id="@+id/container"
    android:background="#ffffffff">
</LinearLayout>

android:id="@+id/container"を定義している以外は、特に何もしていない。

2012年2月5日日曜日

(Canvas)三角形を描画する

Canvasの基本的な使い方については(Canvas)円周を描画するを参照。

多角形を描画するには、Pathオブジェクトを使用する。
Paintオブジェクトに書式の情報、Pathオブジェクトに経路の情報をセットして、
canvas.drawPath(path,paint)
によって多角形を描画できる。

単純に正三角形を描画するコードは以下。

Paint paint = new Paint();
paint.setColor(0xff0000ff);
paint.setStyle(Paint.Style.STROKE);
Path path = new Path();
path.moveTo(150f, 50f);
path.lineTo(150f-58f,150f);
path.lineTo(150f+58f, 150f);
path.close();
canvas.drawPath(path,paint);


上ではPaint.StyleのプロパティをSTROKEにしているが、これをFILLにした場合、囲まれた領域が塗りつぶされる。

(図の①) STROKE、閉曲線(上記の正三角形)

(図の②) STROKE、非閉曲線
Paint paint = new Paint();
paint.setColor(0xff0000ff);
paint.setStyle(Paint.Style.STROKE);
Path path = new Path();
path.moveTo(150f, 50f);
path.lineTo(150f-58f,150f);
path.lineTo(150f+58f, 150f);
canvas.drawPath(path,paint);

(図の③) FILL、閉曲線
Paint paint = new Paint();
paint.setColor(0xff0000ff);
paint.setStyle(Paint.Style.FILL);
Path path = new Path();
path.moveTo(150f, 50f);
path.lineTo(150f-58f,150f);
path.lineTo(150f+58f, 150f);
path.close();
canvas.drawPath(path,paint);

(図の④) FILL、非閉曲線
Paint paint = new Paint();
paint.setColor(0xff0000ff);
paint.setStyle(Paint.Style.FILL);
Path path = new Path();
path.moveTo(150f, 50f);
path.lineTo(150f-58f,150f);
path.lineTo(150f+58f, 150f);
canvas.drawPath(path,paint);



FILLで塗りつぶす場合は、Pathが必ずしも閉じている必要は無いようだ。

ちなみに、
Paint paint = new Paint();
paint.setColor(0xff0000ff);
Path path = new Path();
path.moveTo(150f, 50f);
path.lineTo(150f-58f,150f);
canvas.drawPath(path,paint);
のように経路が単に線分の場合、Paint.StyleをSTROKEにしていると線分が描画されるが、FILLにしていると何も描画されない。

2012年2月4日土曜日

(Canvas)円周を描画する

android.graphics.* android.animation.* のあたりにも手を出してみたい、とようやく考え始め。
まずはシンプルに円を描くコードを作成。

下記のコードは、青色の線で円を描きます。


import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

public class CanvasSampleActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((LinearLayout) findViewById(R.id.container)).addView(new MyView(this));
}

public class MyView extends View {

public MyView(Context context) {
super(context);
}

@Override
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(0xff0000ff);
paint.setStyle(Paint.Style.STROKE);
canvas.drawCircle(200f, 200f, 100f, paint);
}

}

}

なお、R.layout.mainは以下のようになっています。

<?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"
    android:id="@+id/container"
    android:background="#ffffffff">
</LinearLayout>

android:id="@+id/container"を定義している以外は、特に何もしていません。


基本的なポイントとしては、
・Viewを継承したクラスを作成し、その中でonDrawメソッドをオーバーライドして描画プログラムを書く。
・onDrawメソッドは最初の描画時や、invalidate()が呼び出された時などに自動的に呼び出される。
・Paintオブジェクトには色やエフェクト等書式的な情報がセットできる。
・Canvasオブジェクトが「丸を書く」「四角を書く」「線を書く」などの描画メソッドを持っている。描画メソッドは基本的にPaintオブジェクトを引数に取るようになっている。

また、Paint.StyleプロパティはデフォルトではFILLになっており、円や四角を描いた場合、中身はすべて塗りつぶされます。STROKEに変更すると周のみを描くことができます。



2012年1月22日日曜日

音楽ファイルの再生

ボタンを押したら音楽ファイルを再生する、というコード。

まず、res/rawの下に再生する音楽ファイルを入れる。(下の例ではres/raw/sound.mp3)

基本的には
MediaPlayer mp = MediaPlayer.create(this,  R.raw.sound);
mp.start();
で音楽ファイルを再生できる。(sound.mp3ではなくsoundのみ書く。)

ただし、OnClickListenerの中で上のコードを実行しようとすると、thisではContextが指定できないので、もう少し真面目に指定する必要がある。


サンプルコードは

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class soundActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button) findViewById(R.id.button1)).setOnClickListener(play);
}

OnClickListener play = new OnClickListener() {
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(getApplicationContext(),  R.raw.sound);
mp.start();
}
};
}

2012年1月4日水曜日

2012年の日付の素因数分解


2012年の日付(YYYYMMDD形式)を素因数分解してみました。
素数になる日は22回あるようです。

日付 数値 素因数分解
2012/1/1 20120101 23 * 347 * 2521
2012/1/2 20120102 2 * 113 * 127 * 701
2012/1/3 20120103 3^3 * 745189
2012/1/4 20120104 2^3 * 2515013
2012/1/5 20120105 5 * 4024021
2012/1/6 20120106 2 * 3 * 3353351
2012/1/7 20120107 7 * 19 * 151279
2012/1/8 20120108 2^2 * 5030027
2012/1/9 20120109 3 * 101 * 66403
2012/1/10 20120110 2 * 5 * 2012011
2012/1/11 20120111 11 * 139 * 13159
2012/1/12 20120112 2^4 * 3^2 * 17 * 8219
2012/1/13 20120113 13 * 29 * 83 * 643
2012/1/14 20120114 2 * 7 * 73 * 19687
2012/1/15 20120115 3 * 5 * 79 * 16979
2012/1/16 20120116 2^2 * 31 * 211 * 769
2012/1/17 20120117 733 * 27449
2012/1/18 20120118 2 * 3 * 61 * 54973
2012/1/19 20120119 37 * 543787
2012/1/20 20120120 2^3 * 5 * 503003
2012/1/21 20120121 3^2 * 7 * 59 * 5413
2012/1/22 20120122 2 * 11^2 * 71 * 1171
2012/1/23 20120123 103 * 195341
2012/1/24 20120124 2^2 * 3 * 23 * 269 * 271
2012/1/25 20120125 5^3 * 53 * 3037
2012/1/26 20120126 2 * 13^3 * 19 * 241
2012/1/27 20120127 3 * 6706709
2012/1/28 20120128 2^6 * 7 * 97 * 463
2012/1/29 20120129 17 * 1183537
2012/1/30 20120130 2 * 3^3 * 5 * 43 * 1733
2012/1/31 20120131 191 * 105341
2012/2/1 20120201 109 * 197 * 937
2012/2/2 20120202 2 * 3^2 * 19 * 58831
2012/2/3 20120203 20120203 (PRIME)
2012/2/4 20120204 2^2 * 13 * 386927
2012/2/5 20120205 3 * 5 * 7 * 191621
2012/2/6 20120206 2 * 1013 * 9931
2012/2/7 20120207 20120207 (PRIME)
2012/2/8 20120208 2^4 * 3 * 419171
2012/2/9 20120209 31 * 649039
2012/2/10 20120210 2 * 5 * 11 * 101 * 1811
2012/2/11 20120211 3^3 * 433 * 1721
2012/2/12 20120212 2^2 * 7 * 718579
2012/2/13 20120213 20120213 (PRIME)
2012/2/14 20120214 2 * 3 * 17 * 197257
2012/2/15 20120215 5 * 113 * 149 * 239
2012/2/16 20120216 2^3 * 23 * 43 * 2543
2012/2/17 20120217 3 * 13 * 41 * 12583
2012/2/18 20120218 2 * 10060109
2012/2/19 20120219 7 * 2874317
2012/2/20 20120220 2^2 * 3^2 * 5 * 111779
2012/2/21 20120221 11 * 19 * 96269
2012/2/22 20120222 2 * 1091 * 9221
2012/2/23 20120223 3 * 6706741
2012/2/24 20120224 2^5 * 628757
2012/2/25 20120225 5^2 * 97 * 8297
2012/2/26 20120226 2 * 3 * 7 * 103 * 4651
2012/2/27 20120227 4423 * 4549
2012/2/28 20120228 2^2 * 467 * 10771
2012/2/29 20120229 3^2 * 29 * 127 * 607
2012/3/1 20120301 3^2 * 61 * 67 * 547
2012/3/2 20120302 2 * 31 * 43 * 7547
2012/3/3 20120303 7 * 757 * 3797
2012/3/4 20120304 2^4 * 3 * 37 * 11329
2012/3/5 20120305 5 * 4024061
2012/3/6 20120306 2 * 2371 * 4243
2012/3/7 20120307 3 * 317 * 21157
2012/3/8 20120308 2^2 * 13 * 23 * 16823
2012/3/9 20120309 11 * 1829119
2012/3/10 20120310 2 * 3^2 * 5 * 7 * 109 * 293
2012/3/11 20120311 101 * 199211
2012/3/12 20120312 2^3 * 2515039
2012/3/13 20120313 3 * 6706771
2012/3/14 20120314 2 * 10060157
2012/3/15 20120315 5 * 4024063
2012/3/16 20120316 2^2 * 3 * 17 * 19 * 29 * 179
2012/3/17 20120317 7 * 2874331
2012/3/18 20120318 2 * 10060159
2012/3/19 20120319 3^4 * 89 * 2791
2012/3/20 20120320 2^8 * 5 * 11 * 1429
2012/3/21 20120321 13 * 1547717
2012/3/22 20120322 2 * 3 * 97 * 181 * 191
2012/3/23 20120323 20120323 (PRIME)
2012/3/24 20120324 2^2 * 7 * 47 * 15289
2012/3/25 20120325 3 * 5^2 * 268271
2012/3/26 20120326 2 * 10060163
2012/3/27 20120327 167 * 211 * 571
2012/3/28 20120328 2^3 * 3^2 * 113 * 2473
2012/3/29 20120329 103 * 195343
2012/3/30 20120330 2 * 5 * 2012033
2012/3/31 20120331 3 * 7^2 * 11 * 23 * 541
2012/4/1 20120401 7 * 17 * 169079
2012/4/2 20120402 2 * 1531 * 6571
2012/4/3 20120403 3 * 29 * 231269
2012/4/4 20120404 2^2 * 5030101
2012/4/5 20120405 5 * 487 * 8263
2012/4/6 20120406 2 * 3 * 71 * 73 * 647
2012/4/7 20120407 20120407 (PRIME)
2012/4/8 20120408 2^3 * 7 * 11 * 89 * 367
2012/4/9 20120409 3^2 * 569 * 3929
2012/4/10 20120410 2 * 5 * 599 * 3359
2012/4/11 20120411 19 * 251 * 4219
2012/4/12 20120412 2^2 * 3 * 13 * 101 * 1277
2012/4/13 20120413 2399 * 8387
2012/4/14 20120414 2 * 10060207
2012/4/15 20120415 3 * 5 * 7 * 37 * 5179
2012/4/16 20120416 2^5 * 59 * 10657
2012/4/17 20120417 773 * 26029
2012/4/18 20120418 2 * 3^2 * 17 * 47 * 1399
2012/4/19 20120419 11 * 97 * 109 * 173
2012/4/20 20120420 2^2 * 5 * 1006021
2012/4/21 20120421 3 * 131 * 51197
2012/4/22 20120422 2 * 7 * 41 * 35053
2012/4/23 20120423 23 * 61 * 14341
2012/4/24 20120424 2^3 * 3 * 838351
2012/4/25 20120425 5^2 * 13 * 61909
2012/4/26 20120426 2 * 31 * 324523
2012/4/27 20120427 3^3 * 745201
2012/4/28 20120428 2^2 * 5030107
2012/4/29 20120429 7^2 * 410621
2012/4/30 20120430 2 * 3 * 5 * 11 * 19 * 3209
2012/5/1 20120501 20120501 (PRIME)
2012/5/2 20120502 2 * 3 * 67 * 50051
2012/5/3 20120503 13 * 17 * 181 * 503
2012/5/4 20120504 2^3 * 41 * 61343
2012/5/5 20120505 3 * 5 * 137 * 9791
2012/5/6 20120506 2 * 7 * 19 * 75641
2012/5/7 20120507 11 * 1829137
2012/5/8 20120508 2^2 * 3^3 * 186301
2012/5/9 20120509 20120509 (PRIME)
2012/5/10 20120510 2 * 5 * 79 * 25469
2012/5/11 20120511 3 * 557 * 12041
2012/5/12 20120512 2^6 * 47 * 6689
2012/5/13 20120513 7 * 101 * 149 * 191
2012/5/14 20120514 2 * 3 * 359 * 9341
2012/5/15 20120515 5 * 23^2 * 7607
2012/5/16 20120516 2^2 * 13 * 97 * 3989
2012/5/17 20120517 3^2 * 43 * 51991
2012/5/18 20120518 2 * 11 * 914569
2012/5/19 20120519 29 * 31 * 22381
2012/5/20 20120520 2^3 * 3 * 5 * 7 * 17 * 1409
2012/5/21 20120521 1117 * 18013
2012/5/22 20120522 2 * 383 * 26267
2012/5/23 20120523 3 * 6706841
2012/5/24 20120524 2^2 * 5030131
2012/5/25 20120525 5^2 * 19 * 42359
2012/5/26 20120526 2 * 3^2 * 37 * 30211
2012/5/27 20120527 7^2 * 410623
2012/5/28 20120528 2^4 * 83 * 109 * 139
2012/5/29 20120529 3 * 11 * 13 * 46901
2012/5/30 20120530 2 * 5 * 257 * 7829
2012/5/31 20120531 20120531 (PRIME)
2012/6/1 20120601 3 * 19 * 107 * 3299
2012/6/2 20120602 2 * 53 * 189817
2012/6/3 20120603 43 * 293 * 1597
2012/6/4 20120604 2^2 * 3 * 7 * 239531
2012/6/5 20120605 5 * 17 * 236713
2012/6/6 20120606 2 * 11^2 * 29 * 47 * 61
2012/6/7 20120607 3^2 * 13 * 23 * 7477
2012/6/8 20120608 2^5 * 241 * 2609
2012/6/9 20120609 4177 * 4817
2012/6/10 20120610 2 * 3 * 5 * 127 * 5281
2012/6/11 20120611 7 * 83 * 34631
2012/6/12 20120612 2^2 * 31 * 162263
2012/6/13 20120613 3 * 97 * 69143
2012/6/14 20120614 2 * 101 * 99607
2012/6/15 20120615 5 * 4024123
2012/6/16 20120616 2^3 * 3^3 * 93151
2012/6/17 20120617 11 * 443 * 4129
2012/6/18 20120618 2 * 7 * 1437187
2012/6/19 20120619 3 * 71 * 94463
2012/6/20 20120620 2^2 * 5 * 13 * 19 * 4073
2012/6/21 20120621 223 * 90227
2012/6/22 20120622 2 * 3 * 17 * 197261
2012/6/23 20120623 20120623 (PRIME)
2012/6/24 20120624 2^4 * 317 * 3967
2012/6/25 20120625 3^2 * 5^4 * 7^2 * 73
2012/6/26 20120626 2 * 2309 * 4357
2012/6/27 20120627 41 * 229 * 2143
2012/6/28 20120628 2^2 * 3 * 11 * 152429
2012/6/29 20120629 20120629 (PRIME)
2012/6/30 20120630 2 * 5 * 23 * 87481
2012/7/1 20120701 2281 * 8821
2012/7/2 20120702 2 * 7 * 1437193
2012/7/3 20120703 3 * 67 * 100103
2012/7/4 20120704 2^7 * 191 * 823
2012/7/5 20120705 5 * 11 * 31 * 11801
2012/7/6 20120706 2 * 3^2 * 1117817
2012/7/7 20120707 17 * 1183571
2012/7/8 20120708 2^2 * 53 * 107 * 887
2012/7/9 20120709 3 * 7 * 41 * 23369
2012/7/10 20120710 2 * 5 * 97 * 20743
2012/7/11 20120711 13 * 37 * 59 * 709
2012/7/12 20120712 2^3 * 3 * 838363
2012/7/13 20120713 20120713 (PRIME)
2012/7/14 20120714 2 * 10060357
2012/7/15 20120715 3^2 * 5 * 19 * 101 * 233
2012/7/16 20120716 2^2 * 7 * 11 * 65327
2012/7/17 20120717 20120717 (PRIME)
2012/7/18 20120718 2 * 3 * 1069 * 3137
2012/7/19 20120719 20120719 (PRIME)
2012/7/20 20120720 2^4 * 5 * 163 * 1543
2012/7/21 20120721 3 * 6706907
2012/7/22 20120722 2 * 23 * 29 * 15083
2012/7/23 20120723 7^3 * 58661
2012/7/24 20120724 2^2 * 3^4 * 13 * 17 * 281
2012/7/25 20120725 5^2 * 804829
2012/7/26 20120726 2 * 277 * 36319
2012/7/27 20120727 3 * 11^3 * 5039
2012/7/28 20120728 2^3 * 61 * 41231
2012/7/29 20120729 20120729 (PRIME)
2012/7/30 20120730 2 * 3 * 5 * 7 * 95813
2012/7/31 20120731 379 * 53089
2012/8/1 20120801 20120801 (PRIME)
2012/8/2 20120802 2 * 3 * 13^2 * 19843
2012/8/3 20120803 701 * 28703
2012/8/4 20120804 2^2 * 11 * 431 * 1061
2012/8/5 20120805 3^4 * 5 * 49681
2012/8/6 20120806 2 * 139 * 157 * 461
2012/8/7 20120807 7 * 97 * 29633
2012/8/8 20120808 2^3 * 3 * 838367
2012/8/9 20120809 17 * 29 * 40813
2012/8/10 20120810 2 * 5 * 19 * 105899
2012/8/11 20120811 3 * 149 * 45013
2012/8/12 20120812 2^2 * 5030203
2012/8/13 20120813 3433 * 5861
2012/8/14 20120814 2 * 3^2 * 7 * 23 * 53 * 131
2012/8/15 20120815 5 * 11 * 13 * 107 * 263
2012/8/16 20120816 2^4 * 101 * 12451
2012/8/17 20120817 3 * 6706939
2012/8/18 20120818 2 * 43^2 * 5441
2012/8/19 20120819 20120819 (PRIME)
2012/8/20 20120820 2^2 * 3 * 5 * 335347
2012/8/21 20120821 7^2 * 410629
2012/8/22 20120822 2 * 37 * 271903
2012/8/23 20120823 3^2 * 2235647
2012/8/24 20120824 2^3 * 2515103
2012/8/25 20120825 5^2 * 804833
2012/8/26 20120826 2 * 3 * 11 * 17 * 79 * 227
2012/8/27 20120827 20120827 (PRIME)
2012/8/28 20120828 2^2 * 7 * 13 * 167 * 331
2012/8/29 20120829 3 * 19 * 31 * 59 * 193
2012/8/30 20120830 2 * 5 * 2012083
2012/8/31 20120831 2347 * 8573
2012/9/1 20120901 3 * 151 * 44417
2012/9/2 20120902 2 * 2131 * 4721
2012/9/3 20120903 11 * 71 * 25763
2012/9/4 20120904 2^3 * 3^2 * 43 * 67 * 97
2012/9/5 20120905 5 * 7 * 19 * 79 * 383
2012/9/6 20120906 2 * 13 * 23 * 33647
2012/9/7 20120907 3 * 6706969
2012/9/8 20120908 2^2 * 5030227
2012/9/9 20120909 947 * 21247
2012/9/10 20120910 2 * 3 * 5 * 811 * 827
2012/9/11 20120911 17 * 61 * 19403
2012/9/12 20120912 2^4 * 7 * 179651
2012/9/13 20120913 3^3 * 251 * 2969
2012/9/14 20120914 2 * 11 * 41 * 22307
2012/9/15 20120915 5 * 4024183
2012/9/16 20120916 2^2 * 3 * 137 * 12239
2012/9/17 20120917 73 * 101 * 2729
2012/9/18 20120918 2 * 10060459
2012/9/19 20120919 3 * 7^2 * 13 * 10529
2012/9/20 20120920 2^3 * 5 * 53 * 9491
2012/9/21 20120921 883 * 22787
2012/9/22 20120922 2 * 3^2 * 31 * 107 * 337
2012/9/23 20120923 20120923 (PRIME)
2012/9/24 20120924 2^2 * 19 * 264749
2012/9/25 20120925 3 * 5^2 * 11 * 29^3
2012/9/26 20120926 2 * 7 * 1103 * 1303
2012/9/27 20120927 20120927 (PRIME)
2012/9/28 20120928 2^5 * 3 * 17 * 12329
2012/9/29 20120929 23 * 874823
2012/9/30 20120930 2 * 5 * 2012093
2012/10/1 20121001 97 * 207433
2012/10/2 20121002 2 * 11 * 914591
2012/10/3 20121003 3^2 * 7 * 277 * 1153
2012/10/4 20121004 2^2 * 5030251
2012/10/5 20121005 5 * 281 * 14321
2012/10/6 20121006 2 * 3 * 59 * 113 * 503
2012/10/7 20121007 37 * 543811
2012/10/8 20121008 2^4 * 1257563
2012/10/9 20121009 3 * 599 * 11197
2012/10/10 20121010 2 * 5 * 7 * 13 * 22111
2012/10/11 20121011 877 * 22943
2012/10/12 20121012 2^2 * 3^2 * 29 * 19273
2012/10/13 20121013 11 * 17 * 107599
2012/10/14 20121014 2 * 2099 * 4793
2012/10/15 20121015 3 * 5 * 31 * 43271
2012/10/16 20121016 2^3 * 2515127
2012/10/17 20121017 7^2 * 283 * 1451
2012/10/18 20121018 2 * 3 * 101 * 33203
2012/10/19 20121019 19 * 1059001
2012/10/20 20121020 2^2 * 5 * 521 * 1931
2012/10/21 20121021 3^3 * 23 * 32401
2012/10/22 20121022 2 * 193 * 52127
2012/10/23 20121023 13 * 1547771
2012/10/24 20121024 2^6 * 3 * 7 * 11 * 1361
2012/10/25 20121025 5^2 * 389 * 2069
2012/10/26 20121026 2 * 53 * 83 * 2287
2012/10/27 20121027 3 * 983 * 6823
2012/10/28 20121028 2^2 * 5030257
2012/10/29 20121029 47 * 107 * 4001
2012/10/30 20121030 2 * 3^2 * 5 * 17 * 13151
2012/10/31 20121031 7 * 89 * 32297
2012/11/1 20121101 7 * 11 * 13 * 20101
2012/11/2 20121102 2 * 3^3 * 372613
2012/11/3 20121103 20121103 (PRIME)
2012/11/4 20121104 2^4 * 1257569
2012/11/5 20121105 3 * 5 * 67 * 20021
2012/11/6 20121106 2 * 10060553
2012/11/7 20121107 20121107 (PRIME)
2012/11/8 20121108 2^2 * 3 * 7 * 31 * 7727
2012/11/9 20121109 83 * 149 * 1627
2012/11/10 20121110 2 * 5 * 379 * 5309
2012/11/11 20121111 3^2 * 173 * 12923
2012/11/12 20121112 2^3 * 11 * 373 * 613
2012/11/13 20121113 23 * 874831
2012/11/14 20121114 2 * 3 * 13 * 19 * 13577
2012/11/15 20121115 5 * 7^2 * 17 * 4831
2012/11/16 20121116 2^2 * 71 * 70849
2012/11/17 20121117 3 * 677 * 9907
2012/11/18 20121118 2 * 37 * 127 * 2141
2012/11/19 20121119 41 * 43 * 101 * 113
2012/11/20 20121120 2^5 * 3^2 * 5 * 89 * 157
2012/11/21 20121121 20121121 (PRIME)
2012/11/22 20121122 2 * 7 * 1437223
2012/11/23 20121123 3 * 11 * 47 * 12973
2012/11/24 20121124 2^2 * 59 * 85259
2012/11/25 20121125 5^3 * 160969
2012/11/26 20121126 2 * 3 * 439 * 7639
2012/11/27 20121127 13 * 1547779
2012/11/28 20121128 2^3 * 29 * 86729
2012/11/29 20121129 3^6 * 7 * 3943
2012/11/30 20121130 2 * 5 * 2012113
2012/12/1 20121201 3^2 * 31 * 41 * 1759
2012/12/2 20121202 2 * 10060601
2012/12/3 20121203 151 * 133253
2012/12/4 20121204 2^2 * 3 * 1676767
2012/12/5 20121205 5 * 13 * 23 * 43 * 313
2012/12/6 20121206 2 * 7 * 1437229
2012/12/7 20121207 3 * 131 * 51199
2012/12/8 20121208 2^3 * 271 * 9281
2012/12/9 20121209 19 * 73 * 89 * 163
2012/12/10 20121210 2 * 3^4 * 5 * 24841
2012/12/11 20121211 11^2 * 179 * 929
2012/12/12 20121212 2^2 * 5030303
2012/12/13 20121213 3 * 7^2 * 136879
2012/12/14 20121214 2 * 619 * 16253
2012/12/15 20121215 5 * 29 * 193 * 719
2012/12/16 20121216 2^7 * 3 * 61 * 859
2012/12/17 20121217 17 * 47 * 25183
2012/12/18 20121218 2 * 13 * 419 * 1847
2012/12/19 20121219 3^2 * 1013 * 2207
2012/12/20 20121220 2^2 * 5 * 7 * 101 * 1423
2012/12/21 20121221 79 * 254699
2012/12/22 20121222 2 * 3 * 11 * 304867
2012/12/23 20121223 139 * 144757
2012/12/24 20121224 2^3 * 2515153
2012/12/25 20121225 3 * 5^2 * 268283
2012/12/26 20121226 2 * 10060613
2012/12/27 20121227 7 * 181 * 15881
2012/12/28 20121228 2^2 * 3^2 * 19 * 23 * 1279
2012/12/29 20121229 37 * 691 * 787
2012/12/30 20121230 2 * 5 * 2012123
2012/12/31 20121231 3 * 13 * 515929