diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java b/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java index f712f08..928840b 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/MainActivity.java @@ -264,7 +264,7 @@ String key = res.getStringArray(R.array.hikeEntriesKeys)[position]; if(key.equals(getString(R.string.hike_title_record_key))) { if(hikeHandler.isRecording()) { - final ArrayList hikePoints = (ArrayList) hikeHandler.getPoints(); + final ArrayList hikePoints = (ArrayList) hikeHandler.getPoints(); if(hikePoints.size() < 2) return; LayoutInflater inflater = getLayoutInflater(); @@ -283,9 +283,9 @@ timeView.setText(String.format(Locale.getDefault(), "Time so far: %02d:%02d:%02d", hours, minutes, seconds)); AlertDialog.Builder saveHikeBuilder = new AlertDialog.Builder(MainActivity.this); - saveHikeBuilder.setTitle("Save your hike") + saveHikeBuilder.setTitle(R.string.hike_save_title) .setView(hikeDialog) - .setPositiveButton("Save hike", new DialogInterface.OnClickListener() { + .setPositiveButton(R.string.hike_save_ok_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String name = input.getText().toString().trim(); @@ -300,7 +300,7 @@ } } }) - .setNegativeButton("Keep hiking", new DialogInterface.OnClickListener() { + .setNegativeButton(R.string.hike_save_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } @@ -326,9 +326,9 @@ } else { AlertDialog.Builder startHikeBuilder = new AlertDialog.Builder(MainActivity.this); startHikeBuilder - .setTitle("Do you want to start a hike?") - .setMessage("This will record a new hike. From now on your locations will be recorded and you can save it afterwards.") - .setPositiveButton("Start hike", new DialogInterface.OnClickListener() { + .setTitle(R.string.hike_start_question) + .setMessage(R.string.hike_start_desc) + .setPositiveButton(R.string.hike_start_ok_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { hikeHandler.startRecording(); @@ -347,24 +347,64 @@ } else if(key.equals(getString(R.string.hike_title_show_key))) { //TODO Open dialog with all hikes around current position (or enter position) ArrayList pois = (ArrayList) dbHandler.getPoiByType(Types.HIKE); - List> points = new ArrayList<>(); - ArrayList hikes = new ArrayList<>(); - int i = 0; + final List> points = new ArrayList<>(); + final ArrayList hikes = new ArrayList<>(); for(Poi p : pois) { Hike hike = (Hike) p; points.add(dbHandler.getGeoPointsForPoi(hike.getId(), hike.getType())); hikes.add(hike); } - AlertDialog.Builder showHikesBuilder = new AlertDialog.Builder(MainActivity.this); - showHikesBuilder + AlertDialog showHikesDialog = new AlertDialog.Builder(MainActivity.this) .setAdapter(new HikeListAdapter(MainActivity.this, hikes, points), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Toaster("Clicked element " + which, false); + MapView hikeMap = new MapView(MainActivity.this); + Polyline hikePath = new Polyline(MainActivity.this); + Hike hike = hikes.get(which); + List dbPoints = points.get(which); + List pathPoints = new ArrayList<>(); + for(DbGeoPoint dbGeoPoint : dbPoints) { + pathPoints.add(new GeoPoint(dbGeoPoint.getLat(), dbGeoPoint.getLon(), dbGeoPoint.getAlt())); + } + LayoutInflater inflater = getLayoutInflater(); + View rowView = inflater.inflate(R.layout.hike_list_detail, null, true); + TextView titleView = (TextView) rowView.findViewById(R.id.hike_list_detail_title); + TextView authorView = (TextView) rowView.findViewById(R.id.hike_list_detail_author); + TextView lengthView = (TextView) rowView.findViewById(R.id.hike_list_detail_length); + TextView timeView = (TextView) rowView.findViewById(R.id.hike_list_detail_time); + TextView difficultyView = (TextView) rowView.findViewById(R.id.hike_list_detail_difficulty); + LinearLayout contentView = (LinearLayout) rowView.findViewById(R.id.hike_list_detail_inner); + titleView.setText(hike.getName()); + authorView.setText(String.format(Locale.getDefault(), res.getString(R.string.hike_list_author), hike.getAuthor())); + lengthView.setText(String.format(Locale.getDefault(), "Length: %.02fm", hike.getLength())); + timeView.setText(String.format(Locale.getDefault(), "Time: %ds", hike.getTime())); + difficultyView.setText(res.getStringArray(R.array.hike_difficulties)[hike.getDifficulty()]); + hikeMap.setTileSource(TileSourceFactory.MAPNIK); + hikeMap.setBuiltInZoomControls(true); + hikeMap.setMultiTouchControls(true); + IMapController hikeMapController = hikeMap.getController(); + hikeMapController.setZoom(ZOOM_LEVEL); + hikeMapController.setCenter(pathPoints.get(0)); + contentView.addView(hikeMap); + + AlertDialog detailHikeDialog = new AlertDialog.Builder(MainActivity.this) + .setTitle(String.format(Locale.getDefault(), res.getString(R.string.hike_detail_title), hike.getName())) + .setView(rowView) + .setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }) + .create(); + detailHikeDialog.show(); + hikePath.setPoints(pathPoints); + hikePath.setColor(res.getColor(R.color.polyline_color)); + hikeMap.getOverlays().add(hikePath); + hikeMap.invalidate(); } }) - .setTitle("Hikes around you"); - AlertDialog showHikesDialog = showHikesBuilder.create(); + .setTitle(R.string.hike_list_title) + .create(); showHikesDialog.show(); } } diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/adapters/HikeListAdapter.java b/app/src/main/java/de/apps4ics/mountainnavigation/adapters/HikeListAdapter.java index 1270e8c..2e37f22 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/adapters/HikeListAdapter.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/adapters/HikeListAdapter.java @@ -22,6 +22,7 @@ package de.apps4ics.mountainnavigation.adapters; import android.app.Activity; +import android.content.res.Resources; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -40,26 +41,31 @@ private Activity context; private List hikes; private List> points; + private Resources res; public HikeListAdapter(Activity context, List hikes, List> points) { super(context, R.layout.hike_list, new String[hikes.size()]); this.context = context; this.hikes = hikes; this.points = points; + this.res = MainActivity.getRes(); } @Override public View getView(int position, View view, ViewGroup parent) { + Hike hike = hikes.get(position); LayoutInflater inflater = context.getLayoutInflater(); View rowView = inflater.inflate(R.layout.hike_list, null, true); TextView titleView = (TextView) rowView.findViewById(R.id.hike_list_item_title); + TextView authorView = (TextView) rowView.findViewById(R.id.hike_list_item_author); TextView lengthView = (TextView) rowView.findViewById(R.id.hike_list_item_length); TextView timeView = (TextView) rowView.findViewById(R.id.hike_list_item_time); TextView difficultyView = (TextView) rowView.findViewById(R.id.hike_list_item_difficulty); - titleView.setText(hikes.get(position).getName() + " (" + points.get(position).size() + ")"); - lengthView.setText(String.format(Locale.getDefault(), "Length: %.02fm", hikes.get(position).getLength())); - timeView.setText(String.format(Locale.getDefault(), "Time: %ds", hikes.get(position).getTime())); - difficultyView.setText(MainActivity.getRes().getStringArray(R.array.hike_difficulties)[hikes.get(position).getDifficulty()]); + titleView.setText(hike.getName()); + authorView.setText(String.format(Locale.getDefault(), res.getString(R.string.hike_list_author), hike.getAuthor())); + lengthView.setText(String.format(Locale.getDefault(), "Length: %.02fm", hike.getLength())); + timeView.setText(String.format(Locale.getDefault(), "Time: %ds", hike.getTime())); + difficultyView.setText(res.getStringArray(R.array.hike_difficulties)[hike.getDifficulty()]); return rowView; } } diff --git a/app/src/main/res/layout/hike_list.xml b/app/src/main/res/layout/hike_list.xml index 66c8635..1accdba 100644 --- a/app/src/main/res/layout/hike_list.xml +++ b/app/src/main/res/layout/hike_list.xml @@ -34,15 +34,32 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> - + android:orientation="horizontal"> + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index 19d9d67..26abb28 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -78,6 +78,15 @@ Keine Wetterdaten verfügbar Nehme auf… Aufnahme stoppen + Deine Wanderung speichern + Wanderung speichern + Weiter wandern + Möchtest du eine Wanderung aufnehmen? + Damit wird eine neue Wanderung aufgenommen. Dabei werden deine Positionen aufgenommen und du kannst sie später abspeichern. + Wanderung starten + Eigenschaften von %1$s + Wanderungen in deiner Nähe + von %1$s de H:m diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e6a0f04..d9f7ae6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -80,6 +80,15 @@ No weather data available Recording… Stop recording + Save your hike + Save hike + Keep hiking + Do you want to record a hike? + This will record a new hike. From now on your locations will be recorded and you can save it afterwards. + Start hike + Details of %1$s + Hikes around you + from %1$s en h:m a