littledot5566 avatar littledot5566 committed 0adf1e7

*Fixed disappearing text for Go! button in ExpeditionConfigActivity. *Changed location lock dialog to be cancelable and closes activity if cancelled.

Comments (0)

Files changed (4)

res/layout/selectdistance_act_layout.xml

-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:orientation="vertical" >
-
-    <TextView
-        android:id="@+id/distance_tv_title"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/distance_tv_title" />
-
-    <Button
-        android:id="@+id/distance_but_500m"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:onClick="onChooseDistance"
-        android:text="@string/distance_but_500m" />
-
-    <LinearLayout
-        android:id="@+id/distance_ll_custom"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:orientation="horizontal" >
-
-        <EditText
-            android:id="@+id/distance_et_custom"
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:hint="@string/distance_et_custom"
-            android:inputType="numberDecimal"
-            android:visibility="gone" />
-
-        <Button
-            android:id="@+id/distance_but_custom"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:onClick="onChooseCustomDistance"
-            android:text="@string/distance_but_custom" />
-    </LinearLayout>
-
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:id="@+id/distance_tv_title"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/distance_tv_title" />
+
+    <Button
+        android:id="@+id/distance_but_500m"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:onClick="onChooseDistance"
+        android:text="@string/distance_but_500m" />
+
    <Button
+        android:id="@+id/distance_but_1000m"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:onClick="onChooseDistance"
+        android:text="1000m" />
+
+    <LinearLayout
+        android:id="@+id/distance_ll_custom"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:orientation="horizontal" >
+
+        <EditText
+            android:id="@+id/distance_et_custom"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:hint="@string/distance_et_custom"
+            android:inputType="numberDecimal" />
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:onClick="onChooseCustomDistance"
+            android:text="Go!" />
+    </LinearLayout>
+
 </LinearLayout>

res/values/strings.xml

     <string name="main_but_startHunt">Start a new treasure expedition!</string>
     <string name="distance_tv_title">Set your distance!</string>
     <string name="distance_but_500m">500m</string>
-    <string name="distance_et_custom">Enter custom distance</string>
+    <string name="distance_et_custom">Enter custom distance (m)</string>
     <string name="distance_but_custom">Custom</string>
 
 </resources>

src/nctuw/littledot/localtreasure/components/ExpeditionActivity.java

 		if (id == LOCATION_LOCK_DIALOG) {
 			pdLock.setTitle("Calibrating device");
 			pdLock.setMessage("Please walk around so that the GPS can get a fix");
-			// pdLock.setCanceledOnTouchOutside(false);
+			pdLock.setCanceledOnTouchOutside(false);
+			pdLock.setCancelable(true);
 			pdLock.setOnCancelListener(new OnCancelListener() {
 				public void onCancel(DialogInterface dialog) {
 					dialog.dismiss();

src/nctuw/littledot/localtreasure/components/ExpeditionConfigActivity.java

 import nctuw.littledot.localtreasure.R;
 
 import org.holoeverywhere.app.Activity;
+import org.holoeverywhere.widget.Button;
+import org.holoeverywhere.widget.EditText;
+import org.holoeverywhere.widget.Toast;
 
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.Toast;
 
 public class ExpeditionConfigActivity extends Activity {
 	InputMethodManager imm;
 				intent.putExtra(Const.BUNDLE_SOURCE, getClass().getName());
 				intent.putExtra(Const.BUNDLE_DISTANCE, 500D);
 				break;
+			case R.id.distance_but_1000m:
+				intent.putExtra(Const.BUNDLE_SOURCE, getClass().getName());
+				intent.putExtra(Const.BUNDLE_DISTANCE, 1000D);
+				break;
 		}
 
 		startActivity(intent);
 
 	public void onChooseCustomDistance(View v) {
 		EditText et = (EditText) findViewById(R.id.distance_et_custom);
-		Button but = (Button) findViewById(R.id.distance_but_custom);
 
-		if (et.getVisibility() == View.GONE) {
-			et.setVisibility(View.VISIBLE);
-			but.setText("OK!");
-
-		} else {
+		try {
 			double d = Double.parseDouble(et.getText().toString());
 
 			// cannot > 1/2 * circumference of Earth (40075km)
 				startActivity(intent);
 				finish();
 			}
-
+		} catch (NumberFormatException e) {
+			Toast
+					.makeText(this, "Please enter a valid number.", Toast.LENGTH_SHORT)
+					.show();
 		}
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.