[PATCH] Improved code of companion application as suggested by Aurélien

Venkatesh Shukla IIT BHU venkatesh.shukla.eee11 at iitbhu.ac.in
Tue Mar 11 11:30:02 PDT 2014


This commit includes code improvements as suggested by Aurélien -
http://lists.hohndel.org/pipermail/subsurface/2014-March/010705.html

Changes made:
1. Code improvement suggestions incorporated
2. Marker added to the map which appears on long press
3. The marker also shows latitude and longitude on click
3. Select/Unselect all feature added in GPX import

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11 at iitbhu.ac.in>
---
 AndroidManifest.xml                           |    9 +-
 res/drawable-hdpi/ic_action_select_all.png    |  Bin 0 -> 2860 bytes
 res/drawable-mdpi/ic_action_select_all.png    |  Bin 0 -> 2845 bytes
 res/drawable-xhdpi/ic_action_select_all.png   |  Bin 0 -> 2855 bytes
 res/menu/picklocation_gpx.xml                 |    6 +
 res/values/strings.xml                        |   11 +-
 src/org/subsurface/HomeActivity.java          |   97 +++++++------
 src/org/subsurface/PickGpx.java               |   38 +++--
 src/org/subsurface/PickLocationGpx.java       |   52 +++++--
 src/org/subsurface/PickLocationMap.java       |   39 +++--
 src/org/subsurface/model/GpxFileInfo.java     |   16 +--
 src/org/subsurface/ui/GpxDiveListAdapter.java |   63 ++++++--
 src/org/subsurface/ui/GpxListAdapter.java     |    5 +-
 src/org/subsurface/util/GpxParser.java        |  192
+++++++++++++++++++++++++
 14 files changed, 419 insertions(+), 109 deletions(-)
 create mode 100755 res/drawable-hdpi/ic_action_select_all.png
 create mode 100755 res/drawable-mdpi/ic_action_select_all.png
 create mode 100755 res/drawable-xhdpi/ic_action_select_all.png
 create mode 100644 src/org/subsurface/util/GpxParser.java

diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0bb3977..f3b782e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -31,9 +31,9 @@
         </activity>
         <activity android:name="SharePicturePositionActivity"
android:theme="@style/AppTheme">
             <intent-filter>
-             <action android:name="android.intent.action.SEND" />
+ <action android:name="android.intent.action.SEND" />
                 <category android:name="android.intent.category.DEFAULT" />
-             <data android:mimeType="image/jpeg" />
+ <data android:mimeType="image/jpeg" />
             </intent-filter>
         </activity>
         <service android:name="BackgroundLocationService"
android:process=":location_service"/>
@@ -43,7 +43,7 @@
         <activity android:name="DiveDetailActivity"
android:theme="@style/AppTheme.SubScreen" />
         <activity android:name="Preferences"
android:theme="@style/AppTheme" android:label="@string/menu_settings"
android:excludeFromRecents="true" />
         <activity android:name="MapActivity"
android:theme="@style/AppTheme.SubScreen"></activity>
-        <activity
+ <activity
             android:name="PickGpx"
             android:theme="@style/AppTheme.SubScreen"
             android:parentActivityName="HomeActivity">
@@ -76,4 +76,5 @@
             android:value="@integer/google_play_services_version" />
     </application>

