diff --git a/res/drawable-hdpi/ic_center_map.png b/res/drawable-hdpi/ic_center_map.png new file mode 100644 index 0000000..babd8ab Binary files /dev/null and b/res/drawable-hdpi/ic_center_map.png differ diff --git a/res/drawable-hdpi/ic_follow_me.png b/res/drawable-hdpi/ic_follow_me.png new file mode 100644 index 0000000..53b7f5a Binary files /dev/null and b/res/drawable-hdpi/ic_follow_me.png differ diff --git a/res/drawable-hdpi/ic_follow_me_on.png b/res/drawable-hdpi/ic_follow_me_on.png new file mode 100644 index 0000000..7df8c60 Binary files /dev/null and b/res/drawable-hdpi/ic_follow_me_on.png differ diff --git a/res/drawable-mdpi/ic_center_map.png b/res/drawable-mdpi/ic_center_map.png new file mode 100644 index 0000000..70a6861 Binary files /dev/null and b/res/drawable-mdpi/ic_center_map.png differ diff --git a/res/drawable-mdpi/ic_follow_me.png b/res/drawable-mdpi/ic_follow_me.png new file mode 100644 index 0000000..452a149 Binary files /dev/null and b/res/drawable-mdpi/ic_follow_me.png differ diff --git a/res/drawable-mdpi/ic_follow_me_on.png b/res/drawable-mdpi/ic_follow_me_on.png new file mode 100644 index 0000000..fc88b57 Binary files /dev/null and b/res/drawable-mdpi/ic_follow_me_on.png differ diff --git a/res/drawable-xhdpi/ic_center_map.png b/res/drawable-xhdpi/ic_center_map.png new file mode 100644 index 0000000..8241800 Binary files /dev/null and b/res/drawable-xhdpi/ic_center_map.png differ diff --git a/res/drawable-xhdpi/ic_follow_me.png b/res/drawable-xhdpi/ic_follow_me.png new file mode 100644 index 0000000..00ae28a Binary files /dev/null and b/res/drawable-xhdpi/ic_follow_me.png differ diff --git a/res/drawable-xhdpi/ic_follow_me_on.png b/res/drawable-xhdpi/ic_follow_me_on.png new file mode 100644 index 0000000..77a87b1 Binary files /dev/null and b/res/drawable-xhdpi/ic_follow_me_on.png differ diff --git a/res/drawable-xxhdpi/ic_center_map.png b/res/drawable-xxhdpi/ic_center_map.png new file mode 100644 index 0000000..295db21 Binary files /dev/null and b/res/drawable-xxhdpi/ic_center_map.png differ diff --git a/res/drawable-xxhdpi/ic_follow_me.png b/res/drawable-xxhdpi/ic_follow_me.png new file mode 100644 index 0000000..45e2e0f Binary files /dev/null and b/res/drawable-xxhdpi/ic_follow_me.png differ diff --git a/res/drawable-xxhdpi/ic_follow_me_on.png b/res/drawable-xxhdpi/ic_follow_me_on.png new file mode 100644 index 0000000..9d835c4 Binary files /dev/null and b/res/drawable-xxhdpi/ic_follow_me_on.png differ diff --git a/res/drawable-xxxhdpi/ic_center_map.png b/res/drawable-xxxhdpi/ic_center_map.png new file mode 100644 index 0000000..502f327 Binary files /dev/null and b/res/drawable-xxxhdpi/ic_center_map.png differ diff --git a/res/drawable-xxxhdpi/ic_follow_me.png b/res/drawable-xxxhdpi/ic_follow_me.png new file mode 100644 index 0000000..93ccf31 Binary files /dev/null and b/res/drawable-xxxhdpi/ic_follow_me.png differ diff --git a/res/drawable-xxxhdpi/ic_follow_me_on.png b/res/drawable-xxxhdpi/ic_follow_me_on.png new file mode 100644 index 0000000..f335e28 Binary files /dev/null and b/res/drawable-xxxhdpi/ic_follow_me_on.png differ diff --git a/res/layout/activity_map.xml b/res/layout/activity_map.xml index bd7bbc6..1848eeb 100644 --- a/res/layout/activity_map.xml +++ b/res/layout/activity_map.xml @@ -1,9 +1,34 @@ - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 32664a2..339f0a3 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -1,113 +1,118 @@ Stai utilizzando l\'ultimo ritrovato in materia di rispetto della tua privacy. Cerca QR Code Numero fermata Nome fermata Inserisci il numero della fermata Inserisci il nome della fermata Verifica l\'accesso ad Internet! Sembra che nessuna fermata abbia questo nome Errore di lettura del sito 5T/GTT (dannato sito!) Fermata: %1$s Linee: %1$s Scegli la fermata… Nessun passaggio Nessun QR code Preferiti Aiuto Informazioni Più informazioni News Invia bug Codice sorgente Licenza Incontra l\'autore Fermata aggiunta ai preferiti Impossibile aggiungere ai preferiti (memoria piena o database corrotto?)! Preferiti Mappa Nessun preferito? Arghh! Schiaccia sulla stella di una fermata per aggiungerla a questa lista! Rimuovi Rinomina Rinomina fermata Reset Informazioni Tocca la stella per aggiungere la fermata ai preferiti\n\nCome leggere gli orari:\n   12:56* Orario in tempo reale\n   12:56   Orario programmato\n\nTrascina giù per aggiornare l\'orario. OK ! Benvenuto!

