- Fixed a crash on first launch after install on some hardware.

- Moved the beep sound to the music stream and made the volume keys work.
- Bumped the version to 3.0 beta 2.

git-svn-id: https://zxing.googlecode.com/svn/trunk@1080 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2009-10-20 18:09:40 +00:00
parent 967afc8e64
commit c36697c812
4 changed files with 17 additions and 6 deletions

View file

@ -20,8 +20,8 @@ version to be published. The next versionCode will be 7, regardless of whether t
versionName is 2.31, 2.4, or 3.0. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.zxing.client.android"
android:versionName="3.0 beta1"
android:versionCode="35">
android:versionName="3.0 beta2"
android:versionCode="36">
<!-- We require Donut (Android 1.6) or later. -->
<uses-sdk android:minSdkVersion="4"/>
<!-- Donut-specific flags which allow us to run on large and high dpi screens. -->

View file

@ -208,6 +208,9 @@ final class CameraManager {
*/
public Rect getFramingRect() {
if (framingRect == null) {
if (camera == null) {
return null;
}
int width = cameraResolution.x * 3 / 4;
if (width < MIN_FRAME_WIDTH) {
width = MIN_FRAME_WIDTH;

View file

@ -131,7 +131,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
@Override
public void onCreate(Bundle icicle) {
Log.i(TAG, "Creating CaptureActivity");
super.onCreate(icicle);
Window window = getWindow();
@ -244,7 +243,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, SHARE_ID, 0, R.string.menu_share).setIcon(R.drawable.share_menu_item);
menu.add(0, HISTORY_ID, 0, R.string.menu_history).setIcon(android.R.drawable.ic_menu_recent_history);
menu.add(0, HISTORY_ID, 0, R.string.menu_history)
.setIcon(android.R.drawable.ic_menu_recent_history);
menu.add(0, SETTINGS_ID, 0, R.string.menu_settings)
.setIcon(android.R.drawable.ic_menu_preferences);
menu.add(0, HELP_ID, 0, R.string.menu_help)
@ -479,7 +479,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
* run. The easiest way to do this is to check android:versionCode from the manifest, and compare
* it to a value stored as a preference.
*/
private void showHelpOnFirstLaunch() {
private boolean showHelpOnFirstLaunch() {
try {
PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0);
int currentVersion = info.versionCode;
@ -493,10 +493,12 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName(this, HelpActivity.class.getName());
startActivity(intent);
return true;
}
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, e);
}
return false;
}
/**
@ -505,8 +507,11 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
*/
private void initBeepSound() {
if (playBeep && mediaPlayer == null) {
// The volume on STREAM_SYSTEM is not adjustable, and users found it too loud,
// so we now play on the music stream.
setVolumeControlStream(AudioManager.STREAM_MUSIC);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_SYSTEM);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setOnCompletionListener(beepListener);
AssetFileDescriptor file = getResources().openRawResourceFd(R.raw.beep);

View file

@ -62,6 +62,9 @@ public final class ViewfinderView extends View {
@Override
public void onDraw(Canvas canvas) {
Rect frame = CameraManager.get().getFramingRect();
if (frame == null) {
return;
}
int width = canvas.getWidth();
int height = canvas.getHeight();