-</manifest>
\ No newline at end of file
+</manifest>
+
diff --git a/res/drawable-hdpi/ic_action_select_all.png
b/res/drawable-hdpi/ic_action_select_all.png
new file mode 100755
index
0000000000000000000000000000000000000000..81cdf740ac7cc30207d5db1031cb5d38e9022e60
GIT binary patch
literal 2860
zcmV+{3)A$8P)<h;3K|Lk000e1NJLTq001xm001xn0{{R3ZOm)L00009a7bBm000XT
z000XT0n*)m`~Uz7PiaF#P*7-ZbZ>KLZ*U+<Lqi~Na&Km7Y-Iodc-oy)XH-+^7Crag
z^g>IBfRsybQWXdwQbLP>6p<z>Aqfylh#{fb6;Z(vMMVS~$e at S=j*ftg6;Uh<iVD~V
z<RPMtgQJLw%KPDaqifc at _vX$1wbwr9tn;0-&j-K=43<bUQ8j=JsX`tR;Dg7+#^K~H
zK!FM*Z~zbpvt%K2{UZSY_<lS*D<Z%Lz5oGu(+dayz)hRLFdT>f59&ghTmgWD0l;*T
zI7<kC6aYYajzXpYKt=(8otP$50H6c_V9R4-;{Z at C0AMG7=F<Rxo%or10RUT+Ar%3j
zkpLhQWr#!oXgdI`&sK^>09Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p
z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh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zp`1 at sE9D1B_x|{9_MN0im$V;WHDTKCE)YyAzN92m=7T$T9f^|C_%60000<
KMNUMnLSTYT!c9m3

literal 0
HcmV?d00001

diff --git a/res/drawable-mdpi/ic_action_select_all.png
b/res/drawable-mdpi/ic_action_select_all.png
new file mode 100755
index
0000000000000000000000000000000000000000..e9d80d3f3e5767160ab14adc8de01a9dc8496871
GIT binary patch
literal 2845
zcmV+&3*z*NP)<h;3K|Lk000e1NJLTq001BW001BX0{{R3Nwny<00009a7bBm000XT
z000XT0n*)m`~Uz7PiaF#P*7-ZbZ>KLZ*U+<Lqi~Na&Km7Y-Iodc-oy)XH-+^7Crag
z^g>IBfRsybQWXdwQbLP>6p<z>Aqfylh#{fb6;Z(vMMVS~$e at S=j*ftg6;Uh<iVD~V
z<RPMtgQJLw%KPDaqifc at _vX$1wbwr9tn;0-&j-K=43<bUQ8j=JsX`tR;Dg7+#^K~H
zK!FM*Z~zbpvt%K2{UZSY_<lS*D<Z%Lz5oGu(+dayz)hRLFdT>f59&ghTmgWD0l;*T
zI7<kC6aYYajzXpYKt=(8otP$50H6c_V9R4-;{Z at C0AMG7=F<Rxo%or10RUT+Ar%3j
zkpLhQWr#!oXgdI`&sK^>09Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p
z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-<?i
z0%4j!F2Z at 488U%158(66005wo6%pWr^Zj_v4zAA5HjcIqUoGmt2LB>rV&neh&#Q1i
z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_<lS*MWK+n+1cgf
z<k(8YLR(?VSAG6x!e78w{cQPuJpA|d;J)G{fihizM+Erb!p!tcr5w+a34~(Y=8s4G
zw+sLL9n&JjNn*KJDiq^U5^;`1nvC- at r6P$!k}1U{(*I=Q-z at tBKHoI}uxdU5dyy at u
zU1J0GOD7Ombim^G008p4Z^6_k2m^p<gW=D2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BHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i&
z_B8C(+grT%{XWUQ+f at NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01
z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R
z9cLXcYC at Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw
zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD
zJpPl at Psh8QyPB@KTx+ at RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3|
zawq-H%e&ckC+ at AhPrP6BK<z=<L*0kfKU at CX*zeqbYQT4(^U>T#_XdT7&;F71j}Joy
zkC~6lh7E at 6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z
zrTyx_>lv at x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot<a{81DF0~rvGr5Xr~8u`lav1h
z1DNytV>2z=0000WV at Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F}
z00006P)t-s|NsC0|Nm8d^=tqD00DGTPE!Ct=GbNc001dTL_t&t*JEHn1)`y$0T7k|
v7$I1H>VVXrIvgxC9XQp2S!gDs+KUPR*(4P=(@P0m00000NkvXXu0mjfiH<|c

literal 0
HcmV?d00001

diff --git a/res/drawable-xhdpi/ic_action_select_all.png
b/res/drawable-xhdpi/ic_action_select_all.png
new file mode 100755
index
0000000000000000000000000000000000000000..2e918d2ac34f19e9a2e963e7cabdd5451e80bea1
GIT binary patch
literal 2855
zcmV+?3)u9DP)<h;3K|Lk000e1NJLTq002M$002M%0{{R3kf-CF00009a7bBm000XT
z000XT0n*)m`~Uz7PiaF#P*7-ZbZ>KLZ*U+<Lqi~Na&Km7Y-Iodc-oy)XH-+^7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B@KTx+ at RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3|
zawq-H%e&ckC+ at AhPrP6BK<z=<L*0kfKU at CX*zeqbYQT4(^U>T#_XdT7&;F71j}Joy
zkC~6lh7E at 6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z
zrTyx_>lv at x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot<a{81DF0~rvGr5Xr~8u`lav1h
z1DNytV>2z=0000WV at Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F}
z00006P)t-s|NsC0|Nm8d^=tqD00DGTPE!Ct=GbNc001*dL_t(2&tqVq2rx3v0MpNz
z at F{A5kYuZ||6~7$fq at B|8mJVEOQD(}>K@|N5EWmf005S_A@>arXbS)U002ovPDHLk
FV1gWeOgsPp

literal 0
HcmV?d00001

diff --git a/res/menu/picklocation_gpx.xml b/res/menu/picklocation_gpx.xml
index 7868bcd..81162f8 100644
--- a/res/menu/picklocation_gpx.xml
+++ b/res/menu/picklocation_gpx.xml
@@ -1,6 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >

+     <item
+        android:id="@+id/gpxmenu_select_all"
+        android:icon="@drawable/ic_action_select_all"
+        android:showAsAction="always"
+ android:title="@string/menu_select_all"/>
+
     <item
         android:id="@+id/gpxmenu_send"
         android:icon="@drawable/ic_action_accept"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2226c45..9d24f7a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -43,6 +43,8 @@
     <string name="menu_new_map">Use map</string>
     <string name="menu_new_gpx">Import local GPX file</string>
     <string name="menu_accept">Accept</string>
+    <string name="menu_select_all">Select all</string>
+    <string name="menu_unselect_all">Unselect all</string>

     <string name="notification_background_service_on">Background location
service active</string>

@@ -63,7 +65,7 @@
     <string name="error_not_yet_implemented">Not yet implemented</string>
     <string name="error_no_associated_dive">Could not find associated
dive</string>
     <string name="error_background_service_unstoppable">Could not stop
background service</string>
-
+
     <string name="error_bad_http_code">Server returned a bad HTTP
code</string>
     <string name="error_login_invalid">Server did not recognize your
login</string>
     <string name="error_email_already_exists">Your email is already
registered on the server</string>
@@ -94,7 +96,7 @@
     <string name="error_title">Error</string>
     <string name="error_fatal">Subsurface has encountered a fatal error
and must exit.</string>
     <string name="error_generic">An error has occurred. Please check your
settings and retry later</string>
-
+
     <!-- Warning : MM = month, mm = minutes -->
     <string name="date_format_full">MM/dd/yyyy HH:mm</string>
     <string name="date_format_short">MM/dd/yyyy</string>
@@ -132,8 +134,8 @@
     <string name="settings_other_website_summary">Open project
website</string>
     <string name="settings_other_version">Version</string>
     <string name="settings_other_version_summary">Current version:
%s</string>
-
-    <string name="instruction_pickloc">Select the dive point</string>
+
+    <string name="instruction_pickloc">Long press to select Dive
Location</string>

     <string name="gpx_dummy_name">Name of GPX file</string>
     <string name="gpx_dummy_path">Path to GPX file :
qwertyuiopasdfghjklzxcvbnm</string>
@@ -144,4 +146,5 @@
     <string name="title_pickgpx">Select GPX file</string>
     <string name="title_picklocationmap">Select Location</string>
     <string name="title_map_marker">Dive Spot</string>
+
 </resources>
diff --git a/src/org/subsurface/HomeActivity.java
b/src/org/subsurface/HomeActivity.java
index 552bcf4..4a7a16d 100644
--- a/src/org/subsurface/HomeActivity.java
+++ b/src/org/subsurface/HomeActivity.java
@@ -52,15 +52,20 @@ import com.google.android.gms.maps.model.LatLng;
 public class HomeActivity extends SherlockListActivity implements
com.actionbarsherlock.view.ActionMode.Callback, SelectionListener,
OnNavigationListener {

  private static final String TAG = "HomeActivity";
+ private static final int pick_map_reqcode = 999;
+ private static final int pick_gpxfile_reqcode = 998;
+ private static final String LOCATION = "location";
+ private static final String GPX_DIVE_LOGS  = "gpxdivelogs";
+

  private IBinder service = null;
  private final ServiceConnection connection = new ServiceConnection() {
-
+
  @Override
  public void onServiceDisconnected(ComponentName name) {
  service = null;
  }
-
+
  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
  HomeActivity.this.service = service;
@@ -108,13 +113,13 @@ public class HomeActivity extends
SherlockListActivity implements com.actionbars
  private boolean isBackgroundLocationServiceStarted() {
  boolean started = false;
  ActivityManager manager = (ActivityManager)
getSystemService(Context.ACTIVITY_SERVICE);
-    for (RunningServiceInfo service :
manager.getRunningServices(Integer.MAX_VALUE)) {
-        if
(BackgroundLocationService.class.getName().equals(service.service.getClassName()))
{
-            started = true;
-            break;
-        }
-    }
-    return started;
+ for (RunningServiceInfo service :
manager.getRunningServices(Integer.MAX_VALUE)) {
+ if
(BackgroundLocationService.class.getName().equals(service.service.getClassName()))
{
+ started = true;
+ break;
+ }
+ }
+ return started;
  }

  private void refresh() {
@@ -163,15 +168,15 @@ public class HomeActivity extends
SherlockListActivity implements com.actionbars
  Toast.makeText(HomeActivity.this, R.string.error_no_settings,
Toast.LENGTH_SHORT).show();
  } else { // Send locations
  final Handler handler = new Handler() {
-     @Override
-     public void handleMessage(Message msg) {
-     int total = msg.arg1;
-     dialog.setProgress(total);
-     if (total >= dives.size()) { // OK, close dialog
-     dialog.dismiss();
-     }
-     }
-     };
+ @Override
+ public void handleMessage(Message msg) {
+ int total = msg.arg1;
+ dialog.setProgress(total);
+ if (total >= dives.size()) {// OK, close dialog
+ dialog.dismiss();
+ }
+ }
+ };
  new Thread(new Runnable() {
  public void run() {
  int success = 0;
@@ -207,7 +212,12 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars
  }
  }

- //Send location picked from map to the server and update the list
+ /**
+ * Send location picked from map to the server and update the list
+ * @param name Name of the dive
+ * @param latlng Latlng of the dive
+ * @param timestamp timestamp of the dive
+ */
  public void sendMapDiveLog(String name, LatLng latlng, long timestamp) {
  if(name.contentEquals(""))
  {
@@ -267,7 +277,7 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars
  }
  });
  this.locationListener = new LocationListener() {
-
+
  @Override
  public void onStatusChanged(String provider, int status, Bundle extras) {
  if (!cancel.get()) {
@@ -289,7 +299,7 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars
  Toast.makeText(HomeActivity.this, R.string.error_location,
Toast.LENGTH_SHORT).show();
  }
  }
-
+
  @Override
  public void onLocationChanged(final Location location) {
  if (!cancel.get()) {
@@ -334,9 +344,9 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars

  @Override
  protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        UserController.instance.setContext(this);
-        try {
+ super.onCreate(savedInstanceState);
+ UserController.instance.setContext(this);
+ try {
  DiveController.instance.setContext(this);
  } catch (Exception e) {
  new AlertDialog.Builder(this)
@@ -345,18 +355,17 @@ public class HomeActivity extends
SherlockListActivity implements com.actionbars
  .setPositiveButton(android.R.string.ok,
  new DialogInterface.OnClickListener() {
  @Override
- public void onClick(DialogInterface dialog,
- int which) {
+ public void onClick(DialogInterface dialog, int which) {
  finish();
  }
  }).setCancelable(false).show();
  }

-        ArrayAdapter<CharSequence> listAdapter =
ArrayAdapter.createFromResource(
+ ArrayAdapter<CharSequence> listAdapter = ArrayAdapter.createFromResource(
  this, R.array.list_menu_choices,
  R.layout.spinner_item);
-
listAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
  getSupportActionBar().setTitle(null);
+
listAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
  getSupportActionBar().setListNavigationCallbacks(listAdapter, this);
  getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
  // Retrieve location service
@@ -412,7 +421,7 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars
  }

  @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
+ public boolean onCreateOptionsMenu(Menu menu) {
  getSupportMenuInflater().inflate(R.menu.dives, menu);
  refreshItem = menu.findItem(R.id.menu_refresh);
  if (isBackgroundLocationServiceStarted()) {
@@ -420,8 +429,8 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars
  } else {

menu.findItem(R.id.menu_start_background_service).setTitle(getString(R.string.menu_start_background_service));
  }
-        return true;
-    }
+ return true;
+ }

  @Override
  protected void onListItemClick(ListView l, View v, int position, long id)
{
@@ -430,15 +439,13 @@ public class HomeActivity extends
SherlockListActivity implements com.actionbars
  startActivity(detailIntent);
  }

- private static final int pick_map_reqcode = 999;
- private static final int pick_gpxfile_reqcode = 998;
- //Receive result from map activity for map picker event
+ @Override
  public void onActivityResult(int requestcode, int resultCode, Intent
data) {
  if(resultCode == RESULT_OK && data != null) {
  Bundle rec_bundle = data.getExtras();
  switch(requestcode) {
  case pick_map_reqcode:
- final LatLng loc = (LatLng) rec_bundle.get("location");
+ final LatLng loc = (LatLng) rec_bundle.get(LOCATION);
  if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
  AlertDialog.Builder builder = new AlertDialog.Builder(this);
  LinearLayout linlay = new LinearLayout(this);
@@ -473,7 +480,7 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars
  }
  return;
  case pick_gpxfile_reqcode:
- List<DiveLocationLog> gpxdivelogs = (ArrayList<DiveLocationLog>)
rec_bundle.get("gpxdivelog");
+ List<DiveLocationLog> gpxdivelogs = (ArrayList<DiveLocationLog>)
rec_bundle.get(GPX_DIVE_LOGS);
  sendDives(gpxdivelogs);
  return;
  }
@@ -610,9 +617,9 @@ public class HomeActivity extends SherlockListActivity
implements com.actionbars
  .setMessage(R.string.confirm_delete_dives)
  .setNegativeButton(android.R.string.cancel, null)
  .setCancelable(true)
- .setPositiveButton(android.R.string.ok, new
DialogInterface.OnClickListener() {
+ .setPositiveButton(android.R.string.ok, new
DialogInterface.OnClickListener() {
  @Override
- public void onClick(DialogInterface dialog, int which) {
+ public void onClick(DialogInterface dialog, int which) {
  new Thread(new Runnable() {
  public void run() {
  int messageCode = R.string.error_delete_dives;
@@ -627,14 +634,14 @@ public class HomeActivity extends
SherlockListActivity implements com.actionbars
  Log.d(TAG, "Could not delete dives", e);
  }
  final String message = messageCode == -1 ? null : getString(messageCode);
- runOnUiThread(new Runnable() {
- public void run() {
- ((DiveArrayAdapter) getListAdapter()).notifyDataSetChanged();
- if (message != null) {
- Toast.makeText(HomeActivity.this, message, Toast.LENGTH_SHORT).show();
+ runOnUiThread(new Runnable() {
+ public void run() {
+ ((DiveArrayAdapter) getListAdapter()).notifyDataSetChanged();
+ if (message != null) {
+ Toast.makeText(HomeActivity.this, message, Toast.LENGTH_SHORT).show();
+ }
  }
- }
- });
+ });
  }
  }).start();
  }
diff --git a/src/org/subsurface/PickGpx.java
b/src/org/subsurface/PickGpx.java
index f424e3f..2f28ebb 100644
--- a/src/org/subsurface/PickGpx.java
+++ b/src/org/subsurface/PickGpx.java
@@ -23,12 +23,18 @@ import android.widget.Toast;
 import com.actionbarsherlock.app.SherlockListActivity;
 import com.actionbarsherlock.view.MenuItem;
 import com.actionbarsherlock.view.Window;
-
+/**
+ * Activity for choosing Gpx file present in the SD Card
+ * @author Venkatesh Shukla
+ */
 public class PickGpx extends SherlockListActivity implements
OnItemClickListener
 {
- ArrayList<GpxFileInfo> allgpxfiles;
- File sd_card;
- GpxListAdapter gla;
+ private ArrayList<GpxFileInfo> allgpxfiles;
+ private File sd_card;
+ private GpxListAdapter gla;
+ private static final int pick_gpxlocation_reqcode = 997;
+ private static final String GPX_DIVE_LOG = "gpxdivelog";
+ private static final String GPX_FILE_PATH = "gpxfilepath";

  @Override
  protected void onCreate(Bundle savedInstanceState) {
@@ -44,6 +50,9 @@ public class PickGpx extends SherlockListActivity
implements OnItemClickListener
  listview.setOnItemClickListener(this);
  }

+ /**
+ * Find all gpx files present in the sd card and make a ListAdapter from
them
+ */
  private void createAdapter() {
  String sd_state = Environment.getExternalStorageState();
  if(sd_state.contentEquals(Environment.MEDIA_MOUNTED) ||
sd_state.contentEquals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
@@ -59,7 +68,11 @@ public class PickGpx extends SherlockListActivity
implements OnItemClickListener
  }
  }

- //Recursively get all the GPX files in the SD card
+ /**
+ * Recursively get all the GPX files in the SD card
+ * @param file Gpx file to be parsed
+ * @return ArrayList containing all GpxFileInfo
+ */
  private ArrayList<GpxFileInfo> getGpxInDir(File file) {
  ArrayList<GpxFileInfo> gpxfiles = new ArrayList<GpxFileInfo>();
  File[] filelist =  file.listFiles();
@@ -83,6 +96,9 @@ public class PickGpx extends SherlockListActivity
implements OnItemClickListener
  return gpxfiles;
  }

+ /**
+ * Asynchronous task of getting all Gpx files in the SD card and updating
the ListAdapter
+ */
  private class GetAllGpx extends AsyncTask<File, Void, Void> {

  @Override
@@ -112,24 +128,23 @@ public class PickGpx extends SherlockListActivity
implements OnItemClickListener
  }
  }

- private static final int pick_gpxlocation_reqcode = 997;
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
  Intent parseGpxIntent = new Intent(this,PickLocationGpx.class);
- parseGpxIntent.putExtra("gpx_filepath",
allgpxfiles.get(position).getPath());
+ parseGpxIntent.putExtra(GPX_FILE_PATH,
allgpxfiles.get(position).getPath());
  startActivityForResult(parseGpxIntent, pick_gpxlocation_reqcode);
  }
-
+
+ @Override
  public void onActivityResult(int requestcode, int resultCode, Intent
data) {
  if(resultCode == RESULT_OK && data != null) {
  Bundle rec_bundle = data.getExtras();
  switch(requestcode) {
  case pick_gpxlocation_reqcode:
- @SuppressWarnings("unchecked")
- ArrayList<DiveLocationLog> gpxdivelogs = (ArrayList<DiveLocationLog>)
rec_bundle.get("gpxdivelog");
+ ArrayList<DiveLocationLog> gpxdivelogs = (ArrayList<DiveLocationLog>)
rec_bundle.get(GPX_DIVE_LOG);
  Intent resultIntent = new Intent();
  Bundle diveBundle = new Bundle();
- diveBundle.putParcelableArrayList("gpxdivelog", gpxdivelogs);
+ diveBundle.putParcelableArrayList(GPX_DIVE_LOG, gpxdivelogs);
  resultIntent.putExtras(diveBundle);
  setResult(Activity.RESULT_OK, resultIntent);
  finish();
@@ -139,6 +154,7 @@ public class PickGpx extends SherlockListActivity
implements OnItemClickListener
  Toast.makeText(this, R.string.error_no_dive_found,
Toast.LENGTH_SHORT).show();
  }
  }
+
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
  switch(item.getItemId()) {
diff --git a/src/org/subsurface/PickLocationGpx.java
b/src/org/subsurface/PickLocationGpx.java
index c1bb6fa..b87c452 100644
--- a/src/org/subsurface/PickLocationGpx.java
+++ b/src/org/subsurface/PickLocationGpx.java
@@ -8,6 +8,8 @@ import java.util.ArrayList;

 import org.subsurface.model.DiveLocationLog;
 import org.subsurface.ui.GpxDiveListAdapter;
+import org.subsurface.ui.GpxDiveListAdapter.CheckedState;
+import org.subsurface.util.GpxParser;
 import org.xmlpull.v1.XmlPullParserException;

 import android.app.Activity;
@@ -15,6 +17,7 @@ import android.content.Intent;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.support.v4.app.NavUtils;
+import android.util.Log;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
@@ -26,19 +29,25 @@ import com.actionbarsherlock.app.SherlockListActivity;
 import com.actionbarsherlock.view.Menu;
 import com.actionbarsherlock.view.MenuItem;
 import com.actionbarsherlock.view.Window;
-
+/**
+ * Activity to choose the dive locations to import from GPX file
+ * @author Venkatesh Shukla
+ */
 public class PickLocationGpx extends SherlockListActivity implements
OnItemClickListener {

- ListView listview;
- ArrayList<DiveLocationLog> allgpxlogs;
- Intent resultIntent;
+ private ListView listview;
+ private ArrayList<DiveLocationLog> allgpxlogs;
+ private Intent resultIntent;
+ private static final String GPX_DIVE_LOG = "gpxdivelog";
+ private static final String GPX_FILE_PATH = "gpxfilepath";
+ private static final String TAG = "PickLocationGpx";
+
  @Override
- protected void onCreate(Bundle savedInstanceState)
- {
+ protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  allgpxlogs = new ArrayList<DiveLocationLog>();
  resultIntent = new Intent();
- String gpx_filepath = getIntent().getStringExtra("gpx_filepath");
+ String gpx_filepath = getIntent().getStringExtra(GPX_FILE_PATH);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  getSupportActionBar().setTitle(R.string.title_picklocationgpx);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -70,18 +79,31 @@ public class PickLocationGpx extends
SherlockListActivity implements OnItemClick
  return true;
  case R.id.gpxmenu_send:
  Bundle diveBundle = new Bundle();
- diveBundle.putParcelableArrayList("gpxdivelog",
gpxDla.getSelectedDives());
+ diveBundle.putParcelableArrayList(GPX_DIVE_LOG,
gpxDla.getSelectedDives());
  resultIntent.putExtras(diveBundle);
  setResult(Activity.RESULT_OK, resultIntent);
  finish();
  return true;
+ case R.id.gpxmenu_select_all:
+ CheckedState cs = gpxDla.getCheckedState();
+ if(cs == CheckedState.ALLUNCHECKED || cs == CheckedState.MIXED) {
+ gpxDla.setCheckedAll(true);
+ item.setTitle(R.string.menu_unselect_all);
+ } else {
+ gpxDla.setCheckedAll(false);
+ item.setTitle(R.string.menu_select_all);
+ }
+ gpxDla.notifyDataSetChanged();
  }
  return super.onOptionsItemSelected(item);
  }
- // Async task which parses data of GPX file and sets the listAdapter
+
+ /**
+ * Async task which parses data of GPX file and sets the listAdapter
+ */
  private class GetDivesFromGpx extends AsyncTask<String, Void, Void>{
- FileInputStream xmlstream;
- GpxParser parser;
+ private FileInputStream xmlstream;
+ private GpxParser parser;

  @Override
  protected Void doInBackground(String ... paths ) {
@@ -94,13 +116,13 @@ public class PickLocationGpx extends
SherlockListActivity implements OnItemClick
  }
  catch (FileNotFoundException e)
  {
- e.printStackTrace();
+ Log.e(TAG, e.toString());
  } catch (XmlPullParserException e) {
- e.printStackTrace();
+ Log.e(TAG, e.toString());
  } catch (IOException e) {
- e.printStackTrace();
+ Log.e(TAG, e.toString());
  } catch (ParseException e) {
- e.printStackTrace();
+ Log.e(TAG, e.toString());
  }
  }
  return null;
diff --git a/src/org/subsurface/PickLocationMap.java
b/src/org/subsurface/PickLocationMap.java
index 3ae3ff1..bb9643f 100644
--- a/src/org/subsurface/PickLocationMap.java
+++ b/src/org/subsurface/PickLocationMap.java
@@ -9,15 +9,23 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
 import com.actionbarsherlock.view.Menu;
 import com.actionbarsherlock.view.MenuItem;
 import com.google.android.gms.maps.GoogleMap;
-import com.google.android.gms.maps.GoogleMap.OnMapClickListener;
+import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
+import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
 import com.google.android.gms.maps.SupportMapFragment;
 import com.google.android.gms.maps.model.LatLng;
-
-public class PickLocationMap extends SherlockFragmentActivity implements
OnMapClickListener {
+import com.google.android.gms.maps.model.Marker;
+import com.google.android.gms.maps.model.MarkerOptions;
+/**
+ * Activity to choose the dive location on the map
+ * @author Venkatesh Shukla
+ */
+public class PickLocationMap extends SherlockFragmentActivity implements
OnMapLongClickListener, OnMarkerClickListener {

  private GoogleMap mMap;
- public static LatLng latlng;
-
+ private static LatLng latlng;
+ private static final String LOCATION = "location";
+ private MarkerOptions markeropt;
+
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
@@ -25,6 +33,9 @@ public class PickLocationMap extends
SherlockFragmentActivity implements OnMapCl
  getSupportActionBar().setTitle(R.string.title_picklocationmap);
  setContentView(R.layout.dive_picklocation);
  setUpMapIfNeeded();
+ markeropt = new MarkerOptions()
+ .title(getString(R.string.title_map_marker))
+ .draggable(true);
  }

  @Override
@@ -41,7 +52,7 @@ public class PickLocationMap extends
SherlockFragmentActivity implements OnMapCl
  return true;
  case R.id.dive_loc_finish:
  Intent resultIntent = new Intent();
- resultIntent.putExtra("location", latlng);
+ resultIntent.putExtra(LOCATION, latlng);
  setResult(Activity.RESULT_OK, resultIntent);
  finish();
  return true;
@@ -59,19 +70,23 @@ public class PickLocationMap extends
SherlockFragmentActivity implements OnMapCl
  if (mMap == null) {
  mMap = ((SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
  if (mMap != null) {
- setUpMap();
+ mMap.setOnMapLongClickListener(this);
  }
  }
  }

- private void setUpMap() {
- mMap.setOnMapClickListener(this);
- }
-
  @Override
- public void onMapClick(LatLng loc) {
+ public void onMapLongClick(LatLng loc) {
  mMap.clear();
+ markeropt.position(loc);
+ markeropt.snippet(String.format("(%f, %f)", loc.latitude, loc.longitude));
+ mMap.addMarker(markeropt);
  latlng = loc;
  }

+ @Override
+ public boolean onMarkerClick(Marker arg0) {
+ return false;
+ }
+
 }
diff --git a/src/org/subsurface/model/GpxFileInfo.java
b/src/org/subsurface/model/GpxFileInfo.java
index 9606f43..099e001 100644
--- a/src/org/subsurface/model/GpxFileInfo.java
+++ b/src/org/subsurface/model/GpxFileInfo.java
@@ -2,21 +2,24 @@ package org.subsurface.model;

 import java.text.SimpleDateFormat;
 import java.util.Locale;
-
+/**
+ * Model for information on Gpx present in the SD card
+ * @author Venkatesh Shukla
+ */
 public class GpxFileInfo
 {
  private String name;
  private String path;
  private String date;
  private String directory;
- private final SimpleDateFormat sdf;
-
+ private static final String DATEFORMAT = "MM/dd/yy HH:mm:ss";
+
  public GpxFileInfo(String name, String path, long timestamp, String
directory)
  {
  super();
  this.name = name;
  this.path = path;
- sdf = new SimpleDateFormat("MM/dd/yy HH:mm:ss", Locale.getDefault());
+ SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT,
Locale.getDefault());
  this.date = sdf.format(timestamp);
  this.directory = directory;

@@ -30,7 +33,6 @@ public class GpxFileInfo
  public void setName(String name)
  {
  this.name = name;
- return;
  }

  public String getPath()
@@ -41,7 +43,6 @@ public class GpxFileInfo
  public void setPath(String path)
  {
  this.path = path;
- return;
  }

  public String getDate()
@@ -51,8 +52,8 @@ public class GpxFileInfo

  public void setDate(long timestamp)
  {
+ SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT,
Locale.getDefault());
  this.date = sdf.format(timestamp);
- return;
  }


@@ -64,7 +65,6 @@ public class GpxFileInfo
  public void setDirectory(String directory)
  {
  this.directory = directory;
- return;
  }
 }

diff --git a/src/org/subsurface/ui/GpxDiveListAdapter.java
b/src/org/subsurface/ui/GpxDiveListAdapter.java
index 98654fb..57a1169 100644
--- a/src/org/subsurface/ui/GpxDiveListAdapter.java
+++ b/src/org/subsurface/ui/GpxDiveListAdapter.java
@@ -16,22 +16,32 @@ import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.CompoundButton.OnCheckedChangeListener;
 import android.widget.TextView;
-
+/**
+ * Custom ListAdapter for all dives present in a GPX file
+ * @author Venkatesh Shukla
+ */
 public class GpxDiveListAdapter extends BaseAdapter {

+ public enum CheckedState {
+ ALLCHECKED,
+ ALLUNCHECKED,
+ MIXED;
+ }
+
  private final ArrayList<DiveLocationLog> gpxdivelogs;
  private final LayoutInflater inflater;
  private final SimpleDateFormat sdfdate;
  private final SimpleDateFormat sdftime;
  private final boolean[] cbState; // boolean array to save which
checkboxes are checked
-
+ private CheckedState checkedstate;
+
  public GpxDiveListAdapter(Context context, ArrayList<DiveLocationLog>
gpxdivelogs) {
  this.gpxdivelogs = gpxdivelogs;
- inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- sdfdate = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
- sdftime = new SimpleDateFormat("HH:mm", Locale.getDefault());
- cbState = new boolean[gpxdivelogs.size()];
-
+ this.inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ this.sdfdate = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
+ this.sdftime = new SimpleDateFormat("HH:mm", Locale.getDefault());
+ this.cbState = new boolean[gpxdivelogs.size()];
+ this.checkedstate =  CheckedState.ALLUNCHECKED;
  }

  public void addItem(final DiveLocationLog gpxdivelog) {
@@ -48,7 +58,10 @@ public class GpxDiveListAdapter extends BaseAdapter {
  public Object getItem(int position) {
  return gpxdivelogs.get(position);
  }
-
+ /**
+ * get all dives selected by the users
+ * @return An arraylist of DiveLocationLog of all selected dives
+ */
  public ArrayList<DiveLocationLog> getSelectedDives() {
  ArrayList<DiveLocationLog> selectedDives = new
ArrayList<DiveLocationLog>();
  for(int i = 0; i < gpxdivelogs.size(); i++) {
@@ -58,7 +71,39 @@ public class GpxDiveListAdapter extends BaseAdapter {
  }
  return selectedDives;
  }
-
+
+ /**
+ * Get the present state of selected checkboxes
+ * @return CheckedState - ALLCHECKED, ALLUNCHECKED or MIXED of the dives
+ */
+ public CheckedState getCheckedState()
+ {
+ checkedstate = CheckedState.ALLUNCHECKED;
+ int count = 0;
+ for(int i = 0; i < gpxdivelogs.size(); i++) {
+ if(cbState[i]) {
+ count++;
+ }
+ }
+ if(count == gpxdivelogs.size()) {
+ checkedstate = CheckedState.ALLCHECKED;
+ }
+ else if(count != 0) {
+ checkedstate = CheckedState.MIXED;
+ }
+ return checkedstate;
+ }
+
+ /**
+ * Set all the checkboxes of the adapter to true or false state
+ * @param state required to set all the checkboxes.
+ */
+ public void setCheckedAll(boolean state) {
+ for(int i = 0; i < gpxdivelogs.size(); i++) {
+ cbState[i] = state;
+ }
+ }
+
  @Override
  public long getItemId(int position) {
  return position;
diff --git a/src/org/subsurface/ui/GpxListAdapter.java
b/src/org/subsurface/ui/GpxListAdapter.java
index a24b214..33e7157 100644
--- a/src/org/subsurface/ui/GpxListAdapter.java
+++ b/src/org/subsurface/ui/GpxListAdapter.java
@@ -11,7 +11,10 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.BaseAdapter;
 import android.widget.TextView;
-
+/**
+ * Custom list adapter for list of Gpx files in the SD card
+ * @author Venkatesh Shukla
+ */
 public class GpxListAdapter extends BaseAdapter
 {
  private final ArrayList<GpxFileInfo> gpxfiles;
diff --git a/src/org/subsurface/util/GpxParser.java
b/src/org/subsurface/util/GpxParser.java
new file mode 100644
index 0000000..fd600b2
--- /dev/null
+++ b/src/org/subsurface/util/GpxParser.java
@@ -0,0 +1,192 @@
+package org.subsurface.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Locale;
+
+import org.subsurface.model.DiveLocationLog;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.location.Location;
+import android.util.Xml;
+/**
+ * Parser for Gpx files
+ * @author Venkatesh Shukla
+ */
+
+public class GpxParser {
+
+ private static final String ns = null;
+ private static final String DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss";
+ /**
+ * Parse the GPX file
+ * @param in InputStream of the GPX file
+ * @return ArrayList of DiveLocationLogs present in the GPX file
+ * @throws XmlPullParserException
+ * @throws IOException
+ * @throws ParseException
+ */
+ public ArrayList<DiveLocationLog> parse(InputStream in) throws
XmlPullParserException, IOException, ParseException {
+ try {
+ XmlPullParser parser = Xml.newPullParser();
+ parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
+ parser.setInput(in, null);
+ parser.nextTag();
+ return readFeed(parser);
+ } finally {
+ in.close();
+ }
+ }
+ /**
+ * Read and parse the GPX to get DiveLocationLogs
+ * @param parser The XmlPullParser in its present state
+ * @return ArrayList of all the divepoints(as Waypoints) found in the GPX
file.
+ * @throws XmlPullParserException
+ * @throws IOException
+ * @throws ParseException
+ */
+ private ArrayList<DiveLocationLog> readFeed(XmlPullParser parser) throws
XmlPullParserException, IOException, ParseException {
+ ArrayList<DiveLocationLog> alldivelogs = new ArrayList<DiveLocationLog>();
+ parser.require(XmlPullParser.START_TAG, ns, "gpx");
+ while (parser.next() != XmlPullParser.END_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
+ continue;
+ }
+ String name = parser.getName();
+ // Only takes care of waypoints in the gpx
+ if (name.equals("wpt")) {
+ Location diveloc = readLocation(parser);
+ DiveLocationLog dll = readEntry(parser);
+ dll.setLocation(diveloc);
+ alldivelogs.add(dll);
+ } else {
+ skip(parser);
+ }
+ }
+ return alldivelogs;
+ }
+
+ /**
+ * Parses the contents of an entry. If it encounters a name or time, hands
them off
+ * to their respective "read" methods for processing. Otherwise, skips the
tag.
+ * @param parser The XmlPullParser in its present state
+ * @return DiveLocationLog containing Name and Time entries
+ * @throws XmlPullParserException
+ * @throws IOException
+ * @throws ParseException
+ */
+ //
+ private DiveLocationLog readEntry(XmlPullParser parser) throws
XmlPullParserException, IOException, ParseException {
+ parser.require(XmlPullParser.START_TAG, ns, "wpt");
+ String divename = null;
+ Location diveloc = new Location("");
+ long divetimestamp = -1;
+ while (parser.next() != XmlPullParser.END_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
+ continue;
+ }
+ String name = parser.getName();
+ if (name.equals("name")) {
+ divename = readName(parser);
+ } else if (name.equals("time")) {
+ divetimestamp = readTime(parser);
+ } else {
+ skip(parser);
+ }
+ }
+ return new DiveLocationLog(diveloc, divename, divetimestamp);
+ }
+
+ /**
+ * Processes title tags in the feed.
+ * @param parser The XmlPullParser in its present state
+ * @return text present in the name tag of the gpx
+ * @throws IOException
+ * @throws XmlPullParserException
+ */
+ private String readName(XmlPullParser parser) throws IOException,
XmlPullParserException {
+ parser.require(XmlPullParser.START_TAG, ns, "name");
+ String title = readText(parser);
+ parser.require(XmlPullParser.END_TAG, ns, "name");
+ return title;
+ }
+
+ /**
+ * Extracts latitude and longitude attributr from wpt tag in the feed.
+ * @param parser The XmlPullParser in its present state
+ * @return Location of the waypoint extracted from the attributes of wpt
tag
+ * @throws IOException
+ * @throws XmlPullParserException
+ */
+ private Location readLocation(XmlPullParser parser) throws IOException,
XmlPullParserException {
+ Location diveloc = new Location("");
+ Double divelat, divelon;
+ parser.require(XmlPullParser.START_TAG, ns, "wpt");
+ divelat = Double.valueOf(parser.getAttributeValue(null, "lat"));
+ divelon = Double.valueOf(parser.getAttributeValue(null, "lon"));
+ diveloc.setLatitude(divelat);
+ diveloc.setLongitude(divelon);
+ return diveloc;
+ }
+
+ /**
+ * Extracts time from the GPX given in ISO-8601 format and converts to UTC
timestamp
+ * @param parser The XmlPullParser in its present state
+ * @return timestamp of the dive extracted from the time tag of gpx
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @throws ParseException
+ */
+ private long readTime(XmlPullParser parser) throws IOException,
XmlPullParserException, ParseException {
+ parser.require(XmlPullParser.START_TAG, ns, "time");
+ String time = readText(parser);
+ long timestamp = 0;
+ SimpleDateFormat isotime = new SimpleDateFormat(DATEFORMAT,
Locale.getDefault());
+ timestamp = isotime.parse(time).getTime();
+ parser.require(XmlPullParser.END_TAG, ns, "time");
+ return timestamp;
+ }
+
+ /**
+ * For the tags name and time extracts their text values.
+ * @param parser The XmlPullParser in its present state
+ * @return the text present in the present tag
+ * @throws IOException
+ * @throws XmlPullParserException
+ */
+ private String readText(XmlPullParser parser) throws IOException,
XmlPullParserException {
+ String result = "";
+ if (parser.next() == XmlPullParser.TEXT) {
+ result = parser.getText();
+ parser.nextTag();
+ }
+ return result;
+ }
+
+ /**
+ * Skips the tag names not require
+ * @param parser The XmlPullParser in its present state
+ * @throws XmlPullParserException
+ * @throws IOException
+ */
+ private void skip(XmlPullParser parser) throws XmlPullParserException,
IOException {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
+ throw new IllegalStateException();
+ }
+ int depth = 1;
+ while (depth != 0) {
+ switch (parser.next()) {
+ case XmlPullParser.END_TAG:
+ depth--;
+ break;
+ case XmlPullParser.START_TAG:
+ depth++;
+ break;
+ }
+ }
+ }
+}
-- 
1.7.9.5









*Venkatesh Shukla B. Tech  ( Electrical Engineering )III YearIndian
Institute of TechnologyBanaras Hindu UniversityPh No. +91 8960 579 122*
*Email: venkatesh.shukla.eee11 at iitbhu.ac.in
<venkatesh.shukla.eee11 at iitbhu.ac.in>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140312/bf5c8a5f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Improved-code-as-suggested-by-Aur-lien.patch
Type: text/x-patch
Size: 50031 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140312/bf5c8a5f/attachment-0001.bin>


More information about the subsurface mailing list