Grazie per aver scelto BusTO, un\'app indipendente da GTT/5T, per spostarsi a Torino attraverso software libero:

Perché usare BusTO?

- Non sei monitorato
- Non ci sono pubblicità
- La tua privacy è al sicuro
- Inoltre l\'app è molto leggera!

Come Funziona?

Quest\'app ottiene i passaggi dei bus in tempo reale filtrando i dati forniti pubblicamente sul sito www.gtt.to.it o www.5t.torino.it "per uso personale".

Ingredienti:
- Fabio Mazza attuale rockstar developer anziano.
- Andrea Ugo attuale rockstar developer in formazione.
- Ludovico Pavesi ex rockstar developer anziano.
- Valerio Bozzolan attuale manutentore.
- Marco Gagino apprezzato ex collaboratore, ideatore icona e grafica.
- JSoup libreria per "web scaping".
- Google icone e libreria di supporto per il Material Design.
- Tutti i contributori!

Licenze

L\'app e il relativo codice sorgente sono distribuiti sotto la licenza GNU General Public License v3+. Ciò significa che puoi usare, studiare, migliorare e ricondividere quest\'app con qualunque mezzo e per qualsiasi scopo: a patto di mantenere sempre questi diritti a tua volta e di dare credito a Valerio Bozzolan.

Note

Quest\'applicazione è rilasciata nella speranza che sia utile a tutti ma senza NESSUNA garanzia.

Buon utilizzo! :)

]]>
Nome troppo corto, digita più caratteri e riprova %1$s verso %2$s %s (destinazione sconosciuta) Errore interno inaspettato, impossibile estrarre dati dal sito GTT/5T Visualizza sulla mappa Non trovo un\'applicazione dove mostrarla Posizione della fermata non trovata Fermate vicine Ricerca della posizione in corso… Nessuna fermata nei dintorni Preferenze Aggiornamento del database… Numero di fermate Impostazioni Impostazioni Fermate recenti Impostazioni generali Gestione del database Comincia aggiornamento manuale del database Abilitare il GPS Raggio di ricerca Funzionalità sperimentali arriva alle alla fermata Mostra arrivi Mostra fermate Arrivi qui vicino Fermata rimossa dai preferiti + + La mia posizione + Segui posizione
diff --git a/res/values/strings.xml b/res/values/strings.xml index f60e101..f78d599 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,122 +1,129 @@ BusTO You\'re using the latest in technology when it comes to respecting your privacy. Search Scan QR Code Bus stop number Bus stop name Insert bus stop number Insert bus stop name %1$s towards %2$s %s (unknown destination) Verify your Internet connection! Seems that no bus stop have this name Error parsing the 5T/GTT website (damn site!) Name too short, type more characters and retry Arrivals at: %1$s Choose the bus stop… Lines: %1$s No timetable found No QR code Unexpected internal error, cannot extract data from GTT/5T website Help About More about News releases Bug submission Source code Licence Meet the author Bus stop is now in your favorites Bus stop removed from your favorites Favorites Favorites Map No favorites? Arghh! Press on a bus stop star to populate this list! Delete Rename Rename the bus stop Reset About Tap the star to add the bus stop to the favourites\n\nHow to read timelines:\n   12:56* Real-time arrivals\n   12:56   Scheduled arrivals\n\nPull down to refresh the timetable GOT IT! Welcome!

Thanks for using BusTO, a "politically" independent app useful to move around Torino using a Free/Libre software.

Why use this app?

- You\'ll never be tracked
- You\'ll never see boring ads
- We\'ll always respect your privacy
- Moreover, it\'s lightweight!

How does it work?

This app will show you bus timetables gathering data from www.gtt.to.it or www.5t.torino.it "for personal use".

Who worked on BusTO:
- Fabio Mazza current senior rockstar developer.
- Andrea Ugo current junior rockstar developer.
- Ludovico Pavesi previous senior rockstar developer.
- Valerio Bozzolan maintainer and infrastructure sponsor.
- Marco Gagino contributor and icon creator.
- JSoup web scraper library.
- makovkastar floating buttons.
- Google Material Design icons.
- All the contributors!

Licenses

The app and the related source code are released by Valerio Bozzolan under the terms of the GNU General Public License v3+). So everyone is allowed to use, to study, to improve and to share this app by any kind of means and for any purpose: under the conditions of maintaining this rights and of attributing the original work to Valerio Bozzolan.

Notes

This app has been developed hoping to be useful to everyone but without ANY warranty.

This translation is kindly provided by Riccardo Caniato and Marco Gagino.

Get involved! :)

]]>
Cannot add to favorites (storage full or corrupted database?)! View on a map Cannot find any application to show it in Cannot find the position of the stop ListFragment - BusTO it.reyboz.bustorino.preferences db_is_updating Nearby stops Nearby connections Finding the position… No stops nearby Number of stops Preferences Settings Settings Experimental features Search radius Recent stops General settings Database management Launch manual database update Please enable GPS Database update in progress… is arriving at at the stop %1$s - %2$s Show arrivals Show stops + + + Center on my location + Follow me +
diff --git a/src/it/reyboz/bustorino/ActivityMap.java b/src/it/reyboz/bustorino/ActivityMap.java index 2afae46..6b43c1a 100644 --- a/src/it/reyboz/bustorino/ActivityMap.java +++ b/src/it/reyboz/bustorino/ActivityMap.java @@ -1,298 +1,351 @@ package it.reyboz.bustorino; import android.content.Context; import android.content.Intent; import android.location.Location; import android.location.LocationManager; import android.os.Build; import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ImageButton; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.support.v7.preference.PreferenceManager; import android.widget.Toast; 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.FolderOverlay; import org.osmdroid.views.overlay.Marker; import org.osmdroid.views.overlay.Overlay; import org.osmdroid.views.overlay.infowindow.InfoWindow; import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider; import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay; import java.util.List; 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 final String TAG = "Busto-MapActivity"; private static final String MAP_CURRENT_ZOOM_KEY = "map-current-zoom"; private static final String MAP_CENTER_LAT_KEY = "map-center-lat"; private static final String MAP_CENTER_LON_KEY = "map-center-lon"; public static final String BUNDLE_LATIT = "lat"; public static final String BUNDLE_LONGIT = "lon"; public static final String BUNDLE_NAME = "name"; public static final String BUNDLE_ID = "ID"; private static final double DEFAULT_CENTER_LAT = 45.0708; private static final double DEFAULT_CENTER_LON = 7.6858; private static final double POSITION_FOUND_ZOOM = 18.6; - private static MapView map = null; + private MapView map = null; public Context ctx; private MyLocationNewOverlay mLocationOverlay = null; private FolderOverlay stopsFolderOverlay = null; + protected ImageButton btCenterMap; + protected ImageButton btFollowMe; @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); + //map.setTilesScaledToDpi(true); + map.setFlingEnabled(true); // add ability to zoom with 2 fingers map.setMultiTouchControls(true); + btCenterMap = (ImageButton) findViewById(R.id.ic_center_map); + btFollowMe = (ImageButton) findViewById(R.id.ic_follow_me); + //setup FolderOverlay stopsFolderOverlay = new FolderOverlay(); // take the parameters if it's called from other Activities Bundle b = getIntent().getExtras(); startMap(b, savedInstanceState); // 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; } })); + + + + btCenterMap.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Log.i(TAG, "centerMap clicked "); + final GeoPoint myPosition = mLocationOverlay.getMyLocation(); + map.getController().animateTo(myPosition); + } + }); + + + btFollowMe.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Log.i(TAG, "btFollowMe clicked "); + if (!mLocationOverlay.isFollowLocationEnabled()) { + mLocationOverlay.enableFollowLocation(); + btFollowMe.setImageResource(R.drawable.ic_follow_me_on); + } else { + mLocationOverlay.disableFollowLocation(); + btFollowMe.setImageResource(R.drawable.ic_follow_me); + } + } + }); } public void startMap(Bundle incoming, Bundle savedInstanceState) { //parse incoming bundle GeoPoint marker = null; String name = null; String ID = null; if(incoming != null) { double lat = incoming.getDouble(BUNDLE_LATIT); double lon = incoming.getDouble(BUNDLE_LONGIT); marker = new GeoPoint(lat, lon); name = incoming.getString(BUNDLE_NAME); ID = incoming.getString(BUNDLE_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 = null; if (marker != null) { startPoint = marker; mapController.setZoom(POSITION_FOUND_ZOOM); } else if (savedInstanceState != null) { mapController.setZoom(savedInstanceState.getDouble(MAP_CURRENT_ZOOM_KEY)); mapController.setCenter(new GeoPoint(savedInstanceState.getDouble(MAP_CENTER_LAT_KEY), savedInstanceState.getDouble(MAP_CENTER_LON_KEY))); } else { boolean found = false; LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); if(locationManager!=null) { Location userLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (userLocation != null) { mapController.setZoom(POSITION_FOUND_ZOOM); startPoint = new GeoPoint(userLocation); found = true; } } if(!found){ startPoint = new GeoPoint(DEFAULT_CENTER_LAT, DEFAULT_CENTER_LON); mapController.setZoom(16.0); } } // set the minimum zoom level map.setMinZoomLevel(15.0); //add contingency check (shouldn't happen..., but) if (startPoint != null) { mapController.setCenter(startPoint); } // Location Overlay // from OpenBikeSharing (THANK GOD) GpsMyLocationProvider imlp = new GpsMyLocationProvider(this.getBaseContext()); - imlp.setLocationUpdateMinDistance(200); - imlp.setLocationUpdateMinTime(30000); + imlp.setLocationUpdateMinDistance(10); + imlp.setLocationUpdateMinTime(2000); this.mLocationOverlay = new MyLocationNewOverlay(imlp,map); - this.mLocationOverlay.enableMyLocation(); + mLocationOverlay.enableMyLocation(); + mLocationOverlay.enableFollowLocation(); + mLocationOverlay.setOptionsMenuEnabled(true); + /* + mLocationOverlay.runOnFirstFix(() -> { + mapController.setCenter(mLocationOverlay.getMyLocation()); + mapController.animateTo(mLocationOverlay.getMyLocation()); + }); + */ + map.getOverlays().add(this.mLocationOverlay); //add stops overlay map.getOverlays().add(this.stopsFolderOverlay); loadMarkers(); if (marker != null) { // make a marker with the info window open for the searched marker makeMarker(startPoint, name , ID, true); } } public Marker 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); // add to it an icon marker.setIcon(getResources().getDrawable(R.drawable.bus_marker)); // add to it a title marker.setTitle(stopName); // set the description as the ID marker.setSnippet(ID); // show popup info window of the searched marker if (isStartMarker) { marker.showInfoWindow(); } return marker; } public void loadMarkers() { // get rid of the previous markers //map.getOverlays().clear(); //stopsFolderOverlay = new FolderOverlay(); List stopsOverlays = stopsFolderOverlay.getItems(); if (stopsOverlays != null){ stopsOverlays.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()); Marker stopMarker = makeMarker(marker, stop.getStopDefaultName(), stop.ID, false); stopsFolderOverlay.add(stopMarker); } } + protected boolean detachMapFromPosition(){ + if (mLocationOverlay.isFollowLocationEnabled()) { + mLocationOverlay.disableFollowLocation(); + btFollowMe.setImageResource(R.drawable.ic_follow_me); + return true; + } return 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 mLocationOverlay.enableMyLocation(); } 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 mLocationOverlay.disableMyLocation(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putDouble(MAP_CURRENT_ZOOM_KEY, map.getZoomLevelDouble()); outState.putDouble(MAP_CENTER_LAT_KEY, map.getMapCenter().getLatitude()); outState.putDouble(MAP_CENTER_LON_KEY, map.getMapCenter().getLongitude()); } } \ No newline at end of file