Skip to content

Commit ac20e1c

Browse files
committed
almost finished for beta testing
1 parent 46c5919 commit ac20e1c

14 files changed

Lines changed: 274 additions & 276 deletions

SUDEAU/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="net.movelab.sudeau"
4-
android:versionCode="2"
4+
android:versionCode="3"
55
android:installLocation="internalOnly"
6-
android:versionName="1.01" >
6+
android:versionName="1.03" >
77

88
<uses-sdk
99
android:minSdkVersion="9"
@@ -33,7 +33,7 @@
3333
android:value="@integer/google_play_services_version" />
3434
<meta-data
3535
android:name="com.google.android.maps.v2.API_KEY"
36-
android:value="@string/maps_api_key_production" />
36+
android:value="@string/maps_api_key_debugging" />
3737
<activity
3838
android:name="net.movelab.sudeau.Switchboard"
3939
android:theme="@android:style/Theme.Holo"

SUDEAU/res/layout/interactive_image_activity_heatmap.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
33
android:id="@+id/heatMapScrollView"
44
android:layout_width="fill_parent"
5-
android:layout_height="fill_parent" >
5+
android:layout_height="fill_parent">
66

77
<FrameLayout
88
android:id="@+id/my_frame"
9+
android:layout_gravity="center"
910
android:layout_width="wrap_content"
10-
android:layout_height="wrap_content" >
11+
android:layout_height="wrap_content">
1112

1213
<ImageView
1314
android:id="@+id/int_image"

SUDEAU/src/net/movelab/sudeau/ChooseItineraryActivity.java

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ public class ChooseItineraryActivity extends Activity {
9393

9494
private SharedPreferences mPreferences;
9595

96-
// TODO fix this... move all this logic to DB
97-
public boolean r7downloaded;
98-
9996
private static final String TAG = "ChooseItineraryActivity";
10097

10198
private String currentLocale;
@@ -121,11 +118,6 @@ protected void onCreate(Bundle savedInstanceState) {
121118
currentLocale = PropertyHolder.getLocale();
122119
mPreferences = getSharedPreferences("EruletPreferences", MODE_PRIVATE);
123120

124-
// TODO just for testing
125-
// mPreferences.edit().putBoolean("r7d", false).apply();
126-
127-
r7downloaded = mPreferences.getBoolean("r7d", false);
128-
129121
progressBar = (ProgressBar) findViewById(R.id.pbChooseItinerary);
130122
//setUpDBIfNeeded();
131123
setUpMapIfNeeded();
@@ -183,7 +175,6 @@ public void showItineraryOptions(){
183175
}
184176
AlertDialog.Builder builder = new AlertDialog.Builder(this);
185177
final Route r = routeTable.get(selectedMarker);
186-
if(r7downloaded){
187178
builder.setTitle(r.getName(currentLocale));
188179
builder.setIcon(R.drawable.ic_pin_info);
189180
builder.setMessage(r.getDescription(currentLocale));
@@ -220,24 +211,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
220211
startActivity(intent); }
221212
});
222213
}
223-
} else{
224-
builder.setTitle(r.getName(currentLocale));
225-
builder.setMessage(r.getDescription(currentLocale) + "\n\nYou have not yet downloaded the content for this route to your phone. Would you like to download it now?");
226-
builder.setPositiveButton("Download", new DialogInterface.OnClickListener() {
227-
@Override
228-
public void onClick(DialogInterface dialogInterface, int i) {
229-
startDownload();
230-
}
231-
});
232-
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
233-
@Override
234-
public void onClick(DialogInterface dialogInterface, int i) {
235-
dialogInterface.dismiss();
236-
}
237-
});
238214

239-
builder.setCancelable(true);
240-
}
241215
builder.show();
242216
}
243217

@@ -452,159 +426,5 @@ private MapBoxOfflineTileProvider initTileProvider(Context context) {
452426
}
453427

454428

