From f2e81aa8f1dcb395a3ea3d7fb67a157fd90bcee1 Mon Sep 17 00:00:00 2001 From: Korusn Oleksandr Date: Tue, 3 Jan 2017 14:27:47 +0200 Subject: [PATCH] take photo/video/audion note actions; add action fragment bg fix; --- OsmAnd/res/layout/map_hud_quick_actions.xml | 1 + OsmAnd/res/layout/quick_action_add_dialog.xml | 1 + OsmAnd/res/values/strings.xml | 6 + .../plus/quickaction/QuickActionFactory.java | 139 ++++++++++++++++++ 4 files changed, 147 insertions(+) diff --git a/OsmAnd/res/layout/map_hud_quick_actions.xml b/OsmAnd/res/layout/map_hud_quick_actions.xml index 110536ac21..1e16ae9ec4 100644 --- a/OsmAnd/res/layout/map_hud_quick_actions.xml +++ b/OsmAnd/res/layout/map_hud_quick_actions.xml @@ -2,6 +2,7 @@ diff --git a/OsmAnd/res/layout/quick_action_add_dialog.xml b/OsmAnd/res/layout/quick_action_add_dialog.xml index 34aae941b8..dccfad188a 100644 --- a/OsmAnd/res/layout/quick_action_add_dialog.xml +++ b/OsmAnd/res/layout/quick_action_add_dialog.xml @@ -4,6 +4,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="?attr/bg_color" android:paddingTop="24dp"> Action %d Screen %d Add marker + Take audio note + Take video note + Take photo note Add GPX waypoint Add Parking place Add action @@ -2484,6 +2487,9 @@ If you need help with OsmAnd application, please contact our support team: suppo Name Tap on action will add marker to the specified location. Tap on action will add GPX waypiont to the specified location. + 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 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 76926b364f..cd6a8d869d 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java @@ -21,6 +21,7 @@ import net.osmand.plus.GeocodingLookupService; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment; import net.osmand.plus.parkingpoint.ParkingPositionPlugin; @@ -70,6 +71,9 @@ public class QuickActionFactory { quickActions.add(new FavoriteAction()); quickActions.add(new GPXAction()); quickActions.add(new ParkingAction()); + quickActions.add(new TakeAudioNoteAction()); + quickActions.add(new TakePhotoNoteAction()); + quickActions.add(new TakeVideoNoteAction()); quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map)); quickActions.add(new ShowHideFavoritesAction()); @@ -103,6 +107,15 @@ public class QuickActionFactory { case ParkingAction.TYPE: return new ParkingAction(); + case TakeAudioNoteAction.TYPE: + return new TakeAudioNoteAction(); + + case TakePhotoNoteAction.TYPE: + return new TakePhotoNoteAction(); + + case TakeVideoNoteAction.TYPE: + return new TakeVideoNoteAction(); + default: return new QuickAction(); } @@ -133,6 +146,15 @@ public class QuickActionFactory { case ParkingAction.TYPE: return new ParkingAction(quickAction); + case TakeAudioNoteAction.TYPE: + return new TakeAudioNoteAction(quickAction); + + case TakePhotoNoteAction.TYPE: + return new TakePhotoNoteAction(quickAction); + + case TakeVideoNoteAction.TYPE: + return new TakeVideoNoteAction(quickAction); + default: return quickAction; } @@ -566,4 +588,121 @@ public class QuickActionFactory { parent.addView(view); } } + + public static class TakeAudioNoteAction extends QuickAction { + public static final int TYPE = 8; + + protected TakeAudioNoteAction() { + id = System.currentTimeMillis(); + type = TYPE; + nameRes = R.string.quick_action_take_audio_note; + iconRes = R.drawable.ic_action_micro_dark; + } + + public TakeAudioNoteAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + + LatLon latLon = activity.getMapView() + .getCurrentRotatedTileBox() + .getCenterLatLon(); + + AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class); + if (plugin != null) + plugin.recordAudio(latLon.getLatitude(), latLon.getLongitude(), activity); + } + + @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_take_audio_note_discr); + + parent.addView(view); + } + } + + public static class TakeVideoNoteAction extends QuickAction { + public static final int TYPE = 9; + + protected TakeVideoNoteAction() { + id = System.currentTimeMillis(); + type = TYPE; + nameRes = R.string.quick_action_take_video_note ; + iconRes = R.drawable.ic_action_video_dark; + } + + public TakeVideoNoteAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + + LatLon latLon = activity.getMapView() + .getCurrentRotatedTileBox() + .getCenterLatLon(); + + AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class); + if (plugin != null) + plugin.recordVideo(latLon.getLatitude(), latLon.getLongitude(), activity); + } + + @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_take_video_note_discr); + + parent.addView(view); + } + } + + public static class TakePhotoNoteAction extends QuickAction { + public static final int TYPE = 10; + + protected TakePhotoNoteAction() { + id = System.currentTimeMillis(); + type = TYPE; + nameRes = R.string.quick_action_take_photo_note; + iconRes = R.drawable.ic_action_photo_dark; + } + + public TakePhotoNoteAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + + LatLon latLon = activity.getMapView() + .getCurrentRotatedTileBox() + .getCenterLatLon(); + + AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class); + if (plugin != null) + plugin.takePhoto(latLon.getLatitude(), latLon.getLongitude(), activity, false); + } + + @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_take_photo_note_discr); + + parent.addView(view); + } + } }