aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorAnna PS <annapowellsmith@gmail.com>2010-06-15 23:25:29 +0100
committerAnna PS <annapowellsmith@gmail.com>2010-06-15 23:25:29 +0100
commit4486c1894381380c64411aace2f4d1acf91105ca (patch)
tree47b11a46b81724b1bf8da085d18e60a19c7d2b7a /android
parentdbe01e55a0c5799b753c6774126aa988e71eb612 (diff)
Bringing up-to-date with my local copy - latest app on market
Diffstat (limited to 'android')
-rw-r--r--android/Fix My Street/res/drawable/blue_filler.xml6
-rw-r--r--android/Fix My Street/res/layout/about.xml88
-rw-r--r--android/Fix My Street/res/layout/details.xml140
-rw-r--r--android/Fix My Street/res/layout/help.xml74
-rw-r--r--android/Fix My Street/res/layout/home.xml78
-rw-r--r--android/Fix My Street/res/layout/success.xml86
-rw-r--r--android/Fix My Street/res/values/strings.xml15
-rw-r--r--android/Fix My Street/res/values/themes.xml10
-rw-r--r--android/Fix My Street/src/com/android/fixmystreet/About.java132
-rw-r--r--android/Fix My Street/src/com/android/fixmystreet/Details.java501
-rw-r--r--android/Fix My Street/src/com/android/fixmystreet/Help.java118
-rw-r--r--android/Fix My Street/src/com/android/fixmystreet/Home.java1445
-rw-r--r--android/Fix My Street/src/com/android/fixmystreet/Success.java112
13 files changed, 1405 insertions, 1400 deletions
diff --git a/android/Fix My Street/res/drawable/blue_filler.xml b/android/Fix My Street/res/drawable/blue_filler.xml
index 6e90b805f..5d2282a08 100644
--- a/android/Fix My Street/res/drawable/blue_filler.xml
+++ b/android/Fix My Street/res/drawable/blue_filler.xml
@@ -1,3 +1,3 @@
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/filler" android:tileMode="repeat" />
-
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/filler" android:tileMode="repeat" />
+
diff --git a/android/Fix My Street/res/layout/about.xml b/android/Fix My Street/res/layout/about.xml
index d95ffa470..1e413520b 100644
--- a/android/Fix My Street/res/layout/about.xml
+++ b/android/Fix My Street/res/layout/about.xml
@@ -1,45 +1,45 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:padding="0dip" android:fillViewport="true">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:padding="0dip">
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="What is Fix My Street?"
- android:paddingBottom="5dip" android:paddingTop="5dip"
- android:paddingLeft="5dip" android:paddingRight="5dip"
- android:textStyle="bold" />
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Fix My Street helps you report problems in your local area - like potholes or broken streetlights - to your council."
- android:paddingBottom="5dip" android:paddingLeft="5dip"
- android:paddingRight="5dip" />
-
- <TextView android:id="@+id/faq" android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Fix My Street is mainly a website, run by mySociety, a project of a registered charity. For more information, see http://www.fixmystreet.com/faq."
- android:paddingBottom="5dip" android:paddingLeft="5dip"
- android:paddingRight="5dip" android:linksClickable="true" />
-
-
- <TextView android:id="@+id/faq" android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="This application is version 0.8 of Fix My Street for Android, written as a volunteer project by Anna Powell-Smith."
- android:paddingBottom="5dip" android:paddingLeft="5dip"
- android:paddingRight="5dip" android:linksClickable="true" />
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text=" "
- android:layout_weight="1" />
-
- <ImageView android:layout_width="fill_parent" android:scaleType="centerCrop"
- android:layout_gravity="bottom" android:layout_height="wrap_content"
- android:src="@drawable/street_background_smaller"></ImageView>
- </LinearLayout>
-
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:padding="0dip" android:fillViewport="true">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:padding="0dip">
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="What is Fix My Street?"
+ android:paddingBottom="5dip" android:paddingTop="5dip"
+ android:paddingLeft="5dip" android:paddingRight="5dip"
+ android:textStyle="bold" />
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Fix My Street helps you report problems in your local area - like potholes or broken streetlights - to your council."
+ android:paddingBottom="5dip" android:paddingLeft="5dip"
+ android:paddingRight="5dip" />
+
+ <TextView android:id="@+id/faq" android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Fix My Street is mainly a website, run by mySociety, a project of a registered charity. For more information, see http://www.fixmystreet.com/faq."
+ android:paddingBottom="5dip" android:paddingLeft="5dip"
+ android:paddingRight="5dip" android:linksClickable="true" />
+
+
+ <TextView android:id="@+id/faq2" android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text=""
+ android:paddingBottom="5dip" android:paddingLeft="5dip"
+ android:paddingRight="5dip" android:linksClickable="true" />
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text=" "
+ android:layout_weight="1" />
+
+ <ImageView android:layout_width="fill_parent" android:scaleType="centerCrop"
+ android:layout_gravity="bottom" android:layout_height="wrap_content"
+ android:src="@drawable/street_background_smaller"></ImageView>
+ </LinearLayout>
+
</ScrollView> \ No newline at end of file
diff --git a/android/Fix My Street/res/layout/details.xml b/android/Fix My Street/res/layout/details.xml
index 6a5bbe9aa..4464ed3f1 100644
--- a/android/Fix My Street/res/layout/details.xml
+++ b/android/Fix My Street/res/layout/details.xml
@@ -1,71 +1,71 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:fillViewport="true">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:padding="0dip">
-
- <!-- And a name -->
- <TextView android:id="@+id/name_save" android:layout_width="fill_parent"
- android:paddingTop="5dip" android:paddingLeft="5dip"
- android:paddingRight="5dip" android:layout_height="wrap_content"
- android:text="Short title for problem (you can add more later):" />
-
- <!-- Subject -->
-
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:orientation="horizontal"
- android:padding="5dip">
- <TextView android:id="@+id/subject_label"
- android:layout_width="80sp" android:layout_height="24sp"
- android:text="Title:" />
- <EditText android:id="@+id/subject_text"
- android:layout_width="fill_parent" android:layout_height="40sp"
- android:singleLine="True" android:capitalize="sentences" />
- </LinearLayout>
-
- <!-- And a name -->
- <TextView android:id="@+id/name_save" android:layout_width="fill_parent"
- android:paddingLeft="5dip" android:paddingRight="5dip"
- android:layout_height="wrap_content" android:text="We'll save these for next time:" />
-
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:orientation="horizontal"
- android:padding="5dip">
- <TextView android:id="@+id/name_label" android:layout_width="80sp"
- android:layout_height="24sp" android:text="Your name:" />
- <EditText android:id="@+id/name_text" android:layout_width="fill_parent"
- android:layout_height="40sp" android:singleLine="True"
- android:capitalize="words" />
- </LinearLayout>
-
- <!-- An email address -->
-
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:orientation="horizontal"
- android:padding="5dip">
- <TextView android:id="@+id/email_label"
- android:layout_width="80sp" android:layout_height="24sp"
- android:text="Your email:" />
- <EditText android:id="@+id/email_text" android:layout_width="fill_parent"
- android:layout_height="40sp" android:singleLine="True"
- android:capitalize="none" />
- </LinearLayout>
-
- <Button android:id="@+id/submit_button" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="Save details"
- android:padding="5dip" />
-
- <TextView android:layout_width="fill_parent"
- android:layout_weight="1" android:layout_height="wrap_content"
- android:text=" " />
-
- <ImageView android:layout_width="fill_parent"
- android:scaleType="centerCrop" android:layout_gravity="bottom"
- android:layout_height="wrap_content" android:src="@drawable/street_background_smaller"></ImageView>
- </LinearLayout>
-
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:fillViewport="true">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:padding="0dip">
+
+ <!-- And a name -->
+ <TextView android:id="@+id/name_save" android:layout_width="fill_parent"
+ android:paddingTop="5dip" android:paddingLeft="5dip"
+ android:paddingRight="5dip" android:layout_height="wrap_content"
+ android:text="Short title for problem (you can add more later):" />
+
+ <!-- Subject -->
+
+ <LinearLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:orientation="horizontal"
+ android:padding="5dip">
+ <TextView android:id="@+id/subject_label"
+ android:layout_width="80sp" android:layout_height="24sp"
+ android:text="Title:" />
+ <EditText android:id="@+id/subject_text"
+ android:layout_width="fill_parent" android:layout_height="40sp"
+ android:singleLine="True" android:capitalize="sentences" />
+ </LinearLayout>
+
+ <!-- And a name -->
+ <TextView android:id="@+id/name_save" android:layout_width="fill_parent"
+ android:paddingLeft="5dip" android:paddingRight="5dip"
+ android:layout_height="wrap_content" android:text="We'll save these for next time:" />
+
+ <LinearLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:orientation="horizontal"
+ android:padding="5dip">
+ <TextView android:id="@+id/name_label" android:layout_width="80sp"
+ android:layout_height="24sp" android:text="Your name:" />
+ <EditText android:id="@+id/name_text" android:layout_width="fill_parent"
+ android:layout_height="40sp" android:singleLine="True"
+ android:capitalize="words" />
+ </LinearLayout>
+
+ <!-- An email address -->
+
+ <LinearLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:orientation="horizontal"
+ android:padding="5dip">
+ <TextView android:id="@+id/email_label"
+ android:layout_width="80sp" android:layout_height="24sp"
+ android:text="Your email:" />
+ <EditText android:id="@+id/email_text" android:layout_width="fill_parent"
+ android:layout_height="40sp" android:singleLine="True"
+ android:capitalize="none" />
+ </LinearLayout>
+
+ <Button android:id="@+id/submit_button" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="Save details"
+ android:padding="5dip" />
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_weight="1" android:layout_height="wrap_content"
+ android:text=" " />
+
+ <ImageView android:layout_width="fill_parent"
+ android:scaleType="centerCrop" android:layout_gravity="bottom"
+ android:layout_height="wrap_content" android:src="@drawable/street_background_smaller"></ImageView>
+ </LinearLayout>
+
</ScrollView> \ No newline at end of file
diff --git a/android/Fix My Street/res/layout/help.xml b/android/Fix My Street/res/layout/help.xml
index b14da6b1b..2ae8052d9 100644
--- a/android/Fix My Street/res/layout/help.xml
+++ b/android/Fix My Street/res/layout/help.xml
@@ -1,38 +1,38 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:fillViewport="true">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:padding="0dip"
- android:scrollbars="vertical">
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="What do I do?"
- android:paddingBottom="5dip" android:paddingTop="5dip"
- android:paddingLeft="5dip" android:paddingRight="5dip"
- android:textStyle="bold" />
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/instructions"
- android:paddingBottom="5dip" android:paddingLeft="5dip"
- android:paddingRight="5dip" />
-
- <TextView android:id="@+id/faq" android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="For any other questions, see http://www.fixmystreet.com/faq, or email anna@mysociety.org."
- android:paddingBottom="5dip" android:paddingTop="5dip"
- android:paddingLeft="5dip" android:paddingRight="5dip"
- android:textStyle="bold" android:linksClickable="true" />
-
- <TextView android:layout_width="fill_parent" android:layout_weight="1"
- android:layout_height="wrap_content" android:text=" "
- />
-
- <ImageView android:layout_width="fill_parent" android:scaleType="centerCrop"
- android:layout_gravity="bottom" android:layout_height="wrap_content"
- android:src="@drawable/street_background_smaller"></ImageView>
- </LinearLayout>
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:fillViewport="true">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:padding="0dip"
+ android:scrollbars="vertical">
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="What do I do?"
+ android:paddingBottom="5dip" android:paddingTop="5dip"
+ android:paddingLeft="5dip" android:paddingRight="5dip"
+ android:textStyle="bold" />
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="@string/instructions"
+ android:paddingBottom="5dip" android:paddingLeft="5dip"
+ android:paddingRight="5dip" />
+
+ <TextView android:id="@+id/faq" android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="For any other questions, see http://www.fixmystreet.com/faq, or email anna@mysociety.org."
+ android:paddingBottom="5dip" android:paddingTop="5dip"
+ android:paddingLeft="5dip" android:paddingRight="5dip"
+ android:textStyle="bold" android:linksClickable="true" />
+
+ <TextView android:layout_width="fill_parent" android:layout_weight="1"
+ android:layout_height="wrap_content" android:text=" "
+ />
+
+ <ImageView android:layout_width="fill_parent" android:scaleType="centerCrop"
+ android:layout_gravity="bottom" android:layout_height="wrap_content"
+ android:src="@drawable/street_background_smaller"></ImageView>
+ </LinearLayout>
</ScrollView> \ No newline at end of file
diff --git a/android/Fix My Street/res/layout/home.xml b/android/Fix My Street/res/layout/home.xml
index 6e661461b..bcaae0669 100644
--- a/android/Fix My Street/res/layout/home.xml
+++ b/android/Fix My Street/res/layout/home.xml
@@ -1,36 +1,44 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:fillViewport="true">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:paddingTop="10dip">
-
- <Button android:id="@+id/camera_button" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="Take photo"
- android:drawableRight="@drawable/add" />
-
- <Button android:id="@+id/details_button" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="Add details"
- android:drawableRight="@drawable/add" android:paddingRight="10dip"
- android:paddingLeft="10dip" />
-
- <View android:layout_width="1dip" android:layout_height="10dip"
- android:src="@drawable/spacer" />
-
- <Button android:id="@+id/report_button" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="Report to Fix My Street"
- android:paddingRight="10dip" android:paddingLeft="10dip" />
- <TextView android:layout_width="fill_parent" android:layout_weight="1"
- android:layout_height="wrap_content" android:text=" "
- />
-
- <ImageView android:id="@+id/background_image" android:scaleType="centerCrop"
- android:layout_width="fill_parent" android:layout_gravity="bottom"
- android:layout_height="wrap_content" android:src="@drawable/street_background_smaller"></ImageView>
-
- </LinearLayout>
-
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:fillViewport="true">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingTop="10dip">
+
+ <Button android:id="@+id/camera_button" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="Take photo"
+ android:drawableRight="@drawable/add" />
+
+ <Button android:id="@+id/details_button" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="Add details"
+ android:drawableRight="@drawable/add" android:paddingRight="10dip"
+ android:paddingLeft="10dip" />
+
+ <View android:layout_width="1dip" android:layout_height="10dip"
+ android:src="@drawable/spacer" />
+
+ <TextView android:paddingRight="10dip" android:paddingLeft="10dip"
+ android:layout_width="wrap_content" android:textColor="#87190f"
+ android:id="@+id/progress_text" android:layout_height="wrap_content"
+ android:text="Waiting for a GPS fix... Please make sure you can see the sky." />
+
+ <Button android:id="@+id/report_button" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="Report to Fix My Street"
+ android:paddingRight="10dip" android:paddingLeft="10dip" />
+
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_weight="1" android:layout_height="wrap_content"
+ android:text=" " />
+
+ <ImageView android:id="@+id/background_image"
+ android:scaleType="centerCrop" android:layout_width="fill_parent"
+ android:layout_gravity="bottom" android:layout_height="wrap_content"
+ android:src="@drawable/street_background_smaller"></ImageView>
+
+ </LinearLayout>
+
</ScrollView> \ No newline at end of file
diff --git a/android/Fix My Street/res/layout/success.xml b/android/Fix My Street/res/layout/success.xml
index a80283cef..4c24055cc 100644
--- a/android/Fix My Street/res/layout/success.xml
+++ b/android/Fix My Street/res/layout/success.xml
@@ -1,44 +1,44 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:fillViewport="true">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:padding="0dip">
-
- <!--
- <Button android:id="@+id/about_button"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="About Fix My
- Street" />
- -->
-
- <TextView android:id="@+id/hello_text" android:layout_width="fill_parent"
- android:paddingBottom="5dip" android:paddingTop="5dip"
- android:paddingLeft="5dip" android:paddingRight="5dip"
- android:layout_height="wrap_content" android:text="Now check your email!"
- android:textStyle="bold" />
-
- <TextView android:id="@+id/hello_text" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:paddingBottom="5dip"
- android:paddingTop="5dip" android:paddingLeft="5dip"
- android:paddingRight="5dip"
- android:text="You'll receive an email from us soon. Please click on the confirmation link, and provide a few more details." />
-
- <TextView android:id="@+id/hello_text" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:paddingBottom="5dip"
- android:paddingTop="5dip" android:paddingLeft="5dip"
- android:paddingRight="5dip"
- android:text="If the email doesn't arrive within a few hours, please check your spam folder - sometimes the emails can be marked as spam." />
-
- <TextView android:layout_width="fill_parent" android:layout_weight="1"
- android:layout_height="wrap_content" android:text=" "
- />
-
- <ImageView android:layout_width="fill_parent" android:scaleType="centerCrop"
- android:layout_gravity="bottom" android:layout_height="wrap_content"
- android:src="@drawable/street_background_smaller"></ImageView>
- </LinearLayout>
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:fillViewport="true">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:padding="0dip">
+
+ <!--
+ <Button android:id="@+id/about_button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="About Fix My
+ Street" />
+ -->
+
+ <TextView android:id="@+id/hello_text" android:layout_width="fill_parent"
+ android:paddingBottom="5dip" android:paddingTop="5dip"
+ android:paddingLeft="5dip" android:paddingRight="5dip"
+ android:layout_height="wrap_content" android:text="Now check your email!"
+ android:textStyle="bold" />
+
+ <TextView android:id="@+id/hello_text" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingBottom="5dip"
+ android:paddingTop="5dip" android:paddingLeft="5dip"
+ android:paddingRight="5dip"
+ android:text="You'll receive an email from us soon. Please click on the confirmation link, check the location carefully, and provide a few more details." />
+
+ <TextView android:id="@+id/hello_text" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingBottom="5dip"
+ android:paddingTop="5dip" android:paddingLeft="5dip"
+ android:paddingRight="5dip"
+ android:text="If the email doesn't arrive within a few hours, please check your spam folder - sometimes the emails can be marked as spam." />
+
+ <TextView android:layout_width="fill_parent" android:layout_weight="1"
+ android:layout_height="wrap_content" android:text=" "
+ />
+
+ <ImageView android:layout_width="fill_parent" android:scaleType="centerCrop"
+ android:layout_gravity="bottom" android:layout_height="wrap_content"
+ android:src="@drawable/street_background_smaller"></ImageView>
+ </LinearLayout>
</ScrollView> \ No newline at end of file
diff --git a/android/Fix My Street/res/values/strings.xml b/android/Fix My Street/res/values/strings.xml
index 78c16eecb..0c88c4ea7 100644
--- a/android/Fix My Street/res/values/strings.xml
+++ b/android/Fix My Street/res/values/strings.xml
@@ -2,18 +2,7 @@
<resources>
<!-- Welcome screen -->
<string name="app_name">Fix My Street</string>
- <string name="hello">Fix My Street</string>
- <string name="confirm_location">Confirming location...</string>
- <string name="confirm_location_done">Confirmed location</string>
- <string name="take_a_picture">Take a picture of the problem</string>
- <string name="details">Add details</string>
- <string name="report">Report</string>
- <string name="about">About Fix My Street</string>
- <string name="close">Close</string>
- <string name="imageUrl">Enter a URL here</string>
-<!-- Details screen -->
- <string name="details_screen">Tell us about the problem (all fields required):</string>
- <string name="submit">Submit</string>
+
<!-- About screen -->
- <string name="instructions">1. Click \'Take photo\', then on the camera button to take a photo.\n2. Click \'Add details\', then give the problem a name (e.g. \'Broken street light\'), and add your own name and email address. \n3. Click \'Report\' to upload the problem to Fix My Street. \n4. Check your email. You\'ll need to click on a link to confirm the problem and add a few more details. </string>
+ <string name="instructions">1. Click \'Take photo\', then on the camera button to take a photo.\n2. Click \'Add details\', then give the problem a name (e.g. \'Broken street light\'), and add your own name and email address. \n3. Wait for a GPS fix (it\'ll take longer if it\'s cloudy). Then, click the \'Report\' button to upload the problem to Fix My Street. \n4. Check your email. You\'ll need to click on a link to confirm the problem and add a few more details. </string>
</resources>
diff --git a/android/Fix My Street/res/values/themes.xml b/android/Fix My Street/res/values/themes.xml
index 39584c6a9..65ba3b328 100644
--- a/android/Fix My Street/res/values/themes.xml
+++ b/android/Fix My Street/res/values/themes.xml
@@ -1,6 +1,6 @@
-<resources>
- <style name="Theme.Filler" parent="android:Theme">
- <item name="android:windowBackground">@drawable/blue_filler</item>
- <item name="android:textColor">#000000</item>
- </style>
+<resources>
+ <style name="Theme.Filler" parent="android:Theme">
+ <item name="android:windowBackground">@drawable/blue_filler</item>
+ <item name="android:textColor">#000000</item>
+ </style>
</resources> \ No newline at end of file
diff --git a/android/Fix My Street/src/com/android/fixmystreet/About.java b/android/Fix My Street/src/com/android/fixmystreet/About.java
index 9ddffadf6..07d323ce8 100644
--- a/android/Fix My Street/src/com/android/fixmystreet/About.java
+++ b/android/Fix My Street/src/com/android/fixmystreet/About.java
@@ -1,61 +1,73 @@
-package com.android.fixmystreet;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.text.util.Linkify;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.TextView;
-
-public class About extends Activity {
-
- private Bundle extras = null;
-
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.about);
- extras = getIntent().getExtras();
-
- // add links
- TextView noteView = (TextView) findViewById(R.id.faq);
- Linkify.addLinks(noteView, Linkify.ALL);
- }
-
- // ****************************************************
- // Options menu functions
- // ****************************************************
-
- // TODO - add Bundles for these?
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuItem homeItem = menu.add(0, 0, 0, "Home");
- MenuItem aboutItem = menu.add(0, 1, 0, "Help");
- aboutItem.setIcon(android.R.drawable.ic_menu_info_details);
- homeItem.setIcon(android.R.drawable.ic_menu_edit);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case 0:
- Intent i = new Intent(About.this, Home.class);
- if (extras != null) {
- i.putExtras(extras);
- }
- startActivity(i);
- return true;
- case 1:
- Intent j = new Intent(About.this, Help.class);
- if (extras != null) {
- j.putExtras(extras);
- }
- startActivity(j);
- return true;
- }
- return false;
- }
+package com.android.fixmystreet;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Bundle;
+import android.text.util.Linkify;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.TextView;
+
+public class About extends Activity {
+
+ private Bundle extras = null;
+ String versionName = "";
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ setContentView(R.layout.about);
+ extras = getIntent().getExtras();
+
+ try {
+ versionName = getPackageManager().getPackageInfo(getPackageName(),
+ 0).versionName;
+ } catch (NameNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // add links
+ TextView noteView = (TextView) findViewById(R.id.faq);
+ TextView noteView2 = (TextView) findViewById(R.id.faq2);
+ noteView2.setText("This application is version " + versionName + " of Fix My Street for Android, written by Anna Powell-Smith. Thanks to Paul for testing.");
+ Linkify.addLinks(noteView, Linkify.ALL);
+ }
+
+ // ****************************************************
+ // Options menu functions
+ // ****************************************************
+
+ // TODO - add Bundles for these?
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ MenuItem homeItem = menu.add(0, 0, 0, "Home");
+ MenuItem aboutItem = menu.add(0, 1, 0, "Help");
+ aboutItem.setIcon(android.R.drawable.ic_menu_info_details);
+ homeItem.setIcon(android.R.drawable.ic_menu_edit);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case 0:
+ Intent i = new Intent(About.this, Home.class);
+ if (extras != null) {
+ i.putExtras(extras);
+ }
+ startActivity(i);
+ return true;
+ case 1:
+ Intent j = new Intent(About.this, Help.class);
+ if (extras != null) {
+ j.putExtras(extras);
+ }
+ startActivity(j);
+ return true;
+ }
+ return false;
+ }
} \ No newline at end of file
diff --git a/android/Fix My Street/src/com/android/fixmystreet/Details.java b/android/Fix My Street/src/com/android/fixmystreet/Details.java
index 83c5cc78c..802be0342 100644
--- a/android/Fix My Street/src/com/android/fixmystreet/Details.java
+++ b/android/Fix My Street/src/com/android/fixmystreet/Details.java
@@ -1,249 +1,252 @@
-// ********************************************************************************
-//details.java
-//This file is where most of the work of the application happens. It collects the
-//subject of the problem, plus the user's name and email, from the Android form.
-//It uploads them to FixMyStreet, and shows a success or failure message.
-//
-//********************************************************************************
-
-package com.android.fixmystreet;
-
-import java.util.regex.*;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-//import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.EditText;
-
-public class Details extends Activity {
- private EditText nameET;
- private EditText emailET;
- private EditText subjectET;
- String storedName;
- String storedEmail;
- private String subject;
- private String name;
- private String email;
- private View submitButton;
- //private static final String LOG_TAG = "Details";
- public static final String PREFS_NAME = "FMS_Settings";
- final int NAME_WARNING = 999;
- final int SUBJECT_WARNING = 998;
- final int EMAIL_WARNING = 997;
- private Bundle extras;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // set up the page
- setContentView(R.layout.details);
- nameET = (EditText) findViewById(R.id.name_text);
- emailET = (EditText) findViewById(R.id.email_text);
- subjectET = (EditText) findViewById(R.id.subject_text);
- submitButton = this.findViewById(R.id.submit_button);
-
- // set the button listeners
- setListeners();
-
- // fill in name/email, if already defined
- // NB - from settings, rather than from bundle...
- SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
- name = settings.getString("myName", "");
- email = settings.getString("myEmail", "");
- nameET.setText(name);
- emailET.setText(email);
-
- extras = getIntent().getExtras();
- if (extras != null) {
- // Details extras
- subject = extras.getString("subject");
- }
- if (subject != null) {
- subjectET.setText(subject);
- }
- }
-
- private void setListeners() {
- // Save info and pass back to Home activity
- submitButton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- subject = subjectET.getText().toString();
- email = emailET.getText().toString();
- name = nameET.getText().toString();
- if (!textFieldsAreValid(subject)) {
- showDialog(SUBJECT_WARNING);
- } else if (!textFieldsAreValid(name)) {
- showDialog(NAME_WARNING);
- } else if (!isValidEmailAddress(email)) {
- showDialog(EMAIL_WARNING);
- } else {
- if (true) {
- Intent i = new Intent(Details.this, Home.class);
- extras.putString("name", name);
- extras.putString("email", email);
- extras.putString("subject", subject);
- i.putExtras(extras);
- startActivity(i);
- }
- }
- }
- });
- }
-
- // **********************************************************************
- // textFieldsAreValid: Make sure that fields aren't blank
- // **********************************************************************
- public static boolean textFieldsAreValid(String field) {
- if (field == null || field.length() == 0 || field.trim().length() == 0) {
- return false;
- }
- return true;
- }
-
- // **********************************************************************
- // isValidEmailAddress: Check the email address is OK
- // **********************************************************************
- public static boolean isValidEmailAddress(String emailAddress) {
- String emailRegEx;
- Pattern pattern;
- // Regex for a valid email address
- emailRegEx = "^[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z]{2,4}$";
- // Compare the regex with the email address
- pattern = Pattern.compile(emailRegEx);
- Matcher matcher = pattern.matcher(emailAddress);
- if (!matcher.find()) {
- return false;
- }
- return true;
- }
-
- // **********************************************************************
- // onCreateDialog: Dialog warnings
- // **********************************************************************
- @Override
- protected Dialog onCreateDialog(int id) {
- switch (id) {
- case SUBJECT_WARNING:
- return new AlertDialog.Builder(Details.this).setTitle("Subject")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- }).setMessage("Please enter a subject!").create();
- case NAME_WARNING:
- return new AlertDialog.Builder(Details.this)
- .setTitle("Name")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- })
- .setMessage(
- "Please enter your name. We'll remember it for next time.")
- .create();
-
- case EMAIL_WARNING:
- return new AlertDialog.Builder(Details.this)
- .setTitle("Email")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- })
- .setMessage(
- "Please enter a valid email address. We'll remember it for next time.")
- .create();
-
- }
- return null;
- }
-
- // Save user's name and email, if already defined
- @Override
- protected void onStop() {
- super.onStop();
-
- name = nameET.getText().toString();
- email = emailET.getText().toString();
-
- // Save user preferences
- SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
- SharedPreferences.Editor editor = settings.edit();
- editor.putString("myName", name);
- editor.putString("myEmail", email);
-
- // Don't forget to commit your edits!!!
- editor.commit();
- }
-
- // Look at this - is it working ok
- // public boolean testProviders() {
- // Log.e(LOG_TAG, "testProviders");
- // // StringBuilder sb = new StringBuilder("Enabled Providers");
- // // List<String> providers = locationmanager.getProviders(true);
- // // for (String provider : providers) {
- // // Log.e(LOG_TAG, "Provider = " + provider);
- // // listener = new LocationListener() {
- // // public void onLocationChanged(Location location) {
- // // }
- // //
- // // public void onProviderDisabled(String provider) {
- // // }
- // //
- // // public void onProviderEnabled(String provider) {
- // // }
- // //
- // // public void onStatusChanged(String provider, int status,
- // // Bundle extras) {
- // // }
- // // };
- // //
- // // locationmanager.requestLocationUpdates(provider, 0, 0, listener);
- // //
- // // sb.append("\n*").append(provider).append(": ");
- // //
- // // Location location = locationmanager.getLastKnownLocation(provider);
- // //
- // // if (location != null) {
- // // latitude = location.getLatitude();
- // // longitude = location.getLongitude();
- // // latString = latitude.toString();
- // // longString = longitude.toString();
- // // Log.e(LOG_TAG, "Latitude = " + latString);
- // // Log.e(LOG_TAG, "Longitude = " + longString);
- // // if (provider == "gps") {
- // // // Only bother with GPS if available
- // // return true;
- // // }
- // // } else {
- // // Log.e(LOG_TAG, "Location is null");
- // // return false;
- // // }
- // // }
- // // LocationManager lm = (LocationManager)
- // // context.getSystemService(Context.LOCATION_SERVICE);
- // //
- // // Location loc = lm.getLastKnownLocation("gps");
- // // if (loc == null)
- // // {
- // // locType = "Network";
- // // loc = lm.getLastKnownLocation("network");
- // // }
- // //
- // // textMsg.setText(sb);
- //
- // return true;
- // }
-}
+// ********************************************************************************
+//details.java
+//This file is where most of the work of the application happens. It collects the
+//subject of the problem, plus the user's name and email, from the Android form.
+//It uploads them to FixMyStreet, and shows a success or failure message.
+//
+//********************************************************************************
+
+package com.android.fixmystreet;
+
+import java.util.regex.*;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.EditText;
+
+public class Details extends Activity {
+ private EditText nameET;
+ private EditText emailET;
+ private EditText subjectET;
+ String storedName;
+ String storedEmail;
+ private String subject;
+ private String name;
+ private String email;
+ private View submitButton;
+ //private static final String LOG_TAG = "Details";
+ public static final String PREFS_NAME = "Settings";
+ final int NAME_WARNING = 999;
+ final int SUBJECT_WARNING = 998;
+ final int EMAIL_WARNING = 997;
+ private Bundle extras;
+ private Boolean havePicture = false;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // set up the page
+ setContentView(R.layout.details);
+ nameET = (EditText) findViewById(R.id.name_text);
+ emailET = (EditText) findViewById(R.id.email_text);
+ subjectET = (EditText) findViewById(R.id.subject_text);
+ submitButton = this.findViewById(R.id.submit_button);
+
+ // set the button listeners
+ setListeners();
+
+ // fill in name/email, if already defined
+ // NB - from settings, rather than from bundle...
+ SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
+ name = settings.getString("myName", "");
+ email = settings.getString("myEmail", "");
+ nameET.setText(name);
+ emailET.setText(email);
+
+ extras = getIntent().getExtras();
+ if (extras != null) {
+ // Details extras
+ subject = extras.getString("subject");
+ havePicture = extras.getBoolean("photo", havePicture);
+// Log.d(LOG_TAG, "extras havePicture" + havePicture);
+ }
+ if (subject != null) {
+ subjectET.setText(subject);
+ }
+ }
+
+ private void setListeners() {
+ // Save info and pass back to Home activity
+ submitButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ subject = subjectET.getText().toString();
+ email = emailET.getText().toString();
+ name = nameET.getText().toString();
+ if (!textFieldsAreValid(subject)) {
+ showDialog(SUBJECT_WARNING);
+ } else if (!textFieldsAreValid(name)) {
+ showDialog(NAME_WARNING);
+ } else if (!isValidEmailAddress(email)) {
+ showDialog(EMAIL_WARNING);
+ } else {
+ if (true) {
+ Intent i = new Intent(Details.this, Home.class);
+ extras.putString("name", name);
+ extras.putString("email", email);
+ extras.putString("subject", subject);
+ extras.putBoolean("photo", havePicture);
+ i.putExtras(extras);
+ startActivity(i);
+ }
+ }
+ }
+ });
+ }
+
+ // **********************************************************************
+ // textFieldsAreValid: Make sure that fields aren't blank
+ // **********************************************************************
+ public static boolean textFieldsAreValid(String field) {
+ if (field == null || field.length() == 0 || field.trim().length() == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ // **********************************************************************
+ // isValidEmailAddress: Check the email address is OK
+ // **********************************************************************
+ public static boolean isValidEmailAddress(String emailAddress) {
+ String emailRegEx;
+ Pattern pattern;
+ // Regex for a valid email address
+ emailRegEx = "^[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z]{2,4}$";
+ // Compare the regex with the email address
+ pattern = Pattern.compile(emailRegEx);
+ Matcher matcher = pattern.matcher(emailAddress);
+ if (!matcher.find()) {
+ return false;
+ }
+ return true;
+ }
+
+ // **********************************************************************
+ // onCreateDialog: Dialog warnings
+ // **********************************************************************
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ switch (id) {
+ case SUBJECT_WARNING:
+ return new AlertDialog.Builder(Details.this).setTitle("Subject")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ }).setMessage("Please enter a subject!").create();
+ case NAME_WARNING:
+ return new AlertDialog.Builder(Details.this)
+ .setTitle("Name")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ })
+ .setMessage(
+ "Please enter your name. We'll remember it for next time.")
+ .create();
+
+ case EMAIL_WARNING:
+ return new AlertDialog.Builder(Details.this)
+ .setTitle("Email")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ })
+ .setMessage(
+ "Please enter a valid email address. We'll remember it for next time.")
+ .create();
+
+ }
+ return null;
+ }
+
+ // Save user's name and email, if already defined
+ @Override
+ protected void onStop() {
+ super.onStop();
+
+ name = nameET.getText().toString();
+ email = emailET.getText().toString();
+
+ // Save user preferences
+ SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putString("myName", name);
+ editor.putString("myEmail", email);
+
+ // Don't forget to commit your edits!!!
+ editor.commit();
+ }
+
+ // Look at this - is it working ok
+ // public boolean testProviders() {
+ // Log.e(LOG_TAG, "testProviders");
+ // // StringBuilder sb = new StringBuilder("Enabled Providers");
+ // // List<String> providers = locationmanager.getProviders(true);
+ // // for (String provider : providers) {
+ // // Log.e(LOG_TAG, "Provider = " + provider);
+ // // listener = new LocationListener() {
+ // // public void onLocationChanged(Location location) {
+ // // }
+ // //
+ // // public void onProviderDisabled(String provider) {
+ // // }
+ // //
+ // // public void onProviderEnabled(String provider) {
+ // // }
+ // //
+ // // public void onStatusChanged(String provider, int status,
+ // // Bundle extras) {
+ // // }
+ // // };
+ // //
+ // // locationmanager.requestLocationUpdates(provider, 0, 0, listener);
+ // //
+ // // sb.append("\n*").append(provider).append(": ");
+ // //
+ // // Location location = locationmanager.getLastKnownLocation(provider);
+ // //
+ // // if (location != null) {
+ // // latitude = location.getLatitude();
+ // // longitude = location.getLongitude();
+ // // latString = latitude.toString();
+ // // longString = longitude.toString();
+ // // Log.e(LOG_TAG, "Latitude = " + latString);
+ // // Log.e(LOG_TAG, "Longitude = " + longString);
+ // // if (provider == "gps") {
+ // // // Only bother with GPS if available
+ // // return true;
+ // // }
+ // // } else {
+ // // Log.e(LOG_TAG, "Location is null");
+ // // return false;
+ // // }
+ // // }
+ // // LocationManager lm = (LocationManager)
+ // // context.getSystemService(Context.LOCATION_SERVICE);
+ // //
+ // // Location loc = lm.getLastKnownLocation("gps");
+ // // if (loc == null)
+ // // {
+ // // locType = "Network";
+ // // loc = lm.getLastKnownLocation("network");
+ // // }
+ // //
+ // // textMsg.setText(sb);
+ //
+ // return true;
+ // }
+}
diff --git a/android/Fix My Street/src/com/android/fixmystreet/Help.java b/android/Fix My Street/src/com/android/fixmystreet/Help.java
index 3153ffe3c..6445992d8 100644
--- a/android/Fix My Street/src/com/android/fixmystreet/Help.java
+++ b/android/Fix My Street/src/com/android/fixmystreet/Help.java
@@ -1,59 +1,59 @@
-package com.android.fixmystreet;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.text.util.Linkify;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.TextView;
-
-public class Help extends Activity {
- private Bundle extras = null;
-
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- extras = getIntent().getExtras();
- setContentView(R.layout.help);
- TextView noteView = (TextView) findViewById(R.id.faq);
- Linkify.addLinks(noteView, Linkify.ALL);
- }
-
- // ****************************************************
- // Options menu functions
- // ****************************************************
-
- // TODO - add Bundles for these?
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuItem homeItem = menu.add(0, 0, 0, "Home");
- MenuItem aboutItem = menu.add(0, 1, 0, "About");
- homeItem.setIcon(android.R.drawable.ic_menu_edit);
- aboutItem.setIcon(android.R.drawable.ic_menu_info_details);
-
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case 0:
- Intent i = new Intent(Help.this, Home.class);
- if (extras != null) {
- i.putExtras(extras);
- }
- startActivity(i);
- return true;
- case 1:
- Intent j = new Intent(Help.this, About.class);
- if (extras != null) {
- j.putExtras(extras);
- }
- startActivity(j);
- return true;
- }
- return false;
- }
-}
+package com.android.fixmystreet;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.util.Linkify;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.TextView;
+
+public class Help extends Activity {
+ private Bundle extras = null;
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ extras = getIntent().getExtras();
+ setContentView(R.layout.help);
+ TextView noteView = (TextView) findViewById(R.id.faq);
+ Linkify.addLinks(noteView, Linkify.ALL);
+ }
+
+ // ****************************************************
+ // Options menu functions
+ // ****************************************************
+
+ // TODO - add Bundles for these?
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ MenuItem homeItem = menu.add(0, 0, 0, "Home");
+ MenuItem aboutItem = menu.add(0, 1, 0, "About");
+ homeItem.setIcon(android.R.drawable.ic_menu_edit);
+ aboutItem.setIcon(android.R.drawable.ic_menu_info_details);
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case 0:
+ Intent i = new Intent(Help.this, Home.class);
+ if (extras != null) {
+ i.putExtras(extras);
+ }
+ startActivity(i);
+ return true;
+ case 1:
+ Intent j = new Intent(Help.this, About.class);
+ if (extras != null) {
+ j.putExtras(extras);
+ }
+ startActivity(j);
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/android/Fix My Street/src/com/android/fixmystreet/Home.java b/android/Fix My Street/src/com/android/fixmystreet/Home.java
index 38875fd2b..e0543c77f 100644
--- a/android/Fix My Street/src/com/android/fixmystreet/Home.java
+++ b/android/Fix My Street/src/com/android/fixmystreet/Home.java
@@ -1,726 +1,719 @@
-// **************************************************************************
-// Home.java
-// **************************************************************************
-package com.android.fixmystreet;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.Button;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.provider.MediaStore;
-import android.view.View;
-import android.view.View.OnClickListener;
-
-public class Home extends Activity {
- // ****************************************************
- // Local variables
- // ****************************************************
- //private static final String LOG_TAG = "Home";
- private Button btnReport;
- private Button btnDetails;
- private Button btnPicture;
- // Info that's been passed from other activities
- private Boolean haveDetails = false;
- private Boolean havePicture = false;
- private String name = null;
- private String email = null;
- private String subject = null;
- // Location info
- LocationManager locationmanager;
- LocationListener listener;
- private Double latitude;
- private Double longitude;
- private String latString = "";
- private String longString = "";
- // hacky way of checking the results
- private static int globalStatus = 13;
- private static final int SUCCESS = 0;
- private static final int LOCATION_NOT_FOUND = 1;
- private static final int UPLOAD_ERROR = 2;
- private static final int UPLOAD_ERROR_SERVER = 3;
- private static final int LOCATION_NOT_ACCURATE = 4;
- private static final int PHOTO_NOT_FOUND = 5;
- private String serverResponse;
- // Thread handling
- ProgressDialog myProgressDialog = null;
- private ProgressDialog pd;
- final Handler mHandler = new Handler();
- final Runnable mUpdateResults = new Runnable() {
- public void run() {
- pd.dismiss();
- updateResultsInUi();
- }
- };
- private Bundle extras;
- //private Bitmap bmp = null;
-
- // Called when the activity is first created
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.home);
-
- testProviders();
- // showDialog();
-
- btnDetails = (Button) findViewById(R.id.details_button);
- btnPicture = (Button) findViewById(R.id.camera_button);
- btnReport = (Button) findViewById(R.id.report_button);
- btnReport.setVisibility(View.GONE);
-
- if (icicle != null) {
- havePicture = icicle.getBoolean("photo");
- }
-
- extras = getIntent().getExtras();
- checkBundle();
- setListeners();
- }
-
- @Override
- protected void onPause() {
- //Log.d("onPause, havePicture = " + havePicture);
- removeListeners();
- saveState();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- //Log.d(LOG_TAG, "onStop, havePicture = " + havePicture);
- removeListeners();
- super.onStop();
- }
-
- @Override
- public void onRestart() {
- //Log.d(LOG_TAG, "onRestart, havePicture = " + havePicture);
- testProviders();
- checkBundle();
- super.onRestart();
- }
-
- // ****************************************************
- // checkBundle - check the extras that have been passed
- // is the user able to upload things yet, or not?
- // ****************************************************
- private void checkBundle() {
- //Log.d(LOG_TAG, "checkBundle");
-
- // Get the status icons...
- Resources res = getResources();
- Drawable checked = res.getDrawable(R.drawable.done);
-
- if (extras != null) {
- // Details extras
- name = extras.getString("name");
- email = extras.getString("email");
- subject = extras.getString("subject");
- havePicture = extras.getBoolean("photo");
-
- // Do we have the details?
- if ((name != null) && (email != null) && (subject != null)) {
- haveDetails = true;
- //Log.d(LOG_TAG, "Have all details");
- checked.setBounds(0, 0, checked.getIntrinsicWidth(), checked
- .getIntrinsicHeight());
- // envelope.setBounds(0, 0, envelope.getIntrinsicWidth(),
- // envelope
- // .getIntrinsicHeight());
- btnDetails.setText("Details added: '" + subject + "'");
- btnDetails.setCompoundDrawables(null, null, checked, null);
- } else {
- //Log.d(LOG_TAG, "Don't have details");
- }
- } else {
- extras = new Bundle();
- //Log.d(LOG_TAG, "no Bundle at all");
- }
- //Log.d(LOG_TAG, "havePicture = " + havePicture);
-
- // Do we have the photo?
- if (havePicture) {
-
- checked.setBounds(0, 0, checked.getIntrinsicWidth(), checked
- .getIntrinsicHeight());
- // camera.setBounds(0, 0, camera.getIntrinsicWidth(), camera
- // .getIntrinsicHeight());
- btnPicture.setCompoundDrawables(null, null, checked, null);
- btnPicture.setText("Photo taken");
- // code for if we wanted to show a thumbnail - works but crashes
- // ImageView iv = (ImageView) findViewById(R.id.thumbnail);
- // try {
- // Log.d(LOG_TAG, "Trying to look for FMS photo");
- // FileInputStream fstream = null;
- // fstream = new FileInputStream(Environment
- // .getExternalStorageDirectory()
- // + "/" + "FMS_photo.jpg");
- // Log.d("Looking for file at ", Environment
- // .getExternalStorageDirectory()
- // + "/" + "FMS_photo.jpg");
- // bmp = BitmapFactory.decodeStream(fstream);
- // // bmp = BitmapFactory
- // // .decodeStream(openFileInput("FMS_photo.jpg"));
- // iv.setImageBitmap(bmp);
- // System.gc();
- // } catch (FileNotFoundException e) {
- // // TODO Auto-generated catch block
- // Log.d(LOG_TAG, "FMS photo not found");
- // e.printStackTrace();
- // }
- }
-
- // We have details and photo - show the Report button
- if (haveDetails && havePicture) {
- btnReport.setVisibility(View.VISIBLE);
- }
- }
-
- // ****************************************************
- // setListeners - set the button listeners
- // ****************************************************
-
- private void setListeners() {
- btnDetails.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- Intent i = new Intent(Home.this, Details.class);
- extras.putString("name", name);
- extras.putString("email", email);
- extras.putString("subject", subject);
- i.putExtras(extras);
- startActivity(i);
- }
- });
- btnPicture.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- File photo = new File(
- Environment.getExternalStorageDirectory(),
- "FMS_photo.jpg");
- if (photo.exists()) {
- photo.delete();
- }
- Intent imageCaptureIntent = new Intent(
- MediaStore.ACTION_IMAGE_CAPTURE);
- imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri
- .fromFile(photo));
- startActivityForResult(imageCaptureIntent, 1);
- }
- });
- btnReport.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- uploadToFMS();
- }
- });
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- //Log.d(LOG_TAG, "onActivityResult");
- //Log.d(LOG_TAG, "Activity.RESULT_OK code = " + Activity.RESULT_OK);
- //Log.d(LOG_TAG, "resultCode = " + resultCode + "requestCode = "
- // + requestCode);
- if (resultCode == Activity.RESULT_OK && requestCode == 1) {
- havePicture = true;
- extras.putBoolean("photo", true);
- }
- //testProviders();
- //Log.d(LOG_TAG, "havePicture = " + havePicture.toString());
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- //Log.d(LOG_TAG, "onSaveInstanceState");
- if (havePicture != null) {
- // Log.d(LOG_TAG, "mRowId = " + mRowId);
- outState.putBoolean("photo", havePicture);
- }
- // if (name != null) {
- // // Log.d(LOG_TAG, "mRowId = " + mRowId);
- // outState.putString("name", name);
- // }
- // if (email != null) {
- // // Log.d(LOG_TAG, "mRowId = " + mRowId);
- // outState.putString("email", email);
- // }
- // if (subject != null) {
- // // Log.d(LOG_TAG, "mRowId = " + mRowId);
- // outState.putString("subject", subject);
- // }
- }
-
- // TODO - save bits and pieces here
- private void saveState() {
- // Log.d(LOG_TAG, "saveState");
- // String body = mBodyText.getText().toString();
- // String title = mTitleText.getText().toString();
- // // Log.d(LOG_TAG, "title valid");
- // if (mRowId == null) {
- // // Log.d(LOG_TAG, "mRowId = null, creating note");
- // long id = mDbHelper.createNote(body, title);
- // if (id > 0) {
- // mRowId = id;
- // // Log.d(LOG_TAG, "Set mRowId to " + mRowId);
- // }
- // } else {
- // // Log.d(LOG_TAG, "mRowId = " + mRowId + ", updating note");
- // mDbHelper.updateNote(mRowId, body, title);
- // }
- }
-
- // **********************************************************************
- // uploadToFMS: uploads details, handled via a background thread
- // Also checks the age and accuracy of the GPS data first
- // **********************************************************************
- private void uploadToFMS() {
- //Log.d(LOG_TAG, "uploadToFMS");
- pd = ProgressDialog
- .show(
- this,
- "Uploading, please wait...",
- "Uploading. This can take up to a minute, depending on your connection speed. Please be patient!",
- true, false);
- Thread t = new Thread() {
- public void run() {
- doUploadinBackground();
- mHandler.post(mUpdateResults);
- }
- };
- t.start();
- }
-
- private void updateResultsInUi() {
- if (globalStatus == UPLOAD_ERROR) {
- showDialog(UPLOAD_ERROR);
- } else if (globalStatus == UPLOAD_ERROR_SERVER) {
- showDialog(UPLOAD_ERROR_SERVER);
- } else if (globalStatus == LOCATION_NOT_FOUND) {
- showDialog(LOCATION_NOT_FOUND);
- } else if (globalStatus == PHOTO_NOT_FOUND) {
- showDialog(PHOTO_NOT_FOUND);
- } else if (globalStatus == LOCATION_NOT_ACCURATE) {
- showDialog(LOCATION_NOT_ACCURATE);
- } else {
- // Success! - Proceed to the success activity!
- Intent i = new Intent(Home.this, Success.class);
- i.putExtra("latString", latString);
- i.putExtra("lonString", longString);
- startActivity(i);
- }
- }
-
- // **********************************************************************
- // onCreateDialog: Dialog warnings
- // **********************************************************************
- @Override
- protected Dialog onCreateDialog(int id) {
- switch (id) {
- case UPLOAD_ERROR:
- return new AlertDialog.Builder(Home.this)
- .setTitle("Upload error")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- })
- .setMessage(
- "Sorry, there was an error uploading - maybe the network connection is down? Please try again later.")
- .create();
- case UPLOAD_ERROR_SERVER:
- return new AlertDialog.Builder(Home.this)
- .setTitle("Upload error")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- })
- .setMessage(
- "Sorry, there was an error uploading. Please try again later. The server response was: "
- + serverResponse).create();
- case LOCATION_NOT_FOUND:
- return new AlertDialog.Builder(Home.this)
- .setTitle("GPS problem")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- })
- .setMessage(
- "Could not get location! Can you see the sky? Please try again later.")
- .create();
- case PHOTO_NOT_FOUND:
- return new AlertDialog.Builder(Home.this).setTitle("No photo")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- }).setMessage("Photo not found!").create();
- case LOCATION_NOT_ACCURATE:
- return new AlertDialog.Builder(Home.this)
- .setTitle("GPS problem")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- })
- .setMessage(
- "Sorry, your GPS location is not accurate enough. Can you see the sky?")
- .create();
- }
- return null;
- }
-
- // **********************************************************************
- // doUploadinBackground: POST request to FixMyStreet
- // **********************************************************************
- private boolean doUploadinBackground() {
- //Log.d(LOG_TAG, "doUploadinBackground");
-
- String responseString = null;
- PostMethod method;
-
- // DefaultHttpClient httpClient;
- // HttpPost httpPost;
- // HttpResponse response;
- // HttpEntity entity;
- // UrlEncodedFormEntity urlentity;
- // // get the photo data from the URI
- // // Uri uri = (Uri) content.getParcelable("URI");
- // Context context = getApplicationContext();
- // ContentResolver cR = context.getContentResolver();
- //
- // // Get the type of the file
- // MimeTypeMap mime = MimeTypeMap.getSingleton();
- // String type = mime.getExtensionFromMimeType(cR.getType(uri));
- //
- // // Get the InputStream
- // InputStream in = null;
- //
- // try {
- // in = cR.openInputStream(uri);
- // } catch (FileNotFoundException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- // if (in == null) {
- // globalStatus = PHOTO_NOT_FOUND;
- // return false;
- // }
- //
- // // Setting the InputStream Body
- // InputStreamBody body = new InputStreamBody(in, "image." + type);
-
- // TODO - check location updates
- Location location = locationmanager
- .getLastKnownLocation(LocationManager.GPS_PROVIDER);
-
- if (location != null) {
- // TODO - put back in
- long currentTime = System.currentTimeMillis();
- long gpsTime = location.getTime();
- long timeDiffSecs = (currentTime - gpsTime) / 1000;
- //Log.e(LOG_TAG, "Location accuracy = " + location.getAccuracy());
- //Log.e(LOG_TAG, "Location age = " + timeDiffSecs);
- if ((location.getAccuracy() > 150) || (timeDiffSecs > 15)) {
- //Log.e(LOG_TAG, "Location not accurate");
- globalStatus = LOCATION_NOT_ACCURATE;
- return false;
- }
- latitude = location.getLatitude();
- longitude = location.getLongitude();
- latString = latitude.toString();
- longString = longitude.toString();
- //Log.e(LOG_TAG, "Latitude = " + latString);
- //Log.e(LOG_TAG, "Longitude = " + longString);
- } else {
- //Log.e(LOG_TAG, "Location is null");
- globalStatus = LOCATION_NOT_FOUND;
- return false;
- }
-
- // TEMP - testing
- // latString = "51.5";
- // longString = "-0.116667";
-
- method = new PostMethod("http://www.fixmystreet.com/import");
-
- try {
-
- // Bitmap bitmap;
- // ByteArrayOutputStream imageByteStream;
- byte[] imageByteArray = null;
- // ByteArrayPartSource fileSource;
-
- HttpClient client = new HttpClient();
- client.getHttpConnectionManager().getParams().setConnectionTimeout(
- 100000);
-
- // InputStream in =
- // this.getResources().openRawResource(R.drawable.tom);
- // bitmap = android.provider.MediaStore.Images.Media.getBitmap(
- // getContentResolver(), uri);
- // imageByteStream = new ByteArrayOutputStream();
-
- // if (bitmap == null) {
- // Log.d(LOG_TAG, "No bitmap");
- // }
-
- // Compress bmp to jpg, write to the bytes output stream
- // bitmap.compress(Bitmap.CompressFormat.JPEG, 80, imageByteStream);
-
- // Turn the byte stream into a byte array, write to imageData
- // imageByteArray = imageByteStream.toByteArray();
-
- File f = new File(Environment.getExternalStorageDirectory(),
- "FMS_photo.jpg");
-
- // TODO - add a check here
- if (!f.exists()) {
- }
- imageByteArray = getBytesFromFile(f);
-
-// Log
-// .d(LOG_TAG, "len of data is " + imageByteArray.length
-// + " bytes");
-
- // fileSource = new ByteArrayPartSource("photo", imageData);
- FilePart photo = new FilePart("photo", new ByteArrayPartSource(
- "photo", imageByteArray));
-
- photo.setContentType("image/jpeg");
- photo.setCharSet(null);
-
- Part[] parts = { new StringPart("service", "your Android phone"),
- new StringPart("subject", subject),
- new StringPart("name", name),
- new StringPart("email", email),
- new StringPart("lat", latString),
- new StringPart("lon", longString), photo };
-
- method.setRequestEntity(new MultipartRequestEntity(parts, method
- .getParams()));
-
- client.executeMethod(method);
- responseString = method.getResponseBodyAsString();
- method.releaseConnection();
-
- Log.e("httpPost", "Response status: " + responseString);
- Log.e("httpPost", "Latitude = " + latString + " and Longitude = "
- + longString);
-
- // textMsg.setText("Bitmap (bitmap) = " + bitmap.toString()
- // + " AND imageByteArray (byte[]) = "
- // + imageByteArray.toString()
- // + " AND imageByteStream (bytearrayoutputstream) = "
- // + imageByteStream.toString());
-
- } catch (Exception ex) {
- //Log.v(LOG_TAG, "Exception", ex);
- globalStatus = UPLOAD_ERROR;
- serverResponse = "";
- return false;
- } finally {
- method.releaseConnection();
- }
-
- if (responseString.equals("SUCCESS")) {
- // launch the Success page
- globalStatus = SUCCESS;
- return true;
- } else {
- // print the response string?
- serverResponse = responseString;
- globalStatus = UPLOAD_ERROR;
- return false;
- }
- }
-
- public void testProviders() {
- //Log.e(LOG_TAG, "testProviders");
- // Register for location listener
- String location_context = Context.LOCATION_SERVICE;
- locationmanager = (LocationManager) getSystemService(location_context);
- // StringBuilder sb = new StringBuilder("Enabled Providers");
- // List<String> providers = locationmanager.getProviders(true);
- // for (String provider : providers) {
- listener = new LocationListener() {
- public void onLocationChanged(Location location) {
- }
-
- public void onProviderDisabled(String provider) {
- }
-
- public void onProviderEnabled(String provider) {
- }
-
- public void onStatusChanged(String provider, int status,
- Bundle extras) {
- }
- };
- locationmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
- 0, listener);
- if (!locationmanager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
- buildAlertMessageNoGps();
- }
- }
-
- private void buildAlertMessageNoGps() {
- final AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder
- .setMessage(
- "Your GPS seems to be disabled. Do you want to turn it on now?")
- .setCancelable(false).setPositiveButton("Yes",
- new DialogInterface.OnClickListener() {
- public void onClick(
- @SuppressWarnings("unused") final DialogInterface dialog,
- @SuppressWarnings("unused") final int id) {
- Intent j = new Intent();
- j
- .setAction("android.settings.LOCATION_SOURCE_SETTINGS");
- startActivity(j);
- }
- }).setNegativeButton("No",
- new DialogInterface.OnClickListener() {
- public void onClick(final DialogInterface dialog,
- @SuppressWarnings("unused") final int id) {
- dialog.cancel();
- }
- });
- final AlertDialog alert = builder.create();
- alert.show();
- }
-
- public void removeListeners() {
- //Log.e(LOG_TAG, "removeListeners");
- if (locationmanager != null) {
- locationmanager.removeUpdates(listener);
- }
- locationmanager = null;
- //Log.d(LOG_TAG, "Removed " + listener.toString());
- }
-
- // ****************************************************
- // Options menu functions
- // ****************************************************
-
- // TODO - add Bundles for these?
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuItem helpItem = menu.add(0, 0, 0, "Help");
- MenuItem aboutItem = menu.add(0, 1, 0, "About");
- aboutItem.setIcon(android.R.drawable.ic_menu_info_details);
- helpItem.setIcon(android.R.drawable.ic_menu_help);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case 0:
- Intent i = new Intent(Home.this, Help.class);
- if (extras != null) {
- i.putExtras(extras);
- }
- startActivity(i);
- return true;
- case 1:
- Intent j = new Intent(Home.this, About.class);
- if (extras != null) {
- j.putExtras(extras);
- }
- startActivity(j);
- return true;
- }
- return false;
- }
-
- // read the photo file into a byte array...
- public static byte[] getBytesFromFile(File file) throws IOException {
- InputStream is = new FileInputStream(file);
-
- // Get the size of the file
- long length = file.length();
-
- // You cannot create an array using a long type.
- // It needs to be an int type.
- // Before converting to an int type, check
- // to ensure that file is not larger than Integer.MAX_VALUE.
- if (length > Integer.MAX_VALUE) {
- // File is too large
- }
-
- // Bitmap bitmap;
- // ByteArrayOutputStream imageByteStream;
- // byte[] imageByteArray = null;
-
- // InputStream in =
- // this.getResources().openRawResource(R.drawable.tom);
- // bitmap = android.provider.MediaStore.Images.Media.getBitmap(
- // getContentResolver(), uri);
- // imageByteStream = new ByteArrayOutputStream();
-
- // Compress bmp to jpg, write to the bytes output stream
- // bitmap.compress(Bitmap.CompressFormat.JPEG, 80, imageByteStream);
-
- // Turn the byte stream into a byte array, write to imageData
- // imageByteArray = imageByteStream.toByteArray();
-
- // Create the byte array to hold the data
- byte[] bytes = new byte[(int) length];
-
- // Read in the bytes
- int offset = 0;
- int numRead = 0;
- while (offset < bytes.length
- && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
- offset += numRead;
- }
-
- // Ensure all the bytes have been read in
- if (offset < bytes.length) {
- throw new IOException("Could not completely read file "
- + file.getName());
- }
-
- // Close the input stream and return bytes
- is.close();
- return bytes;
- }
-}
+// **************************************************************************
+// Home.java
+// **************************************************************************
+package com.android.fixmystreet;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Handler;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Button;
+import android.widget.TextView;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.provider.MediaStore;
+import android.view.View;
+import android.view.View.OnClickListener;
+
+public class Home extends Activity {
+ // ****************************************************
+ // Local variables
+ // ****************************************************
+ private static final String LOG_TAG = "Home";
+ public static final String PREFS_NAME = "FMS_Settings";
+ private Button btnReport;
+ private Button btnDetails;
+ private Button btnPicture;
+ // Info that's been passed from other activities
+ private Boolean haveDetails = false;
+ private Boolean havePicture = false;
+ private String name = null;
+ private String email = null;
+ private String subject = null;
+ // Location info
+ LocationManager locationmanager = null;
+ LocationListener listener;
+ Location location;
+ private Double latitude;
+ private Double longitude;
+ private String latString = "";
+ private String longString = "";
+ long firstGPSFixTime = 0;
+ long latestGPSFixTime = 0;
+ long previousGPSFixTime = 0;
+ private Boolean locationDetermined = false;
+ int locAccuracy;
+ long locationTimeStored = 0;
+ // hacky way of checking the results
+ private static int globalStatus = 13;
+ private static final int SUCCESS = 0;
+ private static final int LOCATION_NOT_FOUND = 1;
+ private static final int UPLOAD_ERROR = 2;
+ private static final int UPLOAD_ERROR_SERVER = 3;
+ private static final int PHOTO_NOT_FOUND = 5;
+ private static final int UPON_UPDATE = 6;
+ private static final int COUNTRY_ERROR = 7;
+ private String serverResponse;
+ SharedPreferences settings;
+ String versionName = null;
+ // Thread handling
+ ProgressDialog myProgressDialog = null;
+ private ProgressDialog pd;
+ final Handler mHandler = new Handler();
+ final Runnable mUpdateResults = new Runnable() {
+ public void run() {
+ pd.dismiss();
+ updateResultsInUi();
+ }
+ };
+ private Bundle extras;
+ private TextView textProgress;
+ private String exception_string = "";
+
+ // Called when the activity is first created
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ setContentView(R.layout.home);
+ // Log.d(LOG_TAG, "onCreate, havePicture = " + havePicture);
+ settings = getSharedPreferences(PREFS_NAME, 0);
+ testProviders();
+
+ btnDetails = (Button) findViewById(R.id.details_button);
+ btnPicture = (Button) findViewById(R.id.camera_button);
+ btnReport = (Button) findViewById(R.id.report_button);
+ btnReport.setVisibility(View.GONE);
+ textProgress = (TextView) findViewById(R.id.progress_text);
+ textProgress.setVisibility(View.GONE);
+
+ if (icicle != null) {
+ havePicture = icicle.getBoolean("photo");
+ Log.d(LOG_TAG, "icicle not null, havePicture = " + havePicture);
+ } else {
+ Log.d(LOG_TAG, "icicle null");
+ }
+ extras = getIntent().getExtras();
+ checkBundle();
+ setListeners();
+
+ // Show update message - but not to new users
+ int vc = 0;
+ try {
+ vc = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
+ versionName = getPackageManager().getPackageInfo(getPackageName(),
+ 0).versionName;
+ } catch (NameNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // TODO - add this code next time!
+ boolean hasSeenUpdateVersion = settings.getBoolean(
+ "hasSeenUpdateVersion" + vc, false);
+ boolean hasSeenOldVersion = settings.getBoolean("hasSeenUpdateVersion"
+ + (vc - 1), false);
+ if (!hasSeenUpdateVersion && hasSeenOldVersion) {
+ showDialog(UPON_UPDATE);
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putBoolean("hasSeenUpdateVersion" + vc, true);
+ editor.commit();
+ }
+
+ // Check country: show warning if not in Great Britain
+ TelephonyManager mTelephonyMgr = (TelephonyManager) this
+ .getSystemService(Context.TELEPHONY_SERVICE);
+ String country = mTelephonyMgr.getNetworkCountryIso();
+ //Log.d(LOG_TAG, "country = " + country);
+ if (!(country.matches("gb"))) {
+ showDialog(COUNTRY_ERROR);
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ // Log.d(LOG_TAG, "onPause, havePicture = " + havePicture);
+ super.onPause();
+ removeListeners();
+ }
+
+ @Override
+ protected void onStop() {
+ // Log.d(LOG_TAG, "onStop, havePicture = " + havePicture);
+ super.onStop();
+ removeListeners();
+ }
+
+ @Override
+ public void onRestart() {
+ // Log.d(LOG_TAG, "onRestart, havePicture = " + havePicture);
+ testProviders();
+ checkBundle();
+ super.onRestart();
+ }
+
+ // ****************************************************
+ // checkBundle - check the extras that have been passed
+ // is the user able to upload things yet, or not?
+ // ****************************************************
+ private void checkBundle() {
+ // Log.d(LOG_TAG, "checkBundle");
+ // Get the status icons...
+ Resources res = getResources();
+ Drawable checked = res.getDrawable(R.drawable.done);
+ if (extras != null) {
+ // Log.d(LOG_TAG, "Checking extras");
+ // Details extras
+ name = extras.getString("name");
+ email = extras.getString("email");
+ subject = extras.getString("subject");
+ if (!havePicture) {
+ havePicture = extras.getBoolean("photo");
+ }
+ // Do we have the details?
+ if ((name != null) && (email != null) && (subject != null)) {
+ haveDetails = true;
+ // Log.d(LOG_TAG, "Have all details");
+ checked.setBounds(0, 0, checked.getIntrinsicWidth(), checked
+ .getIntrinsicHeight());
+ // envelope.setBounds(0, 0, envelope.getIntrinsicWidth(),
+ // envelope
+ // .getIntrinsicHeight());
+ btnDetails.setText("Details added: '" + subject + "'");
+ btnDetails.setCompoundDrawables(null, null, checked, null);
+ } else {
+ // Log.d(LOG_TAG, "Don't have details");
+ }
+ } else {
+ extras = new Bundle();
+ // Log.d(LOG_TAG, "no Bundle at all");
+ }
+ // Log.d(LOG_TAG, "havePicture = " + havePicture);
+
+ // Do we have the photo?
+ if (havePicture) {
+
+ checked.setBounds(0, 0, checked.getIntrinsicWidth(), checked
+ .getIntrinsicHeight());
+ // camera.setBounds(0, 0, camera.getIntrinsicWidth(), camera
+ // .getIntrinsicHeight());
+ btnPicture.setCompoundDrawables(null, null, checked, null);
+ btnPicture.setText("Photo taken");
+ }
+ if (havePicture && haveDetails) {
+ textProgress.setVisibility(View.VISIBLE);
+ }
+ }
+
+ // ****************************************************
+ // setListeners - set the button listeners
+ // ****************************************************
+
+ private void setListeners() {
+ btnDetails.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ Intent i = new Intent(Home.this, Details.class);
+ extras.putString("name", name);
+ extras.putString("email", email);
+ extras.putString("subject", subject);
+ extras.putBoolean("photo", havePicture);
+
+ i.putExtras(extras);
+ startActivity(i);
+ }
+ });
+ btnPicture.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ File photo = new File(
+ Environment.getExternalStorageDirectory(),
+ "FMS_photo.jpg");
+ if (photo.exists()) {
+ photo.delete();
+ }
+ Intent imageCaptureIntent = new Intent(
+ MediaStore.ACTION_IMAGE_CAPTURE);
+ imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri
+ .fromFile(photo));
+ startActivityForResult(imageCaptureIntent, 1);
+ }
+ });
+ btnReport.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ locationDetermined = true;
+ uploadToFMS();
+ }
+ });
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ // Log.d(LOG_TAG, "onActivityResult");
+ // Log.d(LOG_TAG, "Activity.RESULT_OK code = " + Activity.RESULT_OK);
+ // Log.d(LOG_TAG, "resultCode = " + resultCode + "requestCode = "
+ // + requestCode);
+ if (resultCode == Activity.RESULT_OK && requestCode == 1) {
+ havePicture = true;
+ extras.putBoolean("photo", true);
+ Resources res = getResources();
+ Drawable checked = res.getDrawable(R.drawable.done);
+ checked.setBounds(0, 0, checked.getIntrinsicWidth(), checked
+ .getIntrinsicHeight());
+ btnPicture.setCompoundDrawables(null, null, checked, null);
+ btnPicture.setText("Photo taken");
+ }
+ Log.d(LOG_TAG, "havePicture = " + havePicture.toString());
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ Log.d(LOG_TAG, "onSaveInstanceState, havePicture " + havePicture);
+ // Log.d(LOG_TAG, "onSaveInstanceState");
+ if (havePicture != null) {
+ // Log.d(LOG_TAG, "mRowId = " + mRowId);
+ outState.putBoolean("photo", havePicture);
+ }
+ super.onSaveInstanceState(outState);
+ }
+
+ @Override
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ // Restore UI state from the savedInstanceState.
+ // This bundle has also been passed to onCreate.
+ havePicture = savedInstanceState.getBoolean("photo");
+ Log.d(LOG_TAG, "onRestoreInstanceState, havePicture " + havePicture);
+ }
+
+ // **********************************************************************
+ // uploadToFMS: uploads details, handled via a background thread
+ // Also checks the age and accuracy of the GPS data first
+ // **********************************************************************
+ private void uploadToFMS() {
+ // Log.d(LOG_TAG, "uploadToFMS");
+ pd = ProgressDialog
+ .show(
+ this,
+ "Uploading, please wait...",
+ "Uploading. This can take up to a minute, depending on your connection speed. Please be patient!",
+ true, false);
+ Thread t = new Thread() {
+ public void run() {
+ doUploadinBackground();
+ mHandler.post(mUpdateResults);
+ }
+ };
+ t.start();
+ }
+
+ private void updateResultsInUi() {
+ if (globalStatus == UPLOAD_ERROR) {
+ showDialog(UPLOAD_ERROR);
+ } else if (globalStatus == UPLOAD_ERROR_SERVER) {
+ showDialog(UPLOAD_ERROR_SERVER);
+ } else if (globalStatus == LOCATION_NOT_FOUND) {
+ showDialog(LOCATION_NOT_FOUND);
+ } else if (globalStatus == PHOTO_NOT_FOUND) {
+ showDialog(PHOTO_NOT_FOUND);
+ } else {
+ // Success! - Proceed to the success activity!
+ Intent i = new Intent(Home.this, Success.class);
+ i.putExtra("latString", latString);
+ i.putExtra("lonString", longString);
+ startActivity(i);
+ }
+ }
+
+ // **********************************************************************
+ // onCreateDialog: Dialog warnings
+ // **********************************************************************
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ switch (id) {
+ case COUNTRY_ERROR:
+ return new AlertDialog.Builder(Home.this)
+ .setTitle("Country or network error")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ })
+ .setMessage(
+ "Sorry, FixMyStreet currently only works in Britain. You won't be able to submit reports from your current location. (You may also see this error if you aren't connected to the network.)")
+ .create();
+ case UPLOAD_ERROR:
+ return new AlertDialog.Builder(Home.this)
+ .setTitle("Upload error")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ })
+ .setMessage(
+ "Sorry, there was an error uploading - maybe the network connection is down? Please try again later. Exception: " + exception_string + " " + serverResponse)
+ .create();
+ case UPLOAD_ERROR_SERVER:
+ return new AlertDialog.Builder(Home.this)
+ .setTitle("Upload error")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ })
+ .setMessage(
+ "Sorry, there was an error uploading. Please try again later. The server response was: "
+ + serverResponse).create();
+ case LOCATION_NOT_FOUND:
+ return new AlertDialog.Builder(Home.this)
+ .setTitle("Location problem")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ })
+ .setMessage(
+ "Could not get location! Can you see the sky? Please try again later.")
+ .create();
+ case PHOTO_NOT_FOUND:
+ return new AlertDialog.Builder(Home.this).setTitle("No photo")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ }).setMessage("Photo not found!").create();
+ case UPON_UPDATE:
+ if (versionName == null) {
+ versionName = "";
+ }
+ return new AlertDialog.Builder(Home.this).setTitle("What's new?")
+ .setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ }).setMessage(
+ "New features in version" + versionName
+ + ": better GPS fix.").create();
+ }
+ return null;
+ }
+
+ // **********************************************************************
+ // doUploadinBackground: POST request to FixMyStreet
+ // **********************************************************************
+ private boolean doUploadinBackground() {
+ // Log.d(LOG_TAG, "doUploadinBackground");
+
+ String responseString = null;
+ PostMethod method;
+
+ method = new PostMethod("http://www.fixmystreet.com/import");
+
+ try {
+
+ byte[] imageByteArray = null;
+ HttpClient client = new HttpClient();
+ client.getHttpConnectionManager().getParams().setConnectionTimeout(
+ 100000);
+
+ File f = new File(Environment.getExternalStorageDirectory(),
+ "FMS_photo.jpg");
+
+ // TODO - add a check here
+ if (!f.exists()) {
+ }
+ imageByteArray = getBytesFromFile(f);
+
+ // Log
+ // .d(LOG_TAG, "len of data is " + imageByteArray.length
+ // + " bytes");
+
+ FilePart photo = new FilePart("photo", new ByteArrayPartSource(
+ "photo", imageByteArray));
+
+ photo.setContentType("image/jpeg");
+ photo.setCharSet(null);
+
+ Part[] parts = { new StringPart("service", "Android phone"),
+ new StringPart("subject", subject),
+ new StringPart("name", name),
+ new StringPart("email", email),
+ new StringPart("lat", latString),
+ new StringPart("lon", longString), photo };
+
+ // Log.d(LOG_TAG, "sending off with lat " + latString + " and lon "
+ // + longString);
+
+ method.setRequestEntity(new MultipartRequestEntity(parts, method
+ .getParams()));
+ client.executeMethod(method);
+ responseString = method.getResponseBodyAsString();
+ method.releaseConnection();
+
+ Log.e("httpPost", "Response status: " + responseString);
+ Log.e("httpPost", "Latitude = " + latString + " and Longitude = "
+ + longString);
+
+ } catch (Exception ex) {
+ Log.v(LOG_TAG, "Exception", ex);
+ exception_string = ex.getMessage();
+ globalStatus = UPLOAD_ERROR;
+ serverResponse = "";
+ return false;
+ } finally {
+ method.releaseConnection();
+ }
+
+ if (responseString.equals("SUCCESS")) {
+ // launch the Success page
+ globalStatus = SUCCESS;
+ return true;
+ } else {
+ // print the response string?
+ serverResponse = responseString;
+ globalStatus = UPLOAD_ERROR;
+ return false;
+ }
+ }
+
+ private boolean checkLoc(Location location) {
+ // get accuracy
+ // Log.d(LOG_TAG, "checkLocation");
+ float tempAccuracy = location.getAccuracy();
+ locAccuracy = (int) tempAccuracy;
+ // get time - store the GPS time the first time
+ // it is reported, then check it against future reported times
+ latestGPSFixTime = location.getTime();
+ if (firstGPSFixTime == 0) {
+ firstGPSFixTime = latestGPSFixTime;
+ }
+ if (previousGPSFixTime == 0) {
+ previousGPSFixTime = latestGPSFixTime;
+ }
+ long timeDiffSecs = (latestGPSFixTime - previousGPSFixTime) / 1000;
+
+ // Log.d(LOG_TAG, "~~~~~~~ checkLocation, accuracy = " + locAccuracy
+ // + ", firstGPSFixTime = " + firstGPSFixTime + ", gpsTime = "
+ // + latestGPSFixTime + ", timeDiffSecs = " + timeDiffSecsInt);
+
+ // Check our location - no good if the GPS accuracy is more than 24m
+ if ((locAccuracy > 24) || (timeDiffSecs == 0)) {
+ if (timeDiffSecs == 0) {
+ // nor do we want to report if the GPS time hasn't changed at
+ // all - it is probably out of date
+ textProgress
+ .setText("Waiting for a GPS fix: phone says last fix is out of date. Please make sure you can see the sky.");
+ } else {
+ textProgress
+ .setText("Waiting for a GPS fix: phone says last fix had accuracy of "
+ + locAccuracy
+ + "m. (We need accuracy of 24m.) Please make sure you can see the sky.");
+ }
+ } else if (locAccuracy == 0) {
+ // or if no accuracy data is available
+ textProgress
+ .setText("Waiting for a GPS fix... Please make sure you can see the sky.");
+ } else {
+ // but if all the requirements have been met, proceed
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+ latString = latitude.toString();
+ longString = longitude.toString();
+ if (haveDetails && havePicture) {
+ btnReport.setVisibility(View.VISIBLE);
+ btnReport.setText("GPS found! Report to Fix My Street");
+ textProgress.setVisibility(View.GONE);
+ } else {
+ textProgress.setText("GPS found!");
+ }
+ previousGPSFixTime = latestGPSFixTime;
+ return true;
+ }
+ previousGPSFixTime = latestGPSFixTime;
+ // textProgress.setText("~~~~~~~ checkLocation, accuracy = "
+ // + locAccuracy + ", locationTimeStored = " + locationTimeStored
+ // + ", gpsTime = " + gpsTime);
+ return false;
+ }
+
+ public boolean testProviders() {
+ // Log.e(LOG_TAG, "testProviders");
+ // Register for location listener
+ String location_context = Context.LOCATION_SERVICE;
+ locationmanager = (LocationManager) getSystemService(location_context);
+ // Criteria criteria = new Criteria();
+ // criteria.setAccuracy(Criteria.ACCURACY_FINE);
+ // criteria.setAltitudeRequired(false);
+ // criteria.setBearingRequired(false);
+ // criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
+ // criteria.setSpeedRequired(false);
+ // String provider = locationmanager.getBestProvider(criteria, true);
+ if (!locationmanager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
+ buildAlertMessageNoGps();
+ return false;
+ }
+ listener = new LocationListener() {
+ public void onLocationChanged(Location location) {
+ // keep checking the location + updating text - until we have
+ // what we need
+ if (!locationDetermined) {
+ checkLoc(location);
+ }
+ }
+
+ public void onProviderDisabled(String provider) {
+ }
+
+ public void onProviderEnabled(String provider) {
+ }
+
+ public void onStatusChanged(String provider, int status,
+ Bundle extras) {
+ }
+ };
+ locationmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
+ 0, listener);
+ return true;
+ }
+
+ private void buildAlertMessageNoGps() {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder
+ .setMessage(
+ "Your GPS seems to be disabled. Do you want to turn it on now?")
+ .setCancelable(false).setPositiveButton("Yes",
+ new DialogInterface.OnClickListener() {
+ public void onClick(
+ @SuppressWarnings("unused") final DialogInterface dialog,
+ @SuppressWarnings("unused") final int id) {
+ Intent j = new Intent();
+ j
+ .setAction("android.settings.LOCATION_SOURCE_SETTINGS");
+ startActivity(j);
+ }
+ }).setNegativeButton("No",
+ new DialogInterface.OnClickListener() {
+ public void onClick(final DialogInterface dialog,
+ @SuppressWarnings("unused") final int id) {
+ dialog.cancel();
+ }
+ });
+ final AlertDialog alert = builder.create();
+ alert.show();
+ }
+
+ public void removeListeners() {
+ // Log.e(LOG_TAG, "removeListeners");
+ if ((locationmanager != null) && (listener != null)) {
+ locationmanager.removeUpdates(listener);
+ }
+ locationmanager = null;
+ // Log.d(LOG_TAG, "Removed " + listener.toString());
+ }
+
+ // ****************************************************
+ // Options menu functions
+ // ****************************************************
+
+ // TODO - add Bundles for these?
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ MenuItem helpItem = menu.add(0, 0, 0, "Help");
+ MenuItem aboutItem = menu.add(0, 1, 0, "About");
+ aboutItem.setIcon(android.R.drawable.ic_menu_info_details);
+ helpItem.setIcon(android.R.drawable.ic_menu_help);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case 0:
+ Intent i = new Intent(Home.this, Help.class);
+ if (extras != null) {
+ i.putExtras(extras);
+ }
+ startActivity(i);
+ return true;
+ case 1:
+ Intent j = new Intent(Home.this, About.class);
+ if (extras != null) {
+ j.putExtras(extras);
+ }
+ startActivity(j);
+ return true;
+ }
+ return false;
+ }
+
+ // read the photo file into a byte array...
+ public static byte[] getBytesFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream(file);
+
+ // Get the size of the file
+ long length = file.length();
+
+ // You cannot create an array using a long type.
+ // It needs to be an int type.
+ // Before converting to an int type, check
+ // to ensure that file is not larger than Integer.MAX_VALUE.
+ if (length > Integer.MAX_VALUE) {
+ // File is too large
+ }
+
+ // Create the byte array to hold the data
+ byte[] bytes = new byte[(int) length];
+
+ // Read in the bytes
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length
+ && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
+ offset += numRead;
+ }
+
+ // Ensure all the bytes have been read in
+ if (offset < bytes.length) {
+ throw new IOException("Could not completely read file "
+ + file.getName());
+ }
+
+ // Close the input stream and return bytes
+ is.close();
+ return bytes;
+ }
+}
diff --git a/android/Fix My Street/src/com/android/fixmystreet/Success.java b/android/Fix My Street/src/com/android/fixmystreet/Success.java
index ca3dcee77..a941d4687 100644
--- a/android/Fix My Street/src/com/android/fixmystreet/Success.java
+++ b/android/Fix My Street/src/com/android/fixmystreet/Success.java
@@ -1,57 +1,57 @@
-//*************************************************************
-//
-//*************************************************************
-
-package com.android.fixmystreet;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-//import android.util.Log;
-import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuItem;
-
-public class Success extends Activity {
-
- //private static final String LOG_TAG = "Success";
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.success);
- }
-
- // ****************************************************
- // Options menu functions
- // ****************************************************
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuItem helpItem = menu.add(0, 0, 0, "Home");
- helpItem.setIcon(android.R.drawable.ic_menu_edit);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case 0:
- Intent i = new Intent(Success.this, Home.class);
- startActivity(i);
- return true;
- }
- return false;
- }
-
- // disable the Back key in case things get submitted twice
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- return true;
- }
- return false;
- }
-
+//*************************************************************
+//
+//*************************************************************
+
+package com.android.fixmystreet;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+//import android.util.Log;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class Success extends Activity {
+
+ //private static final String LOG_TAG = "Success";
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.success);
+ }
+
+ // ****************************************************
+ // Options menu functions
+ // ****************************************************
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ MenuItem helpItem = menu.add(0, 0, 0, "Home");
+ helpItem.setIcon(android.R.drawable.ic_menu_edit);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case 0:
+ Intent i = new Intent(Success.this, Home.class);
+ startActivity(i);
+ return true;
+ }
+ return false;
+ }
+
+ // disable the Back key in case things get submitted twice
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ return true;
+ }
+ return false;
+ }
+
} \ No newline at end of file