Commits

Chaim Krause committed 7d7b55b

Initial import.

Comments (0)

Files changed (22)

+syntax: glob
+bin/*
+gen/*

AndroidManifest.xml

+<?xml version="1.0" encoding="utf-8"?>
+<manifest
+	xmlns:android="http://schemas.android.com/apk/res/android"
+	android:versionCode="1"
+	android:versionName="1.0"
+	package="com.combatcoding.GridSquare">
+	<uses-sdk
+		android:minSdkVersion="8" />
+	<uses-permission
+		android:name="android.permission.INTERNET"></uses-permission>
+
+	<application
+		android:icon="@drawable/icon"
+		android:label="@string/app_name">
+		<activity
+			android:name=".MainActivity"
+			android:label="@string/app_name">
+			<intent-filter>
+				<action
+					android:name="android.intent.action.MAIN" />
+				<category
+					android:name="android.intent.category.LAUNCHER" />
+			</intent-filter>
+		</activity>
+		<activity
+			android:name=".AboutActivity"
+			android:label="@string/about"
+			android:theme="@android:style/Theme.Dialog">
+		</activity>
+		<activity
+			android:name=".HelpActivity"
+			android:label="@string/help">
+		</activity>
+	</application>
+</manifest>
+CHANGES
+
+1.0.0  -  20NOV2011  --  Initial release.
+GridSquare is lecensed under the MIT License.
+
+Copyright (C) 2011 by Chaim Krause
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+<html>
+<head>
+<title>GridSquare Help</title>
+</head>
+<body>
+This is the help for GridSquare.
+</body>
+</html>

default.properties

+# 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 use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=Google Inc.:Google APIs:8

libs/android-support-v4.jar

Binary file added.

libs/gdal.jar

Binary file added.

libs/gluegen-rt.jar

Binary file added.

libs/jogl.jar

Binary file added.

libs/worldwind.jar

Binary file added.
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+    native <methods>;
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+   public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+  public static final android.os.Parcelable$Creator *;
+}

res/drawable-hdpi/icon.png

Added
New image

res/drawable-ldpi/icon.png

Added
New image

res/drawable-mdpi/icon.png

Added
New image

res/layout/about.xml

+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  android:orientation="vertical"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent">
+    <TextView android:id="@+id/textAbout" android:layout_width="match_parent" android:text="@string/abouttext" android:layout_height="wrap_content"></TextView>
+    <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/btnClose" android:text="@string/close" android:onClick="closeAbout"></Button>
+    
+</LinearLayout>

res/layout/help.xml

+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  android:orientation="vertical"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent">
+    <WebView android:id="@+id/webView1" android:layout_width="match_parent" android:layout_height="match_parent"></WebView>
+    
+</LinearLayout>

res/layout/main.xml

+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+	xmlns:android="http://schemas.android.com/apk/res/android"
+	android:orientation="vertical"
+	android:layout_width="fill_parent"
+	android:layout_height="fill_parent"
+	android:id="@+id/layMain">
+
+	<!-- MGRS -->
+	<LinearLayout
+		android:layout_width="match_parent"
+		android:layout_height="wrap_content"
+		android:orientation="vertical"
+		android:id="@+id/layMGRS">
+		<TextView
+			android:textAppearance="?android:attr/textAppearanceMedium"
+			android:layout_height="wrap_content"
+			android:id="@+id/headerMGRS"
+			android:text="@string/mgrs"
+			android:layout_width="match_parent"></TextView>
+		<LinearLayout
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:id="@+id/layMGRSa">
+			<EditText
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:id="@+id/editMGRS"
+				android:layout_weight="95">
+			</EditText>
+			<Button
+				android:layout_height="wrap_content"
+				android:layout_width="wrap_content"
+				android:text="@string/convert"
+				android:onClick="convertMGRS"
+				android:id="@+id/btnConvertMGRS"
+				android:layout_weight="5"></Button>
+		</LinearLayout>
+	</LinearLayout>
+
+	<!-- Degrees Minutes Seconds -->
+	<LinearLayout
+		android:layout_width="match_parent"
+		android:layout_height="wrap_content"
+		android:orientation="vertical"
+		android:id="@+id/layDMS">
+		<TextView
+			android:textAppearance="?android:attr/textAppearanceMedium"
+			android:layout_height="wrap_content"
+			android:id="@+id/headerDMS"
+			android:text="@string/DMS"
+			android:layout_width="match_parent"></TextView>
+		<LinearLayout
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:id="@+id/layDMSa">
+			<LinearLayout
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:orientation="vertical"
+				android:layout_weight="95"
+				android:id="@+id/layDMSa1">
+				<TextView
+					android:layout_width="match_parent"
+					android:layout_height="wrap_content"
+					android:layout_weight="95"
+					android:id="@+id/txtLatDMS"
+					android:text="@string/latitude"></TextView>
+				<LinearLayout
+					android:layout_width="match_parent"
+					android:layout_height="wrap_content"
+					android:id="@+id/layDMSa1a">
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLatDeg">
+					</EditText>
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLatMin"></EditText>
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLatSec"></EditText>
+				</LinearLayout>
+				<TextView
+					android:layout_height="wrap_content"
+					android:layout_weight="95"
+					android:text="@string/longitude"
+					android:id="@+id/txtLonDMS"
+					android:layout_width="match_parent"></TextView>
+				<LinearLayout
+					android:layout_width="match_parent"
+					android:layout_height="wrap_content"
+					android:id="@+id/layDMSa1b">
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLonDeg">
+					</EditText>
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLonMin"></EditText>
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLonSec"></EditText>
+				</LinearLayout>
+			</LinearLayout>
+			<Button
+				android:layout_width="wrap_content"
+				android:layout_height="match_parent"
+				android:layout_weight="5"
+				android:text="@string/convert"
+				android:onClick="convertDMS"
+				android:id="@+id/btnConvertDMS"></Button>
+		</LinearLayout>
+	</LinearLayout>
+
+	<!-- Decimal Degrees -->
+	<LinearLayout
+		android:layout_width="match_parent"
+		android:layout_height="wrap_content"
+		android:orientation="vertical"
+		android:id="@+id/layDD">
+		<TextView
+			android:textAppearance="?android:attr/textAppearanceMedium"
+			android:layout_height="wrap_content"
+			android:id="@+id/headerDD"
+			android:text="@string/decdeg"
+			android:layout_width="match_parent"></TextView>
+		<LinearLayout
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:id="@+id/layDDa">
+			<LinearLayout
+				android:layout_width="wrap_content"
+				android:orientation="vertical"
+				android:layout_height="wrap_content"
+				android:layout_weight="95"
+				android:id="@+id/layDDa1">
+				<TextView
+					android:text="@string/latitude"
+					android:layout_width="match_parent"
+					android:layout_height="wrap_content"
+					android:layout_weight="1"
+					android:id="@+id/txtLatDD"></TextView>
+				<LinearLayout
+					android:layout_width="match_parent"
+					android:layout_height="wrap_content"
+					android:id="@+id/layDDa1a">
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLatDD"></EditText>
+				</LinearLayout>
+				<TextView
+					android:layout_height="wrap_content"
+					android:layout_weight="1"
+					android:text="@string/longitude"
+					android:id="@+id/txtLonDD"
+					android:layout_width="match_parent"></TextView>
+				<LinearLayout
+					android:layout_width="match_parent"
+					android:layout_height="wrap_content"
+					android:id="@+id/layDDa1b">
+					<EditText
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:id="@+id/editLonDD"></EditText>
+				</LinearLayout>
+			</LinearLayout>
+			<Button
+				android:layout_width="wrap_content"
+				android:layout_height="match_parent"
+				android:layout_weight="5"
+				android:id="@+id/btnConvertDD"
+				android:text="@string/convert"
+				android:onClick="convertDD"></Button>
+		</LinearLayout>
+	</LinearLayout>
+	
+	<!-- Map and Clear Buttons -->
+	<LinearLayout
+		android:layout_width="match_parent"
+		android:id="@+id/layButtons"
+		android:layout_height="match_parent">
+		<Button
+			android:layout_width="wrap_content"
+			android:layout_weight="50"
+			android:id="@+id/btnMapIt"
+			android:layout_height="match_parent"
+			android:text="@string/mapit"
+			android:onClick="mapit"></Button>
+		<Button
+			android:layout_width="wrap_content"
+			android:layout_weight="50"
+			android:id="@+id/btnClear"
+			android:layout_height="match_parent"
+			android:text="@string/clear"
+			android:onClick="clearit"></Button>
+	</LinearLayout>
+
+</LinearLayout>

res/values/strings.xml

+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="hello">Hello World, MainActivity!</string>
+    <string name="app_name">GridSquare</string>
+    <string name="mgrs">MGRS</string>
+    <string name="DMS">Degrees Minutes Seconds</string>
+    <string name="decdeg">Decimal Degrees</string>
+    <string name="utm">UTM</string>
+    <string name="convert">Convert</string>
+    <string name="latitude">Latitude</string>
+    <string name="longitude">Longitude</string>
+    <string name="mapit">Map It</string>
+    <string name="clear">Clear</string>
+    <string name="about">About GridSquare</string>
+    <string name="abouttext">Version 1.0.0\n\nCopyright 2011 by Chaim Krause\n\nhttp://www.chaim.com/GridSquare</string>
+    <string name="close">Close</string>
+    <string name="help">Help</string>
+</resources>

src/com/combatcoding/GridSquare/AboutActivity.java

+package com.combatcoding.GridSquare;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+
+public class AboutActivity extends Activity {
+
+	@Override
+	public void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.about);
+	}
+
+	public void closeAbout(View v) {
+		finish();
+	}
+}

src/com/combatcoding/GridSquare/HelpActivity.java

+package com.combatcoding.GridSquare;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.webkit.WebView;
+
+public class HelpActivity extends Activity {
+	WebView webview;
+	
+	/** Called when the activity is first created. */
+	@Override
+	public void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.help);
+		
+		webview = (WebView) findViewById(R.id.webView1);
+		webview.loadUrl("file:///help.html");
+	}
+}

