take photo/video/audion note actions; add action fragment bg fix;

This commit is contained in:
Korusn Oleksandr 2017-01-03 14:27:47 +02:00
parent 0187015cac
commit f2e81aa8f1
4 changed files with 147 additions and 0 deletions

View file

@ -2,6 +2,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:animateLayoutChanges="true"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">

View file

@ -4,6 +4,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/bg_color"
android:paddingTop="24dp"> android:paddingTop="24dp">
<TextView <TextView

View file

@ -2468,6 +2468,9 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_item_action">Action %d</string> <string name="quick_action_item_action">Action %d</string>
<string name="quick_action_item_screen">Screen %d</string> <string name="quick_action_item_screen">Screen %d</string>
<string name="quick_action_add_marker">Add marker</string> <string name="quick_action_add_marker">Add marker</string>
<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_add_gpx">Add GPX waypoint</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_add_parking">Add Parking place</string>
<string name="quick_action_new_action">Add action</string> <string name="quick_action_new_action">Add action</string>
@ -2484,6 +2487,9 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="text_name">Name</string> <string name="text_name">Name</string>
<string name="quick_action_add_marker_discr">Tap on action will add marker to the specified location.</string> <string name="quick_action_add_marker_discr">Tap on action will add marker to the specified location.</string>
<string name="quick_action_add_gpx_discr">Tap on action will add GPX waypiont to the specified location.</string> <string name="quick_action_add_gpx_discr">Tap on action will add GPX waypiont to the specified location.</string>
<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_add_parking_discr">Tap on action will add Parking place to the specified location.</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="quick_action_favorite_dialog">Show favorite dialog</string>
<string name="favorite_autofill_toast_text">" is saved to "</string> <string name="favorite_autofill_toast_text">" is saved to "</string>

View file

@ -21,6 +21,7 @@ import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
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.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment;
import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin; import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
@ -70,6 +71,9 @@ public class QuickActionFactory {
quickActions.add(new FavoriteAction()); quickActions.add(new FavoriteAction());
quickActions.add(new GPXAction()); quickActions.add(new GPXAction());
quickActions.add(new ParkingAction()); 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 QuickAction(0, R.string.quick_action_add_configure_map));
quickActions.add(new ShowHideFavoritesAction()); quickActions.add(new ShowHideFavoritesAction());
@ -103,6 +107,15 @@ public class QuickActionFactory {
case ParkingAction.TYPE: case ParkingAction.TYPE:
return new ParkingAction(); return new ParkingAction();
case TakeAudioNoteAction.TYPE:
return new TakeAudioNoteAction();
case TakePhotoNoteAction.TYPE:
return new TakePhotoNoteAction();
case TakeVideoNoteAction.TYPE:
return new TakeVideoNoteAction();
default: default:
return new QuickAction(); return new QuickAction();
} }
@ -133,6 +146,15 @@ public class QuickActionFactory {
case ParkingAction.TYPE: case ParkingAction.TYPE:
return new ParkingAction(quickAction); 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: default:
return quickAction; return quickAction;
} }
@ -566,4 +588,121 @@ public class QuickActionFactory {
parent.addView(view); 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);
}
}
} }