Merge pull request #794 from asmorkalov:android_no_layout

pull/793/merge
Andrey Kamaev 12 years ago committed by OpenCV Buildbot
commit 7711fe2f43
  1. 11
      samples/android/15-puzzle/res/layout/activity_puzzle15.xml
  2. 6
      samples/android/15-puzzle/res/menu/activity_puzzle15.xml
  3. 18
      samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java

@ -1,11 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.opencv.android.JavaCameraView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/puzzle_activity_surface_view" />
</LinearLayout>

@ -1,6 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_start_new_game"
android:title="@string/menu_start_new_game"
android:orderInCategory="100" />
<item android:id="@+id/menu_toggle_tile_numbers" android:title="@string/menu_toggle_tile_numbers"></item>
</menu>

@ -6,6 +6,7 @@ import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat; import org.opencv.core.Mat;
import org.opencv.android.CameraBridgeViewBase; import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener; import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
import org.opencv.android.JavaCameraView;
import android.os.Bundle; import android.os.Bundle;
import android.app.Activity; import android.app.Activity;
@ -22,6 +23,9 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
private CameraBridgeViewBase mOpenCvCameraView; private CameraBridgeViewBase mOpenCvCameraView;
private Puzzle15Processor mPuzzle15; private Puzzle15Processor mPuzzle15;
private MenuItem mItemHideNumbers;
private MenuItem mItemStartNewGame;
private int mGameWidth; private int mGameWidth;
private int mGameHeight; private int mGameHeight;
@ -52,9 +56,9 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_puzzle15); Log.d(TAG, "Creating and seting view");
mOpenCvCameraView = (CameraBridgeViewBase) new JavaCameraView(this, -1);
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.puzzle_activity_surface_view); setContentView(mOpenCvCameraView);
mOpenCvCameraView.setCvCameraViewListener(this); mOpenCvCameraView.setCvCameraViewListener(this);
mPuzzle15 = new Puzzle15Processor(); mPuzzle15 = new Puzzle15Processor();
mPuzzle15.prepareNewGame(); mPuzzle15.prepareNewGame();
@ -83,17 +87,19 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_puzzle15, menu); Log.i(TAG, "called onCreateOptionsMenu");
mItemHideNumbers = menu.add("Show/hide tile numbers");
mItemStartNewGame = menu.add("Start new game");
return true; return true;
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
Log.i(TAG, "Menu Item selected " + item); Log.i(TAG, "Menu Item selected " + item);
if (item.getItemId() == R.id.menu_start_new_game) { if (item == mItemStartNewGame) {
/* We need to start new game */ /* We need to start new game */
mPuzzle15.prepareNewGame(); mPuzzle15.prepareNewGame();
} else if (item.getItemId() == R.id.menu_toggle_tile_numbers) { } else if (item == mItemHideNumbers) {
/* We need to enable or disable drawing of the tile numbers */ /* We need to enable or disable drawing of the tile numbers */
mPuzzle15.toggleTileNumbers(); mPuzzle15.toggleTileNumbers();
} }

Loading…
Cancel
Save