diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 5cd135a..9bba60d 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -14,6 +14,7 @@ diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 37a7509..d5d35ec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/.project b/.project new file mode 100644 index 0000000..d314d80 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + alzapp + Project alzapp created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + + + 1624798007654 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..27b37ed --- /dev/null +++ b/.settings/org.eclipse.buildship.core.prefs @@ -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 diff --git a/app/.classpath b/app/.classpath new file mode 100644 index 0000000..4a04201 --- /dev/null +++ b/app/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/.project b/app/.project new file mode 100644 index 0000000..d0462cc --- /dev/null +++ b/app/.project @@ -0,0 +1,34 @@ + + + app + Project app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + + + 1624798007678 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/app/.settings/org.eclipse.buildship.core.prefs b/app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..b1886ad --- /dev/null +++ b/app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir=.. +eclipse.preferences.version=1 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 49d4d45..4b48a3c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,6 @@ - diff --git a/app/src/main/java/com/example/alzapp/PuzzleMainActivity.java b/app/src/main/java/com/example/alzapp/PuzzleMainActivity.java deleted file mode 100644 index 223c18d..0000000 --- a/app/src/main/java/com/example/alzapp/PuzzleMainActivity.java +++ /dev/null @@ -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(); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/alzapp/QuickPlayMenu.java b/app/src/main/java/com/example/alzapp/QuickPlayMenu.java index 2c90381..5eecb69 100644 --- a/app/src/main/java/com/example/alzapp/QuickPlayMenu.java +++ b/app/src/main/java/com/example/alzapp/QuickPlayMenu.java @@ -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); - - } - }); diff --git a/app/src/main/java/com/example/alzapp/QuizQuestionPage.java b/app/src/main/java/com/example/alzapp/QuizQuestionPage.java index 2117f27..4556ce0 100644 --- a/app/src/main/java/com/example/alzapp/QuizQuestionPage.java +++ b/app/src/main/java/com/example/alzapp/QuizQuestionPage.java @@ -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 {