From 4c2935ce1287eb247a9f7ac6dc3a625d77dd98b9 Mon Sep 17 00:00:00 2001 From: Rosty Date: Tue, 3 Jan 2017 15:25:28 +0200 Subject: [PATCH] quick action navigation voice on/off --- OsmAnd/res/values/strings.xml | 2 + .../plus/quickaction/QuickActionFactory.java | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index dc192b7f5b..95f12bd3c6 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2471,6 +2471,7 @@ If you need help with OsmAnd application, please contact our support team: suppo Take audio note Take video note Take photo note + Voice On/Off Add GPX waypoint Add Parking place Add action @@ -2490,6 +2491,7 @@ If you need help with OsmAnd application, please contact our support team: suppo Tap on action will add audio note to the specified location. Tap on action will add video note to the specified location. Tap on action will add photo note to the specified location. + Tap on action will disable or enable voice during navigation. Tap on action will add Parking place to the specified location. Show favorite dialog " is saved to " diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java index cd6a8d869d..bcc36e0a28 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java @@ -79,6 +79,9 @@ public class QuickActionFactory { quickActions.add(new ShowHideFavoritesAction()); quickActions.add(new ShowHidePoiAction()); + quickActions.add(new QuickAction(0, R.string.quick_action_add_navigation)); + quickActions.add(new NavigationVoiceAction()); + return quickActions; } @@ -116,6 +119,9 @@ public class QuickActionFactory { case TakeVideoNoteAction.TYPE: return new TakeVideoNoteAction(); + case NavigationVoiceAction.TYPE: + return new NavigationVoiceAction(); + default: return new QuickAction(); } @@ -155,6 +161,9 @@ public class QuickActionFactory { case TakeVideoNoteAction.TYPE: return new TakeVideoNoteAction(quickAction); + case NavigationVoiceAction.TYPE: + return new NavigationVoiceAction(quickAction); + default: return quickAction; } @@ -705,4 +714,40 @@ public class QuickActionFactory { parent.addView(view); } } + + public static class NavigationVoiceAction extends QuickAction { + public static final int TYPE = 11; + + protected NavigationVoiceAction() { + id = System.currentTimeMillis(); + type = TYPE; + nameRes = R.string.quick_action_navigation_voice; + iconRes = R.drawable.ic_action_volume_up; + } + + public NavigationVoiceAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + + boolean voice = activity.getMyApplication().getSettings().VOICE_MUTE.get(); + + activity.getMyApplication().getSettings().VOICE_MUTE.set(!voice); + activity.getRoutingHelper().getVoiceRouter().setMute(!voice); + } + + @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_navigation_voice_discr); + + parent.addView(view); + } + } }