Page MenuHomeGitPull.it

D24.1781778784.diff
No OneTemporary

Authored By
Unknown
Size
34 KB
Referenced Files
None
Subscribers
None

D24.1781778784.diff

diff --git a/AndroidManifest.xml b/AndroidManifest.xml
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -85,6 +85,17 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".ActivityMain"/>
</activity>
+ <activity
+ android:name=".ActivityMap"
+ android:label="@string/title_activity_map"
+ android:parentActivityName=".ActivityMain"
+ android:theme="@style/MapTheme">
+
+ <!-- API < 16: -->
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".ActivityMain"/>
+ </activity>
<provider
android:name=".middleware.AppDataProvider"
diff --git a/build.gradle b/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -81,5 +81,7 @@
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'com.android.volley:volley:1.1.1'
+
+ implementation 'org.osmdroid:osmdroid-android:6.1.3'
}
}
diff --git a/res/drawable/bus_marker.xml b/res/drawable/bus_marker.xml
new file mode 100644
--- /dev/null
+++ b/res/drawable/bus_marker.xml
@@ -0,0 +1,12 @@
+<!-- drawable/bus_marker.xml -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:strokeWidth="1"
+ android:strokeColor="#FFF"
+ android:fillColor="@color/metro_red"
+ android:pathData="M12 2C7.58 2 4 2.5 4 6V16A3 3 0 0 0 5 18.22V20A1 1 0 0 0 6 21H7A1 1 0 0 0 8 20V19H14A8 8 0 0 1 13 15.5A5.55 5.55 0 0 1 15.38 11H6V6H18V10A4.07 4.07 0 0 1 18.5 10A5.34 5.34 0 0 1 20 10.22V6C20 2.5 16.42 2 12 2M7.5 14A1.5 1.5 0 1 1 6 15.5A1.5 1.5 0 0 1 7.5 14M18.5 12A3.54 3.54 0 0 0 15 15.5C15 18.1 18.5 22 18.5 22S22 18.1 22 15.5A3.54 3.54 0 0 0 18.5 12M18.5 16.8A1.2 1.2 0 1 1 18.5 14.4A1.29 1.29 0 0 1 19.7 15.6A1.15 1.15 0 0 1 18.5 16.8Z" />
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_angery_bus.xml b/res/drawable/ic_angery_bus.xml
new file mode 100644
--- /dev/null
+++ b/res/drawable/ic_angery_bus.xml
@@ -0,0 +1,233 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:aapt="http://schemas.android.com/aapt"
+ android:width="210dp"
+ android:height="297dp"
+ android:viewportWidth="210"
+ android:viewportHeight="297">
+ <path
+ android:pathData="m120.107,66.77c1.591,-0.344 16.563,1.083 18.126,-1.04 3.036,-4.127 -2.085,-11.766 4.532,-15.463 2.943,-1.644 9.329,-1.647 9.403,3.077 0.024,1.529 0.383,-3.039 0.72,-4.531 0.73,-3.231 3.718,-6.02 7.044,-6.368 5.837,-0.61 7.487,3.854 6.199,8.437 -0.869,3.091 -9.109,8.74 -6.207,7.366 6.672,-3.159 15.486,0.887 10.063,8.946 -0.578,0.859 -1.473,1.643 -2.433,2.061 -2.62,1.14 -2.804,1.472 -5.826,1.387 -12.07,-0.343 3.764,-1.999 -6.874,5.101 -10.508,7.014 -9.102,-3.738 -17.198,-4.347 -2.157,-0.162 -19.766,0.053 -19.416,-2.701"
+ android:strokeLineJoin="round"
+ android:fillColor="#7c7c7c"
+ android:fillType="evenOdd"
+ android:fillAlpha="0.67447899"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m115.58,75.518c-10.665,-0.118 -20.456,-0.768 -31.185,-0.967 -0.833,-0.015 -14.169,-0.015 -13.531,1.234 1.449,2.84 53.201,5.726 56.19,-0.762 0.48,-1.043 -0.809,0.612 -11.473,0.494z"
+ android:strokeLineJoin="round"
+ android:fillColor="#7c7c7c"
+ android:fillType="evenOdd"
+ android:fillAlpha="0.67447899"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m58.928,58.226l0,0c2.256,-0.825 5.19,1.992 6.554,6.294l0.243,0.766c1.364,4.302 0.641,8.459 -1.614,9.284l0,0c-2.256,0.826 -5.19,-1.992 -6.554,-6.294l-0.243,-0.766c-1.364,-4.302 -0.641,-8.458 1.614,-9.284z"
+ android:strokeLineJoin="round"
+ android:fillColor="#000017"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m60.825,73.382c2.308,2.723 7.673,0.521 7.922,-3.593 0.088,-1.458 -0.47,-3.766 -1.283,-6.004 -1.009,-2.779 -2.409,-5.453 -3.448,-6.263 -1.188,-0.926 -4.543,-1.249 -6.349,1.979 -1.806,3.228 0.558,10.814 3.158,13.882z"
+ android:strokeLineJoin="round"
+ android:fillColor="#000000"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m61.8,57.051l0,0c2.256,-0.825 5.19,1.992 6.554,6.294l0.243,0.766c1.364,4.302 0.641,8.459 -1.614,9.284l0,0c-2.256,0.826 -5.19,-1.992 -6.554,-6.294l-0.243,-0.766c-1.364,-4.302 -0.641,-8.458 1.614,-9.284z"
+ android:strokeLineJoin="round"
+ android:fillColor="#5a5a5a"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M68.816,38.726L124.861,38.726c2.309,0 4.181,1.726 4.181,3.856l0,25.278c0,2.129 -1.872,3.856 -4.181,3.856L68.816,71.716c-2.309,0 -4.181,-1.726 -4.181,-3.856l0,-25.278c0,-2.13 1.872,-3.856 4.181,-3.856z"
+ android:strokeLineJoin="round"
+ android:fillColor="#2d008a"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M69.117,40.476L88.513,40.476c1.772,0 3.208,1.535 3.208,3.429l0,15.684c0,1.894 -1.436,3.429 -3.208,3.429L69.117,63.018c-1.772,0 -3.208,-1.535 -3.208,-3.429L65.91,43.905c0,-1.894 1.436,-3.429 3.208,-3.429z"
+ android:strokeLineJoin="round"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round">
+ <aapt:attr name="android:fillColor">
+ <gradient
+ android:startY="40.422176"
+ android:startX="79.03182"
+ android:endY="63.162605"
+ android:endX="79.030495"
+ android:type="linear">
+ <item android:offset="0.0125" android:color="#FF4A4A4A"/>
+ <item android:offset="1" android:color="#FFB8B8B8"/>
+ </gradient>
+ </aapt:attr>
+ </path>
+ <path
+ android:pathData="m124.932,38.784c2.425,0 4.565,2.126 4.565,5.093l0,22.726c0,2.967 -1.966,5.372 -4.391,5.372l-10.54,0 -5.438,0 -9.259,0"
+ android:strokeLineJoin="round"
+ android:fillColor="#ffe200"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m97.07,40.435l25.889,0c1.667,0 3.018,1.377 3.018,3.075l0,16.478c0,1.698 -1.351,3.075 -3.018,3.075l-25.889,0c-1.667,0 -3.018,-1.377 -3.018,-3.075l0,-16.478c0,-1.698 1.351,-3.075 3.018,-3.075z"
+ android:strokeLineJoin="round"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round">
+ <aapt:attr name="android:fillColor">
+ <gradient
+ android:startY="39.909576"
+ android:startX="109.94232"
+ android:endY="62.99693"
+ android:endX="109.99381"
+ android:type="linear">
+ <item android:offset="0.0125" android:color="#FF4A4A4A"/>
+ <item android:offset="1" android:color="#FFB8B8B8"/>
+ </gradient>
+ </aapt:attr>
+ </path>
+ <path
+ android:pathData="m132.335,55.811l0,0c2.2,0.983 2.668,5.182 1.043,9.378l-0.289,0.747c-1.624,4.196 -4.724,6.801 -6.924,5.818l0,0c-2.2,-0.983 -2.667,-5.182 -1.043,-9.378l0.289,-0.747c1.624,-4.196 4.724,-6.801 6.924,-5.818z"
+ android:strokeLineJoin="round"
+ android:fillColor="#000017"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m124.432,68.529c0.055,3.683 5.436,5.842 8.154,2.933 0.963,-1.031 1.964,-3.159 2.732,-5.416 0.953,-2.802 1.548,-5.802 1.267,-7.148 -0.321,-1.539 -2.639,-4.165 -5.98,-3.026 -3.341,1.138 -6.236,8.51 -6.174,12.658z"
+ android:strokeLineJoin="round"
+ android:fillColor="#000000"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m135.213,56.969l0,0c2.2,0.983 2.667,5.182 1.043,9.378l-0.289,0.747c-1.624,4.196 -4.724,6.801 -6.924,5.818l0,0c-2.2,-0.983 -2.667,-5.182 -1.043,-9.378l0.289,-0.747c1.624,-4.196 4.724,-6.801 6.924,-5.818z"
+ android:strokeLineJoin="round"
+ android:fillColor="#5a5a5a"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m102.533,61.793l0,0c2.234,0.89 2.854,5.066 1.383,9.327l-0.262,0.759c-1.47,4.261 -4.474,6.994 -6.708,6.104l0,0c-2.234,-0.89 -2.854,-5.066 -1.383,-9.327l0.262,-0.759c1.471,-4.261 4.474,-6.994 6.708,-6.104z"
+ android:strokeLineJoin="round"
+ android:fillColor="#000017"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m95.098,74.833c0.189,3.677 5.644,5.609 8.255,2.588 0.925,-1.07 1.848,-3.239 2.534,-5.527 0.851,-2.84 1.336,-5.863 1.006,-7.196 -0.377,-1.524 -2.788,-4.051 -6.086,-2.773 -3.298,1.277 -5.922,8.764 -5.709,12.907z"
+ android:strokeLineJoin="round"
+ android:fillColor="#000000"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m105.45,62.83l0,0c2.234,0.89 2.854,5.066 1.383,9.327l-0.262,0.759c-1.47,4.261 -4.474,6.994 -6.708,6.104l0,0c-2.234,-0.89 -2.853,-5.066 -1.383,-9.327l0.262,-0.759c1.47,-4.261 4.474,-6.994 6.708,-6.104z"
+ android:strokeLineJoin="round"
+ android:fillColor="#5a5a5a"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m62.829,61.578 l5.605,1.623"
+ android:strokeLineJoin="round"
+ android:strokeWidth="12.68000031"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#ff0000"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m87.818,62.515 l2.574,-0.62 0.731,-0.176 2.203,-0.531"
+ android:strokeLineJoin="round"
+ android:strokeWidth="12.68000031"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#ff0000"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m60.293,39.013l0,0c0.591,-0.221 1.265,0.057 1.507,0.622l2.321,5.425c0.241,0.564 -0.042,1.201 -0.632,1.422l0,0c-0.591,0.221 -1.265,-0.057 -1.507,-0.622l-2.321,-5.425c-0.241,-0.564 0.042,-1.201 0.632,-1.422z"
+ android:strokeLineJoin="round"
+ android:fillColor="#09006d"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M128.108,58.054"
+ android:strokeLineJoin="round"
+ android:fillColor="#424242"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m64.78,37.712c0,0 5.195,3.318 -0.876,4.021"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4.96999979"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#ff0000"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m65.279,45.419c0,0 2.216,-6.331 4.738,-0.466"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4.96999979"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#ff0000"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m70.316,37.862c0,0 -4.203,3.339 1.605,3.876"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4.96999979"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#ff0000"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M69.099,38.749L124.881,38.749c2.298,0 4.502,0.776 4.638,6.535 0.167,7.038 0.297,15.971 0.297,15.971 0,1.624 -2.637,2.645 -4.936,2.645L69.099,63.9c-2.298,0 -4.161,-1.316 -4.161,-2.94l0,-19.273c0,-1.623 1.863,-2.94 4.161,-2.94z"
+ android:strokeAlpha="0.682819"
+ android:strokeLineJoin="round"
+ android:fillType="evenOdd"
+ android:fillAlpha="0.682819"
+ android:strokeLineCap="round">
+ <aapt:attr name="android:fillColor">
+ <gradient
+ android:startY="38.82988"
+ android:startX="96.88073"
+ android:endY="59.698933"
+ android:endX="96.17543"
+ android:type="linear">
+ <item android:offset="0" android:color="#FFFF0000"/>
+ <item android:offset="0.59409" android:color="#00FFFFFF"/>
+ </gradient>
+ </aapt:attr>
+ </path>
+ <path
+ android:pathData="m69.492,69.584c0,0 2.922,-14.387 18.992,0.127z"
+ android:strokeLineJoin="round"
+ android:fillColor="#fffeff"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m69.83,68.643 l1.736,-2.209 1.625,2.158 2.04,-2.103 1.5,2.142 1.917,-2.327 1.69,2.075 1.44,-2.057 1.7,2.127 1.189,-1.882"
+ android:strokeLineJoin="round"
+ android:strokeWidth="2.02999997"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#333333"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m149.126,40.567c-1.707,2.738 3.902,3.907 4.941,0.789 0.493,-1.48 -3.188,-3.601 -4.941,-0.789z"
+ android:strokeLineJoin="round"
+ android:fillColor="#7c7c7c"
+ android:fillType="evenOdd"
+ android:fillAlpha="0.67447899"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m147.453,47.285c-0.119,2.157 4.512,1.153 4.214,-1.192 -0.349,-2.746 -4.106,-0.772 -4.214,1.192z"
+ android:strokeLineJoin="round"
+ android:fillColor="#7c7c7c"
+ android:fillType="evenOdd"
+ android:fillAlpha="0.67447899"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m143.884,47.948c0.256,1.234 2.227,0.379 1.655,-0.701 -0.412,-0.779 -1.859,-0.282 -1.655,0.701z"
+ android:strokeLineJoin="round"
+ android:fillColor="#7c7c7c"
+ android:fillType="evenOdd"
+ android:fillAlpha="0.67447899"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="m95.327,38.609l0,0c0.581,0.122 0.957,0.672 0.84,1.23l-1.123,5.362c-0.117,0.558 -0.682,0.911 -1.263,0.79l0,0c-0.581,-0.121 -0.957,-0.672 -0.84,-1.23l1.123,-5.362c0.117,-0.558 0.682,-0.911 1.263,-0.79z"
+ android:strokeLineJoin="round"
+ android:fillColor="#09006d"
+ android:fillType="evenOdd"
+ android:strokeLineCap="round"/>
+</vector>
diff --git a/res/drawable/map.xml b/res/drawable/map.xml
new file mode 100644
--- /dev/null
+++ b/res/drawable/map.xml
@@ -0,0 +1,8 @@
+<!-- drawable/map.xml -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path android:fillColor="#FFF" android:pathData="M15,19L9,16.89V5L15,7.11M20.5,3C20.44,3 20.39,3 20.34,3L15,5.1L9,3L3.36,4.9C3.15,4.97 3,5.15 3,5.38V20.5A0.5,0.5 0 0,0 3.5,21C3.55,21 3.61,21 3.66,20.97L9,18.9L15,21L20.64,19.1C20.85,19 21,18.85 21,18.62V3.5A0.5,0.5 0 0,0 20.5,3Z" />
+</vector>
diff --git a/res/layout/activity_favorites.xml b/res/layout/activity_favorites.xml
--- a/res/layout/activity_favorites.xml
+++ b/res/layout/activity_favorites.xml
@@ -1,8 +1,16 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context="it.reyboz.bustorino.ActivityFavorites" >
+ tools:context="it.reyboz.bustorino.ActivityFavorites">
+
+ <ImageView
+ android:id="@+id/angeryBusImageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:srcCompat="@drawable/ic_angery_bus"
+ android:visibility="invisible" />
<TextView
android:id="@+id/favoriteTipTextView"
diff --git a/res/layout/activity_map.xml b/res/layout/activity_map.xml
new file mode 100644
--- /dev/null
+++ b/res/layout/activity_map.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <org.osmdroid.views.MapView android:id="@+id/map"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" />
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/map_popup.xml b/res/layout/map_popup.xml
new file mode 100644
--- /dev/null
+++ b/res/layout/map_popup.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@color/cardview_light_background">
+
+ <TextView
+ android:id="@+id/bubble_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/blue_500" />
+
+ <TextView
+ android:id="@+id/bubble_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/bubble_subdescription"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <ImageView
+ android:id="@+id/bubble_image"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/menu/main.xml b/res/menu/main.xml
--- a/res/menu/main.xml
+++ b/res/menu/main.xml
@@ -2,7 +2,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="it.reyboz.bustorino.ActivityMain">
-
+ <item
+ android:id="@+id/action_map"
+ android:icon="@drawable/map"
+ android:orderInCategory="1"
+ android:title="map"
+ app:showAsAction="ifRoom" />
<!--suppress AndroidDomInspection --> <!-- Android Studio can't find ic_star even though it's there. -->
<item
android:id="@+id/action_favorites"
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
--- a/res/values-it/strings.xml
+++ b/res/values-it/strings.xml
@@ -29,7 +29,8 @@
<string name="added_in_favorites">Fermata aggiunta ai preferiti</string>
<string name="cant_add_to_favorites">Impossibile aggiungere ai preferiti (memoria piena o database corrotto?)!</string>
<string name="title_activity_favorites">Preferiti</string>
- <string name="tip_add_favorite">Tocca il nome di una fermata per aggiungerla in questa lista</string>
+ <string name="title_activity_map">Mappa</string>
+ <string name="tip_add_favorite">Nessun preferito? Arghh! Schiaccia sulla stella di una fermata per aggiungere a questa lista!</string>
<string name="action_remove_from_favourites">Rimuovi</string>
<string name="action_rename_bus_stop_username">Rinomina</string>
<string name="dialog_rename_bus_stop_username_title">Rinomina fermata</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -35,7 +35,8 @@
<string name="removed_from_favorites">Bus stop removed from your favorites</string>
<string name="action_favorites">Favorites</string>
<string name="title_activity_favorites">Favorites</string>
- <string name="tip_add_favorite">Press on a bus stop name to populate this list</string>
+ <string name="title_activity_map">Map</string>
+ <string name="tip_add_favorite">No favorites? Arghh! Press on a bus stop star to populate this list!</string>
<string name="action_remove_from_favourites">Delete</string>
<string name="action_rename_bus_stop_username">Rename</string>
<string name="dialog_rename_bus_stop_username_title">Rename the bus stop</string>
diff --git a/res/values/theme.xml b/res/values/theme.xml
--- a/res/values/theme.xml
+++ b/res/values/theme.xml
@@ -13,6 +13,12 @@
<item name="colorAccent">@color/blue_700</item>
</style>
+ <style name="MapTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+ <item name="colorPrimary">@color/orange_500</item>
+ <item name="colorPrimaryDark">@color/orange_700</item>
+ <item name="colorAccent">@color/teal_500</item>
+ </style>
+
<style name="preferenceTheme" parent="PreferenceThemeOverlay"></style>
</resources>
\ No newline at end of file
diff --git a/src/it/reyboz/bustorino/ActivityFavorites.java b/src/it/reyboz/bustorino/ActivityFavorites.java
--- a/src/it/reyboz/bustorino/ActivityFavorites.java
+++ b/src/it/reyboz/bustorino/ActivityFavorites.java
@@ -17,22 +17,17 @@
*/
package it.reyboz.bustorino;
-import android.database.Cursor;
-import android.support.v4.app.LoaderManager;
-import android.support.v4.content.Loader;
-import android.widget.*;
-import it.reyboz.bustorino.backend.Stop;
-import it.reyboz.bustorino.adapters.StopAdapter;
-import it.reyboz.bustorino.middleware.AsyncStopFavoriteAction;
-import it.reyboz.bustorino.middleware.StopsDB;
-import it.reyboz.bustorino.middleware.UserDB;
-
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
-import android.net.Uri;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.v4.app.LoaderManager;
import android.support.v4.app.NavUtils;
+import android.support.v4.content.Loader;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.ContextMenu;
@@ -41,13 +36,22 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
-import android.content.Intent;
-import android.database.sqlite.SQLiteDatabase;
-import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
import java.util.List;
+import it.reyboz.bustorino.adapters.StopAdapter;
+import it.reyboz.bustorino.backend.Stop;
+import it.reyboz.bustorino.middleware.AsyncStopFavoriteAction;
+import it.reyboz.bustorino.middleware.StopsDB;
+import it.reyboz.bustorino.middleware.UserDB;
+
public class ActivityFavorites extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {
private ListView favoriteListView;
private SQLiteDatabase userDB;
@@ -130,13 +134,17 @@
Toast.makeText(getApplicationContext(),R.string.cannot_show_on_map_no_position,Toast.LENGTH_SHORT).show();
return true;
}
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(theGeoUrl));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- if(intent.resolveActivity(getPackageManager())!=null)
- startActivity(intent);
- else {
- Toast.makeText(getApplicationContext(),R.string.cannot_show_on_map_no_activity,Toast.LENGTH_SHORT).show();
- }
+
+ // start ActivityMap with these extras in intent
+ Intent intent = new Intent(ActivityFavorites.this, ActivityMap.class);
+ Bundle b = new Bundle();
+ b.putDouble("lat", busStop.getLatitude());
+ b.putDouble("lon", busStop.getLongitude());
+ b.putString("name", busStop.getStopDefaultName());
+ b.putString("ID", busStop.ID);
+ intent.putExtras(b);
+
+ startActivity(intent);
return true;
default:
return super.onContextItemSelected(item);
@@ -256,6 +264,8 @@
TextView favoriteTipTextView = (TextView) findViewById(R.id.favoriteTipTextView);
assert favoriteTipTextView != null;
favoriteTipTextView.setVisibility(View.VISIBLE);
+ ImageView angeryBusImageView = (ImageView) findViewById(R.id.angeryBusImageView);
+ angeryBusImageView.setVisibility(View.VISIBLE);
}
/* There's a nice method called notifyDataSetChanged() to avoid building the ListView
diff --git a/src/it/reyboz/bustorino/ActivityMain.java b/src/it/reyboz/bustorino/ActivityMain.java
--- a/src/it/reyboz/bustorino/ActivityMain.java
+++ b/src/it/reyboz/bustorino/ActivityMain.java
@@ -385,6 +385,9 @@
case R.id.action_favorites:
startActivity(new Intent(ActivityMain.this, ActivityFavorites.class));
return true;
+ case R.id.action_map:
+ startActivity(new Intent(ActivityMain.this, ActivityMap.class));
+ return true;
case R.id.action_about:
startActivity(new Intent(ActivityMain.this, ActivityAbout.class));
return true;
diff --git a/src/it/reyboz/bustorino/ActivityMap.java b/src/it/reyboz/bustorino/ActivityMap.java
new file mode 100644
--- /dev/null
+++ b/src/it/reyboz/bustorino/ActivityMap.java
@@ -0,0 +1,212 @@
+package it.reyboz.bustorino;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.RequiresApi;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.preference.PreferenceManager;
+
+import org.osmdroid.api.IMapController;
+import org.osmdroid.config.Configuration;
+import org.osmdroid.events.DelayedMapListener;
+import org.osmdroid.events.MapListener;
+import org.osmdroid.events.ScrollEvent;
+import org.osmdroid.events.ZoomEvent;
+import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
+import org.osmdroid.util.BoundingBox;
+import org.osmdroid.util.GeoPoint;
+import org.osmdroid.views.MapView;
+import org.osmdroid.views.overlay.Marker;
+import org.osmdroid.views.overlay.infowindow.InfoWindow;
+
+import it.reyboz.bustorino.backend.Stop;
+import it.reyboz.bustorino.map.CustomInfoWindow;
+import it.reyboz.bustorino.middleware.StopsDB;
+
+public class ActivityMap extends AppCompatActivity {
+
+ private static MapView map = null;
+ public Context ctx;
+
+ @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
+ @Override public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ //handle permissions first, before map is created. not depicted here
+
+ //load/initialize the osmdroid configuration, this can be done
+ ctx = getApplicationContext();
+ Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
+ //setting this before the layout is inflated is a good idea
+ //it 'should' ensure that the map has a writable location for the map cache, even without permissions
+ //if no tiles are displayed, you can try overriding the cache path using Configuration.getInstance().setCachePath
+ //see also StorageUtils
+ //note, the load method also sets the HTTP User Agent to your application's package name, abusing osm's tile servers will get you banned based on this string
+
+ //inflate and create the map
+ setContentView(R.layout.activity_map);
+
+ map = (MapView) findViewById(R.id.map);
+ map.setTileSource(TileSourceFactory.MAPNIK);
+
+ // add ability to zoom with 2 fingers
+ map.setMultiTouchControls(true);
+
+ // take the parameters if it's called from other Activities
+ Bundle b = getIntent().getExtras();
+ GeoPoint marker = null;
+ String name = null;
+ String ID = null;
+ if(b != null) {
+ double lat = b.getDouble("lat");
+ double lon = b.getDouble("lon");
+ marker = new GeoPoint(lat, lon);
+ name = b.getString("name");
+ ID = b.getString("ID");
+ }
+ startMap(marker, name, ID);
+
+ // on drag and zoom reload the markers
+ map.addMapListener(new DelayedMapListener(new MapListener() {
+
+ @Override
+ public boolean onScroll(ScrollEvent paramScrollEvent) {
+ loadMarkers();
+ return true;
+ }
+
+ @Override
+ public boolean onZoom(ZoomEvent event) {
+ loadMarkers();
+ return true;
+ }
+
+ }));
+ }
+
+ public void startMap(GeoPoint marker, String name, String ID) {
+
+ // move the map on the marker position or on a default view point: Turin, Piazza Castello
+ // and set the start zoom
+ IMapController mapController = map.getController();
+ GeoPoint startPoint;
+ if (marker != null) {
+ startPoint = marker;
+ mapController.setZoom(20.0);
+ } else {
+ startPoint = new GeoPoint(45.0708, 7.6858);
+ mapController.setZoom(18.0);
+ }
+ // set the minimum zoom level
+ map.setMinZoomLevel(15.5);
+ mapController.setCenter(startPoint);
+
+ loadMarkers();
+ if (marker != null) {
+ // make a marker with the info window open for the searched marker
+ makeMarker(startPoint, name , ID, true);
+ }
+
+ }
+
+ public void makeMarker(GeoPoint geoPoint, String stopName, String ID, boolean isStartMarker) {
+
+ // add a marker
+ Marker marker = new Marker(map);
+
+ // set custom info window as info window
+ CustomInfoWindow popup = new CustomInfoWindow(map, ID, stopName);
+ marker.setInfoWindow(popup);
+
+ // make the marker clickable
+ marker.setOnMarkerClickListener((thisMarker, mapView) -> {
+ if (thisMarker.isInfoWindowOpen()) {
+ // on second click
+
+ // create an intent with these extras
+ Intent intent = new Intent(ActivityMap.this, ActivityMain.class);
+ Bundle b = new Bundle();
+ b.putString("bus-stop-ID", ID);
+ b.putString("bus-stop-display-name", stopName);
+ intent.putExtras(b);
+ intent.setFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
+
+ // start ActivityMain with the previous intent
+ startActivity(intent);
+ } else {
+ // on first click
+
+ // hide all opened info window
+ InfoWindow.closeAllInfoWindowsOn(map);
+ // show this particular info window
+ thisMarker.showInfoWindow();
+ // move the map to its position
+ map.getController().animateTo(thisMarker.getPosition());
+ }
+
+ return true;
+ });
+
+ // set its position
+ marker.setPosition(geoPoint);
+ marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
+ // display the marker
+ map.getOverlays().add(marker);
+ // add to it an icon
+ marker.setIcon(getResources().getDrawable(R.drawable.bus_marker));
+ // add to it a title
+ marker.setTitle(stopName);
+
+ // show popup info window of the searched marker
+ if (isStartMarker) {
+ marker.showInfoWindow();
+ }
+
+ }
+
+ public void loadMarkers() {
+
+ // get rid of the previous markers
+ map.getOverlays().clear();
+
+ // get the top, bottom, left and right screen's coordinate
+ BoundingBox bb = map.getBoundingBox();
+ double latFrom = bb.getLatSouth();
+ double latTo = bb.getLatNorth();
+ double lngFrom = bb.getLonWest();
+ double lngTo = bb.getLonEast();
+
+ // get the stops located in those coordinates
+ StopsDB stopsDB = new StopsDB(ctx);
+ stopsDB.openIfNeeded();
+ Stop[] stops = stopsDB.queryAllInsideMapView(latFrom, latTo, lngFrom, lngTo);
+ stopsDB.closeIfNeeded();
+
+ // add new markers of those stops
+ for (Stop stop : stops) {
+ GeoPoint marker = new GeoPoint(stop.getLatitude(), stop.getLongitude());
+ makeMarker(marker, stop.getStopDefaultName(), stop.ID, false);
+ }
+
+ }
+
+ public void onResume(){
+ super.onResume();
+ //this will refresh the osmdroid configuration on resuming.
+ //if you make changes to the configuration, use
+ //SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ //Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this));
+ map.onResume(); //needed for compass, my location overlays, v6.0.0 and up
+ }
+
+ public void onPause(){
+ super.onPause();
+ //this will refresh the osmdroid configuration on resuming.
+ //if you make changes to the configuration, use
+ //SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ //Configuration.getInstance().save(this, prefs);
+ map.onPause(); //needed for compass, my location overlays, v6.0.0 and up
+ }
+}
\ No newline at end of file
diff --git a/src/it/reyboz/bustorino/map/CustomInfoWindow.java b/src/it/reyboz/bustorino/map/CustomInfoWindow.java
new file mode 100644
--- /dev/null
+++ b/src/it/reyboz/bustorino/map/CustomInfoWindow.java
@@ -0,0 +1,42 @@
+package it.reyboz.bustorino.map;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.MotionEvent;
+import android.view.View;
+
+import org.osmdroid.views.MapView;
+import org.osmdroid.views.overlay.infowindow.BasicInfoWindow;
+
+import it.reyboz.bustorino.ActivityMain;
+import it.reyboz.bustorino.R;
+
+public class CustomInfoWindow extends BasicInfoWindow {
+
+ @SuppressLint("ClickableViewAccessibility")
+ public CustomInfoWindow(MapView mapView, String ID, String stopName) {
+ // get the personalized layout
+ super(R.layout.map_popup, mapView);
+
+ // make clickable
+ mView.setOnTouchListener((View v, MotionEvent e) -> {
+ if (e.getAction() == MotionEvent.ACTION_UP) {
+ // on click
+
+ // create an intent with these extras
+ Intent intent = new Intent(mapView.getContext(), ActivityMain.class);
+ Bundle b = new Bundle();
+ b.putString("bus-stop-ID", ID);
+ b.putString("bus-stop-display-name", stopName);
+ intent.putExtras(b);
+ intent.setFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
+
+ // start ActivityMain with the previous intent
+ mapView.getContext().startActivity(intent);
+ }
+ return true;
+ });
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Jun 18, 12:33 (12 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1966296
Default Alt Text
D24.1781778784.diff (34 KB)

Event Timeline