455-
private void startDownload() {
456-
// TODO unhardcode the route number and pass it instead
457-
String url = "http://107.170.174.182/media/holet/zipped_routes/content_route7.zip";
458-
new DownloadFileAsync().execute(url);
459-
}
460-
@Override
461-
protected Dialog onCreateDialog(int id) {
462-
switch (id) {
463-
case DIALOG_DOWNLOAD_PROGRESS:
464-
mProgressDialog = new ProgressDialog(this);
465-
mProgressDialog.setMessage("Downloading route content...please wait");
466-
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
467-
mProgressDialog.setCancelable(true);
468-
mProgressDialog.show();
469-
return mProgressDialog;
470-
default:
471-
return null;
472-
}
473-
}
474-
475-
476-
class DownloadFileAsync extends AsyncTask<String, String, String> {
477-
478-
@Override
479-
protected void onPreExecute() {
480-
super.onPreExecute();
481-
showDialog(DIALOG_DOWNLOAD_PROGRESS);
482-
}
483-
484-
@Override
485-
protected String doInBackground(String... aurl) {
486-
int count;
487-
488-
try {
489-
490-
URL url = new URL(aurl[0]);
491-
Log.d("ANDRO_ASYNC", "uRL: " + url.toString());
492-
493-
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
494-
conn.setRequestMethod("GET");
495-
conn.setDoOutput(true);
496-
conn.connect();
497-
498-
int lenghtOfFile = conn.getContentLength();
499-
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);
500-
501-
Log.d("ANDRO_ASYNC", "SD path: " + Environment.getExternalStorageDirectory().getPath());
502-
503-
File destinationFile = new File(Environment.getExternalStorageDirectory().getPath(), Util.baseFolder + "/route.zip");
504-
String destinationPath = destinationFile.getPath();
505-
Log.d("ANDRO_ASYNC", "Save path: " + destinationPath);
506-
507-
InputStream input = new BufferedInputStream(url.openStream());
508-
OutputStream output = new FileOutputStream(destinationPath);
509-
510-
byte data[] = new byte[1024];
511-
512-
long total = 0;
513-
514-
while ((count = input.read(data)) != -1) {
515-
total += count;
516-
publishProgress(""+(int)((total*90)/lenghtOfFile));
517-
output.write(data, 0, count);
518-
}
519-
520-
output.flush();
521-
output.close();
522-
input.close();
523-
524-
525-
// NOW UNZIP IT
526-
ZipFile thisZipfile = new ZipFile(destinationPath);
527-
int nEntries = thisZipfile.size();
528-
int zipCounter = 0;
529-
530-
String zipFilePath = destinationPath;
531-
Log.d("ANDRO_ASYNC", "read path: " + destinationPath);
532-
// TODO take out hard coded route 7
533-
File target_directory = new File(Environment.getExternalStorageDirectory().getPath(), Util.baseFolder + "/" + Util.routeMediaFolder + "/route_7");
534-
String destDirectory = target_directory.getPath();
535-
Log.d("ANDRO_ASYNC", "Save path: " + destDirectory);
536-
537-
UnzipUtility unzipper = new UnzipUtility();
538-
try {
539-
// unzipper.unzip(zipFilePath, destDirectory);
540-
// publishProgress(""+100);
541-
542-
final int BUFFER_SIZE = 4096;
543-
544-
File destDir = new File(destDirectory);
545-
if (!destDir.exists()) {
546-
destDir.mkdirs();
547-
}
548-
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
549-
ZipEntry entry = zipIn.getNextEntry();
550-
// iterates over entries in the zip file
551-
while (entry != null) {
552-
String filePath = destDirectory + File.separator + entry.getName();
553-
if (!entry.isDirectory()) {
554-
// if the entry is a file, extracts it
555-
// extractFile(zipIn, filePath);
556-
557-
File f = new File(filePath);
558-
File dir = new File(f.getParent());
559-
dir.mkdirs();
560-
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
561-
byte[] bytesIn = new byte[BUFFER_SIZE];
562-
int read = 0;
563-
while ((read = zipIn.read(bytesIn)) != -1) {
564-
bos.write(bytesIn, 0, read);
565-
566-
}
567-
bos.close();
568-
569-
570-
} else {
571-
// if the entry is a directory, make the directory
572-
File dir = new File(filePath);
573-
dir.mkdirs();
574-
}
575-
576-
publishProgress(""+(int)(90+ ((++zipCounter*10)/nEntries)));
577-
578-
zipIn.closeEntry();
579-
entry = zipIn.getNextEntry();
580-
}
581-
zipIn.close();
582-
583-
584-
585-
mPreferences.edit().putBoolean("r7d", true).apply();
586-
r7downloaded = true;
587-
588-
} catch (Exception ex) {
589-
// some errors occurred
590-
ex.printStackTrace();
591-
}
592-
593-
} catch (Exception e) {}
594-
595-
596-
return null;
597-
598-
}
599-
protected void onProgressUpdate(String... progress) {
600-
mProgressDialog.setProgress(Integer.parseInt(progress[0]));
601-
}
602-
603-
@Override
604-
protected void onPostExecute(String unused) {
605-
dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
606-
showItineraryOptions();
607-
}
608-
}
609429

610430
}

SUDEAU/src/net/movelab/sudeau/DetailItineraryActivity.java

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.json.JSONException;
1111
import org.json.JSONObject;
1212

13+
import net.movelab.sudeau.database.DataBaseHelper;
1314
import net.movelab.sudeau.database.DataContainer;
1415
import net.movelab.sudeau.model.FileManifest;
1516
import net.movelab.sudeau.model.HighLight;
@@ -41,6 +42,7 @@
4142
import android.provider.Settings;
4243
import android.util.DisplayMetrics;
4344
import android.util.Log;
45+
import android.util.Property;
4446
import android.view.Display;
4547
import android.view.Gravity;
4648
import android.view.Menu;
@@ -417,7 +419,7 @@ private void saveHighLight(HighLight h) {
417419
Log.d("saveHighLight", "Step id not found " + stepBeingEditedId);
418420
} else {
419421
DataContainer.addHighLightToStep(s, h,
420-
DataContainer.getAndroidId(getContentResolver()),
422+
PropertyHolder.getUserId(),
421423
app.getDataBaseHelper());
422424
}
423425
}
@@ -767,7 +769,7 @@ private void setUpRoutes() {
767769
.getId() : null;
768770
routeInProgress = DataContainer.createEmptyRoute(locale,
769771
app.getDataBaseHelper(),
770-
DataContainer.getAndroidId(getContentResolver()),
772+
PropertyHolder.getUserId(),
771773
idRouteBasedOn);
772774
}
773775
}
@@ -892,6 +894,7 @@ public void onInfoWindowClick(Marker marker) {
892894
DetailHighLightActivity.class);
893895
i.putExtra("step_j", s_j_string);
894896
if(s!=null){
897+
DataBaseHelper.
895898
i.putExtra("route_id", s.getTrack().getRoute().getId());
896899
}
897900
if(h!=null){
@@ -1554,39 +1557,32 @@ private void refreshDecorations(List<Step> steps) {
15541557
}
15551558

15561559
private MapBoxOfflineTileProvider initTileProvider() {
1557-
// File sdcard = Environment.getExternalStorageDirectory();
1558-
File sdcard = new File(Environment.getExternalStorageDirectory(),
1559-
Util.baseFolder + "/" + Util.routeMapsFolder);
1560-
if (selectedRoute.getLocalCarto() != null) {
1561-
File f = new File(sdcard, selectedRoute.getLocalCarto());
1560+
String mapPath = selectedRoute.getLocalCarto();
1561+
if (mapPath != null && !mapPath.isEmpty()) {
1562+
File f = new File(mapPath);
15621563
Log.e("CARTO", f.getPath());
1563-
1564-
// File f = new File(getCacheDir() +
1565-
// "/OSMPublicTransport_HiRes.mbtiles");
15661564
if (f.exists()) {
15671565
Log.e("CARTO EXISTS", f.getPath());
1568-
1569-
// try {
1570-
// InputStream is = getAssets().open(
1571-
// "OSMPublicTransport_HiRes.mbtiles");
1572-
// FileInputStream is = new FileInputStream(f);
1573-
// int size = is.available();
1574-
// byte[] buffer = new byte[size];
1575-
// is.read(buffer);
1576-
// is.close();
1577-
// FileOutputStream fos = new FileOutputStream(f);
1578-
// fos.write(buffer);
1579-
// fos.close();
1580-
// } catch (Exception e) {
1581-
// throw new RuntimeException(e);
1582-
// }
1583-
return new MapBoxOfflineTileProvider(f.getPath());
1566+
return new MapBoxOfflineTileProvider(f.getPath());
15841567
} else {
15851568
Log.d(TAG,
15861569
"Fitxer cartografia no trobat " + f.getAbsolutePath());
15871570
}
15881571
}
1589-
return null;
1572+
// If not returned by now, try the general map path instead
1573+
mapPath = PropertyHolder.getGeneralMapPath();
1574+
if (mapPath != null && !mapPath.isEmpty()) {
1575+
File f = new File(mapPath);
1576+
Log.e("CARTO", f.getPath());
1577+
if (f.exists()) {
1578+
Log.e("CARTO EXISTS", f.getPath());
1579+
return new MapBoxOfflineTileProvider(f.getPath());
1580+
} else {
1581+
Log.d(TAG,
1582+
"Fitxer cartografia no trobat " + f.getAbsolutePath());
1583+
}
1584+
}
1585+
return null;
15901586
}
15911587

15921588
public class FixReceiver extends BroadcastReceiver {
@@ -1768,7 +1764,7 @@ public void onReceive(Context context, Intent intent) {
17681764
int order = stepsInProgress.size();
17691765
s.setOrder(order);
17701766
DataContainer.addStepToTrack(s, routeInProgress.getTrack(),
1771-
DataContainer.getAndroidId(getContentResolver()),
1767+
PropertyHolder.getUserId(),
17721768
app.getDataBaseHelper());
17731769
}
17741770
Log.d("onReceive", "Received new location " + lat + " " + lng

SUDEAU/src/net/movelab/sudeau/EditHighLightActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ protected void onCreate(Bundle savedInstanceState) {
7272
app = (EruletApp) getApplicationContext();
7373
}
7474

75+
// To stop keyboard from popping up immediately and blocking everything
7576
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
7677

7778
setContentView(R.layout.highlight_activity);
7879

79-
8080
setUpInterface();
8181
Bundle extras = getIntent().getExtras();
8282
if (extras != null) {

0 commit comments

Comments
 (0)