diff --git a/.bzrignore b/.bzrignore
index 15d7031..9516879 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -1,34 +1,33 @@
# Built application files
*.apk
*.ap_
# Files for the dex VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Local configuration file (SDK path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Android Studio
*.iml
-.idea
-#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
-.gradle
+.idea/
+.gradle/
build/
#NDK
obj/
# I don't want to see this shit.
Thumbs.db
.DS_Store
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 77c65d0..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-xmas
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 96cc43e..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 288ea0b..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 1a3eaff..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 68bc3ce..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 6564d52..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/it/reyboz/bustorino/ActivityFavorites.java b/src/it/reyboz/bustorino/ActivityFavorites.java
index 2f5fcce..4f81f26 100644
--- a/src/it/reyboz/bustorino/ActivityFavorites.java
+++ b/src/it/reyboz/bustorino/ActivityFavorites.java
@@ -1,216 +1,217 @@
/*
BusTO - Arrival times for Turin public transports.
Copyright (C) 2014 Valerio Bozzolan
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;
import it.reyboz.bustorino.lab.GTTSiteSucker.BusStop;
import it.reyboz.bustorino.lab.MyDB;
import it.reyboz.bustorino.lab.MyDB.DBBusStop;
import it.reyboz.bustorino.lab.adapters.AdapterBusStops;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
import android.text.InputType;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
public class ActivityFavorites extends ActionBarActivity {
private ListView favoriteListView;
private MyDB mDbHelper;
private SQLiteDatabase db;
private EditText bus_stop_name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_favorites);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
mDbHelper = new MyDB(this);
db = mDbHelper.getWritableDatabase();
favoriteListView = (ListView) findViewById(R.id.favoriteListView);
// Back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
createFavoriteList();
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if (v.getId() == R.id.favoriteListView) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_favourites_entry, menu);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
BusStop busStop = (BusStop) favoriteListView.getItemAtPosition(info.position);
switch (item.getItemId()) {
case R.id.action_favourite_entry_delete:
busStop.setIsFavorite(false);
MyDB.DBBusStop.addBusStop(db, busStop);
createFavoriteList();
return true;
case R.id.action_rename_bus_stop_username:
showBusStopUsernameInputDialog(busStop);
return true;
default:
return super.onContextItemSelected(item);
}
}
void createFavoriteList() {
BusStop[] busStops = MyDB.DBBusStop.getFavoriteBusStops(db);
// If no data is found show a friendly message
if (busStops.length == 0) {
favoriteListView.setVisibility(View.INVISIBLE);
TextView favoriteTipTextView = (TextView) findViewById(R.id.favoriteTipTextView);
favoriteTipTextView.setVisibility(View.VISIBLE);
}
// Show results
favoriteListView.setAdapter(new AdapterBusStops(this, R.layout.entry_bus_stop, busStops));
favoriteListView
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView> parent, View view, int position, long id) {
/**
* Casting because of Javamerda
* @url http://stackoverflow.com/questions/30549485/androids-list-view-parameterized-type-in-adapterview-onitemclicklistener
*/
BusStop busStop = (BusStop) parent.getItemAtPosition(position);
Intent intent = new Intent(ActivityFavorites.this,
ActivityMain.class);
Bundle b = new Bundle();
b.putString("bus-stop-ID", busStop.getBusStopID());
intent.putExtras(b);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_NEW_TASK);
Log.d("FavoritesActivity", "Tapped on bus stop: "
+ busStop.getBusStopID());
startActivity(intent);
finish();
}
});
registerForContextMenu(favoriteListView);
}
private class BusStopUsernameOnClickListener implements DialogInterface.OnClickListener {
private BusStop busStop;
BusStopUsernameOnClickListener(BusStop busStop) {
this.busStop = busStop;
}
@Override
public void onClick(DialogInterface dialog, int which) {
}
}
public void showBusStopUsernameInputDialog(BusStop busStop) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View renameDialogLayout = inflater.inflate(R.layout.rename_dialog, null);
bus_stop_name = (EditText) renameDialogLayout.findViewById(R.id.rename_dialog_bus_stop_name);
- bus_stop_name.setText(busStop.getBusStopName());
+ bus_stop_name.setText(busStop.getBusStopUsername());
bus_stop_name.setHint(busStop.getBusStopName());
+ bus_stop_name.setSelectAllOnFocus(true);
builder.setTitle(getString(R.string.dialog_rename_bus_stop_username_title));
builder.setView(renameDialogLayout);
builder.setPositiveButton(getString(android.R.string.ok), new BusStopUsernameOnClickListener(busStop) {
@Override
public void onClick(DialogInterface dialog, int which) {
String busStopUsername = bus_stop_name.getText().toString();
if (busStopUsername == null || busStopUsername.length() == 0) {
busStopUsername = super.busStop.getBusStopName();
}
super.busStop.setBusStopUsername(busStopUsername);
MyDB.DBBusStop.addBusStop(db, super.busStop);
createFavoriteList();
}
});
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.setNeutralButton(R.string.dialog_rename_bus_stop_username_reset_button, new BusStopUsernameOnClickListener(busStop) {
@Override
public void onClick(DialogInterface dialog, int which) {
super.busStop.setBusStopUsername(null);
MyDB.DBBusStop.addBusStop(db, super.busStop, DBBusStop.FORCE_NULL_BUSSTOP_USERNAME);
createFavoriteList();
}
});
builder.show();
}
}
diff --git a/xmas.iml b/xmas.iml
deleted file mode 100644
index a651814..0000000
--- a/xmas.iml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-