diff --git a/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/MapActivity.java b/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/MapActivity.java index d39922e..93b3807 100644 --- a/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/MapActivity.java +++ b/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/MapActivity.java @@ -36,6 +36,7 @@ import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; import android.widget.Toast; import org.osmdroid.api.IMapController; @@ -296,6 +297,23 @@ public void onOpen(Object item) { ImageView emptySlotsLogo = (ImageView) getView().findViewById(R.id.bubble_emptyslots_logo); emptySlotsLogo.setVisibility(View.GONE); } + + ImageView regularBikesLogo = (ImageView) getView().findViewById(R.id.bubble_freebikes_logo); + TextView regularBikesValue = (TextView) getView().findViewById(R.id.bubble_description); + ImageView eBikesLogo = (ImageView) getView().findViewById(R.id.bubble_ebikes_logo); + TextView eBikesValue = (TextView) getView().findViewById(R.id.bubble_ebikes_value); + + int bikes = markerStation.getFreeBikes(); + if(markerStation.getEBikes() != null && regularBikesLogo != null + && eBikesLogo != null && regularBikesValue!= null && eBikesValue != null ) { + int ebikes = markerStation.getEBikes(); + regularBikesValue.setText(String.valueOf(bikes-ebikes)); + regularBikesLogo.setImageResource(R.drawable.ic_regular_bike); + eBikesLogo.setVisibility(View.VISIBLE); + eBikesValue.setVisibility(View.VISIBLE); + eBikesValue.setText(String.valueOf(ebikes)); + } + layout.setClickable(true); layout.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/StationActivity.java b/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/StationActivity.java index 1bebd5f..b4765d3 100644 --- a/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/StationActivity.java +++ b/app/src/main/java/be/brunoparmentier/openbikesharing/app/activities/StationActivity.java @@ -177,6 +177,7 @@ public boolean onMarkerClick(Marker marker, MapView mapView) { Boolean isBankingStation = station.isBanking(); Boolean isBonusStation = station.isBonus(); StationStatus stationStatus = station.getStatus(); + Integer stationEBikes = station.getEBikes(); if (isBankingStation != null) { ImageView stationBanking = (ImageView) findViewById(R.id.stationBanking); @@ -214,6 +215,19 @@ public void onClick(View view) { stationName.setPaintFlags(stationName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } + if (stationEBikes != null) { + ImageView eBikesLogo = (ImageView) findViewById(R.id.stationEBikesLogo); + ImageView regularBikesLogo = (ImageView) findViewById(R.id.stationFreeBikesLogo); + TextView stationEBikesValue = (TextView) findViewById(R.id.stationEBikesValue); + int ebikes = station.getEBikes(); + + eBikesLogo.setVisibility(View.VISIBLE); + stationEBikesValue.setVisibility(View.VISIBLE); + stationEBikesValue.setText(String.valueOf(ebikes)); + regularBikesLogo.setImageResource(R.drawable.ic_regular_bike); + stationFreeBikes.setText(String.valueOf(freeBikes - ebikes)); //display regular bikes only + } + mapController.setCenter(stationLocation); } diff --git a/app/src/main/java/be/brunoparmentier/openbikesharing/app/adapters/StationsListAdapter.java b/app/src/main/java/be/brunoparmentier/openbikesharing/app/adapters/StationsListAdapter.java index e5315a8..890517d 100644 --- a/app/src/main/java/be/brunoparmentier/openbikesharing/app/adapters/StationsListAdapter.java +++ b/app/src/main/java/be/brunoparmentier/openbikesharing/app/adapters/StationsListAdapter.java @@ -57,6 +57,9 @@ public View getView(int position, View convertView, ViewGroup parent) { if (station != null) { TextView stationNameTitle = (TextView) v.findViewById(R.id.stationNameTitle); TextView freeBikesValue = (TextView) v.findViewById(R.id.freeBikesValue); + ImageView regularBikesLogo = (ImageView) v.findViewById(R.id.freeBikesLogo); + TextView freeEBikesValue = (TextView) v.findViewById(R.id.freeEBikesValue); + ImageView eBikesLogo = (ImageView) v.findViewById(R.id.freeEBikesLogo); TextView emptySlotsValue = (TextView) v.findViewById(R.id.emptySlotsValue); StationStatus stationStatus = station.getStatus(); @@ -72,7 +75,17 @@ public View getView(int position, View convertView, ViewGroup parent) { if (freeBikesValue != null) { int bikes = station.getFreeBikes(); - freeBikesValue.setText(String.valueOf(bikes)); + if(station.getEBikes() != null && regularBikesLogo != null + && eBikesLogo != null && freeEBikesValue != null ) { + int ebikes = station.getEBikes(); + freeBikesValue.setText(String.valueOf(bikes-ebikes)); + regularBikesLogo.setImageResource(R.drawable.ic_regular_bike); + eBikesLogo.setVisibility(View.VISIBLE); + freeEBikesValue.setVisibility(View.VISIBLE); + freeEBikesValue.setText(String.valueOf(ebikes)); + } else { + freeBikesValue.setText(String.valueOf(bikes)); + } } if (emptySlotsValue != null) { @@ -91,4 +104,4 @@ public View getView(int position, View convertView, ViewGroup parent) { return v; } -} \ No newline at end of file +} diff --git a/app/src/main/java/be/brunoparmentier/openbikesharing/app/widgets/StationsListAppWidgetService.java b/app/src/main/java/be/brunoparmentier/openbikesharing/app/widgets/StationsListAppWidgetService.java index 82c329d..59f4f3c 100644 --- a/app/src/main/java/be/brunoparmentier/openbikesharing/app/widgets/StationsListAppWidgetService.java +++ b/app/src/main/java/be/brunoparmentier/openbikesharing/app/widgets/StationsListAppWidgetService.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.view.View; import android.widget.RemoteViews; import android.widget.RemoteViewsService; @@ -88,9 +89,19 @@ public RemoteViews getViewAt(int position) { // We construct a remote views item based on our widget item xml file, and set the // text based on the position. RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.app_widget_item); - rv.setTextViewText(R.id.widgetStationNameTitle, stations.get(position).getName()); - rv.setTextViewText(R.id.widgetFreeBikesValue, String.valueOf(stations.get(position).getFreeBikes())); - rv.setTextViewText(R.id.widgetEmptySlotsValue, String.valueOf(stations.get(position).getEmptySlots())); + Station mStation = stations.get(position); + rv.setTextViewText(R.id.widgetStationNameTitle, mStation.getName()); + int bikes = mStation.getFreeBikes(); + if(mStation.getEBikes() != null) { + int ebikes = mStation.getEBikes(); + rv.setImageViewResource(R.id.widgetFreeBikesLogo, R.drawable.ic_regular_bike); + rv.setViewVisibility(R.id.widgetEBikesLogo, View.VISIBLE); + rv.setViewVisibility(R.id.widgetEBikesValue, View.VISIBLE); + rv.setTextViewText(R.id.widgetEBikesValue, String.valueOf(ebikes)); + bikes = bikes - ebikes; + } + rv.setTextViewText(R.id.widgetFreeBikesValue, String.valueOf(bikes)); + rv.setTextViewText(R.id.widgetEmptySlotsValue, String.valueOf(mStation.getEmptySlots())); // Next, we set a fill-intent which will be used to fill-in the pending intent template // which is set on the collection view in StationsListAppWidgetProvider. diff --git a/app/src/main/res/drawable-hdpi/ic_electric_bike.png b/app/src/main/res/drawable-hdpi/ic_electric_bike.png new file mode 100644 index 0000000..bbf9cfc Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_electric_bike.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_regular_bike.png b/app/src/main/res/drawable-hdpi/ic_regular_bike.png new file mode 100644 index 0000000..b1bf40b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_regular_bike.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_electric_bike.png b/app/src/main/res/drawable-mdpi/ic_electric_bike.png new file mode 100644 index 0000000..b36a30f Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_electric_bike.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_regular_bike.png b/app/src/main/res/drawable-mdpi/ic_regular_bike.png new file mode 100644 index 0000000..ff4f0b6 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_regular_bike.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_electric_bike.png b/app/src/main/res/drawable-xhdpi/ic_electric_bike.png new file mode 100644 index 0000000..5e12225 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_electric_bike.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_regular_bike.png b/app/src/main/res/drawable-xhdpi/ic_regular_bike.png new file mode 100644 index 0000000..3a0f4a4 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_regular_bike.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_electric_bike.png b/app/src/main/res/drawable-xxhdpi/ic_electric_bike.png new file mode 100644 index 0000000..ba62fcd Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_electric_bike.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_regular_bike.png b/app/src/main/res/drawable-xxhdpi/ic_regular_bike.png new file mode 100644 index 0000000..4bed8c6 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_regular_bike.png differ diff --git a/app/src/main/res/layout/activity_station.xml b/app/src/main/res/layout/activity_station.xml index b8982e4..135d0d1 100644 --- a/app/src/main/res/layout/activity_station.xml +++ b/app/src/main/res/layout/activity_station.xml @@ -101,13 +101,35 @@ android:textAppearance="?android:attr/textAppearanceMedium" /> + + + + @@ -116,7 +138,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="1" - android:layout_row="2" + android:layout_row="3" android:text="5" android:textAppearance="?android:attr/textAppearanceMedium" /> diff --git a/app/src/main/res/layout/app_widget_item.xml b/app/src/main/res/layout/app_widget_item.xml index e3f275c..5e19ef4 100644 --- a/app/src/main/res/layout/app_widget_item.xml +++ b/app/src/main/res/layout/app_widget_item.xml @@ -61,6 +61,25 @@ android:textColor="@android:color/primary_text_light" android:textAppearance="?android:attr/textAppearanceMedium" /> + + + + + android:rowCount="3"> + + + + + + + + Free bikes:\u00A0 + Electric bikes:\u00A0 Empty slots:\u00A0 All stations Favorites