|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|