diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 702812234d..5040bdd7fc 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Save
+ \n current GPX track
Changes in 1.2:
\n\t* Bug fixes (tuned routing, search, AV recording, voice prompts, some display improvements)
\n\t* Easier hillshade overlay configuration (requires Contour Lines plugin)
diff --git a/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java b/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java
index e7cdfd6075..bf2df0f067 100644
--- a/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java
+++ b/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java
@@ -1,7 +1,7 @@
package net.osmand.plus.background;
-import net.londatiga.android.ActionItem;
-import net.londatiga.android.QuickAction;
+import net.osmand.plus.ContextMenuAdapter;
+import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@@ -26,7 +26,6 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
-import android.view.View;
public class OsmandBackgroundServicePlugin extends OsmandPlugin implements MonitoringInfoControlServices {
public static final int[] SECONDS = new int[]{0, 30, 60, 90};
@@ -147,15 +146,13 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin implements Monit
}
@Override
- public void addMonitorActions(final QuickAction qa, final MonitoringInfoControl li, final OsmandMapTileView view) {
-
- final ActionItem bgServiceAction = new ActionItem();
+ public void addMonitorActions(final ContextMenuAdapter qa, final MonitoringInfoControl li, final OsmandMapTileView view) {
final boolean off = view.getApplication().getNavigationService() == null;
- bgServiceAction.setTitle(view.getResources().getString(!off? R.string.bg_service_sleep_mode_on : R.string.bg_service_sleep_mode_off));
- bgServiceAction.setIcon(view.getResources().getDrawable(!off? R.drawable.monitoring_rec_big : R.drawable.monitoring_rec_inactive));
- bgServiceAction.setOnClickListener(new View.OnClickListener() {
+ int msgId = !off? R.string.bg_service_sleep_mode_on : R.string.bg_service_sleep_mode_off;
+ int draw = !off? R.drawable.monitoring_rec_big : R.drawable.monitoring_rec_inactive;
+ qa.registerItem(msgId, draw, new OnContextMenuClick() {
@Override
- public void onClick(View v) {
+ public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
final Intent serviceIntent = new Intent(view.getContext(), NavigationService.class);
if (view.getApplication().getNavigationService() == null) {
final ValueHolder vs = new ValueHolder();
@@ -172,10 +169,7 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin implements Monit
} else {
view.getContext().stopService(serviceIntent);
}
- qa.dismiss();
}
- });
- qa.addActionItem(bgServiceAction);
-
+ }, 0);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
index 16e37c2ca5..a38c06ef13 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
@@ -2,9 +2,6 @@ package net.osmand.plus.monitoring;
import java.util.EnumSet;
-
-import net.londatiga.android.ActionItem;
-import net.londatiga.android.QuickAction;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
@@ -23,10 +20,10 @@ import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MonitoringInfoControl;
import net.osmand.plus.views.MonitoringInfoControl.MonitoringInfoControlServices;
import net.osmand.plus.views.MonitoringInfoControl.ValueHolder;
-import net.osmand.plus.views.mapwidgets.BaseMapWidget;
-import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
+import net.osmand.plus.views.mapwidgets.BaseMapWidget;
+import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import org.apache.commons.logging.Log;
@@ -256,14 +253,13 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
}
@Override
- public void addMonitorActions(final QuickAction qa, final MonitoringInfoControl li, final OsmandMapTileView view) {
- final ActionItem bgServiceAction = new ActionItem();
+ public void addMonitorActions(final ContextMenuAdapter qa, final MonitoringInfoControl li, final OsmandMapTileView view) {
final boolean off = !view.getSettings().SAVE_TRACK_TO_GPX.get();
- bgServiceAction.setTitle(view.getResources().getString(off? R.string.monitoring_mode_off : R.string.monitoring_mode_on));
- bgServiceAction.setIcon(view.getResources().getDrawable(off ? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big));
- bgServiceAction.setOnClickListener(new View.OnClickListener() {
+ qa.registerItem(off ? R.string.monitoring_mode_off : R.string.monitoring_mode_on, off ? R.drawable.monitoring_rec_inactive
+ : R.drawable.monitoring_rec_big, new OnContextMenuClick() {
+
@Override
- public void onClick(View v) {
+ public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (off) {
final ValueHolder vs = new ValueHolder();
vs.value = view.getSettings().SAVE_TRACK_INTERVAL.get();
@@ -279,18 +275,15 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} else {
view.getSettings().SAVE_TRACK_TO_GPX.set(false);
}
- qa.dismiss();
}
- });
- qa.addActionItem(bgServiceAction);
+ }, -1);
- final ActionItem liveAction = new ActionItem();
final boolean liveoff = !view.getSettings().LIVE_MONITORING.get();
- liveAction.setTitle(view.getResources().getString(liveoff? R.string.live_monitoring_mode_off : R.string.live_monitoring_mode_on));
- liveAction.setIcon(view.getResources().getDrawable(liveoff? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big));
- liveAction.setOnClickListener(new View.OnClickListener() {
+ qa.registerItem(liveoff ? R.string.monitoring_mode_off : R.string.monitoring_mode_on,
+ liveoff ? R.drawable.monitoring_rec_inactive: R.drawable.monitoring_rec_big,
+ new OnContextMenuClick() {
@Override
- public void onClick(View v) {
+ public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (liveoff) {
final ValueHolder vs = new ValueHolder();
vs.value = view.getSettings().LIVE_MONITORING_INTERVAL.get();
@@ -306,18 +299,14 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} else {
view.getSettings().LIVE_MONITORING.set(false);
}
- qa.dismiss();
}
- });
- qa.addActionItem(liveAction);
+ }, -1);
- final ActionItem saveGPXAction = new ActionItem();
- String s = view.getResources().getString(R.string.save_current_track);
- saveGPXAction.setTitle(s.replaceFirst(" ", "\n"));
- saveGPXAction.setIcon(view.getResources().getDrawable(R.drawable.monitoring_rec_inactive));
- saveGPXAction.setOnClickListener(new View.OnClickListener() {
+ qa.registerItem(R.string.save_current_track_widget,
+ R.drawable.monitoring_rec_inactive,
+ new OnContextMenuClick() {
@Override
- public void onClick(View v) {
+ public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
app.getTaskManager().runInBackground(new OsmAndTaskRunnable() {
@Override
@@ -327,19 +316,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
helper.close();
return null;
}
-
- @Override
- protected void onPostExecute(Void result) {
- qa.dismiss();
- }
+
}, null);
-
}
- });
- qa.addActionItem(saveGPXAction);
-
-
-
+ }, -1);
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/views/MonitoringInfoControl.java b/OsmAnd/src/net/osmand/plus/views/MonitoringInfoControl.java
index c76b5a75eb..a8e0d2e453 100644
--- a/OsmAnd/src/net/osmand/plus/views/MonitoringInfoControl.java
+++ b/OsmAnd/src/net/osmand/plus/views/MonitoringInfoControl.java
@@ -3,7 +3,9 @@ package net.osmand.plus.views;
import java.util.ArrayList;
import java.util.List;
+import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction;
+import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@@ -28,7 +30,7 @@ public class MonitoringInfoControl {
public interface MonitoringInfoControlServices {
- public void addMonitorActions(QuickAction qa, MonitoringInfoControl li, OsmandMapTileView view);
+ public void addMonitorActions(ContextMenuAdapter ca, MonitoringInfoControl li, OsmandMapTileView view);
}
public void addMonitorActions(MonitoringInfoControlServices la){
@@ -71,9 +73,27 @@ public class MonitoringInfoControl {
}
private void showBgServiceQAction(final ImageView lockView, final OsmandMapTileView view, final MapActivity map) {
- final QuickAction qa = new QuickAction(lockView);
+ final ContextMenuAdapter ca = new ContextMenuAdapter(map);
for(MonitoringInfoControlServices la : monitoringServices){
- la.addMonitorActions(qa, this, view);
+ la.addMonitorActions(ca, this, view);
+ }
+ final QuickAction qa = new QuickAction(lockView);
+ String[] itemNames = ca.getItemNames();
+ for(int i = 0; i < ca.length(); i++) {
+ final int ij = i;
+ ActionItem ai = new ActionItem();
+ ai.setTitle(itemNames[ij]);
+ if(ca.getImageId(ij) != 0) {
+ ai.setIcon(view.getResources().getDrawable(ca.getImageId(ij)));
+ }
+ ai.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ca.getClickAdapter(ij).onContextMenuClick(ca.getItemId(ij), ij, false, null);
+ qa.dismiss();
+ }
+ });
+ qa.addActionItem(ai);
}
qa.show();