update tree
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>GreenTravel</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,5 @@
|
|||
#Mon Feb 14 17:21:14 UTC 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.commoditysoftware.greentravel"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.01">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<service android:name=".GreenTravelService" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".MainSplash"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".Screen1"> </activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".Screen4"> </activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".Screen5"> </activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".Screen6"> </activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".Screen7"> </activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".StartTrip"> </activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name=".EndTripActivity"> </activity>
|
||||
<activity android:theme="@android:style/Theme.Light" android:name="org.commoditysoftware.greentravel.SettingsActivity"> </activity>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="7" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
</manifest>
|
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 689 B |
After Width: | Height: | Size: 654 B |
After Width: | Height: | Size: 879 B |
After Width: | Height: | Size: 584 B |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
|
@ -0,0 +1,89 @@
|
|||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package org.commoditysoftware.greentravel;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class color {
|
||||
public static final int black=0x7f040004;
|
||||
public static final int darker_gray=0x7f040000;
|
||||
public static final int green=0x7f040003;
|
||||
/** Retrieved via Resources.getColor() and friends.
|
||||
*/
|
||||
public static final int red=0x7f040002;
|
||||
public static final int semitrans_gray=0x7f040001;
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int greendriving_for_android=0x7f020000;
|
||||
public static final int greendriving_settings=0x7f020001;
|
||||
public static final int greendriving_tripcalc=0x7f020002;
|
||||
public static final int ic_menu_end=0x7f020003;
|
||||
public static final int ic_menu_pause=0x7f020004;
|
||||
public static final int ic_menu_resume=0x7f020005;
|
||||
public static final int ic_menu_settings=0x7f020006;
|
||||
public static final int ic_menu_start=0x7f020007;
|
||||
public static final int icon=0x7f020008;
|
||||
public static final int logo=0x7f020009;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int Chronometer01=0x7f070014;
|
||||
public static final int TextView01=0x7f070003;
|
||||
public static final int TextView02=0x7f070009;
|
||||
public static final int TextView03=0x7f07001f;
|
||||
public static final int chrono_text=0x7f070013;
|
||||
public static final int co2=0x7f070005;
|
||||
public static final int co2_label=0x7f070004;
|
||||
public static final int delt_text=0x7f07001a;
|
||||
public static final int distance=0x7f07001c;
|
||||
public static final int distance_label=0x7f07001b;
|
||||
public static final int doStuff=0x7f070006;
|
||||
public static final int donateNow=0x7f07000c;
|
||||
public static final int done=0x7f070011;
|
||||
public static final int gps_text=0x7f070015;
|
||||
public static final int latitude=0x7f070017;
|
||||
public static final int latitude_label=0x7f070016;
|
||||
public static final int learnMore=0x7f070008;
|
||||
public static final int longitude=0x7f070019;
|
||||
public static final int longituede_label=0x7f070018;
|
||||
public static final int proceedToTrip=0x7f07000a;
|
||||
public static final int results_layout=0x7f070002;
|
||||
public static final int screen1_layout=0x7f070007;
|
||||
public static final int screen4_layout=0x7f07000b;
|
||||
public static final int screen5_layout=0x7f07000e;
|
||||
public static final int screen7_layout=0x7f07000f;
|
||||
public static final int settings_layout=0x7f070010;
|
||||
public static final int speec_label=0x7f07001d;
|
||||
public static final int splash_screen_layout=0x7f070000;
|
||||
public static final int start_trip_layout=0x7f070012;
|
||||
public static final int velocity=0x7f07001e;
|
||||
public static final int version=0x7f070001;
|
||||
public static final int whoYouIs=0x7f07000d;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int main=0x7f030000;
|
||||
public static final int results=0x7f030001;
|
||||
public static final int screen1=0x7f030002;
|
||||
public static final int screen4=0x7f030003;
|
||||
public static final int screen5=0x7f030004;
|
||||
public static final int screen7=0x7f030005;
|
||||
public static final int settings=0x7f030006;
|
||||
public static final int start_trip=0x7f030007;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f050001;
|
||||
public static final int hello=0x7f050000;
|
||||
public static final int learn_more=0x7f050002;
|
||||
public static final int proceed=0x7f050003;
|
||||
}
|
||||
public static final class style {
|
||||
public static final int ActionButton=0x7f060000;
|
||||
public static final int TextAppearance=0x7f060001;
|
||||
public static final int TextAppearance_ActionButton=0x7f060002;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
</lint>
|
|
@ -0,0 +1,13 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Indicates whether an apk should be generated for each density.
|
||||
split.density=false
|
||||
# Project target.
|
||||
target=android-7
|
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 370 B |
After Width: | Height: | Size: 659 B |
After Width: | Height: | Size: 684 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 599 B |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 2.2 KiB |
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/splash_screen_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center"
|
||||
android:paddingTop="70dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="40dip"
|
||||
android:layout_marginBottom="40dip"
|
||||
android:src="@drawable/greendriving_for_android"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:id="@+id/version"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:text="Version"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="30dip"
|
||||
android:shadowColor="@android:color/darker_gray"
|
||||
android:shadowRadius="3.0"
|
||||
android:textColor="@android:color/white" />
|
||||
<ImageView
|
||||
android:layout_width="210dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="0dip"
|
||||
android:src="@drawable/logo"
|
||||
android:scaleType="fitCenter" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/results_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="top"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="5dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:src="@drawable/greendriving_for_android"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="70dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView01"
|
||||
android:id="@+id/TextView01"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal" android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:text="CO2 produced" android:layout_marginBottom="0dip" android:id="@+id/co2_label" android:layout_width="150dip" android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="20dip" android:layout_gravity="right" android:textStyle="bold" android:paddingTop="30dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/co2" android:layout_width="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="30dip"
|
||||
android:paddingBottom="0dip" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
<Button android:id="@+id/doStuff" style="@style/ActionButton"
|
||||
android:text="Do Something About It" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen1_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="top"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="5dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:src="@drawable/greendriving_for_android"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView01"
|
||||
android:id="@+id/TextView01"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/learnMore" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="@string/learn_more" android:textColor="@color/green"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView02"
|
||||
android:id="@+id/TextView02"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/proceedToTrip" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="@string/proceed" android:textColor="@color/black"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen4_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="top"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="5dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:src="@drawable/greendriving_for_android"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView01"
|
||||
android:id="@+id/TextView01"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/learnMore" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="@string/learn_more" android:textColor="@color/green"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView02"
|
||||
android:id="@+id/TextView02"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/donateNow" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="Donate Now" android:textColor="@color/black"
|
||||
android:layout_height="wrap_content" android:layout_width="fill_parent"/>
|
||||
<Button android:id="@+id/whoYouIs" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="Who are you ..." android:textColor="@color/black"
|
||||
android:layout_height="wrap_content" android:layout_width="fill_parent"/>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen5_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="top"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="5dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:src="@drawable/greendriving_for_android"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView01"
|
||||
android:id="@+id/TextView01"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/learnMore" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="@string/learn_more" android:textColor="@color/green"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView02"
|
||||
android:id="@+id/TextView02"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/proceedToTrip" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="@string/proceed" android:textColor="@color/black"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen7_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="top"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="5dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:src="@drawable/greendriving_for_android"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView01"
|
||||
android:id="@+id/TextView01"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/learnMore" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="@string/learn_more" android:textColor="@color/green"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView02"
|
||||
android:id="@+id/TextView02"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<Button android:id="@+id/proceedToTrip" style="@style/ActionButton" android:layout_gravity="right"
|
||||
android:text="@string/proceed" android:textColor="@color/black"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/settings_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="top"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="5dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:src="@drawable/greendriving_settings"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView01"
|
||||
android:id="@+id/TextView01"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:text="CO2 Per Mile:" android:layout_marginBottom="0dip" android:id="@+id/co2_label" android:layout_width="150dip" android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingRight="3dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="10dip"
|
||||
android:paddingBottom="0dip" android:paddingLeft="20dip" />
|
||||
|
||||
<EditText android:id="@+id/co2" android:layout_width="125dip" android:layout_weight="0" android:layout_gravity="right"
|
||||
android:inputType="text" android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
<Button android:id="@+id/done" style="@style/ActionButton"
|
||||
android:text="Save" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/start_trip_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="top"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="5dip" >
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:src="@drawable/greendriving_tripcalc"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="378dip"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView01"
|
||||
android:id="@+id/TextView01"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingTop="10dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView02"
|
||||
android:id="@+id/TextView02"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal" android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:text="Elapsed" android:layout_marginBottom="0dip" android:id="@+id/chrono_text" android:layout_width="80dip" android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="20dip" android:layout_gravity="right" android:textStyle="bold" android:paddingTop="10dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<Chronometer android:text="@+id/Chronometer01"
|
||||
android:paddingTop="10dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:id="@+id/Chronometer01" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
</Chronometer>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal" android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:text="GPS" android:layout_marginBottom="0dip" android:id="@+id/gps_text" android:layout_width="80dip" android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="20dip" android:layout_gravity="right" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/latitude_label" android:layout_width="wrap_content" android:text="lat"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/latitude" android:layout_width="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/longituede_label" android:layout_width="wrap_content" android:text="long"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/longitude" android:layout_width="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal" android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:text="Vector" android:layout_marginBottom="0dip" android:id="@+id/delt_text" android:layout_width="80dip" android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="20dip" android:layout_gravity="right" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/distance_label" android:layout_width="wrap_content" android:text="dist"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/distance" android:layout_width="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/speec_label" android:layout_width="wrap_content" android:text="speed"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
<TextView android:layout_marginBottom="0dip" android:id="@+id/velocity" android:layout_width="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:layout_height="wrap_content" android:paddingLeft="8dip" android:layout_gravity="left" android:textStyle="bold" android:paddingTop="3dip"
|
||||
android:paddingBottom="0dip" />
|
||||
</LinearLayout>
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:paddingTop="5dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@+id/TextView03"
|
||||
android:id="@+id/TextView03"
|
||||
android:layout_width="fill_parent">
|
||||
</TextView>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="darker_gray">#5A5A5A</color>
|
||||
<color name="semitrans_gray">#99222222</color>
|
||||
<!-- Retrieved via Resources.getColor() and friends. -->
|
||||
<color name="red">#f00</color>
|
||||
<color name="green">#387C44</color>
|
||||
<color name="black">#000000</color>
|
||||
</resources>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="hello">Hello World, MainSplash!</string>
|
||||
<string name="app_name">GreenTravel</string>
|
||||
<string name="learn_more">Learn More...</string>
|
||||
<string name="proceed">Proceed...</string>
|
||||
</resources>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2007 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- This file contains resource definitions for style. A style is
|
||||
a collection of named values that can be applied as a group. Here,
|
||||
we are using a style to define a common set of XML attributes that
|
||||
will be used in multiple tags. -->
|
||||
|
||||
<resources>
|
||||
<style name="ActionButton">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:textAppearance">@style/TextAppearance.ActionButton</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance" parent="android:TextAppearance">
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.ActionButton">
|
||||
<item name="android:textStyle">italic</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
|
@ -0,0 +1,241 @@
|
|||
package org.commoditysoftware.greentravel ;
|
||||
|
||||
import android.util.FloatMath;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
/**
|
||||
* Class for handling coordinates
|
||||
*
|
||||
* @author Linus Helgesson
|
||||
*
|
||||
*/
|
||||
public class Coordinate {
|
||||
private float mLongitude = 0;
|
||||
private float mLatitude = 0;
|
||||
private float[] mResults = new float[2];
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
public Coordinate () {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor taking a longitude and a latitude
|
||||
*
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
*/
|
||||
public Coordinate(float longitude, float latitude) {
|
||||
this.mLongitude = longitude;
|
||||
this.mLatitude = latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the longitude part of this coordinate
|
||||
*
|
||||
* @return The longitude part of this coordinate
|
||||
*/
|
||||
public float getLongitude() {
|
||||
return mLongitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the longitude part of this coordinate
|
||||
*
|
||||
* @param longitude The longitude part of this coordinate
|
||||
*/
|
||||
public void setLongitude(float longitude) {
|
||||
this.mLongitude = longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latitude part of this coordinate
|
||||
*
|
||||
* @return The latitude part of this coordinate
|
||||
*/
|
||||
public float getLatitude() {
|
||||
return mLatitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the latitude part of this coordinate
|
||||
*
|
||||
* @param latitude The latitude part of this coordinate
|
||||
*/
|
||||
public void setLatitude(float latitude) {
|
||||
this.mLatitude = latitude;
|
||||
}
|
||||
|
||||
private static final float PI_OVER_180 = 0.017453292519943295769236907684886f;
|
||||
|
||||
// Earth medium radius, should maybe be changed to swedish latitude
|
||||
private static final float EARTH_RADIUS = 6371009;
|
||||
|
||||
/**
|
||||
* Calculates a bounding box of a certain size arund a coordinate. This is mainly used for a quick check
|
||||
* in the database for cameras that are close to a coordinate. This function takes a size ion meters as
|
||||
* a parameter and returns an array of two Coordinate objects. The first Coordinate is the upper left corner
|
||||
* while the last coordinate is the bottom right corner.
|
||||
*
|
||||
* @param side The length of the square side in meters
|
||||
*
|
||||
* @return Two cordinates where the first is smaller than the second.
|
||||
*/
|
||||
public Coordinate[] getBoundingBox(float side) {
|
||||
|
||||
Coordinate[] ret = new Coordinate[2];
|
||||
|
||||
float degLatM = 110574.235f;
|
||||
float degLongM = 110572.833f * FloatMath.cos(mLatitude * PI_OVER_180);
|
||||
float deltaLat = side / degLatM;
|
||||
float deltaLong = side / degLongM;
|
||||
|
||||
ret[0] = new Coordinate(getLongitude() - deltaLong, getLatitude() - deltaLat);
|
||||
ret[1] = new Coordinate(getLongitude() + deltaLong, getLatitude() + deltaLat);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the distance between two Coordinate objects using the Spherical law of cosines found at:
|
||||
*
|
||||
* http://www.movable-type.co.uk/scripts/latlong.html
|
||||
*
|
||||
* @param coordinate The coordinate to measure the distance to.
|
||||
* @return the distance in meters
|
||||
*/
|
||||
/*
|
||||
public float distanceTo(Coordinate coordinate) {
|
||||
float lat1 = mLatitude * PI_OVER_180;
|
||||
float lat2 = coordinate.getLatitude() * PI_OVER_180;
|
||||
float dLat = (coordinate.getLatitude() - mLatitude) * PI_OVER_180;
|
||||
float dLong = (coordinate.getLongitude() - mLongitude) * PI_OVER_180;
|
||||
|
||||
float a = FloatMath.sin(dLat/2) * FloatMath.sin(dLat/2) +
|
||||
FloatMath.cos(lat1) * FloatMath.cos(lat2) *
|
||||
FloatMath.sin(dLong/2) * FloatMath.sin(dLong/2);
|
||||
|
||||
return (float)(EARTH_RADIUS * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)));
|
||||
}
|
||||
public float distanceTo(Coordinate coordinate) {
|
||||
float lat1 = mLatitude*PI_OVER_180;
|
||||
float lat2 = coordinate.getLatitude() * PI_OVER_180;
|
||||
float long1 = mLongitude * PI_OVER_180;
|
||||
float long2 = coordinate.getLongitude() * PI_OVER_180;
|
||||
|
||||
return (float)Math.acos(FloatMath.sin(lat1) * FloatMath.sin(lat2) + FloatMath.cos(lat1) * FloatMath.cos(lat2) * FloatMath.cos(long2-long1)) * EARTH_RADIUS;
|
||||
}
|
||||
*/
|
||||
|
||||
public float distanceTo(Coordinate dest) {
|
||||
// See if we already have the result
|
||||
computeDistanceAndBearing(mLatitude, mLongitude,
|
||||
dest.getLatitude(), dest.getLongitude(), mResults);
|
||||
|
||||
return mResults[0];
|
||||
}
|
||||
|
||||
private static void computeDistanceAndBearing(double lat1, double lon1,
|
||||
double lat2, double lon2, float[] results) {
|
||||
// Based on http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
|
||||
// using the "Inverse Formula" (section 4)
|
||||
|
||||
int MAXITERS = 20;
|
||||
// Convert lat/long to radians
|
||||
lat1 *= Math.PI / 180.0;
|
||||
lat2 *= Math.PI / 180.0;
|
||||
lon1 *= Math.PI / 180.0;
|
||||
lon2 *= Math.PI / 180.0;
|
||||
|
||||
double a = 6378137.0; // WGS84 major axis
|
||||
double b = 6356752.3142; // WGS84 semi-major axis
|
||||
double f = (a - b) / a;
|
||||
double aSqMinusBSqOverBSq = (a * a - b * b) / (b * b);
|
||||
|
||||
double L = lon2 - lon1;
|
||||
double A = 0.0;
|
||||
double U1 = Math.atan((1.0 - f) * Math.tan(lat1));
|
||||
double U2 = Math.atan((1.0 - f) * Math.tan(lat2));
|
||||
|
||||
double cosU1 = Math.cos(U1);
|
||||
double cosU2 = Math.cos(U2);
|
||||
double sinU1 = Math.sin(U1);
|
||||
double sinU2 = Math.sin(U2);
|
||||
double cosU1cosU2 = cosU1 * cosU2;
|
||||
double sinU1sinU2 = sinU1 * sinU2;
|
||||
|
||||
double sigma = 0.0;
|
||||
double deltaSigma = 0.0;
|
||||
double cosSqAlpha = 0.0;
|
||||
double cos2SM = 0.0;
|
||||
double cosSigma = 0.0;
|
||||
double sinSigma = 0.0;
|
||||
double cosLambda = 0.0;
|
||||
double sinLambda = 0.0;
|
||||
|
||||
double lambda = L; // initial guess
|
||||
for (int iter = 0; iter < MAXITERS; iter++) {
|
||||
double lambdaOrig = lambda;
|
||||
cosLambda = Math.cos(lambda);
|
||||
sinLambda = Math.sin(lambda);
|
||||
double t1 = cosU2 * sinLambda;
|
||||
double t2 = cosU1 * sinU2 - sinU1 * cosU2 * cosLambda;
|
||||
double sinSqSigma = t1 * t1 + t2 * t2; // (14)
|
||||
sinSigma = Math.sqrt(sinSqSigma);
|
||||
cosSigma = sinU1sinU2 + cosU1cosU2 * cosLambda; // (15)
|
||||
sigma = Math.atan2(sinSigma, cosSigma); // (16)
|
||||
double sinAlpha = (sinSigma == 0) ? 0.0 :
|
||||
cosU1cosU2 * sinLambda / sinSigma; // (17)
|
||||
cosSqAlpha = 1.0 - sinAlpha * sinAlpha;
|
||||
cos2SM = (cosSqAlpha == 0) ? 0.0 :
|
||||
cosSigma - 2.0 * sinU1sinU2 / cosSqAlpha; // (18)
|
||||
|
||||
double uSquared = cosSqAlpha * aSqMinusBSqOverBSq; // defn
|
||||
A = 1 + (uSquared / 16384.0) * // (3)
|
||||
(4096.0 + uSquared *
|
||||
(-768 + uSquared * (320.0 - 175.0 * uSquared)));
|
||||
double B = (uSquared / 1024.0) * // (4)
|
||||
(256.0 + uSquared *
|
||||
(-128.0 + uSquared * (74.0 - 47.0 * uSquared)));
|
||||
double C = (f / 16.0) *
|
||||
cosSqAlpha *
|
||||
(4.0 + f * (4.0 - 3.0 * cosSqAlpha)); // (10)
|
||||
double cos2SMSq = cos2SM * cos2SM;
|
||||
deltaSigma = B * sinSigma * // (6)
|
||||
(cos2SM + (B / 4.0) *
|
||||
(cosSigma * (-1.0 + 2.0 * cos2SMSq) -
|
||||
(B / 6.0) * cos2SM *
|
||||
(-3.0 + 4.0 * sinSigma * sinSigma) *
|
||||
(-3.0 + 4.0 * cos2SMSq)));
|
||||
|
||||
lambda = L +
|
||||
(1.0 - C) * f * sinAlpha *
|
||||
(sigma + C * sinSigma *
|
||||
(cos2SM + C * cosSigma *
|
||||
(-1.0 + 2.0 * cos2SM * cos2SM))); // (11)
|
||||
|
||||
double delta = (lambda - lambdaOrig) / lambda;
|
||||
if (Math.abs(delta) < 1.0e-12) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float distance = (float) (b * A * (sigma - deltaSigma));
|
||||
results[0] = distance;
|
||||
if (results.length > 1) {
|
||||
float initialBearing = (float) Math.atan2(cosU2 * sinLambda,
|
||||
cosU1 * sinU2 - sinU1 * cosU2 * cosLambda);
|
||||
initialBearing *= 180.0 / Math.PI;
|
||||
results[1] = initialBearing;
|
||||
if (results.length > 2) {
|
||||
float finalBearing = (float) Math.atan2(cosU1 * sinLambda,
|
||||
-sinU1 * cosU2 + cosU1 * sinU2 * cosLambda);
|
||||
finalBearing *= 180.0 / Math.PI;
|
||||
results[2] = finalBearing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
|
||||
public class EndTripActivity extends Activity {
|
||||
|
||||
String version;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.results);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.results_layout);
|
||||
((TextView) findViewById(R.id.TextView01)).
|
||||
setText("Carbon burden of this trip: ");
|
||||
|
||||
((TextView) findViewById(R.id.co2)).
|
||||
setText(GreenTravelService.co2Produced());
|
||||
// Hook up button presses to the appropriate event handler.
|
||||
((Button) findViewById(R.id.doStuff)).setOnClickListener(mDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* A call-back for when the user presses the Do Something button.
|
||||
*/
|
||||
OnClickListener mDo = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(EndTripActivity.this, Screen4.class));
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
startActivity(i);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
package org.commoditysoftware.greentravel ;
|
||||
|
||||
import android.util.Log;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.os.Bundle;
|
||||
import java.util.ArrayList;
|
||||
import android.content.Context;
|
||||
import android.app.Notification;
|
||||
import android.location.Criteria;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
|
||||
public class GreenTravelService extends Service implements LocationListener {
|
||||
|
||||
public static Coordinate startPoint;
|
||||
public static double distance;
|
||||
public static double co2Rate = 0.66666;
|
||||
|
||||
private static StartTrip TRIP_HOME;
|
||||
private static final boolean debug = true;
|
||||
private LocationManager mLocationManager;
|
||||
private long lCurrTime = 0, lLastTime = 0;
|
||||
private static Location mLoc = new Location("");
|
||||
private static float mSpeed = 0;
|
||||
|
||||
ArrayList<Messenger> mClients = new ArrayList<Messenger>();
|
||||
|
||||
public static String co2Produced() {
|
||||
String result = "";
|
||||
|
||||
result += (distance * 0.6214) * co2Rate;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Location getLocation() {
|
||||
return mLoc;
|
||||
}
|
||||
|
||||
public static float getSpeed() {
|
||||
return mSpeed;
|
||||
}
|
||||
|
||||
public class LocalBinder extends Binder {
|
||||
GreenTravelService getService() {
|
||||
return GreenTravelService.this;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTripHome(StartTrip home) {
|
||||
startPoint = null;
|
||||
distance = 0.0;
|
||||
TRIP_HOME = home;
|
||||
Log.d("oppm","trip reset");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
startListening();
|
||||
Log.d("oppm","gps started");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return mBinder;
|
||||
}
|
||||
|
||||
// This is the object that receives interactions from clients. See
|
||||
// RemoteService for a more complete example.
|
||||
private final IBinder mBinder = new LocalBinder();
|
||||
|
||||
private void startListening() {
|
||||
|
||||
Criteria criterion = new Criteria();
|
||||
String bestProvider;
|
||||
|
||||
if (mLocationManager == null) {
|
||||
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
|
||||
criterion.setAccuracy(Criteria.ACCURACY_FINE);
|
||||
bestProvider = mLocationManager.getBestProvider(criterion, true);
|
||||
Log.d("oppm","best gps: " + bestProvider + " enabled: " + mLocationManager.isProviderEnabled(bestProvider));
|
||||
|
||||
}
|
||||
|
||||
mLocationManager.requestLocationUpdates(
|
||||
LocationManager.NETWORK_PROVIDER,
|
||||
0,
|
||||
0,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
private void stopListening() {
|
||||
if (mLocationManager != null)
|
||||
mLocationManager.removeUpdates(this);
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void onLocationChanged(Location loc) {
|
||||
lLastTime = lCurrTime;
|
||||
lCurrTime = System.currentTimeMillis();
|
||||
|
||||
float fDist = 0; //Holds distance since last GPS update
|
||||
|
||||
if (mLoc != null)
|
||||
{fDist = loc.distanceTo(mLoc);
|
||||
distance += fDist;
|
||||
}
|
||||
|
||||
long lElapsedTime = (lCurrTime - lLastTime);
|
||||
mSpeed = fDist / lElapsedTime * 1000;
|
||||
|
||||
Coordinate coordCurrent = new Coordinate(
|
||||
(float)loc.getLongitude(),
|
||||
(float)loc.getLatitude());
|
||||
Coordinate coordOld = new Coordinate(
|
||||
(float)mLoc.getLongitude(),
|
||||
(float)mLoc.getLatitude());
|
||||
|
||||
mLoc = loc;
|
||||
|
||||
//Let MainActivity know about the new location
|
||||
TRIP_HOME.updateGPS();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
if (debug) Log.d("oppm","gps provider " + provider + " disabled.");
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
if (debug) Log.d("oppm","gps provider " + provider + " enabled.");
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
if (debug) Log.d("oppm","gps provide r" + provider + " status: " + status);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.IBinder;
|
||||
import android.os.Bundle;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.util.Log;
|
||||
|
||||
public class MainSplash extends Activity {
|
||||
|
||||
String version;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
try {
|
||||
version = getPackageManager().getPackageInfo(getPackageName(),
|
||||
PackageManager.GET_ACTIVITIES).versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
version = "Unknown";
|
||||
}
|
||||
Log.d("oppm","main");
|
||||
setContentView(R.layout.main);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.splash_screen_layout);
|
||||
((TextView) findViewById(R.id.version)).setText("Version " + version);
|
||||
|
||||
|
||||
// wait three seconds and start our activity
|
||||
layout.postDelayed(new Runnable() {
|
||||
//@Override
|
||||
public void run() {
|
||||
startActivity(new Intent(MainSplash.this, Screen1.class));
|
||||
//finish();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.net.Uri;
|
||||
|
||||
public class Screen1 extends Activity {
|
||||
|
||||
private static final String LEARNMORE_URL = "http://www.nrdc.org/globalwarming/f101.asp";
|
||||
|
||||
String version;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.screen1);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.screen1_layout);
|
||||
((TextView) findViewById(R.id.TextView01)).
|
||||
setText("This app uses GPS to apply a model of energy consumption "
|
||||
+ "to distance and time on trip. "
|
||||
);
|
||||
((TextView) findViewById(R.id.TextView02)).
|
||||
setText("In the finished Green Driving app this would support users contributing "
|
||||
+ "in direct proportion to thier contributed carbon burden. "
|
||||
);
|
||||
// Hook up button presses to the appropriate event handler.
|
||||
((Button) findViewById(R.id.learnMore)).setOnClickListener(mLearnMore);
|
||||
((Button) findViewById(R.id.proceedToTrip)).setOnClickListener(mProceedToTrip);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A call-back for when the user presses the Learn More button.
|
||||
*/
|
||||
OnClickListener mLearnMore = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(LEARNMORE_URL));
|
||||
startActivity(i);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A call-back for when the user presses the Proceed button.
|
||||
*/
|
||||
OnClickListener mProceedToTrip = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Screen1.this, StartTrip.class));
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.net.Uri;
|
||||
|
||||
public class Screen4 extends Activity {
|
||||
|
||||
String version;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.results);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.screen4_layout);
|
||||
((TextView) findViewById(R.id.TextView01)).
|
||||
setText("Stub for page 4 of the PDF: Modify Screen4.java,xml " +
|
||||
" as needed. Screen1 does what PDF indicates this needs to.");
|
||||
((Button) findViewById(R.id.donateNow)).setOnClickListener(mDonate);
|
||||
((Button) findViewById(R.id.whoYouIs)).setOnClickListener(mWRU);
|
||||
}
|
||||
|
||||
/**
|
||||
* A call-back for when the user presses the Do Something button.
|
||||
*/
|
||||
OnClickListener mDonate = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("http://paypal.com"));
|
||||
startActivity(i);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* A call-back for when the user presses the Do Something button.
|
||||
*/
|
||||
OnClickListener mWRU = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Screen4.this, Screen5.class));
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
public class Screen5 extends Activity {
|
||||
|
||||
String version;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.results);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.screen5_layout);
|
||||
((TextView) findViewById(R.id.TextView01)).
|
||||
setText("Stub for page 5 of the PDF: Modify Screen5.java,xml " +
|
||||
" as needed. Screen1 does what PDF indicates this needs to.");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
public class Screen7 extends Activity {
|
||||
|
||||
String version;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.results);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.screen7_layout);
|
||||
((TextView) findViewById(R.id.TextView01)).
|
||||
setText("Stub for screen7 of the PDF: Modify Screen7.java,xml " +
|
||||
" as needed. Screen1 does what PDF indicates this needs to.");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
public class SettingsActivity extends Activity {
|
||||
|
||||
String version;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.settings);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.settings_layout);
|
||||
((TextView) findViewById(R.id.TextView01)).
|
||||
setText("Current model settings to use. Consult the nrdc site or other sources. ");
|
||||
((TextView) findViewById(R.id.co2)).
|
||||
setText("" + GreenTravelService.co2Rate);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package org.commoditysoftware.greentravel;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Chronometer;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.util.Log;
|
||||
import android.content.Context;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class StartTrip extends Activity {
|
||||
|
||||
private static boolean paused;
|
||||
private Chronometer clock;
|
||||
private Menu mMenu;
|
||||
private MenuItem mPauseResume;
|
||||
private TextView mDistance,mLatitude,mLongitude,mVelocity;
|
||||
|
||||
private static final int MENU_START = Menu.FIRST;
|
||||
private static final int MENU_PAUSE = Menu.FIRST + 1;
|
||||
private static final int MENU_END = Menu.FIRST + 2;
|
||||
private static final int MENU_SETTINGS = Menu.FIRST + 3;
|
||||
|
||||
private Intent gdsIntention;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.start_trip);
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.start_trip_layout);
|
||||
((TextView) findViewById(R.id.TextView01)).
|
||||
setText("Use the Android menu to control your trip. ");
|
||||
((TextView) findViewById(R.id.TextView02)).
|
||||
setText("Use pause if the fuel burning portion of your "
|
||||
+ "trip is interrupted. Use end to "
|
||||
+ "see the environmental footprint of this trip."
|
||||
);
|
||||
((TextView) findViewById(R.id.TextView03)).
|
||||
setText("This is an early version, exiting "
|
||||
+ " will cancel trip and there is no power optimization. "
|
||||
);
|
||||
mLatitude = ((TextView) findViewById(R.id.latitude));
|
||||
mLongitude = ((TextView) findViewById(R.id.longitude));
|
||||
mDistance = ((TextView) findViewById(R.id.distance));
|
||||
mVelocity = ((TextView) findViewById(R.id.velocity));
|
||||
clock = ((Chronometer) findViewById(R.id.Chronometer01));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
mMenu = menu;
|
||||
MenuItem menuItem = menu.add(0, MENU_START, 0, "Start Trip");
|
||||
menuItem.setIcon(R.drawable.ic_menu_start);
|
||||
menuItem = menu.add(0, MENU_SETTINGS, 0, "Change Model Settings");
|
||||
menuItem.setIcon(R.drawable.ic_menu_settings);
|
||||
mPauseResume = menu.add(0, MENU_PAUSE, 0, "Pause");
|
||||
mPauseResume.setIcon(R.drawable.ic_menu_pause);
|
||||
menuItem = menu.add(0, MENU_END, 0, "End Trip");
|
||||
menuItem.setIcon(R.drawable.ic_menu_end);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
int itemid = item.getItemId();
|
||||
switch (itemid) {
|
||||
case MENU_START:
|
||||
//Start GPS service
|
||||
paused = false;
|
||||
GreenTravelService.setTripHome(this);
|
||||
startService(new Intent(this, GreenTravelService.class));
|
||||
clock.start();
|
||||
break;
|
||||
case MENU_PAUSE:
|
||||
if (!paused) {
|
||||
mPauseResume.setIcon(R.drawable.ic_menu_resume);
|
||||
clock.stop();
|
||||
paused = true;
|
||||
}
|
||||
else {paused = false;
|
||||
clock.start();
|
||||
mPauseResume.setIcon(R.drawable.ic_menu_pause);
|
||||
}
|
||||
break;
|
||||
case MENU_END:
|
||||
clock.stop();
|
||||
stopService (new Intent(this, GreenTravelService.class));
|
||||
if ((GreenTravelService.distance * 0.6214) > 10) {
|
||||
startActivity(new Intent(StartTrip.this, EndTripActivity.class)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
|
||||
} else {
|
||||
startActivity(new Intent(StartTrip.this, Screen7.class)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
|
||||
}
|
||||
break;
|
||||
case MENU_SETTINGS:
|
||||
startActivity(new Intent(StartTrip.this, SettingsActivity.class));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void updateGPS() {
|
||||
boolean starting = (GreenTravelService.startPoint == null);
|
||||
DecimalFormat sevenDecimal = new DecimalFormat("#0.0000000");
|
||||
DecimalFormat noDecimal = new DecimalFormat("#0");
|
||||
|
||||
Coordinate here = new Coordinate(
|
||||
(float)GreenTravelService.getLocation().getLongitude(),
|
||||
(float)GreenTravelService.getLocation().getLatitude());
|
||||
|
||||
if (starting) {
|
||||
GreenTravelService.startPoint = new Coordinate(
|
||||
(float)GreenTravelService.getLocation().getLongitude(),
|
||||
(float)GreenTravelService.getLocation().getLatitude());
|
||||
}
|
||||
|
||||
|
||||
if(!starting) {
|
||||
mLatitude.setText(sevenDecimal.format(here.getLatitude()));
|
||||
mLongitude.setText(sevenDecimal.format(here.getLongitude()));
|
||||
mDistance.setText(noDecimal.format(here.distanceTo(GreenTravelService.startPoint)));
|
||||
mVelocity.setText(noDecimal.format(GreenTravelService.getSpeed()));
|
||||
}
|
||||
else {
|
||||
mLatitude.setText("---");
|
||||
mLongitude.setText("---");
|
||||
mDistance.setText("---");
|
||||
mVelocity.setText(noDecimal.format(0.0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|