diff --git a/.gitignore b/.gitignore index 9382ab82..9e0fa99b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /build *.iml .DS_Store +.navigation +.directory diff --git a/opentripplanner-android/build.gradle b/opentripplanner-android/build.gradle index 6a193e9b..e4338f56 100644 --- a/opentripplanner-android/build.gradle +++ b/opentripplanner-android/build.gradle @@ -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 diff --git a/opentripplanner-android/src/main/AndroidManifest.xml b/opentripplanner-android/src/main/AndroidManifest.xml index abd5ff81..09a44840 100644 --- a/opentripplanner-android/src/main/AndroidManifest.xml +++ b/opentripplanner-android/src/main/AndroidManifest.xml @@ -1,16 +1,16 @@ + + + @@ -54,24 +57,60 @@ + + + + android:windowSoftInputMode="stateHidden"/> + android:windowSoftInputMode="stateHidden"/> + android:windowSoftInputMode="stateHidden"/> + + + + + + + + + + + + + android:value="AIzaSyALtmLxXCR2t7XhB7EHFJ1_CSI8Henkntk"/> + + + + + + + + + + diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/MyActivity.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/MyActivity.java index 4020bedd..c69b4898 100644 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/MyActivity.java +++ b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/MyActivity.java @@ -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; @@ -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 @@ -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 @@ -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"); @@ -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); + } + } } } diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/OTPApp.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/OTPApp.java index f1359240..6f4f548f 100644 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/OTPApp.java +++ b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/OTPApp.java @@ -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"; @@ -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"; @@ -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 */ @@ -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 * diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/DirectionListFragment.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/DirectionListFragment.java index f7350a3b..c01c6ca6 100644 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/DirectionListFragment.java +++ b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/DirectionListFragment.java @@ -16,14 +16,14 @@ package edu.usf.cutr.opentripplanner.android.fragments; -import org.opentripplanner.routing.core.TraverseMode; -import org.opentripplanner.api.model.Itinerary; -import org.opentripplanner.api.model.Leg; - import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceManager; +import android.provider.CalendarContract; +import android.support.v4.widget.PopupMenuCompat; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -31,12 +31,20 @@ import android.widget.ArrayAdapter; import android.widget.ExpandableListView; import android.widget.ImageButton; +import android.widget.PopupMenu; import android.widget.Spinner; import android.widget.TextView; +import android.widget.Toast; + +import org.opentripplanner.api.model.Itinerary; +import org.opentripplanner.api.model.Leg; +import org.opentripplanner.routing.core.TraverseMode; import java.util.ArrayList; import java.util.List; +import edu.usf.cutr.opentripplanner.android.AlarmActivity; +import edu.usf.cutr.opentripplanner.android.NotificationService; import edu.usf.cutr.opentripplanner.android.OTPApp; import edu.usf.cutr.opentripplanner.android.R; import edu.usf.cutr.opentripplanner.android.listeners.OtpFragment; @@ -71,6 +79,8 @@ public class DirectionListFragment extends ExpandableListFragment { TextView arrivalTimeHeader; + Spinner tripList; + OTPBundle otpBundle; @Override @@ -100,6 +110,8 @@ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ImageButton btnDisplayMap = (ImageButton) header.findViewById(R.id.btnDisplayMap); + ImageButton btnShareDirections = (ImageButton) header.findViewById(R.id.btnShareDirections); + ImageButton btnAlarmDirections = (ImageButton) header.findViewById(R.id.btnAlarmDirections); final OtpFragment ofl = this.getFragmentListener(); final DirectionListFragment dlf = this; OnClickListener oclDisplayDirection = new OnClickListener() { @@ -109,11 +121,83 @@ public void onClick(View arg0) { } }; btnDisplayMap.setOnClickListener(oclDisplayDirection); + btnShareDirections.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + + // create popup menu + View menuItemView = getView().findViewById(R.id.btnShareDirections); + PopupMenu popup = new PopupMenu(getActivity(),menuItemView); + popup.getMenuInflater().inflate(R.menu.share_menu, popup.getMenu()); + menuItemView.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(popup)); + + //registering popup with OnMenuItemClickListener + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + public boolean onMenuItemClick(MenuItem item) { + + Intent itn = new Intent(); + itn.setAction(Intent.ACTION_SEND); + itn.setType("text/plain"); + + // fill intend content based on chosen menu item + switch (item.getItemId()) { + case R.id.btnShareDirectionsShort: + itn.putExtra(Intent.EXTRA_TEXT, getDepartureArrivalHeaders(false)); + break; + case R.id.btnShareDirectionsDetailed: + itn.putExtra(Intent.EXTRA_TEXT, getDepartureArrivalHeaders(true)); + break; + default: + break; + } + startActivity(Intent.createChooser(itn, "Share via")); + return true; + } + }); + + popup.show(); + } + }); + btnAlarmDirections.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + + // create popup menu + View menuItemView = getView().findViewById(R.id.btnAlarmDirections); + PopupMenu popup = new PopupMenu(getActivity(),menuItemView); + popup.getMenuInflater().inflate(R.menu.alarm_menu, popup.getMenu()); + menuItemView.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(popup)); + + //registering popup with OnMenuItemClickListener + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + public boolean onMenuItemClick(MenuItem item) { + + switch (item.getItemId()) { + case R.id.btnAlarmDirectionsAlarm: + setAlarmItinerary(); + break; + case R.id.btnAlarmDirectionsNotifications: + setNotificationsItinerary(); + break; + case R.id.btnAlarmDirectionsCalendar: + setCalendarItinerary(); + break; + default: + break; + } + return true; + } + }); + + popup.show(); + } + }); fromHeader = (TextView) header.findViewById(R.id.fromHeader); toHeader = (TextView) header.findViewById(R.id.toHeader); departureTimeHeader = (TextView) header.findViewById(R.id.departureTimeHeader); arrivalTimeHeader = (TextView) header.findViewById(R.id.arrivalTimeHeader); + tripList = (Spinner) header.findViewById(R.id.itinerarySelection); if (savedInstanceState != null) { otpBundle = (OTPBundle) savedInstanceState @@ -142,8 +226,6 @@ public void onClick(View arg0) { } final Activity activity = this.getActivity(); - Spinner itinerarySelectionSpinner = (Spinner) header.findViewById(R.id.itinerarySelection); - String[] itinerarySummaryList = new String[itineraryList.size()]; boolean isTransitIsTagSet = false; @@ -193,7 +275,7 @@ public void onClick(View arg0) { android.R.layout.simple_spinner_item, itinerarySummaryList); itineraryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - itinerarySelectionSpinner.setAdapter(itineraryAdapter); + tripList.setAdapter(itineraryAdapter); AdapterView.OnItemSelectedListener itinerarySpinnerListener = new AdapterView.OnItemSelectedListener() { @@ -237,8 +319,8 @@ public void onNothingSelected(AdapterView parent) { } }; - itinerarySelectionSpinner.setSelection(currentItineraryIndex); - itinerarySelectionSpinner.setOnItemSelectedListener(itinerarySpinnerListener); + tripList.setSelection(currentItineraryIndex); + tripList.setOnItemSelectedListener(itinerarySpinnerListener); // Populate list with our static array of titles. elv = getExpandableListView(); @@ -299,6 +381,66 @@ private void setDepartureArrivalHeaders() { } } + private String getDepartureArrivalHeaders(Boolean detailed) { + + if (detailed) { + Toast.makeText(getActivity(), "..", Toast.LENGTH_SHORT).show(); + + return "From: " + fromHeader.getText().toString() + + "\n At: " + departureTimeHeader.getText().toString() + + "\n To: " + toHeader.getText().toString() + + "\n At: " + arrivalTimeHeader.getText().toString(); + } else { + return "From: " + fromHeader.getText().toString() + " - " + departureTimeHeader.getText().toString() + + "\n To: " + toHeader.getText().toString() + " - " + arrivalTimeHeader.getText().toString(); + } + } + + private void setAlarmItinerary() { + Intent intent = new Intent(getActivity().getApplicationContext(), AlarmActivity.class); + intent.putExtra(OTPApp.BUNDLE_KEY_RESULT_TRIP_START_LOCATION, fromHeader.getText().toString()); + intent.putExtra(OTPApp.BUNDLE_KEY_RESULT_TRIP_END_LOCATION, toHeader.getText().toString()); + startActivity(intent); + } + + private void setNotificationsItinerary() { + // Notification title: short trip description + String departure = (fromHeader.getText().toString().split(","))[0]; + String arrival = (toHeader.getText().toString().split(","))[0]; + String tripDescription = departure + " → " + arrival; + + // Notification content: time remaining before departure; the text contains hour and minutes separated by a : + // The minutes have a space at the end that must be removed in order to keep the app alive + int tripHour = Integer.parseInt((departureTimeHeader.getText().toString()).split(":")[0]); + int tripMinutes = Integer.parseInt(((departureTimeHeader.getText().toString()).split(":")[1]).substring(0,2)); + + Intent intent = new Intent(getActivity().getApplicationContext(), NotificationService.class); + intent.putExtra(OTPApp.TRIP_DESCRIPTION, tripDescription); + intent.putExtra(OTPApp.BUNDLE_KEY_TRIP_TIME, departureTimeHeader.getText().toString().substring(0,5)); + intent.putExtra(OTPApp.BUNDLE_KEY_TRIP_HOUR, tripHour); + intent.putExtra(OTPApp.BUNDLE_KEY_TRIP_MINUTES, tripMinutes); + getActivity().startService(intent); + } + + private void setCalendarItinerary() { + // Obtaining of the selected itinerary, along with its relevant parameters + int selecItinID = (int)tripList.getSelectedItemId(); + Itinerary itinerary = otpBundle.getItineraryList().get(selecItinID); + long startTime = Long.parseLong(itinerary.startTime); + long endTime = Long.parseLong(itinerary.endTime); + String departure = (fromHeader.getText().toString().split(","))[0]; + String arrival = (toHeader.getText().toString().split(","))[0]; + String tripDescription = departure + " → " + arrival; + + Intent intent = new Intent(Intent.ACTION_INSERT); + intent.setData(CalendarContract.Events.CONTENT_URI); + intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime); + intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime); + intent.putExtra(CalendarContract.Events.TITLE, tripDescription); + intent.putExtra(CalendarContract.Events.EVENT_LOCATION, departure); + startActivity(intent); + } + @Override public void onSaveInstanceState(Bundle bundle) { super.onSaveInstanceState(bundle); diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/MainFragment.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/MainFragment.java index 4f2e55c1..2b7003c8 100644 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/MainFragment.java +++ b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/fragments/MainFragment.java @@ -81,7 +81,6 @@ import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; -import android.widget.AutoCompleteTextView; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.ImageButton; @@ -142,6 +141,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import edu.usf.cutr.opentripplanner.android.AddressFavActivity; import edu.usf.cutr.opentripplanner.android.MyActivity; import edu.usf.cutr.opentripplanner.android.OTPApp; import edu.usf.cutr.opentripplanner.android.R; @@ -156,9 +156,12 @@ import edu.usf.cutr.opentripplanner.android.listeners.ServerSelectorCompleteListener; import edu.usf.cutr.opentripplanner.android.listeners.TripRequestCompleteListener; import edu.usf.cutr.opentripplanner.android.maps.CustomUrlTileProvider; +import edu.usf.cutr.opentripplanner.android.model.AddressModel; import edu.usf.cutr.opentripplanner.android.model.OTPBundle; import edu.usf.cutr.opentripplanner.android.model.OptimizeSpinnerItem; import edu.usf.cutr.opentripplanner.android.model.Server; +import edu.usf.cutr.opentripplanner.android.sqlite.FavouriteAddressDB; +import edu.usf.cutr.opentripplanner.android.sqlite.RecentAddressDb; import edu.usf.cutr.opentripplanner.android.sqlite.ServersDataSource; import edu.usf.cutr.opentripplanner.android.tasks.BikeRentalLoad; import edu.usf.cutr.opentripplanner.android.tasks.MetadataRequest; @@ -167,15 +170,16 @@ import edu.usf.cutr.opentripplanner.android.tasks.ServerChecker; import edu.usf.cutr.opentripplanner.android.tasks.ServerSelector; import edu.usf.cutr.opentripplanner.android.tasks.TripRequest; +import edu.usf.cutr.opentripplanner.android.util.AutoCompleteTextViewFromZero; import edu.usf.cutr.opentripplanner.android.util.BikeRentalStationInfo; import edu.usf.cutr.opentripplanner.android.util.ConversionUtils; import edu.usf.cutr.opentripplanner.android.util.CustomInfoWindowAdapter; import edu.usf.cutr.opentripplanner.android.util.DateTimeDialog; import edu.usf.cutr.opentripplanner.android.util.DirectionsGenerator; +import edu.usf.cutr.opentripplanner.android.util.DrawableOnTouchListener; import edu.usf.cutr.opentripplanner.android.util.LocationUtil; import edu.usf.cutr.opentripplanner.android.util.RangeSeekBar; import edu.usf.cutr.opentripplanner.android.util.RangeSeekBar.OnRangeSeekBarChangeListener; -import edu.usf.cutr.opentripplanner.android.util.RightDrawableOnTouchListener; import edu.usf.cutr.opentripplanner.android.util.TripInfo; import edu.usf.cutr.opentripplanner.android.util.PlacesAutoCompleteAdapter; import edu.usf.cutr.opentripplanner.android.util.CustomAddress; @@ -222,6 +226,10 @@ public class MainFragment extends Fragment implements private ImageButton mBtnHandle; + private ImageButton mBtnStreetView; + + private OnMapClickListener mStreetViewBtnHider; + private DrawerLayout mDrawerLayout; private ViewGroup mNavigationDrawerLeftPane; @@ -272,9 +280,13 @@ public class MainFragment extends Fragment implements private Polyline mBoundariesPolyline; - private AutoCompleteTextView mTbStartLocation; + private AutoCompleteTextViewFromZero mTbStartLocation; + + private AutoCompleteTextViewFromZero mTbEndLocation; + + private boolean mTbStartFavourite; - private AutoCompleteTextView mTbEndLocation; + private boolean mTbEndFavourite; private CustomAddress mStartAddress; @@ -360,6 +372,10 @@ public class MainFragment extends Fragment implements private OTPGeocoding mGeoCodingTask; + private String WidgetStartLocation; + + private String WidgetEndLocation; + @SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void removeOnGlobalLayoutListener(View v, @@ -466,9 +482,21 @@ public void onGlobalLayout() { + "elements can be misplaced"); } - mTbStartLocation = (AutoCompleteTextView) mainView - .findViewById(R.id.tbStartLocation); - mTbEndLocation = (AutoCompleteTextView) mainView.findViewById(R.id.tbEndLocation); + mTbStartLocation = (AutoCompleteTextViewFromZero) mainView.findViewById(R.id.tbStartLocation); + mTbEndLocation = (AutoCompleteTextViewFromZero) mainView.findViewById(R.id.tbEndLocation); + + if(WidgetStartLocation != null){ + mTbStartLocation.setText(WidgetStartLocation); + WidgetStartLocation = null; + } + + if(WidgetEndLocation != null){ + mTbEndLocation.setText(WidgetEndLocation); + WidgetEndLocation = null; + } + + mTbStartFavourite = false; + mTbEndFavourite = false; mBtnSwapOriginDestination = (ImageButton) mainView.findViewById(R.id.btnSwapOriginDestination); mDdlOptimization = (ListView) mainView @@ -509,6 +537,14 @@ public void onGlobalLayout() { mBtnHandle = (ImageButton) mainView.findViewById(R.id.btnHandle); mDrawerLayout = (DrawerLayout) mainView.findViewById(R.id.drawerLayout); + mBtnStreetView = (ImageButton) mainView.findViewById(R.id.btnStreetView); + + mStreetViewBtnHider = new OnMapClickListener() { + @Override + public void onMapClick(LatLng latLng) { + showStreetViewBtn(false, null); + } + }; mTbStartLocation.setImeOptions(EditorInfo.IME_ACTION_NEXT); mTbEndLocation.setImeOptions(EditorInfo.IME_ACTION_DONE); @@ -645,6 +681,7 @@ public void onMapClick(LatLng latlng) { } else { setMarker(false, latlng, true, true); } + showStreetViewBtn(false, null); processRequestTrip(); } }; @@ -659,9 +696,9 @@ public void onFocusChange(View v, boolean hasFocus) { CharSequence tvCharSequence = tv.getText(); if (tvCharSequence != null) { - String text = tvCharSequence.toString(); - - if (!TextUtils.isEmpty(text)) { +// String text = tvCharSequence.toString(); +// +// if (!TextUtils.isEmpty(text)) { if (v.getId() == R.id.tbStartLocation) { if (!mIsStartLocationGeocodingCompleted) { mTbStartLocation.showDropDown(); @@ -671,7 +708,7 @@ public void onFocusChange(View v, boolean hasFocus) { mTbEndLocation.showDropDown(); } } - } +// } } else { Log.w(OTPApp.TAG, "Focus has changed, but was not possible to obtain start/end" @@ -753,10 +790,13 @@ public void onMapLongClick(LatLng latlng) { imm.hideSoftInputFromWindow(mTbStartLocation.getWindowToken(), 0); final LatLng latLngFinal = latlng; - final CharSequence[] items = {mApplicationContext.getResources() - .getString(R.string.point_type_selector_start_marker_option), + final CharSequence[] items = { mApplicationContext.getResources() - .getString(R.string.point_type_selector_end_marker_option)}; + .getString(R.string.point_type_selector_start_marker_option), + mApplicationContext.getResources() + .getString(R.string.point_type_selector_end_marker_option), + mApplicationContext.getResources(). + getString(R.string.point_type_selector_street_view_option)}; AlertDialog.Builder builder = new AlertDialog.Builder( MainFragment.this.getActivity()); @@ -765,10 +805,15 @@ public void onMapLongClick(LatLng latlng) { public void onClick(DialogInterface dialog, int item) { if (item == 0) { setMarker(true, latLngFinal, true, true); - } else { + processRequestTrip(); + } else if (item == 1) { setMarker(false, latLngFinal, true, true); + processRequestTrip(); + } else { + Intent streetView = new Intent(android.content.Intent.ACTION_VIEW, + Uri.parse(String.format(OTPApp.STREET_VIEW_STRING, latLngFinal.latitude, latLngFinal.longitude))); + startActivity(streetView); } - processRequestTrip(); } }); AlertDialog alert = builder.create(); @@ -813,7 +858,6 @@ public void onInfoWindowClick(Marker marker) { mMap.setOnInfoWindowClickListener(onInfoWindowClickListener); - DrawerListener dl = new DrawerListener() { @Override @@ -857,23 +901,23 @@ public void onDrawerClosed(View arg0) { startLocationPlacesAutoCompleteAdapter = new PlacesAutoCompleteAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, mOTPApp.getSelectedServer()); mTbStartLocation.setAdapter(startLocationPlacesAutoCompleteAdapter); - mTbStartLocation.setThreshold(3); + mTbStartLocation.setThreshold(0); endLocationPlacesAutoCompleteAdapter = new PlacesAutoCompleteAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, mOTPApp.getSelectedServer()); - mTbStartLocation.setAdapter(startLocationPlacesAutoCompleteAdapter); mTbEndLocation.setAdapter(endLocationPlacesAutoCompleteAdapter); - mTbEndLocation .setThreshold(3); + mTbEndLocation .setThreshold(0); - OnTouchListener otlStart = new RightDrawableOnTouchListener(mTbStartLocation) { + OnTouchListener otlStart = new DrawableOnTouchListener(mTbStartLocation) { @Override - public boolean onDrawableTouch(final MotionEvent event) { + public boolean onRightDrawableTouch(final MotionEvent event) { final CharSequence[] items = { getResources().getString(R.string.text_box_dialog_location_type_current_location), getResources().getString(R.string.text_box_dialog_location_type_contact), - getResources().getString(R.string.text_box_dialog_location_type_map_point)}; + getResources().getString(R.string.text_box_dialog_location_type_map_point), + getResources().getString(R.string.text_box_dialog_location_type_favourite)}; AlertDialog.Builder builder = new AlertDialog.Builder( MainFragment.this.getActivity()); @@ -917,7 +961,8 @@ public void onClick(DialogInterface dialog, int item) { .startActivityForResult(intent, OTPApp.CHOOSE_CONTACT_REQUEST_CODE); - } else { // Point on Map + } else if (items[item] + .equals(getResources().getString(R.string.text_box_dialog_location_type_map_point))) { if (mStartMarker != null) { updateMarkerPosition(mStartMarker.getPosition(), true); } else { @@ -926,6 +971,15 @@ public void onClick(DialogInterface dialog, int item) { getResources().getString(R.string.text_box_need_to_place_marker)); mTbStartLocation.requestFocus(); } + } else { //Favourite + Intent intent = new Intent(MainFragment.this.getActivity(), AddressFavActivity.class); + + ((MyActivity) MainFragment.this.getActivity()) + .setButtonStartLocation(true); + + MainFragment.this.getActivity() + .startActivityForResult(intent, + OTPApp.CHOOSE_ADDRESS_REQUEST_CODE); } } }); @@ -934,18 +988,60 @@ public void onClick(DialogInterface dialog, int item) { return true; } + @Override + public boolean onLeftDrawableTouch(MotionEvent event) { + if(!mTbStartFavourite){ + String text = mTbStartLocation.getText().toString(); + boolean temp = mIsStartLocationChangedByUser; + + if(text.equals("")){ + Toast.makeText(MainFragment.this.mApplicationContext, + mApplicationContext.getResources() + .getString(R.string.toast_address_location_empty), + Toast.LENGTH_LONG).show(); + return false; + } + + mTbStartLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_on, 0, android.R.drawable.ic_input_get, 0); + mTbStartFavourite = true; + + AddressModel address; + if(temp == false){ + address = new AddressModel(mStartAddress.toString(), mStartAddress.getLatitude(), mStartAddress.getLongitude(), mStartAddress.hasLatitude(), mStartAddress.hasLongitude()); + }else{ + address = new AddressModel(text); + } + + if(FavouriteAddressDB.getInstance(MainFragment.this.getActivity()).addAddress(address)){ + Toast.makeText(MainFragment.this.mApplicationContext, + mApplicationContext.getResources() + .getString(R.string.toast_address_location_added_favourites), + Toast.LENGTH_LONG).show(); + }else{ + Toast.makeText(MainFragment.this.mApplicationContext, + mApplicationContext.getResources() + .getString(R.string.toast_address_location_already_stored), + Toast.LENGTH_LONG).show(); + } + return true; + } + return false; + } + }; mTbStartLocation.setOnTouchListener(otlStart); - OnTouchListener otlEnd = new RightDrawableOnTouchListener(mTbEndLocation) { + OnTouchListener otlEnd = new DrawableOnTouchListener(mTbEndLocation) { @Override - public boolean onDrawableTouch(final MotionEvent event) { + public boolean onRightDrawableTouch(final MotionEvent event) { final CharSequence[] items = { getResources().getString(R.string.text_box_dialog_location_type_current_location), getResources().getString(R.string.text_box_dialog_location_type_contact), - getResources().getString(R.string.text_box_dialog_location_type_map_point)}; + getResources().getString(R.string.text_box_dialog_location_type_map_point), + getResources().getString(R.string.text_box_dialog_location_type_favourite)}; AlertDialog.Builder builder = new AlertDialog.Builder( MainFragment.this.getActivity()); @@ -991,7 +1087,8 @@ public void onClick(DialogInterface dialog, int item) { .startActivityForResult(intent, OTPApp.CHOOSE_CONTACT_REQUEST_CODE); - } else { // Point on Map + } else if (items[item] + .equals(getResources().getString(R.string.text_box_dialog_location_type_map_point))) { // Point on Map if (mEndMarker != null) { updateMarkerPosition(mEndMarker.getPosition(), false); } else { @@ -1000,6 +1097,15 @@ public void onClick(DialogInterface dialog, int item) { getResources().getString(R.string.text_box_need_to_place_marker)); mTbEndLocation.requestFocus(); } + } else { //Favourite + Intent intent = new Intent(MainFragment.this.getActivity(), AddressFavActivity.class); + + ((MyActivity) MainFragment.this.getActivity()) + .setButtonStartLocation(false); + + MainFragment.this.getActivity() + .startActivityForResult(intent, + OTPApp.CHOOSE_ADDRESS_REQUEST_CODE); } } }); @@ -1008,6 +1114,47 @@ public void onClick(DialogInterface dialog, int item) { return true; } + @Override + public boolean onLeftDrawableTouch(MotionEvent event) { + if(!mTbEndFavourite){ + String text = mTbEndLocation.getText().toString(); + boolean temp = mIsEndLocationChangedByUser; + + if(text.equals("")){ + Toast.makeText(MainFragment.this.mApplicationContext, + mApplicationContext.getResources() + .getString(R.string.toast_address_location_empty), + Toast.LENGTH_LONG).show(); + return false; + } + + mTbEndLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_on, 0, android.R.drawable.ic_input_get, 0); + mTbEndFavourite = true; + + AddressModel address; + if(temp == false){ + address = new AddressModel(mEndAddress.toString(), mEndAddress.getLatitude(), mEndAddress.getLongitude(), mEndAddress.hasLatitude(), mEndAddress.hasLongitude()); + }else{ + address = new AddressModel(text); + } + if(FavouriteAddressDB.getInstance(MainFragment.this.getActivity()).addAddress(address)){ + + Toast.makeText(MainFragment.this.mApplicationContext, + mApplicationContext.getResources() + .getString(R.string.toast_address_location_added_favourites), + Toast.LENGTH_LONG).show(); + }else{ + Toast.makeText(MainFragment.this.mApplicationContext, + mApplicationContext.getResources() + .getString(R.string.toast_address_location_already_stored), + Toast.LENGTH_LONG).show(); + } + return true; + } + return false; + } + }; mTbEndLocation.setOnTouchListener(otlEnd); @@ -1047,6 +1194,11 @@ public void afterTextChanged(Editable s) { mIsStartLocationChangedByUser = true; } } + if(mTbStartFavourite){ + mTbStartLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_off, 0, android.R.drawable.ic_input_get, 0); + mTbStartFavourite = false; + } } }; @@ -1073,6 +1225,11 @@ public void afterTextChanged(Editable s) { mIsEndLocationChangedByUser = true; } } + if(mTbEndFavourite){ + mTbEndLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_off, 0, android.R.drawable.ic_input_get, 0); + mTbEndFavourite = false; + } } }; @@ -1875,6 +2032,10 @@ private void requestTrip() { imm.hideSoftInputFromWindow(mTbEndLocation.getWindowToken(), 0); imm.hideSoftInputFromWindow(mTbStartLocation.getWindowToken(), 0); + //add start and end location to recent database + RecentAddressDb.getInstance(MainFragment.this.getActivity()).addNewCustom(mStartAddress); + RecentAddressDb.getInstance(MainFragment.this.getActivity()).addNewCustom(mEndAddress); + mTripDate = null; } @@ -2054,12 +2215,12 @@ private void removeFocus(boolean isStartTextbox) { if (isStartTextbox) { mTbStartLocation.clearFocus(); if (!mTbEndLocation.hasFocus()){ - mMap.setOnMapClickListener(null); + mMap.setOnMapClickListener(mStreetViewBtnHider); } } else { mTbEndLocation.clearFocus(); if (!mTbStartLocation.hasFocus()){ - mMap.setOnMapClickListener(null); + mMap.setOnMapClickListener(mStreetViewBtnHider); } } } @@ -2599,6 +2760,19 @@ public void onResume() { super.onResume(); listenForBikeUpdates(mIsAlarmBikeRentalUpdateActive); + if(mTbEndLocation != null){ + if(WidgetEndLocation != null){ + mTbEndLocation.setText(WidgetEndLocation); + WidgetEndLocation = null; + } + } + + if(mTbStartLocation != null){ + if(WidgetStartLocation != null){ + mTbStartLocation.setText(WidgetStartLocation); + WidgetStartLocation = null; + } + } Log.d(OTPApp.TAG, "MainFragment onResume"); } @@ -2976,6 +3150,51 @@ private void restartTextBoxLocation(boolean isStartTextBox) { } } + /** + * Turns on start/end star when text taken from favourite database. + * + * @param isStartTextBox if true start box will be used + */ + public void setStar(boolean isStartTextBox) { + if (isStartTextBox) { + mTbStartLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_on, 0, android.R.drawable.ic_input_get, 0); + mTbStartFavourite = true; + + } else { + mTbEndLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_on, 0, android.R.drawable.ic_input_get, 0); + mTbEndFavourite = true; + } + } + + /** + * Refreshes start/end star when user gets back from favourite address + * + * @param isStartTextBox if true start box will be used + */ + public void refreshStar(boolean isStartTextBox) { + if (isStartTextBox) { + if (mTbStartFavourite){ + if(!FavouriteAddressDB.getInstance(MainFragment.this.getActivity()).isAddressStored(new AddressModel(mStartAddress.toString()))){ + mTbStartLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_off, 0, android.R.drawable.ic_input_get, 0); + mTbStartFavourite = false; + } + + } + } else { + if (mTbEndFavourite){ + if(!FavouriteAddressDB.getInstance(MainFragment.this.getActivity()).isAddressStored(new AddressModel(mEndAddress.toString()))){ + mTbEndLocation.setCompoundDrawablesWithIntrinsicBounds( + android.R.drawable.btn_star_big_off, 0, android.R.drawable.ic_input_get, 0); + mTbEndFavourite = false; + } + + } + } + } + /** * Returns address in string format. *

