Update order

This commit is contained in:
Victor Shcherb 2013-04-18 21:34:57 +02:00
parent 16a4f6d775
commit 11e27ec80a
4 changed files with 52 additions and 56 deletions

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="save_current_track_widget">Save
\n current GPX track</string>
<string name="tip_recent_changes_1_2_t">Changes in 1.2: <string name="tip_recent_changes_1_2_t">Changes in 1.2:
\n\t* Bug fixes (tuned routing, search, AV recording, voice prompts, some display improvements) \n\t* Bug fixes (tuned routing, search, AV recording, voice prompts, some display improvements)
\n\t* Easier hillshade overlay configuration (requires Contour Lines plugin) \n\t* Easier hillshade overlay configuration (requires Contour Lines plugin)

View file

@ -1,7 +1,7 @@
package net.osmand.plus.background; package net.osmand.plus.background;
import net.londatiga.android.ActionItem; import net.osmand.plus.ContextMenuAdapter;
import net.londatiga.android.QuickAction; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.NavigationService; import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -26,7 +26,6 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.view.View;
public class OsmandBackgroundServicePlugin extends OsmandPlugin implements MonitoringInfoControlServices { public class OsmandBackgroundServicePlugin extends OsmandPlugin implements MonitoringInfoControlServices {
public static final int[] SECONDS = new int[]{0, 30, 60, 90}; public static final int[] SECONDS = new int[]{0, 30, 60, 90};
@ -147,15 +146,13 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin implements Monit
} }
@Override @Override
public void addMonitorActions(final QuickAction qa, final MonitoringInfoControl li, final OsmandMapTileView view) { public void addMonitorActions(final ContextMenuAdapter qa, final MonitoringInfoControl li, final OsmandMapTileView view) {
final ActionItem bgServiceAction = new ActionItem();
final boolean off = view.getApplication().getNavigationService() == null; 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)); int msgId = !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)); int draw = !off? R.drawable.monitoring_rec_big : R.drawable.monitoring_rec_inactive;
bgServiceAction.setOnClickListener(new View.OnClickListener() { qa.registerItem(msgId, draw, new OnContextMenuClick() {
@Override @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); final Intent serviceIntent = new Intent(view.getContext(), NavigationService.class);
if (view.getApplication().getNavigationService() == null) { if (view.getApplication().getNavigationService() == null) {
final ValueHolder<Integer> vs = new ValueHolder<Integer>(); final ValueHolder<Integer> vs = new ValueHolder<Integer>();
@ -172,10 +169,7 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin implements Monit
} else { } else {
view.getContext().stopService(serviceIntent); view.getContext().stopService(serviceIntent);
} }
qa.dismiss();
} }
}); }, 0);
qa.addActionItem(bgServiceAction);
} }
} }

View file

@ -2,9 +2,6 @@ package net.osmand.plus.monitoring;
import java.util.EnumSet; import java.util.EnumSet;
import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; 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;
import net.osmand.plus.views.MonitoringInfoControl.MonitoringInfoControlServices; import net.osmand.plus.views.MonitoringInfoControl.MonitoringInfoControlServices;
import net.osmand.plus.views.MonitoringInfoControl.ValueHolder; 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.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView; 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; import org.apache.commons.logging.Log;
@ -256,14 +253,13 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} }
@Override @Override
public void addMonitorActions(final QuickAction qa, final MonitoringInfoControl li, final OsmandMapTileView view) { public void addMonitorActions(final ContextMenuAdapter qa, final MonitoringInfoControl li, final OsmandMapTileView view) {
final ActionItem bgServiceAction = new ActionItem();
final boolean off = !view.getSettings().SAVE_TRACK_TO_GPX.get(); 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)); qa.registerItem(off ? R.string.monitoring_mode_off : R.string.monitoring_mode_on, off ? R.drawable.monitoring_rec_inactive
bgServiceAction.setIcon(view.getResources().getDrawable(off ? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big)); : R.drawable.monitoring_rec_big, new OnContextMenuClick() {
bgServiceAction.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (off) { if (off) {
final ValueHolder<Integer> vs = new ValueHolder<Integer>(); final ValueHolder<Integer> vs = new ValueHolder<Integer>();
vs.value = view.getSettings().SAVE_TRACK_INTERVAL.get(); vs.value = view.getSettings().SAVE_TRACK_INTERVAL.get();
@ -279,18 +275,15 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} else { } else {
view.getSettings().SAVE_TRACK_TO_GPX.set(false); view.getSettings().SAVE_TRACK_TO_GPX.set(false);
} }
qa.dismiss();
} }
}); }, -1);
qa.addActionItem(bgServiceAction);
final ActionItem liveAction = new ActionItem();
final boolean liveoff = !view.getSettings().LIVE_MONITORING.get(); 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)); qa.registerItem(liveoff ? R.string.monitoring_mode_off : R.string.monitoring_mode_on,
liveAction.setIcon(view.getResources().getDrawable(liveoff? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big)); liveoff ? R.drawable.monitoring_rec_inactive: R.drawable.monitoring_rec_big,
liveAction.setOnClickListener(new View.OnClickListener() { new OnContextMenuClick() {
@Override @Override
public void onClick(View v) { public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (liveoff) { if (liveoff) {
final ValueHolder<Integer> vs = new ValueHolder<Integer>(); final ValueHolder<Integer> vs = new ValueHolder<Integer>();
vs.value = view.getSettings().LIVE_MONITORING_INTERVAL.get(); vs.value = view.getSettings().LIVE_MONITORING_INTERVAL.get();
@ -306,18 +299,14 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} else { } else {
view.getSettings().LIVE_MONITORING.set(false); view.getSettings().LIVE_MONITORING.set(false);
} }
qa.dismiss();
} }
}); }, -1);
qa.addActionItem(liveAction);
final ActionItem saveGPXAction = new ActionItem(); qa.registerItem(R.string.save_current_track_widget,
String s = view.getResources().getString(R.string.save_current_track); R.drawable.monitoring_rec_inactive,
saveGPXAction.setTitle(s.replaceFirst(" ", "\n")); new OnContextMenuClick() {
saveGPXAction.setIcon(view.getResources().getDrawable(R.drawable.monitoring_rec_inactive));
saveGPXAction.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
app.getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() { app.getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() {
@Override @Override
@ -328,18 +317,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
return null; return null;
} }
@Override
protected void onPostExecute(Void result) {
qa.dismiss();
}
}, null); }, null);
} }
}); }, -1);
qa.addActionItem(saveGPXAction);
} }
} }

View file

@ -3,7 +3,9 @@ package net.osmand.plus.views;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction; import net.londatiga.android.QuickAction;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -28,7 +30,7 @@ public class MonitoringInfoControl {
public interface MonitoringInfoControlServices { 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){ public void addMonitorActions(MonitoringInfoControlServices la){
@ -71,9 +73,27 @@ public class MonitoringInfoControl {
} }
private void showBgServiceQAction(final ImageView lockView, final OsmandMapTileView view, final MapActivity map) { 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){ 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(); qa.show();