OSDN Git Service

2009/09/24
authorkoike <kazhik@users.sourceforge.jp>
Thu, 24 Sep 2009 08:58:33 +0000 (17:58 +0900)
committerkoike <kazhik@users.sourceforge.jp>
Thu, 24 Sep 2009 08:58:33 +0000 (17:58 +0900)
AndroidManifest.xml
default.properties
res/layout/map.xml
src/net/kazhik/android/tokyorunners/Config.java
src/net/kazhik/android/tokyorunners/RunningRecord.java
src/net/kazhik/android/tokyorunners/TokyoRunners.java

index 666ee93..369ec79 100755 (executable)
@@ -4,8 +4,9 @@
       android:versionCode="1"
       android:versionName="1.0">
     <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
+               <provider android:name="RunningRecordProvider" android:authorities="net.kazhik.android.tokyorunners.runningrecordprovider" />
         <activity android:name=".TokyoRunners"
-                  android:label="@string/app_name">
+                  android:label="@string/app_name" android:screenOrientation="portrait">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
@@ -13,6 +14,7 @@
         </activity>
         <activity android:name="MapMode"></activity>
         <activity android:name="Config"></activity>
+        <activity android:name="RunningHistory"></activity>
            <uses-library android:name="com.google.android.maps"></uses-library>
     </application>
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
index 2595cc8..8433081 100755 (executable)
@@ -7,5 +7,16 @@
 # "build.properties", and override values to adapt the script to your
 # project structure.
 
+# apk configurations. This property allows creation of APK files with limited
+# resources. For example, if your application contains many locales and
+# you wish to release multiple smaller apks instead of a large one, you can
+# define configuration to create apks with limited language sets.
+# Format is a comma separated list of configuration names. For each
+# configuration, a property will declare the resource configurations to
+# include. Example:
+#     apk-configurations=european,northamerica
+#     apk-config-european=en,fr,it,de,es
+#     apk-config-northamerica=en,es
+apk-configurations=
 # Project target.
-target=Google Inc.:Google APIs:3
+target=Google Inc.:Google APIs:4
index fb7e756..26a100b 100755 (executable)
@@ -9,6 +9,6 @@
         android:layout_height="fill_parent"
         android:enabled="true"
         android:clickable="true"
-        android:apiKey="0Skdh34vkCEmlRs8Vub2lCWkST1zREWsYZedlmg"
+        android:apiKey="0Skdh34vkCElURRZoWxbWFQ1re1_HyV364Z5U-g"
         />     
 </LinearLayout>
index cbb4f7f..7dd3d4c 100755 (executable)
@@ -42,7 +42,7 @@ public class Config extends PreferenceActivity implements SharedPreferences.OnSh
     }       \r
 */\r
 \r
