diff --git a/.project b/.project index fd085cf..06a38f7 100644 --- a/.project +++ b/.project @@ -1,68 +1,34 @@ - - -BusTO - - - + BusTO + - - - - - - - - - -com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - - - - - -com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - - - - - -org.eclipse.jdt.core.javabuilder - - - - - - - - - -com.android.ide.eclipse.adt.ApkBuilder - - - - - - - - - - -com.android.ide.eclipse.adt.AndroidNature - - - -org.eclipse.jdt.core.javanature - - - - \ No newline at end of file + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml index 71f32e8..e751b72 100644 --- a/res/layout/activity_main.xml +++ b/res/layout/activity_main.xml @@ -1,110 +1,118 @@ + + - + android:visibility="invisible" /> + android:visibility="invisible" /> \ No newline at end of file diff --git a/res/menu/main.xml b/res/menu/main.xml index 96e79f1..3ed68da 100644 --- a/res/menu/main.xml +++ b/res/menu/main.xml @@ -1,18 +1,23 @@ + \ No newline at end of file diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 72249ef..e23b9d8 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -1,61 +1,67 @@ + Stai utilizzando l\'ultimo ritrovato in materia di rispetto della tua privacy. Cerca Numero fermata Inserisci il numero della fermata Verifica l\'accesso ad Internet! Nessun arrivo previsto per questa fermata :( Fermata %1$s: Nessun passaggio Info Preferiti Fermata aggiunta ai preferiti Preferiti Premi sul nome di una fermata per inserirla in questa lista :) Rimuovi Informazioni 12:56* : Orario in tempo reale \n12:56   : Orario programmato + Come Funziona?\nQuest\'app ottiene i passaggi dei bus in tempo reale filtrando i dati forniti pubblicamente sul sito www.5t.torino.it. OK! + Aiuto Benvenuto! +

Grazie per aver scelto BusTO, un\'app indipendente nata dalla necessità di 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!

-

Informazioni

+

Come Funziona?

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

Ingredienti:
- Valerio Bozzolan come sviluppatore principale.
- Marco Gagino come intenso collaboratore.
- - Paolo Alloatti per l\'icona originale.
+ - Paolo Alloatti per l\'idea dell\'icona.
- JSoup libreria per "web scaping"
E tutti i contributori!

Licenze

L\'app e il relativo codice sorgente sono distribuiti sotto doppia licenza: GNU GPL e CC By-Sa. 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 attribuire sempre a Valerio Bozzolan gli \"sforzi\" per il codice sorgente.

-

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

-

Note

+

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

Invio di bugs/idee: lamentati qui.

+

Codice sorgente: lp:bus-torino.

Contatta l\'autore: Valerio Bozzolan.

Buon utilizzo! :)

]]>
\ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 45c2313..5c6d3ba 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,53 +1,63 @@ BusTO Stai utilizzando l\'ultimo ritrovato in materia di rispetto della tua privacy. Search Bus stop number Insert bus stop number Verify the state of your Internet connection! No bus is supposed to arrive at this stop :( Arrivals at %1$s: No passages About Favorites Bus stop is now in your favorites Favorites Press on a bus stop name to populate this list :) Delete About 12:56* : Real time arrival \n12:56   : Scheduled time of arrival + How does it work?\nThis app will show you the timetable of the buses using the information published on the site http://www.5t.torino.it. GOT IT! + Help Welcome!

Thanks for using BusTO, an indipendent app useful to move around Torino using a Free/Libre and Open Source software.

Why using 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 the timetable of the buses using the information published on the site http://www.5t.torino.it.

+

Who worked on BusTO:
+ - Valerio Bozzolan, the main developer.
+ - Marco Gagino, contributor.
+ - Paolo Alloatti, the concept of the icon.
+ Thanks to all the contributors! +

+

Licenses

The app and the related source code are released by Valerio Bozzolan under the terms of two different licences: the Gnu General Public License v3+ (GNU GPLv3+) and the Creative Commons Attribution - Share alike 4.0 International (CC 4.0 By-Sa). 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 manteining this rights and of attributing the original source code to Valerio Bozzolan.

Notes

This app has been developed hoping to be useful to everyone but without any warranty (such as commercial warranties). If you discover some bugs or if you have some idea, please report them.

- +>

Source code: lp:bus-torino.

+

Mail the author: Valerio Bozzolan.

