diff --git a/android/res/menu/capture.xml b/android/res/menu/capture.xml new file mode 100644 index 000000000..b965932ca --- /dev/null +++ b/android/res/menu/capture.xml @@ -0,0 +1,38 @@ + + +
\ No newline at end of file diff --git a/android/src/com/google/zxing/client/android/CaptureActivity.java b/android/src/com/google/zxing/client/android/CaptureActivity.java index dcf7ced6c..23d3a2035 100755 --- a/android/src/com/google/zxing/client/android/CaptureActivity.java +++ b/android/src/com/google/zxing/client/android/CaptureActivity.java @@ -52,6 +52,7 @@ import android.util.Log; import android.util.TypedValue; import android.view.KeyEvent; import android.view.Menu; +import android.view.MenuInflater; import android.view.MenuItem; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -85,12 +86,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal private static final String TAG = CaptureActivity.class.getSimpleName(); - private static final int SHARE_ID = Menu.FIRST; - private static final int HISTORY_ID = Menu.FIRST + 1; - private static final int SETTINGS_ID = Menu.FIRST + 2; - private static final int HELP_ID = Menu.FIRST + 3; - private static final int ABOUT_ID = Menu.FIRST + 4; - private static final long DEFAULT_INTENT_RESULT_DURATION_MS = 1500L; private static final long BULK_MODE_SCAN_DELAY_MS = 1000L; @@ -334,26 +329,9 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal @Override public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - menu.add(Menu.NONE, SHARE_ID, Menu.NONE, R.string.menu_share) - .setIcon(android.R.drawable.ic_menu_share); - menu.add(Menu.NONE, HISTORY_ID, Menu.NONE, R.string.menu_history) - .setIcon(android.R.drawable.ic_menu_recent_history); - menu.add(Menu.NONE, SETTINGS_ID, Menu.NONE, R.string.menu_settings) - .setIcon(android.R.drawable.ic_menu_preferences); - menu.add(Menu.NONE, HELP_ID, Menu.NONE, R.string.menu_help) - .setIcon(android.R.drawable.ic_menu_help); - menu.add(Menu.NONE, ABOUT_ID, Menu.NONE, R.string.menu_about) - .setIcon(android.R.drawable.ic_menu_info_details); - return true; - } - - // Don't display the share menu item if the result overlay is showing. - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - menu.findItem(SHARE_ID).setVisible(lastResult == null); - return true; + MenuInflater menuInflater = getMenuInflater(); + menuInflater.inflate(R.menu.capture, menu); + return super.onCreateOptionsMenu(menu); } @Override @@ -361,23 +339,23 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); switch (item.getItemId()) { - case SHARE_ID: + case R.id.menu_share: intent.setClassName(this, ShareActivity.class.getName()); startActivity(intent); break; - case HISTORY_ID: + case R.id.menu_history: intent.setClassName(this, HistoryActivity.class.getName()); startActivityForResult(intent, HISTORY_REQUEST_CODE); break; - case SETTINGS_ID: + case R.id.menu_settings: intent.setClassName(this, PreferencesActivity.class.getName()); startActivity(intent); break; - case HELP_ID: + case R.id.menu_help: intent.setClassName(this, HelpActivity.class.getName()); startActivity(intent); break; - case ABOUT_ID: + case R.id.menu_about: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.title_about) + versionName); builder.setMessage(getString(R.string.msg_about) + "\n\n" + getString(R.string.zxing_url));