-       @Override\r
+//     @Override\r
        public void onSharedPreferenceChanged(SharedPreferences pref, String key) {\r
                // if "use_gps" is false, disable "gps_frequency"\r
                \r
index 301b2d0..f63a036 100755 (executable)
@@ -1,6 +1,5 @@
 package net.kazhik.android.tokyorunners;\r
 \r
-import java.io.FileOutputStream;\r
 import java.io.IOException;\r
 import java.io.OutputStreamWriter;\r
 import java.text.SimpleDateFormat;\r
@@ -8,8 +7,10 @@ import java.util.ArrayList;
 import java.util.Date;\r
 import java.util.Iterator;\r
 \r
-import android.content.Context;\r
+import android.content.ContentResolver;\r
+import android.content.ContentValues;\r
 import android.location.Location;\r
+import android.net.Uri;\r
 \r
 public class RunningRecord {\r
        private class Record {\r
@@ -24,7 +25,11 @@ public class RunningRecord {
 //     HashMap<Date, Location> m_record = new HashMap<Date, Location>();\r
        private int m_distance = 0;\r
        private Location m_prevLocation = null;\r
-       \r
+       private ContentResolver m_contentResolver;\r
+\r
+       public RunningRecord(ContentResolver contentResolver) {\r
+               m_contentResolver = contentResolver;\r
+       }\r
        public void addRecord(Date date, Location loc) {\r
                Record newRecord = new Record(date, loc);\r
                m_record.add(newRecord);\r
@@ -78,7 +83,20 @@ public class RunningRecord {
                \r
                \r
        }\r
-       public void save(String filename) {\r
+       public void save() {\r
+               for (Iterator<Record> it = m_record.iterator(); it.hasNext();) {\r
+                       Record rec = (Record)it.next();\r
+                       \r
+               ContentValues values = new ContentValues();\r
+               values.put("start_time", 0);\r
+               values.put("current_time", rec.date.getTime());\r
+               values.put("point_name", "");\r
+               values.put("distance", 0);\r
+               values.put("latitude", rec.location.getLatitude() * 1E6);\r
+               values.put("longitude", rec.location.getLongitude() * 1E6);\r
+               m_contentResolver.insert(Uri.parse("content://net.kazhik.android.tokyorunners.runningrecordprovider"), values);\r
+                       \r
+               }\r
                \r
                \r
        }\r
index 099fa2e..58753fe 100755 (executable)
@@ -1,24 +1,21 @@
 package net.kazhik.android.tokyorunners;
 
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Dialog;
+import android.content.ContentValues;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.database.Cursor;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.location.LocationProvider;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.SystemClock;
 import android.preference.PreferenceManager;
@@ -35,7 +32,6 @@ import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.Chronometer;
 import android.widget.ListView;
-import android.widget.SimpleAdapter;
 import android.widget.TextView;
 
 public class TokyoRunners extends Activity implements
@@ -53,7 +49,7 @@ public class TokyoRunners extends Activity implements
        
        private GestureDetector m_gestureDetector;
        
-       private RunningRecord m_runningRecord = new RunningRecord();
+       private RunningRecord m_runningRecord;
        
     class StartStopButton implements OnClickListener {
                public void onClick(View v) {
@@ -101,6 +97,9 @@ public class TokyoRunners extends Activity implements
         
         m_elapsedTime = (Chronometer)findViewById(R.id.elapsed_time);
         m_lapTime = (Chronometer)findViewById(R.id.lap_time);
+
+        m_runningRecord = new RunningRecord(getContentResolver());
+       
         
         Button btnStartStop = (Button)findViewById(R.id.button_start_stop);
            btnStartStop.setOnClickListener(new StartStopButton());
@@ -161,14 +160,14 @@ public class TokyoRunners extends Activity implements
                builder.setTitle(R.string.dialog_save_title);
                builder.setMessage(R.string.dialog_save_message);
                builder.setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() {
-                               @Override
+//                             @Override
                                public void onClick(DialogInterface dialog, int which) {
                                        saveRecord();
                                        // TODO Auto-generated method stub
                                }
                        });
                builder.setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() {
-                               @Override
+//                             @Override
                                public void onClick(DialogInterface dialog, int which) {
                                        dialog.cancel();
                                        
@@ -321,6 +320,26 @@ public class TokyoRunners extends Activity implements
        }
        
        private void saveRecord() {
+               if (m_running) {
+                       return;
+               }
+               m_runningRecord.save();
+               
+               /*
+               
+        getIntent().setData(Uri.parse("content://net.kazhik.android.tokyorunners.runningrecordprovider"));
+
+        ContentValues values = new ContentValues();
+        values.put("name", "Pen");
+        values.put("description", "This is a pen");
+        getContentResolver().insert(getIntent().getData(), values);
+        Cursor cur = managedQuery(getIntent().getData(), null, null, null, null);
+        while (cur.moveToNext()) {
+            Log.d(cur.getString(1), cur.getString(2));
+        }
+*/
+        
+/*
                FileOutputStream outFile = null;
                OutputStreamWriter stWriter = null;
                try {
@@ -340,7 +359,7 @@ public class TokyoRunners extends Activity implements
                        } catch (IOException e) {
                        }
                }
-
+*/
        }
        
     @Override