src/com/combatcoding/GridSquare/MainActivity.java

+package com.combatcoding.GridSquare;
+
+import gov.nasa.worldwind.geom.Angle;
+import gov.nasa.worldwind.geom.LatLon;
+import gov.nasa.worldwind.geom.coords.MGRSCoord;
+import gov.nasa.worldwind.globes.Globe;
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.EditText;
+
+public class MainActivity extends Activity {
+	
+	EditText editMGRS;
+	EditText editLatDeg;
+	EditText editLatMin;
+	EditText editLatSec;
+	EditText editLonDeg;
+	EditText editLonMin;
+	EditText editLonSec;
+	EditText editLatDD;
+	EditText editLonDD;
+	
+	/** Called when the activity is first created. */
+	@Override
+	public void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.main);
+
+		editMGRS = (EditText) findViewById(R.id.editMGRS);
+		editLatDeg = (EditText) findViewById(R.id.editLatDeg);
+		editLatMin = (EditText) findViewById(R.id.editLatMin);
+		editLatSec = (EditText) findViewById(R.id.editLatSec);
+		editLonDeg = (EditText) findViewById(R.id.editLonDeg);
+		editLonMin = (EditText) findViewById(R.id.editLonMin);
+		editLonSec = (EditText) findViewById(R.id.editLonSec);
+		editLatDD = (EditText) findViewById(R.id.editLatDD);
+		editLonDD = (EditText) findViewById(R.id.editLonDD);
+	}
+	
+	public void clearit(View v) {
+		editMGRS.setText("");
+		editLatDeg.setText("");
+		editLatMin.setText("");
+		editLatSec.setText("");
+		editLonDeg.setText("");
+		editLonMin.setText("");
+		editLonSec.setText("");
+		editLatDD.setText("");
+		editLonDD.setText("");
+	}
+	
+	public void convertMGRS(View v) {
+		Globe globe = null;
+		String mgrs_as_string = editMGRS.getText().toString();
+		MGRSCoord mgrscoord = MGRSCoord.fromString(mgrs_as_string, globe);
+		LatLon latlon = new LatLon(mgrscoord.getLatitude(), mgrscoord.getLongitude());
+
+		toDMS(latlon);
+		toDD(latlon);
+	}
+
+	public void convertDMS(View v) {
+		String deg;
+		String min;
+		String sec;
+		
+		deg = editLatDeg.getText().toString();
+		min = editLatMin.getText().toString();
+		sec = editLatSec.getText().toString();
+		Angle latitude = Angle.fromDMS(deg + " " + min + " " + sec);
+		
+		deg = editLonDeg.getText().toString();
+		min = editLonMin.getText().toString();
+		sec = editLonSec.getText().toString();
+		Angle longitude = Angle.fromDMS(deg + " " + min + " " + sec);
+		
+		LatLon latlon = new LatLon(latitude, longitude);
+		
+		toMGRS(latlon);
+		toDD(latlon);
+	}
+	
+	public void convertDD(View v) {
+		String str;
+		Double dbl;
+
+		str = editLatDD.getText().toString() + "d";
+		dbl = Double.valueOf(str);
+		Angle latitude = Angle.fromDegreesLatitude(dbl);
+		
+		str = editLonDD.getText().toString() + "d";
+		dbl = Double.valueOf(str);
+		Angle longitude = Angle.fromDegreesLongitude(dbl);
+		
+		LatLon latlon = new LatLon(latitude, longitude);
+		
+		toMGRS(latlon);
+		toDMS(latlon);
+	}
+	
+	private void toMGRS(LatLon latlon) {
+		MGRSCoord mgrscoord = MGRSCoord.fromLatLon(latlon.getLatitude(), latlon.getLongitude());
+		editMGRS.setText(mgrscoord.toString());
+	}
+
+	private void toDMS(LatLon latlon) {
+		String latitude = latlon.getLatitude().toDMSString();
+		editLatDeg.setText(latitude.split(" ")[0]);
+		editLatMin.setText(latitude.split(" ")[1]);
+		editLatSec.setText(latitude.split(" ")[2]);
+
+		String longitude = latlon.getLongitude().toDMSString();
+		editLonDeg.setText(longitude.split(" ")[0]);
+		editLonMin.setText(longitude.split(" ")[1]);
+		editLonSec.setText(longitude.split(" ")[2]);
+	}
+
+	private void toDD(LatLon latlong) {
+		editLatDD.setText(latlong.getLatitude().toDecimalDegreesString(14));
+		editLonDD.setText(latlong.getLongitude().toDecimalDegreesString(14));
+	}
+	
+	public void mapit(View v) {
+		Globe globe = null;
+		MGRSCoord mgrs = MGRSCoord.fromString(editMGRS.getText().toString(), globe);
+		String latitude = Double.toString(mgrs.getLatitude().getDegrees());
+		String longitude = Double.toString(mgrs.getLongitude().getDegrees());
+		String uri = "geo:" + latitude + "," + longitude + "?z=13";
+		Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
+		startActivity(i);
+	}
+	
+	@Override public boolean onCreateOptionsMenu(Menu menu) {
+	    menu.add(Menu.NONE, 1, Menu.NONE, "Help");
+	    menu.add(Menu.NONE, 2, Menu.NONE, "About");
+	    menu.add(Menu.NONE, 3, Menu.NONE, "Exit");
+	    return true;
+	}
+	    
+	@Override public boolean onOptionsItemSelected(MenuItem item) {
+	    switch (item.getItemId()) {
+	    	case 1:
+	    		startActivity(new Intent(MainActivity.this, HelpActivity.class));
+	    		return true;
+	        case 2:
+	        	startActivity(new Intent(MainActivity.this, AboutActivity.class));
+	            return true;
+	        case 3:
+	        	finish();
+	        default: ;
+	    }
+	    return false;
+	}
+	
+}