quick action navigation voice on/off

This commit is contained in:
Rosty 2017-01-03 15:25:28 +02:00
parent f2e81aa8f1
commit 4c2935ce12
2 changed files with 47 additions and 0 deletions

View file

@ -2471,6 +2471,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_take_audio_note">Take audio note</string>
<string name="quick_action_take_video_note">Take video note</string>
<string name="quick_action_take_photo_note">Take photo note</string>
<string name="quick_action_navigation_voice">Voice On/Off</string>
<string name="quick_action_add_gpx">Add GPX waypoint</string>
<string name="quick_action_add_parking">Add Parking place</string>
<string name="quick_action_new_action">Add action</string>
@ -2490,6 +2491,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_take_audio_note_discr">Tap on action will add audio note to the specified location.</string>
<string name="quick_action_take_video_note_discr">Tap on action will add video note to the specified location.</string>
<string name="quick_action_take_photo_note_discr">Tap on action will add photo note to the specified location.</string>
<string name="quick_action_navigation_voice_discr">Tap on action will disable or enable voice during navigation.</string>
<string name="quick_action_add_parking_discr">Tap on action will add Parking place to the specified location.</string>
<string name="quick_action_favorite_dialog">Show favorite dialog</string>
<string name="favorite_autofill_toast_text">" is saved to "</string>

View file

@ -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);
}
}
}