Add recordings to local manager
This commit is contained in:
parent
ac54d2ea1e
commit
bfa8ea4519
5 changed files with 102 additions and 1 deletions
|
@ -40,7 +40,18 @@
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<receiver android:name="net.osmand.plus.audionotes.MediaRemoteControlReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.CAMERA_BUTTON" />
|
||||||
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
</activity>
|
</activity>
|
||||||
|
<receiver android:name="net.osmand.plus.audionotes.MediaRemoteControlReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
<activity android:name="net.osmand.plus.activities.SettingsActivity" android:label="@string/settings_activity" android:configChanges="keyboardHidden|orientation"></activity>
|
<activity android:name="net.osmand.plus.activities.SettingsActivity" android:label="@string/settings_activity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||||
<activity android:name="net.osmand.plus.activities.search.SearchActivity" android:label="@string/search_activity" ></activity>
|
<activity android:name="net.osmand.plus.activities.search.SearchActivity" android:label="@string/search_activity" ></activity>
|
||||||
<activity android:name="net.osmand.plus.activities.NavigatePointActivity"></activity>
|
<activity android:name="net.osmand.plus.activities.NavigatePointActivity"></activity>
|
||||||
|
|
|
@ -40,6 +40,7 @@ import net.osmand.plus.views.TextInfoControl;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -49,6 +50,7 @@ import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.BitmapFactory.Options;
|
import android.graphics.BitmapFactory.Options;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.media.ExifInterface;
|
import android.media.ExifInterface;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.media.MediaRecorder;
|
import android.media.MediaRecorder;
|
||||||
|
@ -78,6 +80,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
private static final String MPEG4_EXTENSION = "mp4";
|
private static final String MPEG4_EXTENSION = "mp4";
|
||||||
private static final String IMG_EXTENSION = "jpg";
|
private static final String IMG_EXTENSION = "jpg";
|
||||||
private static final Log log = LogUtil.getLog(AudioVideoNotesPlugin.class);
|
private static final Log log = LogUtil.getLog(AudioVideoNotesPlugin.class);
|
||||||
|
private static Method mRegisterMediaButtonEventReceiver;
|
||||||
|
private static Method mUnregisterMediaButtonEventReceiver;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private TextInfoControl recordControl;
|
private TextInfoControl recordControl;
|
||||||
|
|
||||||
|
@ -212,6 +216,27 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void initializeRemoteControlRegistrationMethods() {
|
||||||
|
try {
|
||||||
|
if (mRegisterMediaButtonEventReceiver == null) {
|
||||||
|
mRegisterMediaButtonEventReceiver = AudioManager.class.getMethod(
|
||||||
|
"registerMediaButtonEventReceiver",
|
||||||
|
new Class[] { ComponentName.class } );
|
||||||
|
}
|
||||||
|
if (mUnregisterMediaButtonEventReceiver == null) {
|
||||||
|
mUnregisterMediaButtonEventReceiver = AudioManager.class.getMethod(
|
||||||
|
"unregisterMediaButtonEventReceiver",
|
||||||
|
new Class[] { ComponentName.class } );
|
||||||
|
}
|
||||||
|
/* success, this device will take advantage of better remote */
|
||||||
|
/* control event handling */
|
||||||
|
} catch (NoSuchMethodException nsme) {
|
||||||
|
/* failure, still using the legacy behavior, but this app */
|
||||||
|
/* is future-proof! */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return ID;
|
return ID;
|
||||||
|
@ -234,8 +259,16 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean init(final OsmandApplication app) {
|
public boolean init(final OsmandApplication app) {
|
||||||
|
initializeRemoteControlRegistrationMethods();
|
||||||
|
AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
if(am != null){
|
||||||
|
registerMediaListener(am);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerLayers(MapActivity activity) {
|
public void registerLayers(MapActivity activity) {
|
||||||
|
@ -247,7 +280,35 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
activity.getMapView().addLayer(audioNotesLayer, 3.5f);
|
activity.getMapView().addLayer(audioNotesLayer, 3.5f);
|
||||||
registerWidget(activity);
|
registerWidget(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
@ -562,6 +623,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);
|
||||||
|
if(am != null){
|
||||||
|
unregisterMediaListener(am);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.osmand.plus.audionotes;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class MediaRemoteControlReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Toast.makeText(context, "Intent sent", Toast.LENGTH_LONG).show();
|
||||||
|
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
|
||||||
|
AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
|
||||||
|
if(plugin != null && intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,10 +12,12 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ParkingPluginActivity"
|
android:name=".ParkingPluginActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name" >
|
||||||
|
<!--
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
-->
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,11 @@
|
||||||
<activity
|
<activity
|
||||||
android:name="net.osmand.srtmPlugin.SRTMPluginActivity"
|
android:name="net.osmand.srtmPlugin.SRTMPluginActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name" >
|
||||||
|
<!--
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter> -->
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue