diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..758de96 100755 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/res/layout/activity_settings.xml b/res/layout/activity_settings.xml index acff019..e433a97 100644 --- a/res/layout/activity_settings.xml +++ b/res/layout/activity_settings.xml @@ -1,21 +1,21 @@ \ No newline at end of file diff --git a/res/menu/main.xml b/res/menu/main.xml index 3d1064a..aa3390a 100644 --- a/res/menu/main.xml +++ b/res/menu/main.xml @@ -1,52 +1,57 @@ + \ No newline at end of file diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 892db79..eab6e55 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -1,89 +1,95 @@ 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 Tocca il nome di una fermata per aggiungerla in questa lista Rimuovi Rinomina Rinomina fermata Reset Informazioni Tocca il nome della fermata per aggiungerla 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 \"politicamente\" 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:
- Valerio Bozzolan sviluppatore principale.
- Marco Gagino intenso collaboratore, creatore dell\'icona, responsabile della grafica.
- Paolo Alloatti per l\'idea dell\'icona.
- JSoup libreria per "web scaping".
- makovkastar bottone fluttuante.
- Google icone 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 Fermate vicine Ricerca della posizione in corso… Nessuna fermata nei dintorni Preferenze Aggiornamento del database… + Numero di fermate + Impostazioni + Impostazioni + Fermate recenti + Abilitare il GPS + Raggio di ricerca
diff --git a/res/values/keys.xml b/res/values/keys.xml new file mode 100644 index 0000000..18be176 --- /dev/null +++ b/res/values/keys.xml @@ -0,0 +1,5 @@ + + + layout_pref + \ No newline at end of file diff --git a/res/values/pref_keys.xml b/res/values/pref_keys.xml new file mode 100644 index 0000000..e6923a1 --- /dev/null +++ b/res/values/pref_keys.xml @@ -0,0 +1,7 @@ + + + + pref_num_recents + pref_radius_recents + pref_exp_features + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 413e489..4563cec 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,103 +1,105 @@ 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 Favorites Favorites Press on a bus stop name to populate this list Delete Rename Rename the bus stop Reset About Tap the bus stop name to add it 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:
- Valerio Bozzolan main developer.
- Marco Gagino main contributor and icon creator.
- Paolo Alloatti original concept of the icon.
- 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 ListFragment - BusTO it.reyboz.bustorino.preferences db_is_updating Nearby stops Finding the position… No stops nearby Number of stops Preferences Settings Settings + Experimental features + Search radius Recent stops Please enable GPS Database update in progress…
diff --git a/res/values/theme.xml b/res/values/theme.xml index 691ca25..9766bd6 100644 --- a/res/values/theme.xml +++ b/res/values/theme.xml @@ -1,16 +1,18 @@ + + \ No newline at end of file diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index e74149b..e3dca9e 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -1,23 +1,32 @@ + android:title="General"> + + + + android:title="@string/pref_num_elements" android:key="@string/pref_key_num_recents" android:inputType="numberDecimal" + + android:digits="0123456789" android:ems="10" + /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + /> - - \ No newline at end of file + + diff --git a/src/it/reyboz/bustorino/ActivitySettings.java b/src/it/reyboz/bustorino/ActivitySettings.java index 9dc7bbf..17cdf61 100644 --- a/src/it/reyboz/bustorino/ActivitySettings.java +++ b/src/it/reyboz/bustorino/ActivitySettings.java @@ -1,41 +1,37 @@ package it.reyboz.bustorino; import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.util.Log; -import android.view.View; -import it.reyboz.bustorino.fragments.PreferFragment; +import it.reyboz.bustorino.fragments.SettingsFragment; public class ActivitySettings extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); ActionBar ab = getSupportActionBar(); if(ab!=null) { ab.setIcon(R.drawable.ic_launcher); ab.setDisplayHomeAsUpEnabled(true); } else { Log.e("SETTINGS_ACTIV","ACTION BAR IS NULL"); } FragmentManager framan = getSupportFragmentManager(); FragmentTransaction ft = framan.beginTransaction(); - ft.add(R.id.setting_container,new PreferFragment()); - ft.commitNow(); + ft.replace(R.id.setting_container,new SettingsFragment()); + ft.commit(); } } /** * Interesting thing * Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) * .setAction("Action", null).show(); */ diff --git a/src/it/reyboz/bustorino/fragments/NearbyStopsFragment.java b/src/it/reyboz/bustorino/fragments/NearbyStopsFragment.java index 6fdc50a..27c988c 100644 --- a/src/it/reyboz/bustorino/fragments/NearbyStopsFragment.java +++ b/src/it/reyboz/bustorino/fragments/NearbyStopsFragment.java @@ -1,363 +1,373 @@ /* BusTO - Fragments components Copyright (C) 2018 Fabio Mazza This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package it.reyboz.bustorino.fragments; import android.content.Context; import android.content.SharedPreferences; import android.database.Cursor; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; +import android.support.v7.preference.PreferenceManager; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; import it.reyboz.bustorino.R; import it.reyboz.bustorino.backend.Route; import it.reyboz.bustorino.backend.Stop; import it.reyboz.bustorino.backend.utils; import it.reyboz.bustorino.middleware.AppDataProvider; import it.reyboz.bustorino.middleware.NextGenDB.Contract.*; import it.reyboz.bustorino.adapters.SquareStopAdapter; import it.reyboz.bustorino.util.StopSorterByDistance; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; +import java.util.*; public class NearbyStopsFragment extends Fragment implements LoaderManager.LoaderCallbacks { private FragmentListener mListener; private LocationManager locManager; private FragmentLocationListener locationListener; private final String[] PROJECTION = {StopsTable.COL_ID,StopsTable.COL_LAT,StopsTable.COL_LONG, StopsTable.COL_NAME,StopsTable.COL_TYPE,StopsTable.COL_LINES_STOPPING}; private final static String DEBUG_TAG = "NearbyStopsFragment"; //data Bundle private final String BUNDLE_LOCATION = "location"; private final int LOADER_ID = 0; private RecyclerView gridRecyclerView; private SquareStopAdapter dataAdapter; private AutoFitGridLayoutManager gridLayoutManager; boolean canStartDBQuery = true; private Location lastReceivedLocation = null; private ProgressBar loadingProgressBar; private int distance; private SharedPreferences globalSharedPref; private SharedPreferences.OnSharedPreferenceChangeListener preferenceChangeListener; private TextView messageTextView; private CommonScrollListener scrollListener; private boolean firstLoc = true; public static final int COLUMN_WIDTH_DP = 250; + private Integer MAX_DISTANCE = -3; + private int MIN_NUM_STOPS = -1; + public NearbyStopsFragment() { // Required empty public constructor } /** * Use this factory method to create a new instance of * this fragment using the provided parameters. * @return A new instance of fragment NearbyStopsFragment. */ public static NearbyStopsFragment newInstance() { NearbyStopsFragment fragment = new NearbyStopsFragment(); Bundle args = new Bundle(); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { /* mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); */ } locManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); locationListener = new FragmentLocationListener(this); globalSharedPref = getContext().getSharedPreferences(getString(R.string.mainSharedPreferences),Context.MODE_PRIVATE); globalSharedPref.registerOnSharedPreferenceChangeListener(preferenceChangeListener); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_nearby_stops, container, false); gridRecyclerView = (RecyclerView) root.findViewById(R.id.stopGridRecyclerView); gridLayoutManager = new AutoFitGridLayoutManager(getContext().getApplicationContext(), utils.convertDipToPixels(getContext(),COLUMN_WIDTH_DP)); gridRecyclerView.setLayoutManager(gridLayoutManager); gridRecyclerView.setHasFixedSize(false); loadingProgressBar = (ProgressBar) root.findViewById(R.id.loadingBar); messageTextView = (TextView) root.findViewById(R.id.messageTextView); preferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Log.d(DEBUG_TAG,"Key "+key+" was changed"); if(key.equals(getString(R.string.databaseUpdatingPref))){ if(!sharedPreferences.getBoolean(getString(R.string.databaseUpdatingPref),true)){ canStartDBQuery = true; Log.d(DEBUG_TAG,"The database has finished updating, can start update now"); } } } }; scrollListener = new CommonScrollListener(mListener,false); return root; } @Override public void onAttach(Context context) { super.onAttach(context); if (context instanceof FragmentListener) { mListener = (FragmentListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener"); } } @Override public void onPause() { super.onPause(); canStartDBQuery = false; locManager.removeUpdates(locationListener); gridRecyclerView.setAdapter(null); Log.d(DEBUG_TAG,"On paused called"); } @Override public void onResume() { super.onResume(); canStartDBQuery = !globalSharedPref.getBoolean(getString(R.string.databaseUpdatingPref),false); try{ if(canStartDBQuery) locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000,5,locationListener); } catch (SecurityException ex){ //ignored //try another location provider } if(dataAdapter!=null){ gridRecyclerView.setAdapter(dataAdapter); loadingProgressBar.setVisibility(View.GONE); } Log.d(DEBUG_TAG,"OnResume called"); + + //Re-read preferences + SharedPreferences shpr = PreferenceManager.getDefaultSharedPreferences(getContext().getApplicationContext()); + //For some reason, they are all saved as strings + MAX_DISTANCE = shpr.getInt(getString(R.string.pref_key_radius_recents),1000); + MIN_NUM_STOPS = Integer.parseInt(shpr.getString(getString(R.string.pref_key_num_recents),"12")); } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); gridRecyclerView.setVisibility(View.INVISIBLE); gridRecyclerView.addOnScrollListener(scrollListener); } @Override public void onDetach() { super.onDetach(); mListener = null; } @Override public Loader onCreateLoader(int id, Bundle args) { //BUILD URI lastReceivedLocation = args.getParcelable(BUNDLE_LOCATION); Uri.Builder builder = new Uri.Builder(); builder.scheme("content").authority(AppDataProvider.AUTHORITY) .appendPath("stops").appendPath("location") .appendPath(String.valueOf(lastReceivedLocation.getLatitude())) .appendPath(String.valueOf(lastReceivedLocation.getLongitude())) .appendPath(String.valueOf(distance)); //distance CursorLoader cl = new CursorLoader(getContext(),builder.build(),PROJECTION,null,null,null); - cl.setUpdateThrottle(1000); + cl.setUpdateThrottle(2000); return cl; } + @Override public void onLoadFinished(Loader loader, Cursor data) { ArrayList stopList = new ArrayList<>(); data.moveToFirst(); - if(data.getCount()<4 && !globalSharedPref.getBoolean(getString(R.string.databaseUpdatingPref),false) && distance<=1000){ + if (0 > MAX_DISTANCE) throw new AssertionError(); + if(!globalSharedPref.getBoolean(getString(R.string.databaseUpdatingPref),false) && (data.getCount()0) { //quick trial to hopefully always get the stops in the correct order Collections.sort(stopList,new StopSorterByDistance(lastReceivedLocation)); if(firstLoc) { dataAdapter = new SquareStopAdapter(stopList, mListener, lastReceivedLocation); gridRecyclerView.setAdapter(dataAdapter); firstLoc = false; }else { dataAdapter.setStops(stopList); dataAdapter.setUserPosition(lastReceivedLocation); } dataAdapter.notifyDataSetChanged(); if (gridRecyclerView.getVisibility() != View.VISIBLE) { loadingProgressBar.setVisibility(View.GONE); gridRecyclerView.setVisibility(View.VISIBLE); } messageTextView.setVisibility(View.GONE); } else { messageTextView.setVisibility(View.VISIBLE); messageTextView.setText(R.string.no_stops_nearby); loadingProgressBar.setVisibility(View.GONE); } } @Override public void onLoaderReset(Loader loader) { } /** * Local locationListener, to use for the GPS */ class FragmentLocationListener implements LocationListener{ LoaderManager.LoaderCallbacks callbacks; private int oldLocStatus = -2; public FragmentLocationListener(LoaderManager.LoaderCallbacks callbacks) { this.callbacks = callbacks; } @Override public void onLocationChanged(Location location) { //set adapter float accuracy = location.getAccuracy(); if(accuracy<60 && canStartDBQuery) { - distance = 100; + distance = 20; final Bundle msgBundle = new Bundle(); msgBundle.putParcelable(BUNDLE_LOCATION,location); getLoaderManager().restartLoader(LOADER_ID,msgBundle,callbacks); } Log.d("LocationListener","can start loader "+ canStartDBQuery); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { if(oldLocStatus!=status){ if(status == LocationProvider.OUT_OF_SERVICE || status == LocationProvider.TEMPORARILY_UNAVAILABLE) { messageTextView.setText(R.string.enableGpsText); messageTextView.setVisibility(View.VISIBLE); }else if(status == LocationProvider.AVAILABLE){ messageTextView.setVisibility(View.GONE); } oldLocStatus = status; } } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } } /** * Simple trick to get an automatic number of columns (from https://www.journaldev.com/13792/android-gridlayoutmanager-example) * */ class AutoFitGridLayoutManager extends GridLayoutManager { private int columnWidth; private boolean columnWidthChanged = true; public AutoFitGridLayoutManager(Context context, int columnWidth) { super(context, 1); setColumnWidth(columnWidth); } public void setColumnWidth(int newColumnWidth) { if (newColumnWidth > 0 && newColumnWidth != columnWidth) { columnWidth = newColumnWidth; columnWidthChanged = true; } } @Override public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { if (columnWidthChanged && columnWidth > 0) { int totalSpace; if (getOrientation() == VERTICAL) { totalSpace = getWidth() - getPaddingRight() - getPaddingLeft(); } else { totalSpace = getHeight() - getPaddingTop() - getPaddingBottom(); } int spanCount = Math.max(1, totalSpace / columnWidth); setSpanCount(spanCount); columnWidthChanged = false; } super.onLayoutChildren(recycler, state); } } } diff --git a/src/it/reyboz/bustorino/fragments/PreferFragment.java b/src/it/reyboz/bustorino/fragments/SettingsFragment.java similarity index 79% rename from src/it/reyboz/bustorino/fragments/PreferFragment.java rename to src/it/reyboz/bustorino/fragments/SettingsFragment.java index f325599..ebfa69f 100644 --- a/src/it/reyboz/bustorino/fragments/PreferFragment.java +++ b/src/it/reyboz/bustorino/fragments/SettingsFragment.java @@ -1,26 +1,26 @@ package it.reyboz.bustorino.fragments; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceFragmentCompat; import it.reyboz.bustorino.R; -public class PreferFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { - private static final String TAG = PreferFragment.class.getName(); +public class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { + private static final String TAG = SettingsFragment.class.getName(); SharedPreferences preferences; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.preferences,rootKey); preferences = getContext().getSharedPreferences(getString(R.string.mainSharedPreferences), Context.MODE_PRIVATE); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Preference pref = findPreference(key); } }