Page MenuHomeGitPull.it

D63.1729597114.diff
No OneTemporary

Size
13 KB
Referenced Files
None
Subscribers
None

D63.1729597114.diff

diff --git a/res/layout/activity_about.xml b/res/layout/activity_about.xml
--- a/res/layout/activity_about.xml
+++ b/res/layout/activity_about.xml
@@ -1,22 +1,46 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="it.reyboz.bustorino.ActivityAbout">
+<LinearLayout 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.ActivityAbout" android:orientation="vertical">
<!-- The ActionBar displayed at the top -->
<include
- layout="@layout/default_toobar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ layout="@layout/default_toobar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
<TextView
- android:id="@+id/aboutTextView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="5dip"
- android:layout_marginLeft="@dimen/activity_horizontal_margin"
- android:layout_marginRight="@dimen/activity_horizontal_margin"
- android:textAppearance="?android:attr/textAppearanceMedium"/>
+ android:id="@+id/aboutTextView"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_marginTop="5dip"
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:layout_marginRight="@dimen/activity_horizontal_margin"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:layout_weight="0.85"
+ />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_marginLeft="8dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginRight="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginTop="2dp"
+ android:id="@+id/theDivider"
+ android:background="@android:color/darker_gray"/>
+ <TextView
+ android:text="@string/app_version"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" android:id="@+id/versionTextView"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ android:gravity="center_vertical"
+ android:layout_margin="10dp"
+ android:layout_marginLeft="20dp"
+ android:layout_marginStart="20dp"
+
+ />
+
-</RelativeLayout>
\ No newline at end of file
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/nav_header.xml b/res/layout/nav_header.xml
--- a/res/layout/nav_header.xml
+++ b/res/layout/nav_header.xml
@@ -30,4 +30,10 @@
android:textColor="#FFFFFF"
android:textSize="20sp" />
+ <!--<TextView
+ android:text="@string/app_version"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" android:id="@+id/versionTextView"
+ android:textAppearance="@style/TextAppearance.AppCompat.Small"
+ android:gravity="center_vertical" android:layout_margin="10dp"/>-->
</LinearLayout>
\ No newline at end of file
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
@@ -148,5 +148,6 @@
<string name="donate_now">Offrici un caffè</string>
<string name="map">Mappa</string>
<string name="stop_search_view_title">Ricerca fermate</string>
+ <string name="app_version">Versione app</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3,7 +3,7 @@
<string name="app_name" translatable="false">BusTO</string>
<string name="app_name_full" translatable="false">Libre BusTO</string>
- <string name="app_name_debug" translatable="false">BusTO Debug</string>
+ <string name="app_name_debug" translatable="false">BusTO dev</string>
<string name="app_description">You\'re using the latest in technology when it comes to respecting your privacy.
</string>
<string name="search">Search</string>
@@ -102,6 +102,7 @@
<string name="nearby_stops_message">Nearby stops</string>
<string name="nearby_arrivals_message">Nearby connections</string>
+ <string name="app_version">App version</string>
<string name="position_searching_message">Finding the position&#8230;</string>
<string name="no_stops_nearby">No stops nearby</string>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -27,6 +27,12 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
/>
- </androidx.preference.PreferenceCategory>
+ </androidx.preference.PreferenceCategory>
+ <!--
+ <androidx.preference.Preference
+ android:layout="@layout/pref_extra_version"
+ android:key="version"
+ />
+ -->
</androidx.preference.PreferenceScreen>
diff --git a/src/it/reyboz/bustorino/ActivityAbout.java b/src/it/reyboz/bustorino/ActivityAbout.java
--- a/src/it/reyboz/bustorino/ActivityAbout.java
+++ b/src/it/reyboz/bustorino/ActivityAbout.java
@@ -17,9 +17,8 @@
*/
package it.reyboz.bustorino;
+import android.util.Log;
import androidx.appcompat.widget.Toolbar;
-import androidx.core.app.NavUtils;
-import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.text.Html;
import android.text.Spanned;
@@ -45,6 +44,10 @@
setSupportActionBar(mToolbar);
if (getSupportActionBar()!=null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ TextView versionText = findViewById(R.id.versionTextView);
+ Log.d("BusTO About", "The version text view is: "+versionText);
+ versionText.setText(getResources().getText(R.string.app_version)+": "+BuildConfig.VERSION_NAME);
}
@Override
diff --git a/src/it/reyboz/bustorino/ActivityPrincipal.java b/src/it/reyboz/bustorino/ActivityPrincipal.java
--- a/src/it/reyboz/bustorino/ActivityPrincipal.java
+++ b/src/it/reyboz/bustorino/ActivityPrincipal.java
@@ -111,6 +111,10 @@
mNavView = findViewById(R.id.nvView);
setupDrawerContent(mNavView);
+ /*View header = mNavView.getHeaderView(0);
+
+ */
+ //mNavView.getMenu().findItem(R.id.versionFooter).
/// LEGACY CODE
//---------------------------- START INTENT CHECK QUEUE ------------------------------------
diff --git a/src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java b/src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java
--- a/src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java
+++ b/src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java
@@ -19,6 +19,7 @@
import androidx.annotation.Nullable;
import android.util.Log;
+import it.reyboz.bustorino.data.GTTInfoInject;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -242,8 +243,8 @@
if(response==null) return null;
ArrayList<Stop> stopslist;
try{
- JSONObject responseJSON = new JSONObject(response);
- JSONArray stops = responseJSON.getJSONArray("stops");
+ //JSONObject responseJSON = new JSONObject(response);
+ JSONArray stops = new JSONArray(response);//responseJSON.getJSONArray("stops");
stopslist = new ArrayList<>(stops.length());
for (int i=0;i<stops.length();i++){
JSONObject currentStop = stops.getJSONObject(i);
@@ -256,21 +257,37 @@
lines[l] = FiveTNormalizer.routeDisplayToInternal(lines[l]);
}
Route.Type t;
- switch (currentStop.getString("type")){
- case "BUS":
- t = Route.Type.BUS;
- break;
- case "METRO":
- t = Route.Type.METRO;
- break;
- case "TRENO":
- t = Route.Type.RAILWAY;
- break;
- default:
- t = Route.Type.UNKNOWN;
+ switch (currentStop.getString("type")){
+ case "BUS":
+ t = Route.Type.BUS;
+ break;
+ case "METRO":
+ t = Route.Type.METRO;
+ break;
+ case "TRENO":
+ t = Route.Type.RAILWAY;
+ break;
+ default:
+ t = Route.Type.UNKNOWN;
+ }
+ String stopName = currentStop.getString("name");
+ String stopID;
+ if(stopName.toLowerCase().contains("metro"))
+ t= Route.Type.METRO;
+ try {
+ stopID = currentStop.getString("id");
+ } catch (JSONException exc){
+ // we don't have the ID
+ //check if we have it already as hardcoded
+ stopID = GTTInfoInject.findIDWhenMissingByName(stopName);
+ if(stopID.length()==0){
+ // we haven't found it, skip stop
+ Log.e(DEBUG_NAME, "Cannot find the ID for stop name: "+stopName);
+ continue;
}
- Stop s = new Stop(currentStop.getString("id"),
- currentStop.getString("name"),null,location,t,Arrays.asList(lines),
+ }
+ Stop s = new Stop(stopID, stopName,
+ null,location,t,Arrays.asList(lines),
Double.parseDouble(currentStop.getString("lat")),
Double.parseDouble(currentStop.getString("lng")));
if(placeName!=null)
diff --git a/src/it/reyboz/bustorino/data/GTTInfoInject.java b/src/it/reyboz/bustorino/data/GTTInfoInject.java
new file mode 100644
--- /dev/null
+++ b/src/it/reyboz/bustorino/data/GTTInfoInject.java
@@ -0,0 +1,91 @@
+package it.reyboz.bustorino.data;
+
+import java.util.Locale;
+
+/**
+ * We need this class as !!TEMPORARY!! fix
+ * To supply data which is not available by the GTT APIs anymore
+ */
+public abstract class GTTInfoInject {
+
+ public static String findIDWhenMissingByName(String stopName){
+ String stringSwitch = stopName.toUpperCase(Locale.ROOT).trim();
+ //if (stringSwitch.contains("METRO")){
+ String finalID;
+ switch (stringSwitch){
+ case "METRO FERMI":
+ finalID="8210";
+ break;
+ case "METRO PARADISO":
+ finalID="8211";
+ break;
+ case "METRO MARCHE":
+ finalID="8212";
+ break;
+ case "METRO MASSAUA":
+ finalID="8213";
+ break;
+ case "METRO POZZO STRADA":
+ finalID="8214";
+ break;
+ case "METRO MONTE GRAPPA":
+ finalID="8215";
+ break;
+ case "METRO RIVOLI":
+ finalID="8216";
+ break;
+ case "METRO RACCONIGI":
+ finalID="8217";
+ break;
+ case "METRO BERNINI":
+ finalID="8218";
+ break;
+ case "METRO PRINCIPI ACAJA":
+ finalID="8219";
+ break;
+ case "METRO XVIII DICEMBRE":
+ finalID="8220";
+ break;
+ case "METRO PORTA SUSA":
+ finalID="8221";
+ break;
+ case "METRO VINZAGLIO":
+ finalID="8222";
+ break;
+ case "METRO RE UMBERTO":
+ finalID="8223";
+ break;
+ case "METRO PORTA NUOVA":
+ finalID="8224";
+ break;
+ case "METRO MARCONI":
+ finalID="8225";
+ break;
+ case "METRO NIZZA":
+ finalID="8226";
+ break;
+ case "METRO DANTE":
+ finalID="8227";
+ break;
+ case "METRO CARDUCCI":
+ finalID="8228";
+ break;
+ case "METRO SPEZIA":
+ finalID="8229";
+ break;
+ case "METRO LINGOTTO":
+ finalID="8230";
+ break;
+ case "METRO ITALIA 61":
+ case "METRO ITALIA61":
+ finalID="8231";
+ break;
+ case "METRO BENGASI":
+ finalID="8232";
+ break;
+ default:
+ finalID="";
+ }
+ return finalID;
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 22, 13:38 (7 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
639213
Default Alt Text
D63.1729597114.diff (13 KB)

Event Timeline