Added auto zoom map on/off quick action
This commit is contained in:
parent
df04784bc8
commit
a513966ba3
4 changed files with 90 additions and 0 deletions
|
@ -9,6 +9,10 @@
|
|||
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
|
||||
-->
|
||||
<string name="quick_action_auto_zoom">Auto zoom map on/off</string>
|
||||
<string name="quick_action_auto_zoom_desc">Tapping the action button will turn on/off auto zoom map according to your speed.</string>
|
||||
<string name="quick_action_auto_zoom_on">Auto zoom map on</string>
|
||||
<string name="quick_action_auto_zoom_off">Auto zoom map off</string>
|
||||
<string name="quick_action_add_destination">Add destination</string>
|
||||
<string name="quick_action_replace_destination">Replace destination</string>
|
||||
<string name="quick_action_add_first_intermediate">Add first intermediate</string>
|
||||
|
|
|
@ -955,6 +955,10 @@ public class OsmandSettings {
|
|||
RouteService.values()).makeProfile();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<AutoZoomMap> AUTO_ZOOM_MAP_PREV =
|
||||
new EnumIntPreference<AutoZoomMap>("auto_zoom_map_new_prev", AutoZoomMap.NONE,
|
||||
AutoZoomMap.values()).makeProfile().cache();
|
||||
|
||||
public final CommonPreference<AutoZoomMap> AUTO_ZOOM_MAP =
|
||||
new EnumIntPreference<AutoZoomMap>("auto_zoom_map_new", AutoZoomMap.NONE,
|
||||
AutoZoomMap.values()).makeProfile().cache();
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.osmand.plus.quickaction.actions.MapUnderlayAction;
|
|||
import net.osmand.plus.quickaction.actions.MarkerAction;
|
||||
import net.osmand.plus.quickaction.actions.NavAddDestinationAction;
|
||||
import net.osmand.plus.quickaction.actions.NavAddFirstIntermediateAction;
|
||||
import net.osmand.plus.quickaction.actions.NavAutoZoomMapAction;
|
||||
import net.osmand.plus.quickaction.actions.NavReplaceDestinationAction;
|
||||
import net.osmand.plus.quickaction.actions.NavVoiceAction;
|
||||
import net.osmand.plus.quickaction.actions.NewAction;
|
||||
|
@ -125,6 +126,7 @@ public class QuickActionFactory {
|
|||
QuickAction addDestination = new NavAddDestinationAction();
|
||||
QuickAction addFirstIntermediate = new NavAddFirstIntermediateAction();
|
||||
QuickAction replaceDestination = new NavReplaceDestinationAction();
|
||||
QuickAction autoZoomMap = new NavAutoZoomMapAction();
|
||||
|
||||
ArrayList<QuickAction> navigationQuickActions = new ArrayList<>();
|
||||
|
||||
|
@ -140,6 +142,9 @@ public class QuickActionFactory {
|
|||
if (!replaceDestination.hasInstanceInList(active)) {
|
||||
navigationQuickActions.add(replaceDestination);
|
||||
}
|
||||
if (!autoZoomMap.hasInstanceInList(active)) {
|
||||
navigationQuickActions.add(autoZoomMap);
|
||||
}
|
||||
|
||||
if (navigationQuickActions.size() > 0) {
|
||||
quickActions.add(new QuickAction(0, R.string.quick_action_add_navigation));
|
||||
|
@ -214,6 +219,9 @@ public class QuickActionFactory {
|
|||
case NavReplaceDestinationAction.TYPE:
|
||||
return new NavReplaceDestinationAction();
|
||||
|
||||
case NavAutoZoomMapAction.TYPE:
|
||||
return new NavAutoZoomMapAction();
|
||||
|
||||
default:
|
||||
return new QuickAction();
|
||||
}
|
||||
|
@ -283,6 +291,9 @@ public class QuickActionFactory {
|
|||
case NavReplaceDestinationAction.TYPE:
|
||||
return new NavReplaceDestinationAction(quickAction);
|
||||
|
||||
case NavAutoZoomMapAction.TYPE:
|
||||
return new NavAutoZoomMapAction(quickAction);
|
||||
|
||||
default:
|
||||
return quickAction;
|
||||
}
|
||||
|
@ -352,6 +363,9 @@ public class QuickActionFactory {
|
|||
case NavReplaceDestinationAction.TYPE:
|
||||
return R.drawable.ic_action_target;
|
||||
|
||||
case NavAutoZoomMapAction.TYPE:
|
||||
return R.drawable.ic_action_search_dark;
|
||||
|
||||
default:
|
||||
return R.drawable.ic_action_plus;
|
||||
}
|
||||
|
@ -421,6 +435,9 @@ public class QuickActionFactory {
|
|||
case NavReplaceDestinationAction.TYPE:
|
||||
return R.string.quick_action_replace_destination;
|
||||
|
||||
case NavAutoZoomMapAction.TYPE:
|
||||
return R.string.quick_action_auto_zoom;
|
||||
|
||||
default:
|
||||
return R.string.quick_action_new_action;
|
||||
}
|
||||
|
@ -442,6 +459,7 @@ public class QuickActionFactory {
|
|||
case NavAddDestinationAction.TYPE:
|
||||
case NavAddFirstIntermediateAction.TYPE:
|
||||
case NavReplaceDestinationAction.TYPE:
|
||||
case NavAutoZoomMapAction.TYPE:
|
||||
return false;
|
||||
|
||||
default: return true;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package net.osmand.plus.quickaction.actions;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
|
||||
public class NavAutoZoomMapAction extends QuickAction {
|
||||
|
||||
public static final int TYPE = 23;
|
||||
|
||||
public NavAutoZoomMapAction() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public NavAutoZoomMapAction(QuickAction quickAction) {
|
||||
super(quickAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapActivity activity) {
|
||||
|
||||
OsmandSettings settings = activity.getMyApplication().getSettings();
|
||||
if (settings.AUTO_ZOOM_MAP.get() == AutoZoomMap.NONE) {
|
||||
settings.AUTO_ZOOM_MAP.set(settings.AUTO_ZOOM_MAP_PREV.get());
|
||||
} else {
|
||||
settings.AUTO_ZOOM_MAP_PREV.set(settings.AUTO_ZOOM_MAP.get());
|
||||
settings.AUTO_ZOOM_MAP.set(AutoZoomMap.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawUI(ViewGroup parent, MapActivity activity) {
|
||||
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.quick_action_with_text, parent, false);
|
||||
|
||||
((TextView) view.findViewById(R.id.text)).setText(
|
||||
R.string.quick_action_auto_zoom_desc);
|
||||
|
||||
parent.addView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionText(OsmandApplication application) {
|
||||
|
||||
return application.getSettings().AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE
|
||||
? application.getString(R.string.quick_action_auto_zoom_off)
|
||||
: application.getString(R.string.quick_action_auto_zoom_on);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionWithSlash(OsmandApplication application) {
|
||||
|
||||
return application.getSettings().AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue