Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

WIP - Review changes from https://github.com/Wacken88/HSL-OTP-for-Android #471

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/build
*.iml
.DS_Store
.navigation
.directory
4 changes: 2 additions & 2 deletions opentripplanner-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ android {
defaultConfig {
versionCode 15
versionName "2.1.2"
minSdkVersion 8
targetSdkVersion 13
minSdkVersion 14
targetSdkVersion 11
}

// http://stackoverflow.com/questions/20673625/gradle-0-7-0-duplicate-files-during-packaging-of-apk
Expand Down
55 changes: 47 additions & 8 deletions opentripplanner-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 University of South Florida

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
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
Expand All @@ -22,6 +22,9 @@
<!-- To plan trip from/to contact address -->
<uses-permission android:name="android.permission.READ_CONTACTS"/>

<!-- To set an alarm for a trip -->
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>

<!-- Android Maps API V2 -->
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand Down Expand Up @@ -54,24 +57,60 @@
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="edu.usf.cutr.opentripplanner.android.OpenTripPlanner.WIDGET_SEARCH"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:theme="@style/MyTheme"
android:windowSoftInputMode="stateHidden"></activity>
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".AboutActivity"
android:theme="@style/MyTheme"
android:windowSoftInputMode="stateHidden"></activity>
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".AboutPlayServicesActivity"
android:theme="@style/MyTheme"
android:windowSoftInputMode="stateHidden"></activity>
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".AddressFavActivity"
android:theme="@style/MyTheme"
android:windowSoftInputMode="stateHidden"/>

<activity
android:name=".AlarmActivity"
android:theme="@style/MyTheme"
android:windowSoftInputMode="stateHidden"/>

<activity
android:name=".OTPAppWidgetLocationActivity"
android:theme="@style/Theme.Transparent">
<intent-filter>
<action android:name="edu.usf.cutr.opentripplanner.android.OpenTripPlanner.GET_MY_LOCATION_STRING"/>
<action android:name="edu.usf.cutr.opentripplanner.android.OpenTripPlanner.GET_END_LOCATION_STRING"/>
</intent-filter>
</activity>

<service android:name=".NotificationService" />

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD5XadJhAK7jIKFz5TcT7t-gsWw_OTvlBI"/>
android:value="AIzaSyALtmLxXCR2t7XhB7EHFJ1_CSI8Henkntk"/>

<receiver
android:name="OTPAppWidgetProvider"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="edu.usf.cutr.opentripplanner.android.OpenTripPlanner.WIDGET_SEARCH" />
<action android:name="edu.usf.cutr.opentripplanner.android.OpenTripPlanner.SEND_MY_LOCATION_STRING" />
<action android:name="edu.usf.cutr.opentripplanner.android.OpenTripPlanner.SEND_END_LOCATION_STRING" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget" />
</receiver>
</application>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.View;

import com.google.android.gms.maps.model.LatLng;

Expand All @@ -39,16 +40,19 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.prefs.PreferenceChangeEvent;
import java.util.Locale;

import edu.usf.cutr.opentripplanner.android.fragments.DirectionListFragment;
import edu.usf.cutr.opentripplanner.android.fragments.MainFragment;
import edu.usf.cutr.opentripplanner.android.listeners.DateCompleteListener;
import edu.usf.cutr.opentripplanner.android.listeners.OtpFragment;
import edu.usf.cutr.opentripplanner.android.model.AddressModel;
import edu.usf.cutr.opentripplanner.android.model.OTPBundle;
import edu.usf.cutr.opentripplanner.android.model.Server;
import edu.usf.cutr.opentripplanner.android.sqlite.ServersDataSource;
import edu.usf.cutr.opentripplanner.android.tasks.ServerChecker;
import edu.usf.cutr.opentripplanner.android.util.AutoCompleteTextViewFromZero;
import edu.usf.cutr.opentripplanner.android.util.CustomAddress;

/**
* Main Activity for the OTP for Android app
Expand Down Expand Up @@ -100,6 +104,23 @@ public void onCreate(Bundle savedInstanceState) {
fragmentTransaction.commit();
}

Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
Log.d(OTPApp.TAG,"OnCreate with Intent action " + action);
if(OTPApp.INTENT_WIDGET_SEARCH.equals(action) && type != null){
if("text/plain".equals(type)){
if(intent.getStringExtra("StartLocation")!=null && mainFragment != null) {
Log.d(OTPApp.TAG,"StartLocation: " + intent.getStringExtra("StartLocation"));
mainFragment.setWidgetLocation(intent.getStringExtra("StartLocation"), true);
}
if(intent.getStringExtra("EndLocation")!=null && mainFragment != null) {
Log.d(OTPApp.TAG,"EndLocation: " + intent.getStringExtra("EndLocation"));
mainFragment.setWidgetLocation(intent.getStringExtra("EndLocation"), false);
}
}
}

}

@Override
Expand Down Expand Up @@ -161,8 +182,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (changedParametersMustRequestTrip) {
mainFragment.processRequestTrip();
}
break;
}
break;
case OTPApp.CHOOSE_CONTACT_REQUEST_CODE:
if (resultCode == RESULT_OK) {
Log.d(OTPApp.TAG, "CHOOSE CONTACT RESULT OK");
Expand All @@ -188,8 +209,66 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mainFragment.processRequestTrip();
}

break;
}
break;
case OTPApp.CHOOSE_ADDRESS_REQUEST_CODE:
if (resultCode == RESULT_OK) {
Log.d(OTPApp.TAG, "CHOOSE ADDRESS RESULT OK");

Bundle res = data.getExtras();
String address = res.getString(AddressFavActivity.FAVOURITE_ADDRESS_RESULT_PARAM_NAME);
double latitude = res.getDouble(AddressFavActivity.FAVOURITE_ADDRESS_RESULT_PARAM_LAT);
double longitude = res.getDouble(AddressFavActivity.FAVOURITE_ADDRESS_RESULT_PARAM_LONG);

boolean coordsMissing = (latitude == AddressFavActivity.FAVOURITE_ADDRESS_RESULT_PARAM_ERROR_DOUBLE || longitude == AddressFavActivity.FAVOURITE_ADDRESS_RESULT_PARAM_ERROR_DOUBLE);
mainFragment.setTextBoxLocation(address, isButtonStartLocation);
mainFragment.setStar(isButtonStartLocation);

SharedPreferences.Editor prefsEditor = PreferenceManager
.getDefaultSharedPreferences(this).edit();
if (isButtonStartLocation){
prefsEditor.putBoolean(OTPApp.PREFERENCE_KEY_ORIGIN_IS_MY_LOCATION, false);
}
else{
prefsEditor.putBoolean(OTPApp.PREFERENCE_KEY_DESTINATION_IS_MY_LOCATION, false);
}
prefsEditor.commit();
if(coordsMissing)
mainFragment.processAddress(isButtonStartLocation, address, false);
else{
AddressModel a = new AddressModel(address, latitude, longitude, true, true);

mainFragment.useNewAddress(isButtonStartLocation, a.getAsCustomAddress(getResources().getConfiguration().locale), false);
}
mainFragment.setStar(isButtonStartLocation);
mainFragment.processRequestTrip();
}
else {
mainFragment.refreshStar(isButtonStartLocation);
}
break;
}
}

@Override
protected void onResume(){
super.onResume();

Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
Log.d(OTPApp.TAG,"On Resume with Intent action " + action);
if(action != null && type != null){
if("text/plain".equals(type)){
if(intent.getStringExtra("StartLocation")!=null && mainFragment != null) {
Log.d(OTPApp.TAG,"StartLocation: " + intent.getStringExtra("StartLocation"));
mainFragment.setWidgetLocation(intent.getStringExtra("StartLocation"), true);
}
if(intent.getStringExtra("EndLocation")!=null && mainFragment != null) {
Log.d(OTPApp.TAG,"EndLocation: " + intent.getStringExtra("EndLocation"));
mainFragment.setWidgetLocation(intent.getStringExtra("EndLocation"), false);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class OTPApp extends Application {

public static final int CHOOSE_CONTACT_REQUEST_CODE = 1;

public static final int CHOOSE_ADDRESS_REQUEST_CODE = 9;

public static final String METADATA_LOCATION = "/metadata";

public static final String BIKE_RENTAL_LOCATION = "/bike_rental";
Expand Down Expand Up @@ -157,6 +159,12 @@ public class OTPApp extends Application {

public static final String BUNDLE_KEY_TRIP_DATE = "trip date";

public static final String BUNDLE_KEY_TRIP_TIME = "trip time";

public static final String BUNDLE_KEY_TRIP_HOUR = "trip hour";

public static final String BUNDLE_KEY_TRIP_MINUTES = "trip minutes";

public static final String BUNDLE_KEY_ARRIVE_BY = "arrive by";

public static final String BUNDLE_KEY_TIMEPICKER_SAVED_HOUR = "timepicker hours";
Expand All @@ -181,6 +189,10 @@ public class OTPApp extends Application {

public static final int COLOR_ROUTE_LINE = 0x7F0000FF;

public static final int NOTIFICATION_ID = 42;

public static final String TRIP_DESCRIPTION = "trip description";

/**
* Preference keys
*/
Expand Down Expand Up @@ -293,6 +305,27 @@ public class OTPApp extends Application {
public static final String INTENT_NOTIFICATION_RESUME_APP_WITH_TRIP_ID
= "edu.usf.cutr.opentripplanner.android.OpenTripPlanner.NOTIFICATION_RESUME";

public static final String INTENT_GET_MY_LOCATION_STRING
= "edu.usf.cutr.opentripplanner.android.OpenTripPlanner.GET_MY_LOCATION_STRING";

public static final String INTENT_GET_END_LOCATION_STRING
= "edu.usf.cutr.opentripplanner.android.OpenTripPlanner.GET_END_LOCATION_STRING";

public static final String SEND_MY_LOCATION_STRING
= "edu.usf.cutr.opentripplanner.android.OpenTripPlanner.SEND_MY_LOCATION_STRING";

public static final String SEND_END_LOCATION_STRING
= "edu.usf.cutr.opentripplanner.android.OpenTripPlanner.SEND_END_LOCATION_STRING";

public static final String LAYOUT_PARAMETERS
= "edu.usf.cutr.opentripplanner.android.OpenTripPlanner.LAYOUT_PARAMETERS";

public static final String STREET_VIEW_STRING
= "google.streetview:cbll= %f,%f &cbp=0,90,0,0,1&mz=8";

public static final String INTENT_WIDGET_SEARCH
= "edu.usf.cutr.opentripplanner.android.OpenTripPlanner.WIDGET_SEARCH";

/**
* Sets the currently selected OTP server
*
Expand Down
Loading