commit
4912f3993a
1 changed files with 53 additions and 53 deletions
|
@ -112,8 +112,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
private static final int TAKE_VIDEO_NOTE_ITEM_ORDER = 4300;
|
private static final int TAKE_VIDEO_NOTE_ITEM_ORDER = 4300;
|
||||||
private static final int TAKE_PHOTO_NOTE_ITEM_ORDER = 4500;
|
private static final int TAKE_PHOTO_NOTE_ITEM_ORDER = 4500;
|
||||||
|
|
||||||
private static Method mRegisterMediaButtonEventReceiver;
|
// private static Method mRegisterMediaButtonEventReceiver;
|
||||||
private static Method mUnregisterMediaButtonEventReceiver;
|
// private static Method mUnregisterMediaButtonEventReceiver;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private TextInfoWidget recordControl;
|
private TextInfoWidget recordControl;
|
||||||
|
|
||||||
|
@ -513,24 +513,24 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeRemoteControlRegistrationMethods() {
|
// private static void initializeRemoteControlRegistrationMethods() {
|
||||||
try {
|
// try {
|
||||||
// API 8
|
// API 8
|
||||||
if (mRegisterMediaButtonEventReceiver == null) {
|
// if (mRegisterMediaButtonEventReceiver == null) {
|
||||||
mRegisterMediaButtonEventReceiver = AudioManager.class.getMethod("registerMediaButtonEventReceiver",
|
// mRegisterMediaButtonEventReceiver = AudioManager.class.getMethod("registerMediaButtonEventReceiver",
|
||||||
new Class[]{ComponentName.class});
|
// new Class[]{ComponentName.class});
|
||||||
}
|
// }
|
||||||
if (mUnregisterMediaButtonEventReceiver == null) {
|
// if (mUnregisterMediaButtonEventReceiver == null) {
|
||||||
mUnregisterMediaButtonEventReceiver = AudioManager.class.getMethod("unregisterMediaButtonEventReceiver",
|
// mUnregisterMediaButtonEventReceiver = AudioManager.class.getMethod("unregisterMediaButtonEventReceiver",
|
||||||
new Class[]{ComponentName.class});
|
// new Class[]{ComponentName.class});
|
||||||
}
|
// }
|
||||||
/* success, this device will take advantage of better remote */
|
// /* success, this device will take advantage of better remote */
|
||||||
/* control event handling */
|
// /* control event handling */
|
||||||
} catch (NoSuchMethodException nsme) {
|
// } catch (NoSuchMethodException nsme) {
|
||||||
/* failure, still using the legacy behavior, but this app */
|
// /* failure, still using the legacy behavior, but this app */
|
||||||
/* is future-proof! */
|
// /* is future-proof! */
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -579,11 +579,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean init(@NonNull final OsmandApplication app, Activity activity) {
|
public boolean init(@NonNull final OsmandApplication app, Activity activity) {
|
||||||
initializeRemoteControlRegistrationMethods();
|
// initializeRemoteControlRegistrationMethods();
|
||||||
AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
|
// AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
|
||||||
if (am != null) {
|
// if (am != null) {
|
||||||
registerMediaListener(am);
|
// registerMediaListener(am);
|
||||||
}
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,30 +602,30 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
return currentRecording;
|
return currentRecording;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerMediaListener(AudioManager am) {
|
// private void registerMediaListener(AudioManager am) {
|
||||||
|
//
|
||||||
|
// ComponentName receiver = new ComponentName(app.getPackageName(), MediaRemoteControlReceiver.class.getName());
|
||||||
|
// try {
|
||||||
|
// if (mRegisterMediaButtonEventReceiver == null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// mRegisterMediaButtonEventReceiver.invoke(am, receiver);
|
||||||
|
// } catch (Exception ite) {
|
||||||
|
// log.error(ite.getMessage(), ite);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
ComponentName receiver = new ComponentName(app.getPackageName(), MediaRemoteControlReceiver.class.getName());
|
// private void unregisterMediaListener(AudioManager am) {
|
||||||
try {
|
// ComponentName receiver = new ComponentName(app.getPackageName(), MediaRemoteControlReceiver.class.getName());
|
||||||
if (mRegisterMediaButtonEventReceiver == null) {
|
// try {
|
||||||
return;
|
// if (mUnregisterMediaButtonEventReceiver == null) {
|
||||||
}
|
// return;
|
||||||
mRegisterMediaButtonEventReceiver.invoke(am, receiver);
|
// }
|
||||||
} catch (Exception ite) {
|
// mUnregisterMediaButtonEventReceiver.invoke(am, receiver);
|
||||||
log.error(ite.getMessage(), ite);
|
// } catch (Exception ite) {
|
||||||
}
|
// log.error(ite.getMessage(), ite);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
private void unregisterMediaListener(AudioManager am) {
|
|
||||||
ComponentName receiver = new ComponentName(app.getPackageName(), MediaRemoteControlReceiver.class.getName());
|
|
||||||
try {
|
|
||||||
if (mUnregisterMediaButtonEventReceiver == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mUnregisterMediaButtonEventReceiver.invoke(am, receiver);
|
|
||||||
} catch (Exception ite) {
|
|
||||||
log.error(ite.getMessage(), ite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
|
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
|
||||||
|
@ -869,8 +869,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void mapActivityResume(MapActivity activity) {
|
public void mapActivityResume(MapActivity activity) {
|
||||||
this.mapActivity = activity;
|
this.mapActivity = activity;
|
||||||
((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver(
|
// ((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver(
|
||||||
new ComponentName(activity, MediaRemoteControlReceiver.class));
|
// new ComponentName(activity, MediaRemoteControlReceiver.class));
|
||||||
if (runAction != -1) {
|
if (runAction != -1) {
|
||||||
takeAction(activity, actionLon, actionLat, runAction);
|
takeAction(activity, actionLon, actionLat, runAction);
|
||||||
runAction = -1;
|
runAction = -1;
|
||||||
|
@ -1712,10 +1712,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable(OsmandApplication app) {
|
public void disable(OsmandApplication app) {
|
||||||
AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
|
// AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
|
||||||
if (am != null) {
|
// if (am != null) {
|
||||||
unregisterMediaListener(am);
|
// unregisterMediaListener(am);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue