Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

create project droiddancermotion reader/writer

  • Loading branch information...
commit f6821462ae2f96f2ad50fde42425e0f990f1d10a 1 parent fea59fa
@yokmama yokmama authored
Showing with 1,101 additions and 3 deletions.
  1. +28 −0 DroidDancerMotionReader/AndroidManifest.xml
  2. BIN  DroidDancerMotionReader/ic_launcher-web.png
  3. BIN  DroidDancerMotionReader/libs/android-support-v4.jar
  4. +20 −0 DroidDancerMotionReader/proguard-project.txt
  5. +14 −0 DroidDancerMotionReader/project.properties
  6. BIN  DroidDancerMotionReader/res/drawable-hdpi/ic_action_search.png
  7. BIN  DroidDancerMotionReader/res/drawable-hdpi/ic_launcher.png
  8. BIN  DroidDancerMotionReader/res/drawable-ldpi/ic_launcher.png
  9. BIN  DroidDancerMotionReader/res/drawable-mdpi/ic_action_search.png
  10. BIN  DroidDancerMotionReader/res/drawable-mdpi/ic_launcher.png
  11. BIN  DroidDancerMotionReader/res/drawable-xhdpi/ic_action_search.png
  12. BIN  DroidDancerMotionReader/res/drawable-xhdpi/ic_launcher.png
  13. +15 −0 DroidDancerMotionReader/res/layout/activity_main.xml
  14. +6 −0 DroidDancerMotionReader/res/menu/activity_main.xml
  15. +7 −0 DroidDancerMotionReader/res/values-large/dimens.xml
  16. +5 −0 DroidDancerMotionReader/res/values-v11/styles.xml
  17. +5 −0 DroidDancerMotionReader/res/values-v14/styles.xml
  18. +7 −0 DroidDancerMotionReader/res/values/dimens.xml
  19. +8 −0 DroidDancerMotionReader/res/values/strings.xml
  20. +5 −0 DroidDancerMotionReader/res/values/styles.xml
  21. +110 −0 DroidDancerMotionReader/src/com/example/droiddancermotionreader/MainActivity.java
  22. +9 −0 DroidDancerMotionReader/src/com/example/droiddancermotionreader/MotionData.java
  23. +65 −0 DroidDancerMotionReader/src/com/example/droiddancermotionreader/MotionItem.java
  24. +29 −0 DroidDancerMotionWriter/AndroidManifest.xml
  25. BIN  DroidDancerMotionWriter/ic_launcher-web.png
  26. BIN  DroidDancerMotionWriter/libs/android-support-v4.jar
  27. +20 −0 DroidDancerMotionWriter/proguard-project.txt
  28. +14 −0 DroidDancerMotionWriter/project.properties
  29. BIN  DroidDancerMotionWriter/res/drawable-hdpi/ic_action_search.png
  30. BIN  DroidDancerMotionWriter/res/drawable-hdpi/ic_launcher.png
  31. BIN  DroidDancerMotionWriter/res/drawable-ldpi/ic_launcher.png
  32. BIN  DroidDancerMotionWriter/res/drawable-mdpi/ic_action_search.png
  33. BIN  DroidDancerMotionWriter/res/drawable-mdpi/ic_launcher.png
  34. BIN  DroidDancerMotionWriter/res/drawable-xhdpi/ic_action_search.png
  35. BIN  DroidDancerMotionWriter/res/drawable-xhdpi/ic_launcher.png
  36. +115 −0 DroidDancerMotionWriter/res/layout/activity_edit.xml
  37. +46 −0 DroidDancerMotionWriter/res/layout/activity_main.xml
  38. +83 −0 DroidDancerMotionWriter/res/layout/list_item.xml
  39. +6 −0 DroidDancerMotionWriter/res/menu/activity_main.xml
  40. +7 −0 DroidDancerMotionWriter/res/values-large/dimens.xml
  41. +5 −0 DroidDancerMotionWriter/res/values-v11/styles.xml
  42. +5 −0 DroidDancerMotionWriter/res/values-v14/styles.xml
  43. +7 −0 DroidDancerMotionWriter/res/values/dimens.xml
  44. +8 −0 DroidDancerMotionWriter/res/values/strings.xml
  45. +5 −0 DroidDancerMotionWriter/res/values/styles.xml
  46. +70 −0 DroidDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/EditActivity.java
  47. +243 −0 DroidDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/MainActivity.java
  48. +65 −0 DroidDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/MotionItem.java
  49. +66 −0 DroidDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/MotionListAdapter.java
  50. +2 −2 DroidRobo01/.classpath
  51. +1 −1  DroidRobo01/project.properties