This translation is kindly provided by Riccardo Caniato.

]]>
\ No newline at end of file diff --git a/src/it/reyboz/bustorino/MainActivity.java b/src/it/reyboz/bustorino/MainActivity.java index 6aa30b6..a6e281e 100644 --- a/src/it/reyboz/bustorino/MainActivity.java +++ b/src/it/reyboz/bustorino/MainActivity.java @@ -1,306 +1,324 @@ package it.reyboz.bustorino; import java.util.ArrayList; import java.util.HashMap; import it.reyboz.bustorino.GTTSiteSucker.BusLinePassages; import it.reyboz.bustorino.GTTSiteSucker.BusStop; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; import android.view.KeyEvent; public class MainActivity extends ActionBarActivity { private EditText busStopIDEditText; private TextView busStopNameTextView; private TextView legend; + private TextView howDoesItWork; private Button hideHint; + private MenuItem action_help; private ProgressBar annoyingSpinner; private ListView resultsListView; private MyAsyncWget myAsyncWget; private DBBusTo mDbHelper; private SQLiteDatabase db; private Integer lastSearchedBusStopID; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); busStopIDEditText = (EditText) findViewById(R.id.busStopIDEditText); busStopNameTextView = (TextView) findViewById(R.id.busStopNameTextView); legend = (TextView) findViewById(R.id.legend); + howDoesItWork = (TextView) findViewById(R.id.howDoesItWork); hideHint = (Button) findViewById(R.id.hideHint); annoyingSpinner = (ProgressBar) findViewById(R.id.annoyingSpinner); resultsListView = (ListView) findViewById(R.id.resultsListView); myAsyncWget = new MyAsyncWget(); // IME_ACTION_SEARCH keyboard option busStopIDEditText .setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { onSearchClick(v); return true; } return false; } }); // Get data in write mode mDbHelper = new DBBusTo(this); db = mDbHelper.getWritableDatabase(); // Intercept calls from other part of the apps Bundle b = getIntent().getExtras(); if (b != null) { String busStopID = b.getString("busStopID"); if (busStopID != null) { launchSearchAction(busStopID); busStopIDEditText.setText(busStopID); } } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); + + action_help = menu.findItem(R.id.action_help); + + action_help.setVisible(false); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { /* * case R.id.action_settings: Intent intentSettings = new * Intent(MainActivity.this,AboutActivity.class); * startActivity(intentSettings); return true; */ case R.id.action_about: Intent intentAbout = new Intent(MainActivity.this, AboutActivity.class); startActivity(intentAbout); return true; case R.id.action_favorites: Intent intentFavorites = new Intent(MainActivity.this, FavoritesActivity.class); startActivity(intentFavorites); return true; + case R.id.action_help: + howDoesItWork.setVisibility(View.VISIBLE); + legend.setVisibility(View.VISIBLE); + hideHint.setVisibility(View.VISIBLE); + return true; } return super.onOptionsItemSelected(item); } /** * Catch the Async action! * * @author boz */ public class MyAsyncWget extends AsyncWget { protected void onPostExecute(String htmlResponse) { // Network errors? if (htmlResponse == null || exceptions != null) { NetworkTools.showNetworkError(MainActivity.this); stopSpinner(); Log.e("MainActivity", "Network error!"); return; } // Try sucking arrivals BusStop busStop = GTTSiteSucker.getBusStopSuckingHTML(htmlResponse); // Parse errors? if (busStop == null) { Toast.makeText(getApplicationContext(), R.string.no_arrival_times, Toast.LENGTH_SHORT).show(); stopSpinner(); Log.e("MainActivity", "Parse error! htmlResponse: " + htmlResponse); return; } // Remember last successfully searched busStopID Integer busStopID = busStop.getBusStopID(); lastSearchedBusStopID = busStopID; // Retrieve passages BusLinePassages[] passagesBusLine = busStop.getPassagesBusLine(); // No passages? if (passagesBusLine.length == 0) { Toast.makeText(getApplicationContext(), R.string.no_arrival_times, Toast.LENGTH_SHORT).show(); stopSpinner(); Log.d("MainActivity", "No passages!"); return; } // Hide the keyboard before showing passages hideKeyboard(); String busStopName = busStop.getBusStopName(); String busStopNameDisplay; if (busStopName == null) { busStopNameDisplay = String.valueOf(busStopID); } else { busStopNameDisplay = busStopName; } busStopNameTextView.setText(String.format( getString(R.string.passages), busStopNameDisplay)); // Insert GTTBusStop info in the DB ContentValues values = new ContentValues(); values.put(DBBusTo.BusStop.COLUMN_NAME_BUSSTOP_ID, busStopID); values.put(DBBusTo.BusStop.COLUMN_NAME_BUSSTOP_NAME, busStopName); long lastInserted = db.insertWithOnConflict( DBBusTo.BusStop.TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE); Log.d("MainActivity", "DBBusTo last BusStopID inserted: " + lastInserted); // Populate the stupid ListView SimpleAdapter ArrayList> entries = new ArrayList>(); for (BusLinePassages passageBusLine : passagesBusLine) { HashMap entry = new HashMap(); String passages = passageBusLine.getTimePassagesString(); if (passages == null) { passages = getString(R.string.no_passages); } entry.put("icon", passageBusLine.getBusLineName()); entry.put("passages", passages); entries.add(entry); } // Show results using the stupid SimpleAdapter String[] from = { "icon", "passages" }; int[] to = { R.id.busLineIcon, R.id.busLine }; SimpleAdapter adapter = new SimpleAdapter(getApplicationContext(), entries, R.layout.bus_line_passage_entry, from, to); resultsListView.setAdapter(adapter); resultsListView .setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView av, View view, int i, long l) { String busLine = ((TextView) av.getChildAt(i) .findViewById(R.id.busLineIcon)).getText() .toString(); Log.d("MainActivity", "Tapped busLine: " + busLine); } }); - // Stop annoying spinner + // Stops annoying spinner stopSpinner(); + + // Shows Help option in the menu + action_help.setVisible(true); - // Show busStopName + // Shows busStopName busStopNameTextView.setVisibility(View.VISIBLE); - // Show hint? + // Shows hint? if (getThisOption("show_legend")) { + howDoesItWork.setVisibility(View.VISIBLE); legend.setVisibility(View.VISIBLE); hideHint.setVisibility(View.VISIBLE); } else { + howDoesItWork.setVisibility(View.GONE); legend.setVisibility(View.GONE); } - // Show results + // Shows results resultsListView.setVisibility(View.VISIBLE); } } public void launchSearchAction(String busStopID) { if (busStopID.isEmpty()) { Toast.makeText(getApplicationContext(), R.string.insert_bus_stop_number_error, Toast.LENGTH_SHORT).show(); } else if (!NetworkTools.isConnected(this)) { NetworkTools.showNetworkError(this); } else { startSpinner(); myAsyncWget.cancel(true); myAsyncWget = new MyAsyncWget(); myAsyncWget.execute(GTTSiteSucker .arrivalTimesByLineQuery(busStopID)); } } public void addInFavorites(View v) { if (lastSearchedBusStopID != null) { ContentValues newValues = new ContentValues(); newValues.put(DBBusTo.BusStop.COLUMN_NAME_BUSSTOP_ISFAVORITE, 1); db.update( DBBusTo.BusStop.TABLE_NAME, newValues, DBBusTo.somethingEqualsInt(DBBusTo.BusStop.COLUMN_NAME_BUSSTOP_ID), new String[] { String.valueOf(lastSearchedBusStopID) }); Toast.makeText(getApplicationContext(), R.string.added_in_favorites, Toast.LENGTH_SHORT).show(); } } public void onSearchClick(View v) { launchSearchAction(busStopIDEditText.getText().toString()); } // Hides hint public void onHideHint (View v) { + howDoesItWork.setVisibility(View.GONE); legend.setVisibility(View.GONE); hideHint.setVisibility(View.GONE); setThisOption("show_legend", false); } private void stopSpinner() { annoyingSpinner.setVisibility(View.INVISIBLE); } private void startSpinner() { annoyingSpinner.setVisibility(View.VISIBLE); } private void hideKeyboard() { InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Check if no view has focus View view = getCurrentFocus(); if (view != null) { inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } private void setThisOption(String optionName, boolean value) { SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); editor.putBoolean(optionName, value); editor.commit(); } private boolean getThisOption(String optionName) { SharedPreferences preferences = getPreferences(MODE_PRIVATE); return preferences.getBoolean(optionName, true); } } \ No newline at end of file