diff --git a/OsmAnd/res/layout/fragment_on_save_current_track.xml b/OsmAnd/res/layout/fragment_on_save_current_track.xml
index c4dc6ffd06..ea38ee7d03 100644
--- a/OsmAnd/res/layout/fragment_on_save_current_track.xml
+++ b/OsmAnd/res/layout/fragment_on_save_current_track.xml
@@ -21,19 +21,20 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingBottom="12dp">
+ android:paddingBottom="@dimen/content_padding_small">
@@ -41,14 +42,14 @@
android:id="@+id/show_on_map_button"
android:background="?attr/dlg_btn_primary"
android:layout_width="0dp"
- android:layout_height="@dimen/bottom_sheet_cancel_button_height"
+ android:layout_height="@dimen/bottom_sheet_cancel_button_height_small"
android:layout_weight="1"
- android:text="Show on the map"
- android:textAllCaps="true"
+ android:text="@string/shared_string_show_on_map"
+ android:textAllCaps="false"
android:textColor="?attr/dlg_btn_primary_text"
android:textSize="@dimen/default_desc_text_size"
- android:layout_marginLeft="8dp"
- android:layout_marginRight="16dp"
+ android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
+ android:layout_marginRight="@dimen/bottom_sheet_content_margin"
/>
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index d138a38e96..67418f1137 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,7 +11,8 @@
Thx - Hardy
-->
- saved
+ Open track
+ Track %s is saved
Wake on turn
Set the time for which the screen will turn on.
Use proximity sensor
diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java
index 63f3789102..273f22e2e2 100644
--- a/OsmAnd/src/net/osmand/AndroidUtils.java
+++ b/OsmAnd/src/net/osmand/AndroidUtils.java
@@ -13,6 +13,7 @@ import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PointF;
+import android.graphics.Typeface;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
@@ -31,10 +32,13 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.text.Spannable;
import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.text.style.ImageSpan;
+import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.util.DisplayMetrics;
import android.util.TypedValue;
@@ -551,4 +555,24 @@ public class AndroidUtils {
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager.inKeyguardRestrictedInputMode();
}
+
+ public static CharSequence insertStyledSubstring(CharSequence preFormattedString, CharSequence textToInsert, int typefaceStyle) {
+ final String placeholder = "%s";
+ if (typefaceStyle < 0 || typefaceStyle > 3) {
+ return preFormattedString;
+ }
+ if (!preFormattedString.toString().contains(placeholder)) {
+ return preFormattedString;
+ }
+ int indexOfPlaceholder = preFormattedString.toString().indexOf(placeholder);
+ SpannableStringBuilder ssb = new SpannableStringBuilder();
+ ssb.append(preFormattedString.subSequence(0, indexOfPlaceholder));
+ int startIndex = ssb.length();
+ ssb.append(textToInsert).append(" ");
+ ssb.setSpan(new StyleSpan(typefaceStyle), startIndex, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ startIndex = ssb.length();
+ ssb.append(preFormattedString.subSequence(indexOfPlaceholder+2, preFormattedString.length()));
+ ssb.setSpan(new StyleSpan(Typeface.NORMAL), startIndex, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return ssb;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java
index 6e9466fd61..3cfe963b02 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java
@@ -5,9 +5,6 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.style.StyleSpan;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
@@ -16,10 +13,15 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import java.io.File;
+import net.osmand.AndroidUtils;
+import net.osmand.GPXUtilities;
+import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment;
+import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
@@ -39,7 +41,7 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
} else {
dismiss();
}
-
+
final File f = new File (app.getAppCustomization().getTracksDir() +"/"+ savedGpxName + ".gpx");
final boolean nightMode = !app.getSettings().isLightContent();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
@@ -48,17 +50,9 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
TextView tv = mainView.findViewById(R.id.saved_track_name_string);
Button openTrackBtn = mainView.findViewById(R.id.open_track_button);
Button showOnMapBtn = mainView.findViewById(R.id.show_on_map_button);
-
- SpannableStringBuilder ssb = new SpannableStringBuilder();
- ssb.append(app.getResources().getString(R.string.shared_string_gpx_track)).append(" ");
- int startIndex = ssb.length();
- ssb.append(savedGpxName).append(" ");
- ssb.setSpan(new StyleSpan(Typeface.BOLD), startIndex, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- startIndex = ssb.length();
- ssb.append(app.getResources().getString(R.string.shared_string_saved));
- ssb.setSpan(new StyleSpan(Typeface.NORMAL), startIndex, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- tv.setText(ssb);
-
+
+ tv.setText(AndroidUtils.insertStyledSubstring(app.getString(R.string.shared_string_track_is_saved), savedGpxName, Typeface.BOLD));
+
openTrackBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -71,6 +65,18 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
@Override
public void onClick(View v) {
//show track on MapActivity
+ GpxInfo gpxInfo = new GpxInfo();
+ gpxInfo.setGpx(GPXUtilities.loadGPXFile(f));
+ boolean e = true;
+ if (gpxInfo.gpx != null) {
+ OsmandSettings settings = app.getSettings();
+ WptPt loc = gpxInfo.gpx.findPointToShow();
+ if (loc != null) {
+ settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
+ e = false;
+ app.getSelectedGpxHelper().setGpxFileToDisplay(gpxInfo.gpx);
+ }
+ }
dismiss();
}
});
@@ -84,5 +90,4 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
f.setArguments(b);
f.show(fragmentManager, TAG);
}
-
}