Fixes #3
This commit is contained in:
parent
25e5343cf5
commit
eaf3448aeb
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
</component>
|
||||
</project>
|
|
@ -14,6 +14,7 @@
|
|||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>alzapp</name>
|
||||
<comment>Project alzapp created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1624798007654</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
|
@ -0,0 +1,13 @@
|
|||
arguments=
|
||||
auto.sync=false
|
||||
build.scans.enabled=false
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||
connection.project.dir=
|
||||
eclipse.preferences.version=1
|
||||
gradle.user.home=
|
||||
java.home=C\:/Program Files/Java/jdk-11.0.8
|
||||
jvm.arguments=
|
||||
offline.mode=false
|
||||
override.workspace.settings=true
|
||||
show.console.view=true
|
||||
show.executions.view=true
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
</classpath>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>app</name>
|
||||
<comment>Project app created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1624798007678</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
connection.project.dir=..
|
||||
eclipse.preferences.version=1
|
|
@ -15,7 +15,6 @@
|
|||
<activity android:name=".QuizQuestionPage" />
|
||||
<activity android:name=".UserAreaActivity" />
|
||||
<activity android:name=".QuickPlayMenu" />
|
||||
<activity android:name=".PuzzleMainActivity"/>
|
||||
<activity android:name=".TileMatchingActivity" />
|
||||
<activity android:name=".WelcomeActivity" />
|
||||
<activity android:name=".JumbleActivity" />
|
||||
|
|
|
@ -1,322 +0,0 @@
|
|||
package com.example.alzapp;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Chronometer;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.example.alzapp.A_Star_Class_Solver.model.Board;
|
||||
import com.example.alzapp.A_Star_Class_Solver.model.Place;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
//import com.example.alzapp.A_Star_Class_Solver.model.R;
|
||||
|
||||
|
||||
public class PuzzleMainActivity extends AppCompatActivity {
|
||||
|
||||
/** The main view. */
|
||||
private ViewGroup mainView;
|
||||
|
||||
/** The game board. */
|
||||
private Board board;
|
||||
|
||||
/** The board view that generates the tiles and lines using 2-D graphics. */
|
||||
private BoardView boardView;
|
||||
|
||||
/** Text view to show the user the number of movements. */
|
||||
private TextView moves;
|
||||
|
||||
/** The board size. Default value is an 4x4 game. */
|
||||
private int boardSize = 4;
|
||||
|
||||
private Chronometer chronometer;
|
||||
public boolean running;
|
||||
|
||||
Button b;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see android.support.v7.app.ActionBarActivity#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_slide_tile_puzzle);
|
||||
mainView = (ViewGroup) findViewById(R.id.mainLayout);
|
||||
chronometer = (Chronometer) findViewById(R.id.slidingTileChronometer);
|
||||
moves = (TextView) findViewById(R.id.moves);
|
||||
moves.setTextColor(Color.WHITE);
|
||||
moves.setTextSize(20);
|
||||
this.newGame();
|
||||
|
||||
|
||||
b = findViewById(R.id.btnSelectImage);
|
||||
b.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
photoPickerIntent.setType("image/*");
|
||||
photoPickerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, false);
|
||||
startActivityForResult(Intent.createChooser(photoPickerIntent,"Complete Action Using"), 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!running) {
|
||||
chronometer.start();
|
||||
running = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 1 && resultCode == RESULT_OK && data != null) {
|
||||
Uri pickedImage = data.getData();
|
||||
String[] filePath = { MediaStore.Images.Media.DATA };
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(pickedImage));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
bitmap = resizeBitmapFitXY(this.boardView.getWidth(), this.boardView.getHeight(), bitmap);
|
||||
boardView.setBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap resizeBitmapFitXY(int width, int height, Bitmap bitmap){
|
||||
Bitmap background = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
float originalWidth = bitmap.getWidth(), originalHeight = bitmap.getHeight();
|
||||
Canvas canvas = new Canvas(background);
|
||||
float scale, xTranslation = 0.0f, yTranslation = 0.0f;
|
||||
if (originalWidth > originalHeight) {
|
||||
scale = height/originalHeight;
|
||||
xTranslation = (width - originalWidth * scale)/2.0f;
|
||||
}
|
||||
else {
|
||||
scale = width / originalWidth;
|
||||
yTranslation = (height - originalHeight * scale)/2.0f;
|
||||
}
|
||||
Matrix transformation = new Matrix();
|
||||
transformation.postTranslate(xTranslation, yTranslation);
|
||||
transformation.preScale(scale, scale);
|
||||
Paint paint = new Paint();
|
||||
paint.setFilterBitmap(true);
|
||||
canvas.drawBitmap(bitmap, transformation, paint);
|
||||
return background;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new game.
|
||||
*/
|
||||
private void newGame() {
|
||||
this.board = new Board(this.boardSize);
|
||||
this.board.addBoardChangeListener(boardChangeListener);
|
||||
this.board.rearrange();
|
||||
this.mainView.removeView(boardView);
|
||||
this.boardView = new BoardView(this, board);
|
||||
this.mainView.addView(boardView);
|
||||
this.moves.setText("Number of movements: 0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the size of the board
|
||||
*
|
||||
* @param newSize
|
||||
*/
|
||||
public void changeSize(int newSize) {
|
||||
if (newSize != this.boardSize) {
|
||||
this.boardSize = newSize;
|
||||
this.newGame();
|
||||
boardView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_settings:
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
SettingsDialogFragment settings = new SettingsDialogFragment(
|
||||
this.boardSize);
|
||||
settings.show(fm, "fragment_settings");
|
||||
break;
|
||||
case R.id.action_new_game:
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("New Game")
|
||||
.setMessage("Are you sure you want to begin a new game?")
|
||||
.setPositiveButton(android.R.string.yes,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
board.rearrange();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
// do nothing
|
||||
}
|
||||
}).setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
break;
|
||||
case R.id.action_help:
|
||||
boardView.autoSolve();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/** The board change listener. */
|
||||
private Board.BoardChangeListener boardChangeListener = new Board.BoardChangeListener() {
|
||||
public void tileSlid(Place from, Place to, int numOfMoves) {
|
||||
moves.setText("Number of movements: "
|
||||
+ Integer.toString(numOfMoves));
|
||||
}
|
||||
|
||||
public void solved(int numOfMoves) {
|
||||
moves.setText("Solved in " + Integer.toString(numOfMoves)
|
||||
+ " moves!");
|
||||
|
||||
if(running){
|
||||
chronometer.stop();
|
||||
running = false;
|
||||
}
|
||||
|
||||
Toast.makeText(getApplicationContext(), "You won!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The Class SettingsDialogFragment. Shows the settings alert dialog in
|
||||
* order to change the size of the board.
|
||||
*/
|
||||
public class SettingsDialogFragment extends DialogFragment {
|
||||
|
||||
/** The size. */
|
||||
private int size;
|
||||
|
||||
/**
|
||||
* Instantiates a new settings dialog fragment.
|
||||
*
|
||||
* @param size
|
||||
* the size
|
||||
*/
|
||||
public SettingsDialogFragment(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size.
|
||||
*
|
||||
* @param size
|
||||
* the new size
|
||||
*/
|
||||
void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size.
|
||||
*
|
||||
* @return the size
|
||||
*/
|
||||
int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* android.support.v4.app.DialogFragment#onCreateDialog(android.os.Bundle
|
||||
* )
|
||||
*/
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
// Set the dialog title
|
||||
builder.setTitle("Define the size of the puzzle")
|
||||
.setSingleChoiceItems(R.array.size_options, this.size - 2,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
setSize(which + 2);
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
.setPositiveButton("Change",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
((PuzzleMainActivity) getActivity())
|
||||
.changeSize(getSize());
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,14 +83,6 @@ public class QuickPlayMenu extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
slidingTiles.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(QuickPlayMenu.this,PuzzleMainActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
//import com.example.alzapp.Question;
|
||||
|
||||
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class QuizQuestionPage extends AppCompatActivity {
|
||||
|
|
Loading…
Reference in New Issue