View
28 DroidDancerMotionReader/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.droiddancermotionreader"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="10"
+ android:targetSdkVersion="15" />
+ <uses-permission android:name="android.permission.NFC" />
+ <uses-feature android:name="android.hardware.nfc" android:required="true" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/title_activity_main"
+ android:launchMode="singleTop" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
View
BIN  DroidDancerMotionReader/ic_launcher-web.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionReader/libs/android-support-v4.jar
Binary file not shown
View
20 DroidDancerMotionReader/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
View
14 DroidDancerMotionReader/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-16
View
BIN  DroidDancerMotionReader/res/drawable-hdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionReader/res/drawable-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionReader/res/drawable-ldpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionReader/res/drawable-mdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionReader/res/drawable-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionReader/res/drawable-xhdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionReader/res/drawable-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
15 DroidDancerMotionReader/res/layout/activity_main.xml
@@ -0,0 +1,15 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_centerVertical="true"
+ android:padding="@dimen/padding_medium"
+ android:text="@string/hello_world"
+ tools:context=".MainActivity" />
+
+</RelativeLayout>
View
6 DroidDancerMotionReader/res/menu/activity_main.xml
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/menu_settings"
+ android:title="@string/menu_settings"
+ android:orderInCategory="100"
+ android:showAsAction="never" />
+</menu>
View
7 DroidDancerMotionReader/res/values-large/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <dimen name="padding_small">8dp</dimen>
+ <dimen name="padding_medium">16dp</dimen>
+ <dimen name="padding_large">16dp</dimen>
+
+</resources>
View
5 DroidDancerMotionReader/res/values-v11/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Holo.Light" />
+
+</resources>
View
5 DroidDancerMotionReader/res/values-v14/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
+
+</resources>
View
7 DroidDancerMotionReader/res/values/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <dimen name="padding_small">8dp</dimen>
+ <dimen name="padding_medium">8dp</dimen>
+ <dimen name="padding_large">16dp</dimen>
+
+</resources>
View
8 DroidDancerMotionReader/res/values/strings.xml
@@ -0,0 +1,8 @@
+<resources>
+
+ <string name="app_name">DroidDancerMotionReader</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="menu_settings">Settings</string>
+ <string name="title_activity_main">MainActivity</string>
+
+</resources>
View
5 DroidDancerMotionReader/res/values/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Light" />
+
+</resources>
View
110 DroidDancerMotionReader/src/com/example/droiddancermotionreader/MainActivity.java
@@ -0,0 +1,110 @@
+package com.example.droiddancermotionreader;
+
+import java.util.List;
+
+import android.nfc.NdefMessage;
+import android.nfc.NdefRecord;
+import android.nfc.NfcAdapter;
+import android.nfc.Tag;
+import android.nfc.tech.Ndef;
+import android.nfc.tech.NdefFormatable;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.support.v4.app.NavUtils;
+
+public class MainActivity extends Activity {
+ private static final String TAG = "DroidDancerMotionReader";
+ private NfcAdapter nfcadapter;
+ private IntentFilter[] nfcfilters = new IntentFilter[] {
+ new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED)
+ };
+ private String[][] nfctechLists = new String[][] {
+ new String[] {
+ Ndef.class.getName()
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ nfcadapter = NfcAdapter.getDefaultAdapter(this);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.activity_main, menu);
+ return true;
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ String action = intent.getAction();
+ if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
+ Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
+ NdefMessage[] msgs;
+ Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
+ if (rawMsgs != null) {
+ msgs = new NdefMessage[rawMsgs.length];
+ for (int i = 0; i < rawMsgs.length; i++) {
+ msgs[i] = (NdefMessage) rawMsgs[i];
+ }
+ readNdefMessages(tag, msgs);
+ }
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ nfcadapter.disableForegroundDispatch(this);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
+ getClass()), 0);
+ nfcadapter.enableForegroundDispatch(this, pendingIntent, nfcfilters, nfctechLists);
+ }
+
+ private MotionData readNdefMessages(Tag tag, NdefMessage[] msgs) {
+ MotionData motiondata = new MotionData();
+ for(NdefMessage msg : msgs){
+ NdefRecord rec = msg.getRecords()[0];
+ byte[] data = rec.getPayload();
+ motiondata.repeat = Byte.valueOf(data[0]);
+ int size = Byte.valueOf(data[1]);
+ Log.d(TAG, "repeat="+Byte.valueOf(motiondata.repeat).toString());
+ Log.d(TAG, "size"+size);
+ int pos=2;
+ for(int i=0; i<size; i++){
+ MotionItem item = new MotionItem();
+ item.setLed(data[pos++]==1);
+ item.setArmleft(data[pos++]);
+ item.setArmright(data[pos++]);
+ item.setRotleft(data[pos++]);
+ item.setRotright(data[pos++]);
+ item.setTime(data[pos++]);
+ motiondata.items.add(item);
+ Log.d(TAG, "led="+item.isLed());
+ Log.d(TAG, "armleft="+Byte.valueOf(item.getArmleft()).toString());
+ Log.d(TAG, "armright="+Byte.valueOf(item.getArmright()).toString());
+ Log.d(TAG, "rotleft="+Byte.valueOf(item.getRotleft()).toString());
+ Log.d(TAG, "rotright="+Byte.valueOf(item.getRotright()).toString());
+ Log.d(TAG, "time="+Byte.valueOf(item.getTime()).toString());
+
+ }
+ }
+ return motiondata;
+ }
+
+}
View
9 DroidDancerMotionReader/src/com/example/droiddancermotionreader/MotionData.java
@@ -0,0 +1,9 @@
+package com.example.droiddancermotionreader;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MotionData {
+ byte repeat;
+ List<MotionItem> items = new ArrayList<MotionItem>();
+}
View
65 DroidDancerMotionReader/src/com/example/droiddancermotionreader/MotionItem.java
@@ -0,0 +1,65 @@
+package com.example.droiddancermotionreader;
+
+import java.util.Random;
+
+public class MotionItem {
+ private static Random _rand = new Random(System.nanoTime());
+ private long uid;
+ private boolean led;
+ private byte armleft;
+ private byte armright;
+ private byte rotleft;
+ private byte rotright;
+ private byte time;
+
+ public MotionItem(){
+ uid = _rand.nextLong();
+ }
+
+ public long getUid() {
+ return uid;
+ }
+
+ public void setUid(long uid) {
+ this.uid = uid;
+ }
+
+ public boolean isLed() {
+ return led;
+ }
+ public void setLed(boolean led) {
+ this.led = led;
+ }
+ public byte getArmleft() {
+ return armleft;
+ }
+ public void setArmleft(byte armleft) {
+ this.armleft = armleft;
+ }
+ public byte getArmright() {
+ return armright;
+ }
+ public void setArmright(byte armright) {
+ this.armright = armright;
+ }
+ public byte getRotleft() {
+ return rotleft;
+ }
+ public void setRotleft(byte rotleft) {
+ this.rotleft = rotleft;
+ }
+ public byte getRotright() {
+ return rotright;
+ }
+ public void setRotright(byte rotright) {
+ this.rotright = rotright;
+ }
+ public byte getTime() {
+ return time;
+ }
+ public void setTime(byte time) {
+ this.time = time;
+ }
+
+
+}
View
29 DroidDancerMotionWriter/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="jp.co.kayo.android.droiddancermotionwriter"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="14"
+ android:targetSdkVersion="15" />
+ <uses-permission android:name="android.permission.NFC" />
+ <uses-feature android:name="android.hardware.nfc" android:required="true" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/title_activity_main"
+ android:launchMode="singleTop" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".EditActivity"></activity>
+ </application>
+
+</manifest>
View
BIN  DroidDancerMotionWriter/ic_launcher-web.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionWriter/libs/android-support-v4.jar
Binary file not shown
View
20 DroidDancerMotionWriter/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
View
14 DroidDancerMotionWriter/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-16
View
BIN  DroidDancerMotionWriter/res/drawable-hdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionWriter/res/drawable-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionWriter/res/drawable-ldpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionWriter/res/drawable-mdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionWriter/res/drawable-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionWriter/res/drawable-xhdpi/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  DroidDancerMotionWriter/res/drawable-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
115 DroidDancerMotionWriter/res/layout/activity_edit.xml
@@ -0,0 +1,115 @@
+<?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" >
+
+ <GridLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/GridLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:columnCount="2" >
+
+ <!-- LED -->
+
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="RED" />
+
+ <CheckBox
+ android:id="@+id/checkbox1"
+ android:layout_gravity="left"
+ android:checked="false" />
+
+ <Space android:layout_columnSpan="2" />
+ <!-- Arm -->
+
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Left Arm Power" />
+
+ <EditText
+ android:id="@+id/editText1"
+ android:inputType="number"
+ android:text="1" />
+
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Right Arm Power" />
+
+ <EditText
+ android:id="@+id/editText2"
+ android:layout_gravity="left"
+ android:inputType="number"
+ android:text="2" />
+
+ <!-- Rotate -->
+
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Left Mortor Power" />
+
+ <EditText
+ android:id="@+id/editText3"
+ android:layout_gravity="left"
+ android:inputType="number"
+ android:text="3" />
+
+ <TextView
+ android:layout_gravity="right"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Right Mortor Power" />
+
+ <EditText
+ android:id="@+id/editText4"
+ android:layout_gravity="left"
+ android:inputType="number"
+ android:text="4" />
+
+ <!-- Time -->
+
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Time" />
+
+ <EditText
+ android:id="@+id/editText5"
+ android:layout_gravity="left"
+ android:inputType="number"
+ android:text="5" />
+
+ <Space android:layout_columnSpan="2" />
+ </GridLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal" >
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Cancel" />
+
+ <Button
+ android:id="@+id/button2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Ok" />
+ </LinearLayout>
+
+</LinearLayout>
View
46 DroidDancerMotionWriter/res/layout/activity_main.xml
@@ -0,0 +1,46 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:gravity="center_vertical" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Repeat" />
+
+ <SeekBar
+ android:id="@+id/seekBar1"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:max="10"
+ android:progress="0" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="0" />
+ </LinearLayout>
+
+ <ListView
+ android:id="@+id/listView1"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1" >
+ </ListView>
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="Add" />
+
+</LinearLayout>
View
83 DroidDancerMotionWriter/res/layout/list_item.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/GridLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:columnCount="5" >
+
+ <!-- LED -->
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="RED" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_columnSpan="2"
+ android:layout_gravity="left"
+ android:text="true" />
+ <Space android:layout_columnSpan="2" />
+ <!-- Arm -->
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Left Arm Power" />
+
+ <TextView
+ android:id="@+id/textView2"
+ android:layout_columnSpan="2"
+ android:layout_gravity="fill_horizontal"
+ android:text="1" />
+
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Right Arm Power" />
+
+ <TextView
+ android:id="@+id/textView3"
+ android:layout_gravity="left"
+ android:text="2" />
+
+ <!-- Rotate -->
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Left Mortor Power" />
+
+ <TextView
+ android:id="@+id/textView4"
+ android:layout_gravity="left"
+ android:layout_columnSpan="2"
+ android:text="3" />
+
+ <TextView
+ android:layout_gravity="right"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Right Mortor Power" />
+
+ <TextView
+ android:id="@+id/textView5"
+ android:layout_gravity="left"
+ android:text="4" />
+
+ <!-- Time -->
+ <TextView
+ android:layout_gravity="left"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="Time" />
+
+ <TextView
+ android:id="@+id/textView6"
+ android:layout_gravity="left"
+ android:layout_columnSpan="2"
+ android:text="5" />
+ <Space android:layout_columnSpan="2" />
+
+</GridLayout>
View
6 DroidDancerMotionWriter/res/menu/activity_main.xml
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/menu_settings"
+ android:title="@string/menu_settings"
+ android:orderInCategory="100"
+ android:showAsAction="never" />
+</menu>
View
7 DroidDancerMotionWriter/res/values-large/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <dimen name="padding_small">8dp</dimen>
+ <dimen name="padding_medium">16dp</dimen>
+ <dimen name="padding_large">16dp</dimen>
+
+</resources>
View
5 DroidDancerMotionWriter/res/values-v11/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Holo.Light" />
+
+</resources>
View
5 DroidDancerMotionWriter/res/values-v14/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
+
+</resources>
View
7 DroidDancerMotionWriter/res/values/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <dimen name="padding_small">8dp</dimen>
+ <dimen name="padding_medium">8dp</dimen>
+ <dimen name="padding_large">16dp</dimen>
+
+</resources>
View
8 DroidDancerMotionWriter/res/values/strings.xml
@@ -0,0 +1,8 @@
+<resources>
+
+ <string name="app_name">DroidDancerMotionWriter</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="menu_settings">Settings</string>
+ <string name="title_activity_main">MainActivity</string>
+
+</resources>
View
5 DroidDancerMotionWriter/res/values/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Light" />
+
+</resources>
View
70 DroidDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/EditActivity.java
@@ -0,0 +1,70 @@
+package jp.co.kayo.android.droiddancermotionwriter;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.CheckBox;
+import android.widget.EditText;
+
+public class EditActivity extends Activity {
+ private long uid;
+ private CheckBox checkbox1;
+ private EditText editText1;
+ private EditText editText2;
+ private EditText editText3;
+ private EditText editText4;
+ private EditText editText5;
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit);
+
+ checkbox1 = (CheckBox)findViewById(R.id.checkbox1);
+ editText1 = (EditText)findViewById(R.id.editText1);
+ editText2 = (EditText)findViewById(R.id.editText2);
+ editText3 = (EditText)findViewById(R.id.editText3);
+ editText4 = (EditText)findViewById(R.id.editText4);
+ editText5 = (EditText)findViewById(R.id.editText5);
+
+ findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+ findViewById(R.id.button2).setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Intent data = new Intent();
+ data.putExtra("uid", uid);
+ data.putExtra("led", checkbox1.isChecked());
+ data.putExtra("armleft", Byte.parseByte(editText1.getText().toString()));
+ data.putExtra("armright", Byte.parseByte(editText2.getText().toString()));
+ data.putExtra("rotleft", Byte.parseByte(editText3.getText().toString()));
+ data.putExtra("rotright", Byte.parseByte(editText4.getText().toString()));
+ data.putExtra("time", Byte.parseByte(editText5.getText().toString()));
+ setResult(100, data);
+ finish();
+ }
+ });
+
+ Intent intent = getIntent();
+ if(intent != null){
+ uid = intent.getLongExtra("uid", 0);
+ checkbox1.setChecked(intent.getBooleanExtra("led", false));
+ editText1.setText(Byte.toString(intent.getByteExtra("armleft", (byte)0)));
+ editText2.setText(Byte.toString(intent.getByteExtra("armright", (byte)0)));
+ editText3.setText(Byte.toString(intent.getByteExtra("rotleft", (byte)0)));
+ editText4.setText(Byte.toString(intent.getByteExtra("rotright", (byte)0)));
+ editText5.setText(Byte.toString(intent.getByteExtra("time", (byte)0)));
+ }
+
+ }
+
+}
View
243 DroidDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/MainActivity.java
@@ -0,0 +1,243 @@
+
+package jp.co.kayo.android.droiddancermotionwriter;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import android.nfc.FormatException;
+import android.nfc.NdefMessage;
+import android.nfc.NdefRecord;
+import android.nfc.NfcAdapter;
+import android.nfc.Tag;
+import android.nfc.tech.Ndef;
+import android.nfc.tech.NdefFormatable;
+import android.os.Bundle;
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.SeekBar;
+import android.widget.Toast;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+import android.support.v4.app.NavUtils;
+
+public class MainActivity extends Activity {
+ private static final String TAG = "DroidDancerMotionWriter";
+ private TextView textView1;
+ private SeekBar seekBar1;
+ private ListView listView1;
+ private MotionListAdapter adapter;
+ private Button button1;
+ private List<MotionItem> items = new ArrayList<MotionItem>();
+ private NfcAdapter nfcadapter;
+ private IntentFilter[] nfcfilters = new IntentFilter[] {
+ new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED)
+ };
+ private String[][] nfctechLists = new String[][] {
+ new String[] {
+ Ndef.class.getName()
+ },
+ new String[] {
+ NdefFormatable.class.getName()
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ nfcadapter = NfcAdapter.getDefaultAdapter(this);
+
+ listView1 = (ListView) findViewById(R.id.listView1);
+ textView1 = (TextView) findViewById(R.id.textView1);
+ seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
+ seekBar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ textView1.setText(String.format("%2d", progress));
+
+ }
+ });
+ button1 = (Button) findViewById(R.id.button1);
+ button1.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ MotionItem item = new MotionItem();
+ item.setLed(false);
+ item.setArmleft((byte) 0);
+ item.setArmright((byte) 0);
+ item.setRotleft((byte) 0);
+ item.setRotright((byte) 0);
+ item.setTime((byte) 1);
+ items.add(item);
+ adapter.setData(items);
+ adapter.notifyDataSetChanged();
+ }
+ });
+
+ adapter = new MotionListAdapter(this);
+ listView1.setAdapter(adapter);
+ listView1.setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ MotionItem item = adapter.getItem(arg2);
+
+ Intent intent = new Intent(MainActivity.this, EditActivity.class);
+ intent.putExtra("uid", item.getUid());
+ intent.putExtra("led", item.isLed());
+ intent.putExtra("armleft", item.getArmleft());
+ intent.putExtra("armright", item.getArmright());
+ intent.putExtra("rotleft", item.getRotleft());
+ intent.putExtra("rotright", item.getRotright());
+ intent.putExtra("time", item.getTime());
+
+ startActivityForResult(intent, 100);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.activity_main, menu);
+ return true;
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == 100 && resultCode == 100 && data != null) {
+ long uid = data.getLongExtra("uid", -1);
+ if (uid != -1) {
+ for (MotionItem item : items) {
+ if (item.getUid() == uid) {
+ item.setLed(data.getBooleanExtra("led", false));
+ item.setArmleft(data.getByteExtra("armleft", (byte) 0));
+ item.setArmright(data.getByteExtra("armright", (byte) 0));
+ item.setRotleft(data.getByteExtra("rotleft", (byte) 0));
+ item.setRotright(data.getByteExtra("rotright", (byte) 0));
+ item.setTime(data.getByteExtra("time", (byte) 0));
+ adapter.notifyDataSetChanged();
+ break;
+ }
+ }
+ }
+
+ }
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ String action = intent.getAction();
+ if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
+ Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
+ writeNdefMotionTag(tag);
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ nfcadapter.disableForegroundDispatch(this);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
+ getClass()), 0);
+ nfcadapter.enableForegroundDispatch(this, pendingIntent, nfcfilters, nfctechLists);
+ }
+
+ private void writeNdefMotionTag(Tag tag) {
+ try {
+ if (Arrays.asList(tag.getTechList()).contains(NdefFormatable.class.getName())) {
+ NdefFormatable ndef = NdefFormatable.get(tag);
+ try {
+ if (!ndef.isConnected()) {
+ ndef.connect();
+ }
+ ndef.format(createNdefMessage());
+ Toast.makeText(this, "Write Success.", Toast.LENGTH_SHORT).show();
+ } finally {
+ ndef.close();
+ }
+ }
+ else if (Arrays.asList(tag.getTechList()).contains(Ndef.class.getName())) {
+ Ndef ndef = Ndef.get(tag);
+ try {
+ if (!ndef.isConnected()) {
+ ndef.connect();
+ }
+ if(ndef.isWritable()){
+ ndef.writeNdefMessage(createNdefMessage());
+ Toast.makeText(this, "Write Success.", Toast.LENGTH_SHORT).show();
+ }
+ else{
+ Toast.makeText(this, "Writing is not supported", Toast.LENGTH_SHORT).show();
+ }
+ } finally {
+ ndef.close();
+ }
+ }
+
+ } catch (FormatException e) {
+ Log.e(TAG, "FormatException", e);
+ Toast.makeText(this, "Writing Error", Toast.LENGTH_SHORT).show();
+ } catch (IOException e) {
+ Log.e(TAG, "IOException", e);
+ Toast.makeText(this, "Writing Error", Toast.LENGTH_SHORT).show();
+ }
+
+ }
+
+ private NdefMessage createNdefMessage() throws IOException {
+ byte[] mimeBytes = "application/jp.co.kayo.android.droiddancermotionwriter".getBytes(Charset.forName("US-ASCII"));
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ byte[] header = new byte[2];
+ header[0] = new Integer(seekBar1.getProgress()).byteValue();
+ header[1] = new Integer(items.size()).byteValue();
+ bytes.write(header);
+ for(MotionItem item : items){
+ byte[] data = new byte[6];
+ data[0] = new Integer(item.isLed()?1:0).byteValue();
+ data[1] = new Integer(item.getArmleft()).byteValue();
+ data[2] = new Integer(item.getArmright()).byteValue();
+ data[3] = new Integer(item.getRotleft()).byteValue();
+ data[4] = new Integer(item.getRotright()).byteValue();
+ data[5] = new Integer(item.getTime()).byteValue();
+ bytes.write(data);
+ }
+
+ NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, new byte[0], bytes.toByteArray());
+
+ return new NdefMessage(new NdefRecord[]{record});
+ }
+
+}
View
65 DroidDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/MotionItem.java
@@ -0,0 +1,65 @@
+package jp.co.kayo.android.droiddancermotionwriter;
+
+import java.util.Random;
+
+public class MotionItem {
+ private static Random _rand = new Random(System.nanoTime());
+ private long uid;
+ private boolean led;
+ private byte armleft;
+ private byte armright;
+ private byte rotleft;
+ private byte rotright;
+ private byte time;
+
+ public MotionItem(){
+ uid = _rand.nextLong();
+ }
+
+ public long getUid() {
+ return uid;
+ }
+
+ public void setUid(long uid) {
+ this.uid = uid;
+ }
+
+ public boolean isLed() {
+ return led;
+ }
+ public void setLed(boolean led) {
+ this.led = led;
+ }
+ public byte getArmleft() {
+ return armleft;
+ }
+ public void setArmleft(byte armleft) {
+ this.armleft = armleft;
+ }
+ public byte getArmright() {
+ return armright;
+ }
+ public void setArmright(byte armright) {
+ this.armright = armright;
+ }
+ public byte getRotleft() {
+ return rotleft;
+ }
+ public void setRotleft(byte rotleft) {
+ this.rotleft = rotleft;
+ }
+ public byte getRotright() {
+ return rotright;
+ }
+ public void setRotright(byte rotright) {
+ this.rotright = rotright;
+ }
+ public byte getTime() {
+ return time;
+ }
+ public void setTime(byte time) {
+ this.time = time;
+ }
+
+
+}
View
66 ...dDancerMotionWriter/src/jp/co/kayo/android/droiddancermotionwriter/MotionListAdapter.java
@@ -0,0 +1,66 @@
+package jp.co.kayo.android.droiddancermotionwriter;
+
+import java.util.List;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+public class MotionListAdapter extends ArrayAdapter<MotionItem>{
+ LayoutInflater inflater;
+ public MotionListAdapter(Context context) {
+ super(context, 0);
+ inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ public void setData(List<MotionItem> items){
+ clear();
+ if(items!=null){
+ addAll(items);
+ }
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+ if(convertView == null){
+ convertView = inflater.inflate(R.layout.list_item, parent, false);
+ holder = new ViewHolder();
+ holder.textView1 = (TextView)convertView.findViewById(R.id.textView1);
+ holder.textView2 = (TextView)convertView.findViewById(R.id.textView2);
+ holder.textView3 = (TextView)convertView.findViewById(R.id.textView3);
+ holder.textView4 = (TextView)convertView.findViewById(R.id.textView4);
+ holder.textView5 = (TextView)convertView.findViewById(R.id.textView5);
+ holder.textView6 = (TextView)convertView.findViewById(R.id.textView6);
+
+ convertView.setTag(holder);
+ }
+ else{
+ holder = (ViewHolder)convertView.getTag();
+ }
+ MotionItem item = getItem(position);
+
+ holder.textView1.setText(Boolean.toString(item.isLed()));
+ holder.textView2.setText(Byte.toString(item.getArmleft()));
+ holder.textView3.setText(Byte.toString(item.getArmright()));
+ holder.textView4.setText(Byte.toString(item.getRotleft()));
+ holder.textView5.setText(Byte.toString(item.getRotright()));
+ holder.textView6.setText(Byte.toString(item.getTime()));
+
+ return convertView;
+ }
+
+
+ private class ViewHolder{
+ TextView textView1;
+ TextView textView2;
+ TextView textView3;
+ TextView textView4;
+ TextView textView5;
+ TextView textView6;
+ }
+
+}
View
4 DroidRobo01/.classpath
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="libs/android-support-v4.jar"/>
@@ -9,5 +7,7 @@
<classpathentry exported="true" kind="lib" path="jar/twitter4j-core-android-2.2.5.jar"/>
<classpathentry exported="true" kind="lib" path="jar/twitter4j-media-support-android-2.2.5.jar"/>
<classpathentry exported="true" kind="lib" path="jar/twitter4j-stream-android-2.2.5.jar" sourcepath="jar-src/twitter4j-stream-2.2.5-sources.jar"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
View
2  DroidRobo01/project.properties
@@ -9,4 +9,4 @@
# Project target.
target=Google Inc.:Google APIs:10
-android.library.reference.1=../../../myfile/mydoc/eclipseAndroid/AndyLib
+android.library.reference.1=../../andylib/AndyLib

0 comments on commit f682146

Please sign in to comment.
Something went wrong with that request. Please try again.