@@ -3075,6 +3294,7 @@ public void showRouteOnMap(List itinerary, int animateCamera) { } } mCustomInfoWindowAdapter.setMarkers(mModeMarkers); + mCustomInfoWindowAdapter.setMainFragment(this); mMap.setInfoWindowAdapter(mCustomInfoWindowAdapter); if (animateCamera == 1){ if (firstTransitMarker != null){ @@ -3091,6 +3311,22 @@ public void showRouteOnMap(List itinerary, int animateCamera) { } } + public void showStreetViewBtn(boolean show, final LatLng latLng){ + if(show){ + mBtnStreetView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + Intent streetView = new Intent(android.content.Intent.ACTION_VIEW, + Uri.parse(String.format(OTPApp.STREET_VIEW_STRING, latLng.latitude, latLng.longitude))); + startActivity(streetView); + } + }); + mBtnStreetView.setVisibility(View.VISIBLE); + }else{ + mBtnStreetView.setVisibility(View.INVISIBLE); + } + } + private MarkerOptions generateModeMarkerOptions(Leg leg, LatLng location, int stepIndex){ MarkerOptions modeMarkerOption = new MarkerOptions().position(location); Drawable drawable = getResources().getDrawable(getPathIcon(leg.mode)); @@ -4361,4 +4597,12 @@ public GraphMetadata getmCustomServerMetadata() { public void setmCustomServerMetadata(GraphMetadata mCustomServerMetadata) { this.mCustomServerMetadata = mCustomServerMetadata; } + + public void setWidgetLocation(String location, boolean isStartLocation){ + if(isStartLocation){ + WidgetStartLocation = location; + }else{ + WidgetEndLocation = location; + } + } } \ No newline at end of file diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomAddress.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomAddress.java index d8824ce2..697a89e5 100644 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomAddress.java +++ b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomAddress.java @@ -67,7 +67,7 @@ public String toString(){ } if (TextUtils.isEmpty(sb.toString())){ int maxLines = (OTPApp.ADDRESS_MAX_LINES_TO_SHOW > getMaxAddressLineIndex()) - ? getMaxAddressLineIndex() : OTPApp.ADDRESS_MAX_LINES_TO_SHOW; + ? getMaxAddressLineIndex() + 1 : OTPApp.ADDRESS_MAX_LINES_TO_SHOW; sb.append(getAddressLine(0)); for (int i = 1; i < maxLines; i++) { if (getAddressLine(i) != null) { @@ -80,7 +80,7 @@ public String toString(){ public String getStringAddress(boolean multiline) { int maxLines = (OTPApp.ADDRESS_MAX_LINES_TO_SHOW > getMaxAddressLineIndex()) - ? getMaxAddressLineIndex() : OTPApp.ADDRESS_MAX_LINES_TO_SHOW; + ? getMaxAddressLineIndex() + 1 : OTPApp.ADDRESS_MAX_LINES_TO_SHOW; if (maxLines >= 0) { diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomInfoWindowAdapter.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomInfoWindowAdapter.java index d78669af..c83427de 100644 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomInfoWindowAdapter.java +++ b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/CustomInfoWindowAdapter.java @@ -28,6 +28,7 @@ import java.util.Map; import edu.usf.cutr.opentripplanner.android.R; +import edu.usf.cutr.opentripplanner.android.fragments.MainFragment; public class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter{ @@ -37,6 +38,8 @@ public class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter{ private Context context; + private MainFragment mainFragment; + public CustomInfoWindowAdapter(LayoutInflater layoutInflater, Context context){ this.layoutInflater = layoutInflater; this.context = context; @@ -92,6 +95,7 @@ else if (delayInSeconds > 0) { liveUpdatesText.setText(delayFullText); } } + mainFragment.showStreetViewBtn(true, marker.getPosition()); return view; } @@ -99,4 +103,8 @@ else if (delayInSeconds > 0) { public void setMarkers(Map markers) { this.markers = markers; } + + public void setMainFragment(MainFragment mainFragment) { + this.mainFragment = mainFragment; + } } diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/PlacesAutoCompleteAdapter.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/PlacesAutoCompleteAdapter.java index b4a7a629..aca0b516 100644 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/PlacesAutoCompleteAdapter.java +++ b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/PlacesAutoCompleteAdapter.java @@ -6,8 +6,12 @@ import android.widget.Filterable; import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import edu.usf.cutr.opentripplanner.android.model.AddressModel; import edu.usf.cutr.opentripplanner.android.model.Server; +import edu.usf.cutr.opentripplanner.android.sqlite.RecentAddressDb; import edu.usf.cutr.opentripplanner.android.util.CustomAddress; public class PlacesAutoCompleteAdapter extends ArrayAdapter implements Filterable { @@ -44,16 +48,27 @@ public Filter getFilter() { @Override protected Filter.FilterResults performFiltering(CharSequence constraint) { FilterResults filterResults = new FilterResults(); - if (constraint != null) { + if (constraint != null && constraint.length() > 0) { // Retrieve the autocomplete results. resultList = LocationUtil.processGeocoding(context, selectedServer, constraint.toString()); - if (resultList != null){ - // Assign the data to the FilterResults - filterResults.values = resultList; - filterResults.count = resultList.size(); + }else if (constraint != null && constraint.length() == 0){ + //Retrieve recently used addresses + List addreses = RecentAddressDb.getInstance(context).getAllAddresses(); + if(addreses != null){ + resultList.clear(); + Locale locale = context.getResources().getConfiguration().locale; + for(AddressModel a : addreses){ + resultList.add(a.getAsCustomAddress(locale)); + } } } + if (resultList != null){ + // Assign the data to the FilterResults + filterResults.values = resultList; + filterResults.count = resultList.size(); + } + return filterResults; } diff --git a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/RightDrawableOnTouchListener.java b/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/RightDrawableOnTouchListener.java deleted file mode 100644 index 2c25b150..00000000 --- a/opentripplanner-android/src/main/java/edu/usf/cutr/opentripplanner/android/util/RightDrawableOnTouchListener.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2013 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 - * limitations under the License. - */ - -package edu.usf.cutr.opentripplanner.android.util; - -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.view.MotionEvent; -import android.view.View; -import android.view.View.OnTouchListener; -import android.widget.TextView; - -public abstract class RightDrawableOnTouchListener implements OnTouchListener { - - Drawable drawable; - - private int fuzz = 10; - - /** - * @param view - */ - public RightDrawableOnTouchListener(TextView view) { - super(); - final Drawable[] drawables = view.getCompoundDrawables(); - if (drawables != null && drawables.length == 4) { - this.drawable = drawables[2]; - } - } - - /* - * (non-Javadoc) - * - * @see android.view.View.OnTouchListener#onTouch(android.view.View, android.view.MotionEvent) - */ - @Override - public boolean onTouch(final View v, final MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN && drawable != null) { - final int x = (int) event.getX(); - final int y = (int) event.getY(); - final Rect bounds = drawable.getBounds(); - if (x >= (v.getRight() - bounds.width() - fuzz) && x <= ( - v.getRight() - v.getPaddingRight() + fuzz) - && y >= (v.getPaddingTop() - fuzz) - && y <= (v.getHeight() - v.getPaddingBottom()) + fuzz) { - return onDrawableTouch(event); - } - } - return false; - } - - public abstract boolean onDrawableTouch(final MotionEvent event); - -} \ No newline at end of file diff --git a/opentripplanner-android/src/main/res/drawable-hdpi/ic_launcher.png b/opentripplanner-android/src/main/res/drawable-hdpi/ic_launcher.png index a293c71f..0296cb5c 100644 Binary files a/opentripplanner-android/src/main/res/drawable-hdpi/ic_launcher.png and b/opentripplanner-android/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/opentripplanner-android/src/main/res/drawable-mdpi/ic_launcher.png b/opentripplanner-android/src/main/res/drawable-mdpi/ic_launcher.png index 6b520ba6..6b14a25d 100644 Binary files a/opentripplanner-android/src/main/res/drawable-mdpi/ic_launcher.png and b/opentripplanner-android/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/opentripplanner-android/src/main/res/drawable-xhdpi/ic_launcher.png b/opentripplanner-android/src/main/res/drawable-xhdpi/ic_launcher.png index 9c99e49f..deb5c0cf 100644 Binary files a/opentripplanner-android/src/main/res/drawable-xhdpi/ic_launcher.png and b/opentripplanner-android/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/opentripplanner-android/src/main/res/drawable-xxhdpi/ic_launcher.png b/opentripplanner-android/src/main/res/drawable-xxhdpi/ic_launcher.png index 405aadc7..c9333ecb 100644 Binary files a/opentripplanner-android/src/main/res/drawable-xxhdpi/ic_launcher.png and b/opentripplanner-android/src/main/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/opentripplanner-android/src/main/res/drawable-xxxhdpi/ic_launcher.png b/opentripplanner-android/src/main/res/drawable-xxxhdpi/ic_launcher.png index 51556cac..d39723c4 100644 Binary files a/opentripplanner-android/src/main/res/drawable-xxxhdpi/ic_launcher.png and b/opentripplanner-android/src/main/res/drawable-xxxhdpi/ic_launcher.png differ diff --git a/opentripplanner-android/src/main/res/layout-land-ldpi-v14/main.xml b/opentripplanner-android/src/main/res/layout-land-ldpi-v14/main.xml index 41241b4d..864ad6e3 100644 --- a/opentripplanner-android/src/main/res/layout-land-ldpi-v14/main.xml +++ b/opentripplanner-android/src/main/res/layout-land-ldpi-v14/main.xml @@ -57,7 +57,7 @@ android:background="@drawable/button_layout"> - - + - - + + + - - + - - + + + - - + - - + + + - - + - - + + + - - + - - + + + - - + - - + + + - - + - - + + + + + + + + - - + - - + + + Reiseplan + + Diese Reiseroute wählen + Benachrichtung erhalten + In den Kalender eintragen + Einen Alarm stellen + + Name des Alarms + M + D + M + D + F + S + S + Von Nach @@ -456,7 +471,7 @@ - + OpenTripPlanner für Android diff --git a/opentripplanner-android/src/main/res/values-es/strings.xml b/opentripplanner-android/src/main/res/values-es/strings.xml index 545b1b06..bd386d9d 100644 --- a/opentripplanner-android/src/main/res/values-es/strings.xml +++ b/opentripplanner-android/src/main/res/values-es/strings.xml @@ -348,6 +348,19 @@ Indicaciones + + Elegir este itinerario + Recibir notificaciones + Programar una alarma + + L + M + M + J + V + S + D + De A @@ -457,7 +470,7 @@ - + OpenTripPlanner para Android diff --git a/opentripplanner-android/src/main/res/values-fr/strings.xml b/opentripplanner-android/src/main/res/values-fr/strings.xml index 78a10dfb..5f21325b 100644 --- a/opentripplanner-android/src/main/res/values-fr/strings.xml +++ b/opentripplanner-android/src/main/res/values-fr/strings.xml @@ -348,6 +348,26 @@ Feuille de route + + Choisir cet itinéraire + Recevoir des notifications + Créer un événement dans l\'agenda + Définir une alarme + + Intitulé de l\'alarme + Répéter + L + M + M + J + V + S + D + + minute(s) avant le départ ( + Départ immédiat ! + Heure de départ dépassée. + De À diff --git a/opentripplanner-android/src/main/res/values-gl/strings.xml b/opentripplanner-android/src/main/res/values-gl/strings.xml index 83195b02..95ccad95 100644 --- a/opentripplanner-android/src/main/res/values-gl/strings.xml +++ b/opentripplanner-android/src/main/res/values-gl/strings.xml @@ -348,6 +348,20 @@ Indicacións + + + Escoller este itinerario + Recibir notificacións + Axustar unha alarma + + L + M + M + X + V + S + D + De A @@ -457,7 +471,7 @@ - + OpenTripPlanner para Android diff --git a/opentripplanner-android/src/main/res/values-it/strings.xml b/opentripplanner-android/src/main/res/values-it/strings.xml index c95f5588..1c23de5a 100644 --- a/opentripplanner-android/src/main/res/values-it/strings.xml +++ b/opentripplanner-android/src/main/res/values-it/strings.xml @@ -348,6 +348,19 @@ Direzione + + Scegliere questo itinerario + Ricevere le notifiche + Impostare una sveglia + + L + M + M + G + V + S + D + Da A @@ -457,7 +470,7 @@ - + diff --git a/opentripplanner-android/src/main/res/values-pt/strings.xml b/opentripplanner-android/src/main/res/values-pt/strings.xml index 15d74aa4..6e340efb 100644 --- a/opentripplanner-android/src/main/res/values-pt/strings.xml +++ b/opentripplanner-android/src/main/res/values-pt/strings.xml @@ -347,6 +347,19 @@ Direcções + + Escolher este itinerário + Receber notificações + Definir um alarme + + S + T + Q + Q + S + S + D + De Até @@ -456,7 +469,7 @@ - + OpenTripPlanner para Android diff --git a/opentripplanner-android/src/main/res/values-ro/strings.xml b/opentripplanner-android/src/main/res/values-ro/strings.xml index 6ecddc51..6706bbe7 100644 --- a/opentripplanner-android/src/main/res/values-ro/strings.xml +++ b/opentripplanner-android/src/main/res/values-ro/strings.xml @@ -348,6 +348,19 @@ Indicații + + Alege acest itinerar + Primeşte notificări + Setează o alarmă + + L + M + M + J + V + S + D + De la Până la @@ -457,7 +470,7 @@ - + diff --git a/opentripplanner-android/src/main/res/values/colors.xml b/opentripplanner-android/src/main/res/values/colors.xml index d48756e4..79a2e94b 100644 --- a/opentripplanner-android/src/main/res/values/colors.xml +++ b/opentripplanner-android/src/main/res/values/colors.xml @@ -26,4 +26,5 @@ #50FF0000 #50FFFFFF #50FFFF00 + #00000000 \ No newline at end of file diff --git a/opentripplanner-android/src/main/res/values/donottranslate.xml b/opentripplanner-android/src/main/res/values/donottranslate.xml index 3b6e3d21..d85b4cb8 100644 --- a/opentripplanner-android/src/main/res/values/donottranslate.xml +++ b/opentripplanner-android/src/main/res/values/donottranslate.xml @@ -15,8 +15,8 @@ the License. --> - OpenTripPlanner - + HSL OpenTripPlanner + "http://api.tiles.mapbox.com/v4/opentripplannerhigh.jcah6hla/{z}/{x}/{y}@2x.png256?access_token=pk.eyJ1Ijoib3BlbnRyaXBwbGFubmVyaGlnaCIsImEiOiIyT2xxdVRjIn0.1n9CkukOWpsIgExzdcWfJg" "http://api.tiles.mapbox.com/v4/opentripplannerlow.jcagk4b3/{z}/{x}/{y}.png256?access_token=pk.eyJ1Ijoib3BlbnRyaXBwbGFubmVybG93IiwiYSI6ImRja1VOUjAifQ.1XBo8j8DGWj2EdIsxXGHdQ" diff --git a/opentripplanner-android/src/main/res/values/strings.xml b/opentripplanner-android/src/main/res/values/strings.xml index a40ea0a3..3bcfe68c 100644 --- a/opentripplanner-android/src/main/res/values/strings.xml +++ b/opentripplanner-android/src/main/res/values/strings.xml @@ -44,6 +44,7 @@ Current location Contact address Point on map + Favourite locations GO! @@ -99,6 +100,8 @@ Found Change in Settings + Location added to favourites. + @@ -128,6 +131,9 @@ Realtime updates not available for this trip, times might be outdated + There is nothing to add. + + Address is already saved. @@ -151,6 +157,7 @@ Start location End location + Street view @@ -197,6 +204,10 @@ Arrive at: Depart at: + + + + Select address @@ -349,6 +360,27 @@ Directions + + Choose this itinerary + Receive notifications + Create a calendar event + Set an alarm + + Name of the alarm + Repetition + M + T + W + T + F + S + S + + minute(s) before departure ( + ) + Departure now! + This trip is now past. + From To @@ -458,7 +490,7 @@ - + OpenTripPlanner for Android diff --git a/opentripplanner-android/src/main/res/values/styles.xml b/opentripplanner-android/src/main/res/values/styles.xml index 3bc1fcc1..fa18a597 100644 --- a/opentripplanner-android/src/main/res/values/styles.xml +++ b/opentripplanner-android/src/main/res/values/styles.xml @@ -2,4 +2,12 @@ + \ No newline at end of file