├── bin
├── classes.dex
├── resources.ap_
├── FelicaEdit.apk
└── jp
│ └── co
│ └── yumemi
│ ├── nfc
│ ├── NFCUtil.class
│ ├── NfcTag.class
│ ├── FelicaTag.class
│ ├── NullNfcTag.class
│ ├── TagFactory.class
│ ├── NfcException.class
│ ├── ReadResponse.class
│ ├── FelicaTag$IDm.class
│ ├── FelicaTag$PMm.class
│ ├── PollingResponse.class
│ ├── FelicaTag$SystemCode.class
│ ├── FelicaTag$ServiceCode.class
│ ├── FelicaTag$CommandPacket.class
│ └── FelicaTag$CommandResponse.class
│ ├── rd
│ ├── misc
│ │ ├── Util.class
│ │ └── SimpleAlert.class
│ └── felicaedit
│ │ ├── R.class
│ │ ├── R$id.class
│ │ ├── R$xml.class
│ │ ├── R$array.class
│ │ ├── R$attr.class
│ │ ├── EditBlock.class
│ │ ├── FelicaEdit.class
│ │ ├── R$drawable.class
│ │ ├── R$layout.class
│ │ ├── R$string.class
│ │ ├── SystemList.class
│ │ └── ServiceList.class
│ └── LICENSE
├── res
├── drawable-hdpi
│ └── icon.png
├── drawable-ldpi
│ └── icon.png
├── drawable-mdpi
│ └── icon.png
├── xml
│ └── nfc_filter.xml
├── layout
│ ├── service.xml
│ ├── edit_block_byte.xml
│ ├── edit_block.xml
│ └── main.xml
└── values
│ └── strings.xml
├── .classpath
├── README.jp.txt
├── default.properties
├── README.txt
├── README.en.txt
├── src
└── jp
│ └── co
│ └── yumemi
│ ├── nfc
│ ├── NFCUtil.java
│ ├── TagFactory.java
│ ├── NfcException.java
│ ├── NfcTag.java
│ ├── PollingResponse.java
│ ├── ReadResponse.java
│ └── FelicaTag.java
│ ├── LICENSE
│ └── rd
│ ├── misc
│ ├── SimpleAlert.java
│ └── Util.java
│ └── felicaedit
│ ├── SystemList.java
│ ├── FelicaEdit.java
│ ├── EditBlock.java
│ └── ServiceList.java
├── LICENSE
├── .project
├── proguard.cfg
├── AndroidManifest.xml
└── gen
└── jp
└── co
└── yumemi
└── rd
└── felicaedit
└── R.java
/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/classes.dex
--------------------------------------------------------------------------------
/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/resources.ap_
--------------------------------------------------------------------------------
/bin/FelicaEdit.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/FelicaEdit.apk
--------------------------------------------------------------------------------
/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/NFCUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/NFCUtil.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/NfcTag.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/NfcTag.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/FelicaTag.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/FelicaTag.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/NullNfcTag.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/NullNfcTag.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/TagFactory.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/TagFactory.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/misc/Util.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/misc/Util.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/NfcException.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/NfcException.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/ReadResponse.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/ReadResponse.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/FelicaTag$IDm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/FelicaTag$IDm.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/FelicaTag$PMm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/FelicaTag$PMm.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/PollingResponse.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/PollingResponse.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R$id.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R$xml.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R$xml.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/misc/SimpleAlert.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/misc/SimpleAlert.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R$array.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R$array.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R$attr.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/FelicaTag$SystemCode.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/FelicaTag$SystemCode.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/EditBlock.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/EditBlock.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/FelicaEdit.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/FelicaEdit.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R$drawable.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R$layout.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/R$string.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/SystemList.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/SystemList.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/FelicaTag$ServiceCode.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/FelicaTag$ServiceCode.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/rd/felicaedit/ServiceList.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/rd/felicaedit/ServiceList.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/FelicaTag$CommandPacket.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/FelicaTag$CommandPacket.class
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/nfc/FelicaTag$CommandResponse.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mokemokechicken/Android_NFC_FelicaEdit/HEAD/bin/jp/co/yumemi/nfc/FelicaTag$CommandResponse.class
--------------------------------------------------------------------------------
/res/xml/nfc_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | android.nfc.tech.NfcF
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.jp.txt:
--------------------------------------------------------------------------------
1 | ■ これは何?
2 | AndroidのNFC機能を使って、FeliCaのデータを読み書きするアプリケーションです。
3 |
4 | ■ 注意事項
5 | 基本的に全て無保証ですので、自己責任においてご利用下さい。
6 | 特に下記の点にご注意下さい。
7 |
8 | * 本アプリケーションは、@hide 扱いのJava Classを使用しているため、NexusSのAndroid2.3での動作は確認していますが、他のデバイス、他のOSバージョンで動く保証はありません。
9 | * 本アプリケーションは、実際にFeliCaの非暗号化&書き込み可能領域のデータを更新することができますが、正常に更新するという保証もありませんし、更新した結果問題が発生した場合も責任は負えません。
10 |
11 |
--------------------------------------------------------------------------------
/res/layout/service.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-10
12 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | * WHAT IS THIS?
2 | It is an application which can read and write FeliCa data using Android NFC function.
3 |
4 | * BE CAREFUL!
5 | * This application uses Java Class marked @hide, and it can run on NexusS with AndroidOS2.3. But, there is no guarantee with other devices or other OS versions.
6 | * This application can write actually data into non-encrypted and writable memory of FeliCa. But, there is no guarantee of normal writing and the result of writing.
7 |
8 |
--------------------------------------------------------------------------------
/README.en.txt:
--------------------------------------------------------------------------------
1 | * WHAT IS THIS?
2 | It is an application which can read and write FeliCa data using Android NFC function.
3 |
4 | * BE CAREFUL!
5 | * This application uses Java Class marked @hide, and it can run on NexusS with AndroidOS2.3. But, there is no guarantee with other devices or other OS versions.
6 | * This application can write actually data into non-encrypted and writable memory of FeliCa. But, there is no guarantee of normal writing and the result of writing.
7 |
8 |
--------------------------------------------------------------------------------
/res/layout/edit_block_byte.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/layout/edit_block.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/nfc/NFCUtil.java:
--------------------------------------------------------------------------------
1 | package jp.co.yumemi.nfc;
2 |
3 | import android.nfc.Tag;
4 | import android.nfc.tech.TagTechnology;
5 |
6 | public class NFCUtil {
7 | static public boolean hasTech(Tag tag, String klassName) {
8 | for (String tech : tag.getTechList()) {
9 | if (tech.equals(klassName)) {
10 | return true;
11 | }
12 | }
13 | return false;
14 | }
15 |
16 | static public boolean hasTech(Tag tag, Class extends TagTechnology> tech) {
17 | return hasTech(tag, tech.getCanonicalName());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2011 YUMEMI Inc.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/bin/jp/co/yumemi/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2011 YUMEMI Inc.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2011 YUMEMI Inc.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/nfc/TagFactory.java:
--------------------------------------------------------------------------------
1 | package jp.co.yumemi.nfc;
2 |
3 | import android.content.Intent;
4 | import android.nfc.NfcAdapter;
5 | import android.nfc.Tag;
6 | import android.nfc.tech.MifareClassic;
7 | import android.nfc.tech.NfcF;
8 | import android.os.Parcelable;
9 |
10 | public class TagFactory {
11 |
12 | public static NfcTag create(Intent intent) {
13 | return create(intent.getParcelableExtra(NfcAdapter.EXTRA_TAG));
14 | }
15 |
16 | public static NfcTag create(Parcelable tag) {
17 | if (tag != null && tag instanceof Tag) {
18 | Tag t = (Tag)tag;
19 | if (NFCUtil.hasTech(t, NfcF.class)) {
20 | return new FelicaTag(t);
21 | } else {
22 | return new NfcTag(t);
23 | }
24 | }
25 | return new NullNfcTag(null);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/nfc/NfcException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | package jp.co.yumemi.nfc;
14 |
15 | public class NfcException extends Exception{
16 | private static final long serialVersionUID = 1L;
17 | public NfcException(Exception e) {
18 | super(e);
19 | }
20 | public NfcException(String s) {
21 | super(s);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | FeliCaをかざしてみてください
4 | FelicaEdit
5 | システムコード検索
6 | 終了
7 | サービス一覧
8 | Tap to Edit Data
9 |
10 | - 0
11 | - 1
12 | - 2
13 | - 3
14 | - 4
15 | - 5
16 | - 6
17 | - 7
18 | - 8
19 | - 9
20 | - A
21 | - B
22 | - C
23 | - D
24 | - E
25 | - F
26 |
27 | Save
28 |
29 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | FelicaEdit
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembernames class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembernames class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers enum * {
30 | public static **[] values();
31 | public static ** valueOf(java.lang.String);
32 | }
33 |
34 | -keep class * implements android.os.Parcelable {
35 | public static final android.os.Parcelable$Creator *;
36 | }
37 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/gen/jp/co/yumemi/rd/felicaedit/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package jp.co.yumemi.rd.felicaedit;
9 |
10 | public final class R {
11 | public static final class array {
12 | public static final int hex=0x7f060000;
13 | }
14 | public static final class attr {
15 | }
16 | public static final class drawable {
17 | public static final int icon=0x7f020000;
18 | }
19 | public static final class id {
20 | public static final int btn_save=0x7f070000;
21 | public static final int data_list_view=0x7f070001;
22 | public static final int scrollView1=0x7f070004;
23 | public static final int service_list=0x7f070006;
24 | public static final int sp1=0x7f070002;
25 | public static final int sp2=0x7f070003;
26 | public static final int textView1=0x7f070005;
27 | }
28 | public static final class layout {
29 | public static final int edit_block=0x7f030000;
30 | public static final int edit_block_byte=0x7f030001;
31 | public static final int main=0x7f030002;
32 | public static final int service=0x7f030003;
33 | }
34 | public static final class string {
35 | public static final int EditBlockTitle=0x7f050005;
36 | public static final int app_name=0x7f050001;
37 | public static final int dump=0x7f050002;
38 | public static final int end=0x7f050003;
39 | public static final int hello=0x7f050000;
40 | public static final int save=0x7f050006;
41 | public static final int service_list_title=0x7f050004;
42 | }
43 | public static final class xml {
44 | public static final int nfc_filter=0x7f040000;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/rd/misc/SimpleAlert.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | package jp.co.yumemi.rd.misc;
14 |
15 | import android.app.Activity;
16 | import android.app.AlertDialog;
17 | import android.content.DialogInterface;
18 | import android.content.DialogInterface.OnClickListener;
19 |
20 | /**
21 | * 簡易メッセージダイアログ用クラス。
22 | * @author morishita_2
23 | *
24 | */
25 | public class SimpleAlert implements OnClickListener {
26 | private final Activity parent;
27 |
28 | private AlertDialog.Builder builder;
29 | public AlertDialog.Builder getBuilder() {
30 | return builder;
31 | }
32 |
33 | private boolean finishParent;
34 | public SimpleAlert(Activity activity) {
35 | this.parent = activity;
36 | }
37 |
38 | /**
39 | * ダイアログにメッセージとOKボタンを表示します。
40 | * @param message 表示するMessage
41 | * @param finishParent if true ならば、閉じたときに parent.finish() を呼び出します。
42 | */
43 | public void show(String message, boolean finishParent) {
44 | if (builder == null) {
45 | initBuilder();
46 | }
47 | this.finishParent = finishParent;
48 | builder.setMessage(message);
49 | builder.create().show();
50 | }
51 |
52 | public AlertDialog.Builder initBuilder() {
53 | builder = new AlertDialog.Builder(parent);
54 | builder.setPositiveButton("OK", this);
55 | return builder;
56 | }
57 |
58 | @Override
59 | public void onClick(DialogInterface dialog, int which) {
60 | if (finishParent) {
61 | this.parent.finish();
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/nfc/NfcTag.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | /*
14 | * 本packageは、
15 | * kazzz さんの nfc-felica(http://d.hatena.ne.jp/Kazzz/20110130/p1) からソースを色々複製して利用しています。
16 | * 整理しようと思ったのですが、現状あまり整理できてないです。。
17 | * 最終的には、MIFARE系,FeliCa系,NFC(NDEF)系を、上手く処理できるように整理できると良いと思っています。
18 | */
19 |
20 |
21 | /*
22 | * Changes
23 | * * 2011/2/5: k_morishita
24 | * ** net.kazzz.felica.lib.FeliCaLib.executeRaw() を複製して修正。
25 | */
26 |
27 |
28 | package jp.co.yumemi.nfc;
29 |
30 | import jp.co.yumemi.rd.misc.Util;
31 | import android.content.Intent;
32 | import android.nfc.NfcAdapter;
33 | import android.nfc.Tag;
34 | import android.os.Parcelable;
35 |
36 | public class NfcTag {
37 | static private final String TAG = "NfcTag";
38 |
39 | protected final Tag tag;
40 | public Tag getTag() {
41 | return tag;
42 | }
43 |
44 | public static final String TYPE_NULL = "NULL";
45 | public static final String TYPE_OTHER = "OTHER";
46 | public static final String TYPE_FELICA = "FeliCa";
47 |
48 | public NfcTag(Tag tag) {
49 | this.tag = tag;
50 | }
51 |
52 | public byte[] getId() {
53 | return tag.getId();
54 | }
55 |
56 | public void putTagService(Intent intent) {
57 | intent.putExtra(NfcAdapter.EXTRA_TAG, tag);
58 | }
59 |
60 | public String getType() {
61 | return TYPE_OTHER;
62 | }
63 |
64 | public String getTechListAsString() {
65 | return Util.getHexString(tag.getTechList());
66 | }
67 | }
68 |
69 | class NullNfcTag extends NfcTag {
70 | public NullNfcTag(Tag tag) {
71 | super(tag);
72 | }
73 |
74 | public String getType() {
75 | return TYPE_NULL;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/nfc/PollingResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | /*
14 | * Changes
15 | * * 2010/2/5: k_morishita
16 | * ** net.kazzz.felica.command.PollingResponse から複製して修正。
17 | */
18 |
19 | package jp.co.yumemi.nfc;
20 |
21 | import java.util.Arrays;
22 |
23 | import jp.co.yumemi.nfc.FelicaTag.CommandResponse;
24 | import jp.co.yumemi.nfc.FelicaTag.PMm;
25 | import jp.co.yumemi.rd.misc.Util;
26 |
27 | /**
28 | * Pollingコマンドのレスポンスを抽象化したクラスを提供します
29 | *
30 | * @author Kazzz
31 | * @date 2011/01/22
32 | * @since Android API Level 9
33 | *
34 | */
35 |
36 | public class PollingResponse extends CommandResponse {
37 | final PMm pmm;
38 | final byte[] requestData;
39 | /**
40 | * コンストラクタ
41 | *
42 | * @param data コマンド実行結果で戻ったバイト列をセット
43 | */
44 | public PollingResponse(CommandResponse response) {
45 | super(response);
46 | this.pmm = new PMm(Arrays.copyOfRange(this.data, 0, 8));
47 | this.requestData = Arrays.copyOfRange(this.data, 8, data.length);
48 | }
49 | /**
50 | * PMmを取得します
51 | *
52 | * @return PMm pmmが戻ります
53 | */
54 | public PMm getPMm() {
55 | return this.pmm;
56 | }
57 | /* (non-Javadoc)
58 | * @see java.lang.Object#toString()
59 | */
60 | @Override
61 | public String toString() {
62 | StringBuilder sb = new StringBuilder();
63 | sb.append("FeliCa レスポンス パケット \n");
64 | sb.append(" コマンド名 :" + Util.getHexString(this.responseCode) + "\n");
65 | sb.append(" データ長 : " + Util.getHexString(this.length) + "\n");
66 | sb.append(" コマンドコード : " + Util.getHexString(this.responseCode) + "\n");
67 | if ( this.idm != null )
68 | sb.append(" " + this.idm.toString() + "\n");
69 | if ( this.pmm != null )
70 | sb.append(" " + this.pmm.toString() + "\n");
71 | sb.append(" データ: " + Util.getHexString(this.data) + "\n");
72 | return sb.toString();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/rd/felicaedit/SystemList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | package jp.co.yumemi.rd.felicaedit;
14 |
15 | import jp.co.yumemi.nfc.FelicaTag;
16 | import jp.co.yumemi.nfc.NfcException;
17 | import jp.co.yumemi.nfc.TagFactory;
18 | import jp.co.yumemi.nfc.FelicaTag.SystemCode;
19 | import android.app.ListActivity;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.view.View;
23 | import android.widget.ArrayAdapter;
24 | import android.widget.ListView;
25 |
26 | /**
27 | * 1つのFeliCaに含まれるシステムコードの一覧を表示する Activity
28 | * @author morishita_2
29 | *
30 | */
31 | public class SystemList extends ListActivity {
32 | private SystemCode[] systemCodeList;
33 | private FelicaTag felica;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 |
39 | Intent intent = getIntent();
40 | felica = (FelicaTag)TagFactory.create(intent);
41 | systemCodeList = null;
42 | try {
43 | systemCodeList = felica.getSystemCodeList();
44 | ArrayAdapter adapter = new ArrayAdapter(this,
45 | android.R.layout.simple_list_item_1, systemCodeList);
46 | // アダプタを設定
47 | setListAdapter(adapter);
48 | } catch (NfcException e) {
49 | ArrayAdapter adapter = new ArrayAdapter(this,
50 | android.R.layout.simple_list_item_1, new String[]{"読込みに失敗しました"});
51 | // アダプタを設定
52 | setListAdapter(adapter);
53 | }
54 | }
55 |
56 | @Override
57 | protected void onListItemClick(ListView l, View v, int position, long id) {
58 | super.onListItemClick(l, v, position, id);
59 | if (systemCodeList == null) return;
60 | SystemCode sc = systemCodeList[position];
61 | Intent intent = new Intent(SystemList.this, ServiceList.class);
62 | felica.putTagService(intent);
63 | // intent.putExtra(NfcTag.ANDROID_NFC_EXTRA_TAG, felica.getTagService());
64 | intent.putExtra(SystemCode.class.getCanonicalName(), sc.getBytes());
65 | startActivity(intent);
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/rd/felicaedit/FelicaEdit.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | package jp.co.yumemi.rd.felicaedit;
14 |
15 | import jp.co.yumemi.nfc.NfcTag;
16 | import jp.co.yumemi.nfc.TagFactory;
17 | import jp.co.yumemi.rd.misc.Util;
18 | import android.app.Activity;
19 | import android.content.Intent;
20 | import android.nfc.NfcAdapter;
21 | import android.os.Bundle;
22 | import android.util.Log;
23 | import android.widget.TextView;
24 | import android.widget.Toast;
25 |
26 | /**
27 | * 起動時に呼び出される Activity。
28 | * 結局あまり仕事していないので不要かもしれない。
29 | *
30 | * 何度か起動しているうちに、ちゃんとTagを読まなくなることがあります(><).
31 | * その場合は、アプリを一旦終了してから、かざしてみてください。
32 | * @author k_morishita
33 | */
34 | public class FelicaEdit extends Activity {
35 | static private String TAG = "FelicaEdit";
36 | private NfcTag nfcTag;
37 |
38 | /** Called when the activity is first created. */
39 | @Override
40 | public void onCreate(Bundle savedInstanceState) {
41 | Log.d(TAG, "onCreate");
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.main);
44 |
45 | Intent intent = this.getIntent();
46 | String action = intent.getAction();
47 |
48 | if (!NfcAdapter.getDefaultAdapter().isEnabled()) {
49 | setText("NFCが使えません");
50 | } else {
51 | if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
52 | this.nfcTag = TagFactory.create(intent);
53 | String txt = action + "\n" + nfcTag.getTechListAsString();
54 | Toast.makeText(this, txt, 15).show();
55 | scan();
56 | }
57 | }
58 | }
59 |
60 | private void setText(String text) {
61 | TextView tv = (TextView)findViewById(R.id.textView1);
62 | tv.setText(text);
63 | }
64 |
65 | private void scan() {
66 | if (nfcTag == null || !nfcTag.getType().equals(NfcTag.TYPE_FELICA)) {
67 | StringBuffer sb = new StringBuffer();
68 | sb.append("FeliCaカードではないようです\n");
69 | sb.append("TagType: " + nfcTag.getType()+"\n");
70 | sb.append(Util.getHexString(nfcTag.getId())+"\n");
71 | if (nfcTag != null) {
72 | sb.append(nfcTag.getTechListAsString()+"\n");
73 | }
74 | setText(sb.toString());
75 | return;
76 | }
77 | Intent intent = new Intent(FelicaEdit.this, SystemList.class);
78 | nfcTag.putTagService(intent);
79 | startActivity(intent);
80 | finish();
81 | }
82 |
83 | }
--------------------------------------------------------------------------------
/src/jp/co/yumemi/nfc/ReadResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | /*
14 | * Changes
15 | * * 2010/2/5: k_morishita
16 | * ** net.kazzz.felica.command.ReadResponse から複製して修正。
17 | */
18 |
19 | package jp.co.yumemi.nfc;
20 |
21 | import java.util.Arrays;
22 |
23 | import jp.co.yumemi.nfc.FelicaTag.CommandResponse;
24 | import jp.co.yumemi.rd.misc.Util;
25 |
26 | /**
27 | * Read コマンドのレスポンスを抽象化したクラスを提供します
28 | *
29 | * @author Kazzz
30 | * @date 2011/01/22
31 | * @since Android API Level 9
32 | *
33 | */
34 |
35 | public class ReadResponse extends CommandResponse {
36 | final int statusFlag1;
37 | final int statusFlag2;
38 | final int blockCount;
39 | final byte[] blockData;
40 | /**
41 | * コンストラクタ
42 | *
43 | * @param data コマンド実行結果で戻ったバイト列をセット
44 | */
45 | public ReadResponse(CommandResponse response) {
46 | super(response);
47 | this.statusFlag1 = this.data[0];
48 | this.statusFlag2 = this.data[1];
49 | if ( this.getStatusFlag1() == 0 ) {
50 | this.blockCount = this.data[2];
51 | this.blockData = Arrays.copyOfRange(this.data, 3, data.length);
52 | } else {
53 | this.blockCount = 0;
54 | this.blockData = null;
55 | }
56 | }
57 |
58 | /**
59 | * statusFlag1を取得します
60 | * @return int statusFlag1が戻ります
61 | */
62 | public int getStatusFlag1() {
63 | return this.statusFlag1;
64 | }
65 |
66 | /**
67 | * statusFlag2を取得します
68 | * @return int statusFlag2が戻ります
69 | */
70 | public int getStatusFlag2() {
71 | return this.statusFlag2;
72 | }
73 |
74 | /**
75 | * blockDataを取得します
76 | * @return byte[] blockDataが戻ります
77 | */
78 | public byte[] getBlockData() {
79 | return this.blockData;
80 | }
81 |
82 | /**
83 | * blockCountを取得します
84 | * @return int blockCountが戻ります
85 | */
86 | public int getBlockCount() {
87 | return this.blockCount;
88 | }
89 |
90 | /* (non-Javadoc)
91 | * @see java.lang.Object#toString()
92 | */
93 | @Override
94 | public String toString() {
95 | StringBuilder sb = new StringBuilder();
96 | sb.append("FeliCa レスポンス パケット \n");
97 | sb.append(" コマンドコード : " + Util.getHexString(this.responseCode) + "\n");
98 | sb.append(" データ長 : " + Util.getHexString(this.length) + "\n");
99 | if ( this.idm != null )
100 | sb.append(" " + this.idm.toString() + "\n");
101 | sb.append(" ステータスフラグ1 : " + Util.getHexString((byte)(this.statusFlag1 & 0xff)) + "\n");
102 | sb.append(" ステータスフラグ2 : " + Util.getHexString((byte)(this.statusFlag2 & 0xff)) + "\n");
103 | if ( this.blockData != null )
104 | sb.append(" ブロックデータ: " + Util.getHexString(this.blockData) + "\n");
105 | return sb.toString();
106 | }
107 | }
108 |
109 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/rd/felicaedit/EditBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 | package jp.co.yumemi.rd.felicaedit;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | import jp.co.yumemi.nfc.FelicaTag;
19 | import jp.co.yumemi.nfc.NfcException;
20 | import jp.co.yumemi.nfc.TagFactory;
21 | import jp.co.yumemi.nfc.FelicaTag.ServiceCode;
22 | import jp.co.yumemi.nfc.FelicaTag.SystemCode;
23 | import jp.co.yumemi.rd.misc.SimpleAlert;
24 | import android.app.Activity;
25 | import android.app.AlertDialog;
26 | import android.app.Dialog;
27 | import android.content.DialogInterface;
28 | import android.content.Intent;
29 | import android.os.Bundle;
30 | import android.view.LayoutInflater;
31 | import android.view.View;
32 | import android.widget.AdapterView;
33 | import android.widget.ArrayAdapter;
34 | import android.widget.ListView;
35 | import android.widget.Spinner;
36 | import android.widget.AdapterView.OnItemClickListener;
37 |
38 | /**
39 | * 特定のサービスコード・ブロックを編集するための Activity
40 | * @author k_morishita
41 | */
42 | public class EditBlock extends Activity implements DialogInterface.OnClickListener, View.OnClickListener, OnItemClickListener {
43 | private static final String TAG = "EditBlock";
44 | private static final String BYTE_DATA = "data";
45 | public static final String BLOCK_INDEX = "BLOCK_INDEX";
46 | private static final int BYTE_DIALOG = 1;
47 |
48 | private FelicaTag felica; // FeliCa オブジェクト
49 | private SystemCode systemCode; // システムコード
50 | private ServiceCode serviceCode; // サービスコード
51 | private int blockIndex; // 編集対象BlockのIndex
52 | private byte[] blockData; // 対象BlockのData
53 |
54 | @Override
55 | protected void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 |
58 | Intent intent = getIntent();
59 | this.felica = (FelicaTag)TagFactory.create(intent);
60 | this.systemCode = new SystemCode(intent.getByteArrayExtra(SystemCode.class.getCanonicalName()));
61 | this.serviceCode = new ServiceCode(intent.getByteArrayExtra(ServiceCode.class.getCanonicalName()));
62 | this.blockIndex = intent.getIntExtra(BLOCK_INDEX, -1);
63 | setContentView(R.layout.edit_block);
64 | findViewById(R.id.btn_save).setOnClickListener(this);
65 | ((ListView)findViewById(R.id.data_list_view)).setOnItemClickListener(this);
66 | try {
67 | felica.polling(systemCode);
68 | blockData = felica.readWithoutEncryption(serviceCode, blockIndex);
69 | updateList();
70 | } catch (NfcException e) {
71 | new SimpleAlert(this).show("データを読み込めませんでした", true);
72 | }
73 | }
74 |
75 | /**
76 | * 画面を更新する
77 | */
78 | private void updateList() {
79 | if (blockData == null) return;
80 | List byteList = new ArrayList();
81 | for (int i=0; i adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, byteList);
85 | // アダプタを設定
86 | ListView lv = (ListView)findViewById(R.id.data_list_view);
87 | lv.setAdapter(adapter);
88 | }
89 |
90 | /**
91 | * 編集用に選択された位置を保持
92 | */
93 | private int bytePosition;
94 |
95 | /**
96 | * BlockDataの中のどのByteを編集するか、という画面で、1つの項目がTapされた。
97 | */
98 | @Override
99 | public void onItemClick(AdapterView> l, View v, int position, long id) {
100 | if (blockData == null) return;
101 | byte data = blockData[position];
102 | Bundle bundle = new Bundle();
103 | bundle.putByte(BYTE_DATA, data);
104 | bytePosition = position;
105 | showDialog(BYTE_DIALOG, bundle);
106 | }
107 |
108 | /**
109 | * Save ボタンが押された。書込みを行い、呼び出し元Activityに戻ります。
110 | */
111 | @Override
112 | public void onClick(View v) {
113 | SimpleAlert sa = new SimpleAlert(this);
114 | if (blockData != null) {
115 | try {
116 | if (felica.writeWithoutEncryption(serviceCode, blockIndex, blockData) == 0) {
117 |
118 | sa.show("保存しました", true);
119 | } else {
120 | sa.show("保存失敗しました", true);
121 | }
122 | } catch (NfcException e) {
123 | sa.show("保存に失敗しました\n"+e.getMessage(), true);
124 | }
125 | }
126 | }
127 |
128 | //
129 | // 個々以降は、 ByteEdit Dialog 用の部分です。まとまりが悪い。。
130 | //
131 | /**
132 | * 最初に編集用ダイアログ(Selectが2つ並んでいるダイアログ)が呼び出されたときに、実行されます。
133 | */
134 | @Override
135 | protected Dialog onCreateDialog(int id, Bundle args) {
136 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
137 | LayoutInflater factory = LayoutInflater.from(this);
138 | final View inputView = factory.inflate(R.layout.edit_block_byte, null);
139 | builder.setView(inputView)
140 | .setTitle("入力してください")
141 | .setPositiveButton("OK", this)
142 | .setNegativeButton("CANCEL", this);
143 | return builder.create();
144 | }
145 |
146 | private Spinner sp1;
147 | private Spinner sp2;
148 | /**
149 | * 編集用ダイアログが呼び出される度に実行されます。
150 | */
151 | @Override
152 | protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
153 | super.onPrepareDialog(id, dialog, args);
154 | sp1 = (Spinner)dialog.findViewById(R.id.sp1);
155 | sp2 = (Spinner)dialog.findViewById(R.id.sp2);
156 | byte data = args.getByte(BYTE_DATA);
157 | sp1.setSelection((int)((data >>> 4) & 0x0F)); // 元データをデフォルト値として設定
158 | sp2.setSelection((int)(data & 0x0F)); // 元データをデフォルト値として設定
159 | }
160 |
161 | /**
162 | * ByteEdit Dialog で OK か NG が押された。
163 | */
164 | @Override
165 | public void onClick(DialogInterface dialog, int which) {
166 | switch(which) {
167 | case DialogInterface.BUTTON_POSITIVE:
168 | byte data = (byte)((sp1.getSelectedItemPosition() << 4) + sp2.getSelectedItemPosition());
169 | blockData[bytePosition] = data;
170 | updateList();
171 | break;
172 |
173 | case DialogInterface.BUTTON_NEGATIVE:
174 | break;
175 | }
176 | sp1 = sp2 = null;
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/src/jp/co/yumemi/rd/felicaedit/ServiceList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | * Unless required by applicable law or agreed to in writing, software
7 | * distributed under the License is distributed on an "AS IS" BASIS,
8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 | * See the License for the specific language governing permissions and
10 | * limitations under the License.
11 | */
12 |
13 |
14 | package jp.co.yumemi.rd.felicaedit;
15 |
16 | import java.util.ArrayList;
17 | import java.util.HashMap;
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | import jp.co.yumemi.nfc.FelicaTag;
22 | import jp.co.yumemi.nfc.NfcException;
23 | import jp.co.yumemi.nfc.TagFactory;
24 | import jp.co.yumemi.nfc.FelicaTag.ServiceCode;
25 | import jp.co.yumemi.nfc.FelicaTag.SystemCode;
26 | import jp.co.yumemi.rd.misc.SimpleAlert;
27 | import jp.co.yumemi.rd.misc.Util;
28 | import android.app.Activity;
29 | import android.content.Intent;
30 | import android.os.Bundle;
31 | import android.view.View;
32 | import android.widget.ExpandableListAdapter;
33 | import android.widget.ExpandableListView;
34 | import android.widget.SimpleExpandableListAdapter;
35 | import android.widget.TextView;
36 |
37 | /**
38 | * 1つのシステムコードに含まれるサービスの一覧を表示するActivity.
39 | * @author morishita_2
40 | */
41 | public class ServiceList extends Activity implements ExpandableListView.OnChildClickListener{
42 | private List serviceCodeList;
43 | private FelicaTag felica;
44 | private SystemCode systemCode;
45 |
46 | List>> childData;
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | setContentView(R.layout.service);
52 | setTitle(R.string.service_list_title);
53 | Intent intent = getIntent();
54 | this.felica = (FelicaTag)TagFactory.create(intent);
55 | this.systemCode = new SystemCode(intent.getByteArrayExtra(SystemCode.class.getCanonicalName()));
56 | // ExpandableListView はなかなかややっこしい: see http://d.hatena.ne.jp/rudi/20100720/1279632918
57 | ExpandableListView listView = (ExpandableListView)findViewById(R.id.service_list);
58 | TextView tv = new TextView(this); // HeaderView用
59 | listView.addHeaderView(tv);
60 | try {
61 | felica.polling(systemCode);
62 | tv.setText(String.format("%s\nIDm: %s", systemCode.toString(), felica.getIdm().simpleToString()));
63 | this.serviceCodeList = felica.getServiceCodeList();
64 | List