Add default action to media button click

This commit is contained in:
Victor Shcherb 2015-01-15 09:55:30 +01:00
parent 2b80f2a887
commit 003f7c1baf
2 changed files with 13 additions and 2 deletions

View file

@ -507,7 +507,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
}
private void defaultAction(final MapActivity mapActivity) {
public void defaultAction(final MapActivity mapActivity) {
final Location loc = app.getLocationProvider().getLastKnownLocation();
// double lat = mapActivity.getMapView().getLatitude();
// double lon = mapActivity.getMapView().getLongitude();
@ -591,6 +591,15 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public void mapActivityPause(MapActivity activity) {
stopRecording(activity);
}
@Override
public void mapActivityResume(MapActivity activity) {
this.activity = activity;;
}
public MapActivity getActivity() {
return activity;
}
public void recordVideo(final double lat, final double lon, final MapActivity mapActivity) {
if (AV_EXTERNAL_RECORDER.get()) {

View file

@ -11,9 +11,11 @@ public class MediaRemoteControlReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
if(plugin != null && intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
if(plugin != null && intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null &&
plugin.getActivity() != null) {
// System.out.println("OsmAnd AV Button pressed " + intent.getIntExtra(Intent.EXTRA_KEY_EVENT, 0));
// Toast.makeText(context, "Button pressed " + intent.getIntExtra(Intent.EXTRA_KEY_EVENT, 0), Toast.LENGTH_LONG).show();
plugin.defaultAction(plugin.getActivity());
}
}
}