From f8623ccb12da655aee7e530c4745d4b66696069c Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Fri, 23 Oct 2015 05:19:25 -0700 Subject: [PATCH] Target API 22 since not yet updated for new permission model; fix beep problem that surfaces in Android 6; update plugins --- android/AndroidManifest.xml | 2 +- .../zxing/client/android/BeepManager.java | 18 +++++------------- pom.xml | 10 +++++----- zxingorg/pom.xml | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 3ea9e72d0..bd25a7d26 100755 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -30,7 +30,7 @@ - + diff --git a/android/src/com/google/zxing/client/android/BeepManager.java b/android/src/com/google/zxing/client/android/BeepManager.java index e7828598d..39779a0a0 100644 --- a/android/src/com/google/zxing/client/android/BeepManager.java +++ b/android/src/com/google/zxing/client/android/BeepManager.java @@ -32,8 +32,7 @@ import java.io.IOException; /** * Manages beeps and vibrations for {@link CaptureActivity}. */ -final class BeepManager implements - MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, Closeable { +final class BeepManager implements MediaPlayer.OnErrorListener, Closeable { private static final String TAG = BeepManager.class.getSimpleName(); @@ -87,9 +86,6 @@ final class BeepManager implements private MediaPlayer buildMediaPlayer(Context activity) { MediaPlayer mediaPlayer = new MediaPlayer(); - mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); - mediaPlayer.setOnCompletionListener(this); - mediaPlayer.setOnErrorListener(this); try { AssetFileDescriptor file = activity.getResources().openRawResourceFd(R.raw.beep); try { @@ -97,6 +93,9 @@ final class BeepManager implements } finally { file.close(); } + mediaPlayer.setOnErrorListener(this); + mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + mediaPlayer.setLooping(false); mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME); mediaPlayer.prepare(); return mediaPlayer; @@ -107,12 +106,6 @@ final class BeepManager implements } } - @Override - public void onCompletion(MediaPlayer mp) { - // When the beep has finished playing, rewind to queue up another one. - mp.seekTo(0); - } - @Override public synchronized boolean onError(MediaPlayer mp, int what, int extra) { if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) { @@ -120,8 +113,7 @@ final class BeepManager implements activity.finish(); } else { // possibly media player error, so release and recreate - mp.release(); - mediaPlayer = null; + close(); updatePrefs(); } return true; diff --git a/pom.xml b/pom.xml index 6718acf7a..1f239978e 100644 --- a/pom.xml +++ b/pom.xml @@ -210,7 +210,7 @@ org.apache.maven.plugins maven-clean-plugin - 2.6.1 + 3.0.0 @@ -277,7 +277,7 @@ org.apache.maven.plugins maven-release-plugin - 2.5.2 + 2.5.3 org.apache.maven.scm @@ -328,7 +328,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18.1 + 2.19 0.5C @@ -362,7 +362,7 @@ - 23 + 22 true @@ -417,7 +417,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.16 + 2.17 src/checkstyle/checkstyle.xml diff --git a/zxingorg/pom.xml b/zxingorg/pom.xml index 5887bf704..6af882a46 100644 --- a/zxingorg/pom.xml +++ b/zxingorg/pom.xml @@ -61,7 +61,7 @@ org.eclipse.jetty jetty-maven-plugin - 9.3.4.RC0 + 9.3.5.v20151012 src/web