diff --git a/OsmAnd/res/drawable/sherpafy_tour_row.xml b/OsmAnd/res/drawable/sherpafy_tour_row.xml
new file mode 100644
index 0000000000..70de77c04b
--- /dev/null
+++ b/OsmAnd/res/drawable/sherpafy_tour_row.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/sherpafy_list_tour_item.xml b/OsmAnd/res/layout/sherpafy_list_tour_item.xml
index 890757b8b0..a630480f32 100644
--- a/OsmAnd/res/layout/sherpafy_list_tour_item.xml
+++ b/OsmAnd/res/layout/sherpafy_list_tour_item.xml
@@ -2,7 +2,7 @@
+ android:background="@drawable/sherpafy_tour_row" >
diff --git a/OsmAnd/res/layout/sherpafy_loading.xml b/OsmAnd/res/layout/sherpafy_loading.xml
index d0d09c4a70..965fe8f724 100644
--- a/OsmAnd/res/layout/sherpafy_loading.xml
+++ b/OsmAnd/res/layout/sherpafy_loading.xml
@@ -24,4 +24,4 @@
android:textSize="18sp" />
-
\ No newline at end of file
+
diff --git a/OsmAnd/res/layout/sherpafy_stage_info.xml b/OsmAnd/res/layout/sherpafy_stage_info.xml
new file mode 100644
index 0000000000..44364f395e
--- /dev/null
+++ b/OsmAnd/res/layout/sherpafy_stage_info.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/sherpafy_stage_list_item.xml b/OsmAnd/res/layout/sherpafy_stage_list_item.xml
index 092d057924..c6fd46e575 100644
--- a/OsmAnd/res/layout/sherpafy_stage_list_item.xml
+++ b/OsmAnd/res/layout/sherpafy_stage_list_item.xml
@@ -6,17 +6,21 @@
android:paddingTop="8dp"
android:orientation="horizontal" >
-
-
+ android:layout_marginRight="8dp" >
+
+
+ android:layout_weight="1"
+ android:orientation="vertical">
@@ -40,11 +44,11 @@
\ No newline at end of file
diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml
index 2e91517112..08eb8bbc77 100644
--- a/OsmAnd/res/values/colors.xml
+++ b/OsmAnd/res/values/colors.xml
@@ -65,4 +65,7 @@
#dd6CB336
#33888888
+ #ff33b5e5
+ #b9b9b9
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/sherpafy.xml b/OsmAnd/res/values/sherpafy.xml
index 515c0f4805..dbc0d30a1b 100644
--- a/OsmAnd/res/values/sherpafy.xml
+++ b/OsmAnd/res/values/sherpafy.xml
@@ -3,8 +3,11 @@
Tour Information
Stages
Instructions
+ Please read before start
Overview
+ About your tour
Gallery
+ Pictures of your tour
MORE INFORMATION
Continue
Start
@@ -18,6 +21,7 @@
Download more
No tour selected
Couldn\'t create settings file in tour folder.
+ Stage
Stages
Tours
Current
@@ -27,6 +31,9 @@
Loading selected tour \'%s\'…
Tour
Select tour
+ Continue
+ Start
+ Continue tour
Start tour
Download tour
Sherpafy
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyHtmlFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyHtmlFragment.java
new file mode 100644
index 0000000000..0517693541
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyHtmlFragment.java
@@ -0,0 +1,38 @@
+package net.osmand.plus.sherpafy;
+
+import net.osmand.plus.OsmandApplication;
+import android.os.Bundle;
+import android.view.View;
+import android.webkit.WebView;
+
+import com.actionbarsherlock.app.SherlockFragment;
+
+public class SherpafyHtmlFragment extends SherlockFragment {
+ public static final String HTML = "HTML";
+ public static final String TITLE = "TITLE";
+ OsmandApplication app;
+ private WebView wv;
+
+ public SherpafyHtmlFragment() {
+ }
+
+
+ public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
+ Bundle savedInstanceState) {
+ app = (OsmandApplication) getSherlockActivity().getApplication();
+ wv = new WebView(getActivity());
+ return wv;
+ }
+
+ @Override
+ public void onViewCreated(final View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ String data = getArguments().getString(HTML);
+ String tl = getArguments().getString(TITLE);
+ if(tl != null){
+ getSherlockActivity().getSupportActionBar().setTitle(tl);
+ }
+ wv.loadData("
"+data+" parent, View view, int position,long arg3) {
+// view.findViewById(R.id.AreaPreview).setSelected(true);
+// }
+// });
}
protected void openAccessCode(final boolean startDownload) {
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyStageFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyStageFragment.java
new file mode 100644
index 0000000000..43ef4d6d4d
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyStageFragment.java
@@ -0,0 +1,201 @@
+package net.osmand.plus.sherpafy;
+
+import java.util.List;
+
+import net.osmand.access.AccessibleAlertBuilder;
+import net.osmand.plus.GPXUtilities.GPXFile;
+import net.osmand.plus.GPXUtilities.WptPt;
+import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
+import net.osmand.plus.OsmAndFormatter;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import net.osmand.plus.sherpafy.TourInformation.StageInformation;
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.Html.ImageGetter;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+import android.widget.ImageView;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import com.actionbarsherlock.app.SherlockFragment;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+public class SherpafyStageFragment extends SherlockFragment {
+ public static final String STAGE_PARAM = "STAGE";
+ public static final String TOUR_PARAM = "TOUR";
+ private static final int START = 8;
+ OsmandApplication app;
+ private SherpafyCustomization customization;
+ private StageInformation stage;
+ private TourInformation tour;
+ private View view;
+
+ public SherpafyStageFragment() {
+ }
+
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ app = (OsmandApplication) getSherlockActivity().getApplication();
+ customization = (SherpafyCustomization) app.getAppCustomization();
+
+ setHasOptionsMenu(true);
+ String id = getArguments().getString(TOUR_PARAM);
+ for(TourInformation ti : customization.getTourInformations()) {
+ if(ti.getId().equals(id)) {
+ tour = ti;
+ getSherlockActivity().getSupportActionBar().setTitle(tour.getName());
+ break;
+ }
+ }
+ int k = getArguments().getInt(STAGE_PARAM);
+ if(tour != null && tour.getStageInformation().size() > k) {
+ stage = tour.getStageInformation().get(k);
+ getSherlockActivity().getSupportActionBar().setTitle(getString(R.string.tab_stage) + " " + (k+1));
+ }
+ }
+
+
+
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ // createMenuItem(menu, ACTION_GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
+ // MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ if (tour != null) {
+ ((TourViewActivity) getSherlockActivity()).createMenuItem(menu, START, R.string.start_tour,
+ 0, 0,
+ MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == START) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ view = inflater.inflate(R.layout.sherpafy_stage_info, container, false);
+ WebView description = (WebView) view.findViewById(R.id.Description);
+ ImageView icon = (ImageView) view.findViewById(R.id.Icon);
+ TextView additional = (TextView) view.findViewById(R.id.AdditionalText);
+ TextView text = (TextView) view.findViewById(R.id.Text);
+ TextView header = (TextView) view.findViewById(R.id.HeaderText);
+
+ if(stage.getImageBitmap() != null) {
+ icon.setImageBitmap(stage.getImageBitmap()) ;
+ } else {
+ icon.setVisibility(View.GONE);
+ }
+ if (stage.getDistance() > 0) {
+ additional.setText(OsmAndFormatter.getFormattedDistance((float) stage.getDistance(), getMyApplication()));
+ } else {
+ additional.setText("");
+ }
+ header.setText(stage.getName());
+ text.setText(stage.getShortDescription());
+ description.loadData("" + stage.getFullDescription() + " imagewidth) {
+// bmp.setBounds(0, 0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());
+// } else {
+// double scale = (double) (displaySize.x - 1) / imagewidth;
+// bmp.setBounds(0, 0, (int) (scale * bmp.getIntrinsicWidth()),
+// (int) (scale * bmp.getIntrinsicHeight()));
+// }
+ return bmp;
+ }
+
+ };
+ }
+
+
+
+ private void addOnClickListener(final TextView tv) {
+ tv.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (v.getTag() instanceof Bitmap) {
+ final AccessibleAlertBuilder dlg = new AccessibleAlertBuilder(getActivity());
+ dlg.setPositiveButton(R.string.default_buttons_ok, null);
+ ScrollView sv = new ScrollView(getActivity());
+ ImageView img = new ImageView(getActivity());
+ img.setImageBitmap((Bitmap) tv.getTag());
+ sv.addView(img);
+ dlg.setView(sv);
+ dlg.show();
+ }
+ }
+ });
+ }
+
+ private void prepareBitmap(Bitmap imageBitmap) {
+ ImageView img = null;
+ if (imageBitmap != null) {
+ img.setImageBitmap(imageBitmap);
+ img.setAdjustViewBounds(true);
+ img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ img.setCropToPadding(true);
+ img.setVisibility(View.VISIBLE);
+ } else {
+ img.setVisibility(View.GONE);
+ }
+ }
+
+ private void goToMap() {
+ if (customization.getSelectedStage() != null) {
+ GPXFile gpx = customization.getSelectedStage().getGpx();
+ List sgpx = getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
+ if (gpx == null && sgpx.size() > 0) {
+ getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
+ } else if (sgpx.size() != 1 || sgpx.get(0).getGpxFile() != gpx) {
+ getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
+ if (gpx != null && gpx.findPointToShow() != null) {
+ WptPt p = gpx.findPointToShow();
+ getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null);
+ getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx);
+ }
+ }
+ }
+ Intent newIntent = new Intent(getActivity(), customization.getMapActivity());
+ newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ this.startActivityForResult(newIntent, 0);
+ }
+
+ private OsmandApplication getMyApplication() {
+ return (OsmandApplication) getActivity().getApplication();
+ }
+
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyTourOverviewFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyTourFragment.java
similarity index 58%
rename from OsmAnd/src/net/osmand/plus/sherpafy/SherpafyTourOverviewFragment.java
rename to OsmAnd/src/net/osmand/plus/sherpafy/SherpafyTourFragment.java
index 79a2dd926f..6cf7b4d374 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyTourOverviewFragment.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyTourFragment.java
@@ -3,23 +3,14 @@ package net.osmand.plus.sherpafy;
import java.util.ArrayList;
import java.util.List;
-import net.osmand.access.AccessibleAlertBuilder;
-import net.osmand.plus.GPXUtilities.GPXFile;
-import net.osmand.plus.GPXUtilities.WptPt;
-import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
+import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.actions.ShareDialog;
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
import net.osmand.util.Algorithms;
import android.app.Activity;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.text.Html;
-import android.text.Html.ImageGetter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -29,23 +20,23 @@ import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.ListView;
-import android.widget.ScrollView;
import android.widget.TextView;
-import android.widget.Toast;
import com.actionbarsherlock.app.SherlockListFragment;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
-public class SherpafyTourOverviewFragment extends SherlockListFragment {
+public class SherpafyTourFragment extends SherlockListFragment {
private static final int SHARE_ID = 6;
+ private static final int START = 7;
OsmandApplication app;
private SherpafyCustomization customization;
private TourInformation tour;
private StageAdapter stageAdapter;
+ private ImageView imageView;
- public SherpafyTourOverviewFragment() {
+ public SherpafyTourFragment() {
}
@@ -92,7 +83,20 @@ public class SherpafyTourOverviewFragment extends SherlockListFragment {
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
- Toast.makeText(getActivity(), getListAdapter().getItem(position).toString(), Toast.LENGTH_LONG).show();
+ if(position > 0) {
+ StageItem si = (StageItem) getListAdapter().getItem(position - 1);
+ if(si.type instanceof StageInformation) {
+ ((TourViewActivity) getSherlockActivity()).selectMenu(si.type);
+ } else {
+ if(si.type ==StageItemType.GALLERY) {
+ //((TourViewActivity) getSherlockActivity()).showGallery(tour);
+ } else if(si.type ==StageItemType.OVERVIEW) {
+ ((TourViewActivity) getSherlockActivity()).showHtmlFragment(si.header, tour.getFulldescription());
+ } else if(si.type ==StageItemType.INSTRUCTIONS) {
+ ((TourViewActivity) getSherlockActivity()).showHtmlFragment(si.header, tour.getInstructions());
+ }
+ }
+ }
}
@@ -101,9 +105,12 @@ public class SherpafyTourOverviewFragment extends SherlockListFragment {
// createMenuItem(menu, ACTION_GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
// MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
if (tour != null) {
- ((TourViewActivity) getSherlockActivity()).createMenuItem(menu, SHARE_ID, R.string.settings,
- R.drawable.ic_action_gshare_light, R.drawable.ic_action_gshare_dark,
+ ((TourViewActivity) getSherlockActivity()).createMenuItem(menu, START, R.string.start_tour,
+ 0, 0,
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ ((TourViewActivity) getSherlockActivity()).createMenuItem(menu, SHARE_ID, R.string.share_fav,
+ R.drawable.ic_action_gshare_light, R.drawable.ic_action_gshare_dark,
+ MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
}
@@ -124,16 +131,25 @@ public class SherpafyTourOverviewFragment extends SherlockListFragment {
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- List items = new ArrayList();
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View v = super.onCreateView(inflater, container, savedInstanceState);
+ imageView = new ImageView(getActivity());
+ imageView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
+ imageView.setScaleType(ScaleType.CENTER_CROP);
+ return v;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ List items = new ArrayList();
items.add(new StageItem(StageItemType.TEXT, "", getString(R.string.sherpafy_tour_info_txt), false));
items.add(new StageItem(StageItemType.OVERVIEW, getString(R.string.sherpafy_overview),
- getString(R.string.sherpafy_overview), false));
+ getString(R.string.sherpafy_overview_desr), false));
items.add(new StageItem(StageItemType.INSTRUCTIONS, getString(R.string.sherpafy_instructions),
- getString(R.string.sherpafy_instructions), false));
+ getString(R.string.sherpafy_instructions_desr), false));
items.add(new StageItem(StageItemType.GALLERY, getString(R.string.sherpafy_gallery),
- getString(R.string.sherpafy_gallery), false));
+ getString(R.string.sherpafy_gallery_descr), false));
items.add(new StageItem(StageItemType.TEXT, "", getString(R.string.sherpafy_stages_txt), true));
if (tour != null) {
for (StageInformation si : tour.getStageInformation()) {
@@ -141,17 +157,21 @@ public class SherpafyTourOverviewFragment extends SherlockListFragment {
items.add(it);
}
stageAdapter = new StageAdapter(items);
-
- ImageView iv = new ImageView(getActivity());
- iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
- iv.setScaleType(ScaleType.CENTER_CROP);
- iv.setImageBitmap(tour.getImageBitmap());
- getListView().addHeaderView(iv);
+ imageView.setImageBitmap(tour.getImageBitmap());
+ if(imageView != null) {
+ getListView().addHeaderView(imageView);
+ }
setListAdapter(stageAdapter);
}
}
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ setListAdapter(null);
+ }
+
class StageAdapter extends ArrayAdapter {
@@ -172,9 +192,13 @@ public class SherpafyTourOverviewFragment extends SherlockListFragment {
TextView text = (TextView) row.findViewById(R.id.Text);
TextView addtext = (TextView) row.findViewById(R.id.AdditionalText);
- if(ti.type instanceof StageInformation) {
- // TODO !!
- addtext.setText("10 km");
+ if (ti.type instanceof StageInformation) {
+ double d = ((StageInformation) ti.type).getDistance();
+ if (d > 0) {
+ addtext.setText(OsmAndFormatter.getFormattedDistance((float) d, getMyApplication()));
+ } else {
+ addtext.setText("");
+ }
} else {
addtext.setText("");
}
@@ -206,90 +230,13 @@ public class SherpafyTourOverviewFragment extends SherlockListFragment {
} else {
img.setVisibility(View.VISIBLE);
img.setImageDrawable(new StageImageDrawable(getActivity(),
- StageImageDrawable.INFO_COLOR, ti.txt.substring(0, 1) +"", 0 ));
+ StageImageDrawable.INFO_COLOR, ti.header.substring(0, 1) +"", 0 ));
}
return row;
}
}
- private ImageGetter getImageGetter(final View v) {
- return new Html.ImageGetter() {
- @Override
- public Drawable getDrawable(String s) {
- Bitmap file = customization.getSelectedTour().getImageBitmapFromPath(s);
- v.setTag(file);
- Drawable bmp = new BitmapDrawable(getResources(), file);
- // if image is thicker than screen - it may cause some problems, so we need to scale it
- int imagewidth = bmp.getIntrinsicWidth();
- // TODO
-// if (displaySize.x - 1 > imagewidth) {
-// bmp.setBounds(0, 0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());
-// } else {
-// double scale = (double) (displaySize.x - 1) / imagewidth;
-// bmp.setBounds(0, 0, (int) (scale * bmp.getIntrinsicWidth()),
-// (int) (scale * bmp.getIntrinsicHeight()));
-// }
- return bmp;
- }
-
- };
- }
-
-
-
- private void addOnClickListener(final TextView tv) {
- tv.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
- if (v.getTag() instanceof Bitmap) {
- final AccessibleAlertBuilder dlg = new AccessibleAlertBuilder(getActivity());
- dlg.setPositiveButton(R.string.default_buttons_ok, null);
- ScrollView sv = new ScrollView(getActivity());
- ImageView img = new ImageView(getActivity());
- img.setImageBitmap((Bitmap) tv.getTag());
- sv.addView(img);
- dlg.setView(sv);
- dlg.show();
- }
- }
- });
- }
-
- private void prepareBitmap(Bitmap imageBitmap) {
- ImageView img = null;
- if (imageBitmap != null) {
- img.setImageBitmap(imageBitmap);
- img.setAdjustViewBounds(true);
- img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
- img.setCropToPadding(true);
- img.setVisibility(View.VISIBLE);
- } else {
- img.setVisibility(View.GONE);
- }
- }
-
- private void goToMap() {
- if (customization.getSelectedStage() != null) {
- GPXFile gpx = customization.getSelectedStage().getGpx();
- List sgpx = getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
- if (gpx == null && sgpx.size() > 0) {
- getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
- } else if (sgpx.size() != 1 || sgpx.get(0).getGpxFile() != gpx) {
- getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
- if (gpx != null && gpx.findPointToShow() != null) {
- WptPt p = gpx.findPointToShow();
- getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null);
- getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx);
- }
- }
- }
- Intent newIntent = new Intent(getActivity(), customization.getMapActivity());
- newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
- this.startActivityForResult(newIntent, 0);
- }
-
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/StageImageDrawable.java b/OsmAnd/src/net/osmand/plus/sherpafy/StageImageDrawable.java
index b7088bfc7a..e9a0c1f31c 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/StageImageDrawable.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/StageImageDrawable.java
@@ -90,7 +90,7 @@ public class StageImageDrawable extends Drawable {
// bs.inset((int)(bs.width() - min + 3 * density) / 2,
// (int) (bs.height() - min + 3 * density) / 2);
if(textPaint != null) {
- textPaint.setTextSize(bs.height() * 3 / 4);
+ textPaint.setTextSize(bs.height() * 5 / 8);
}
if(drawable != null) {
drawable.setBounds(bs);
@@ -108,7 +108,7 @@ public class StageImageDrawable extends Drawable {
if (drawable != null) {
drawable.draw(canvas);
} else if(text != null ){
- canvas.drawText(text, cx, cy + 3 * rx / 8, textPaint);
+ canvas.drawText(text, cx, cy + rx / 2, textPaint);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java
index 163982ae9e..75bbb5753c 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourInformation.java
@@ -28,10 +28,12 @@ public class TourInformation {
private String homeUrl = "";
private String shortDescription = "";
private String fulldescription = "";
+ private String instructions = "";
private Bitmap defaultImg = null;
private File imgFile;
private List stageInformation = new ArrayList();
+
public TourInformation(File f) {
this.folder = f;
this.name = f.getName().replace('_', ' ');
@@ -41,6 +43,10 @@ public class TourInformation {
return folder.getName();
}
+ public String getInstructions() {
+ return instructions;
+ }
+
private static Reader getUTF8Reader(InputStream f) throws IOException {
BufferedInputStream bis = new BufferedInputStream(f);
@@ -78,6 +84,10 @@ public class TourInformation {
stage.name = name;
} else if (tag.equals("fullDescription")){
fulldescription = getInnerXml(parser);
+ } else if (tag.equals("instructions")){
+ instructions = getInnerXml(parser);
+ } else if (stage != null && tag.equals("interval")){
+ stage.distance = Double.parseDouble(getDefAttribute(parser, "distance", "0"));
} else if (stage != null && tag.equals("description")){
stage.fullDescription = getInnerXml(parser);
}
@@ -90,21 +100,23 @@ public class TourInformation {
stage = null;
} else if(stage != null && tag.equals("fullDescription")) {
stage.fullDescription = text;
- } else if(stage != null && tag.equals("image")) {
+ } else if(stage != null && tag.equals("defaultImage")) {
if(text.startsWith(FILE_PREFIX)) {
stage.imgFile = getFile(text);
}
+ } else if(tag.equals("defaultImage")) {
+ if(text.startsWith(FILE_PREFIX)) {
+ imgFile = getFile(text);
+ }
} else if(stage != null && tag.equals("gpx")) {
if(text.startsWith(FILE_PREFIX)) {
stage.gpxFile = getFile(text);
}
- } else if(tag.equals("fullDescription")) {
- fulldescription = text;
} else if(tag.equals("shortDescription")) {
- shortDescription = text;
- } else if(tag.equals("defaultImage")) {
- if(text.startsWith(FILE_PREFIX)) {
- imgFile = getFile(text);
+ if(stage != null) {
+ stage.shortDescription = text;
+ } else {
+ shortDescription = text;
}
}
text = "";
@@ -180,6 +192,7 @@ public class TourInformation {
String fullDescription = "";
Bitmap img = null;
File imgFile;
+ double distance;
private TourInformation tour;
private int order;
@@ -228,6 +241,10 @@ public class TourInformation {
public String toString() {
return name;
}
+
+ public double getDistance() {
+ return distance;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java
index 7b80d37abf..ed2295bf47 100644
--- a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java
+++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java
@@ -219,14 +219,14 @@ public class TourViewActivity extends SherlockFragmentActivity {
Fragment fragment = fragments.get(item);
if (new Integer(R.string.sherpafy_tours).equals(item)) {
if (fragment == null) {
- fragment = new SherpafyToursFragment();
+ fragment = new SherpafySelectToursFragment();
fragments.put(item, fragment);
}
state = STATE_SELECT_TOUR;
} else if(item instanceof TourInformation) {
state = STATE_TOUR_VIEW;
if (fragment == null) {
- fragment = new SherpafyTourOverviewFragment();
+ fragment = new SherpafyTourFragment();
Bundle bl = new Bundle();
bl.putString("TOUR", ((TourInformation) item).getId());
fragment.setArguments(bl);
@@ -234,6 +234,14 @@ public class TourViewActivity extends SherlockFragmentActivity {
}
} else if(item instanceof StageInformation) {
state = STATE_STAGE_OVERVIEW;
+ if (fragment == null) {
+ fragment = new SherpafyStageFragment();
+ Bundle bl = new Bundle();
+ bl.putString(SherpafyStageFragment.TOUR_PARAM, ((StageInformation) item).getTour().getId());
+ bl.putInt(SherpafyStageFragment.STAGE_PARAM, ((StageInformation) item).getOrder());
+ fragment.setArguments(bl);
+ fragments.put(item, fragment);
+ }
}
if(fragment != null) {
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
@@ -265,4 +273,18 @@ public class TourViewActivity extends SherlockFragmentActivity {
}
updateActionBarTitle();
}
+
+
+
+ public void showHtmlFragment(String title, String cont) {
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ SherpafyHtmlFragment fragment = new SherpafyHtmlFragment();
+ Bundle bl = new Bundle();
+ bl.putString(SherpafyHtmlFragment.HTML, cont);
+ bl.putString(SherpafyHtmlFragment.TITLE, title);
+ fragment.setArguments(bl);
+ fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
+ }
+
+
}