diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java index 58beb21..f9a3722 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java @@ -130,7 +130,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On if(view instanceof Button) { Button b = (Button)view; switch(b.getId()) { - case R.id.aboutButton: + /**case R.id.aboutButton: i = new Intent(this, AboutActivity.class); break; case R.id.continueButton: @@ -144,7 +144,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On break; case R.id.helpButton: // TODO: create help page.. what is supposed to be in there?! - break; + break;*/ case R.id.playButton: GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem()); int index = difficultyBar.getProgress()-1; diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java index 9cb8c9e..86c7337 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java @@ -3,6 +3,7 @@ package tu_darmstadt.sudoku.ui.view; import android.content.Context; import android.util.AttributeSet; import android.widget.Button; +import android.widget.ImageButton; import android.widget.ToggleButton; /** diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButtonType.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButtonType.java index 88939b7..4c51bb1 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButtonType.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButtonType.java @@ -1,5 +1,8 @@ package tu_darmstadt.sudoku.ui.view; +import android.support.annotation.DrawableRes; +import android.support.annotation.StringRes; + import java.util.ArrayList; import java.util.List; @@ -7,15 +10,25 @@ import java.util.List; * Created by Chris on 15.11.2015. */ public enum SudokuButtonType { - Unspecified, - Value, - Do, - Undo, - Hint, - NoteToggle, - NumberOrCellFirst, - Delete, - Reset; + Unspecified(R.drawable.ic_accessibility_black_48dp),// placeholder + Value(R.drawable.ic_accessibility_black_48dp), // should be non picture + Do(R.drawable.ic_redo_black_48dp), + Undo(R.drawable.ic_undo_black_48dp), + Hint(R.drawable.ic_lightbulb_outline_black_48dp), + NoteToggle(R.drawable.ic_create_black_48dp), + NumberOrCellFirst(R.drawable.ic_accessibility_black_48dp),//placeholder + Delete(R.drawable.ic_delete_black_48dp), + Reset(R.drawable.ic_settings_backup_restore_black_48dp); + + private int resID; + + SudokuButtonType(@DrawableRes int res){ + this.resID = res; + } + + public int getResID() { + return resID; + } public static List getSpecialButtons() { ArrayList result = new ArrayList(); diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButton.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButton.java new file mode 100644 index 0000000..b490de3 --- /dev/null +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButton.java @@ -0,0 +1,22 @@ +package tu_darmstadt.sudoku.ui.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ImageButton; + +/** + * Created by TMZ_LToP on 07.12.2015. + */ +public class SudokuSpecialButton extends ImageButton{ + private int value = -1; + private SudokuButtonType type = SudokuButtonType.Unspecified; + + public SudokuSpecialButton(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setValue(int value) { this.value = value; } + public void setType(SudokuButtonType type) { this.type = type; } + public int getValue () { return value; } + public SudokuButtonType getType() { return type; } +} diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java index a935db9..e778b38 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java @@ -1,10 +1,22 @@ package tu_darmstadt.sudoku.ui.view; import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.RotateDrawable; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.RotateAnimation; +import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.LinearLayout; import java.util.ArrayList; @@ -18,7 +30,7 @@ import tu_darmstadt.sudoku.game.GameBoard; */ public class SudokuSpecialButtonLayout extends LinearLayout { - SudokuButton [] fixedButtons; + SudokuSpecialButton[] fixedButtons; public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size(); GameController gameController; SudokuKeyboardLayout keyboard; @@ -27,8 +39,8 @@ public class SudokuSpecialButtonLayout extends LinearLayout { OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { - if(v instanceof SudokuButton) { - SudokuButton btn = (SudokuButton)v; + if(v instanceof SudokuSpecialButton) { + SudokuSpecialButton btn = (SudokuSpecialButton)v; int row = gameController.getSelectedRow(); int col = gameController.getSelectedCol(); @@ -38,7 +50,22 @@ public class SudokuSpecialButtonLayout extends LinearLayout { gameController.deleteSelectedValue(); break; case NoteToggle: - btn.setText(keyboard.notesEnabled ? "ON" : "OFF"); + //btn.setText(keyboard.notesEnabled ? "ON" : "OFF"); + //TODO: add rotation + + AnimationSet aniset = new AnimationSet(true); + aniset.setInterpolator(new DecelerateInterpolator()); + aniset.setFillAfter(true); + aniset.setFillEnabled(true); + + RotateAnimation rotate = new RotateAnimation(0.0f,(keyboard.notesEnabled ? 90.0f:-90.0f), + RotateAnimation.RELATIVE_TO_SELF,0.5f, + Animation.RELATIVE_TO_SELF,0.5f); + rotate.setDuration(1500); + rotate.setFillAfter(true); + aniset.addAnimation(rotate); + + btn.startAnimation(aniset); keyboard.toggleNotesEnabled(); break; case Do: @@ -74,21 +101,23 @@ public class SudokuSpecialButtonLayout extends LinearLayout { public void setButtons(int width, GameController gc,SudokuKeyboardLayout key) { keyboard=key; gameController = gc; - fixedButtons = new SudokuButton[fixedButtonsCount]; + fixedButtons = new SudokuSpecialButton[fixedButtonsCount]; LayoutParams p; int i = 0; //ArrayList type = (ArrayList) SudokuButtonType.getSpecialButtons(); for (SudokuButtonType t : SudokuButtonType.getSpecialButtons()){ - fixedButtons[i] = new SudokuButton(getContext(),null); + fixedButtons[i] = new SudokuSpecialButton(getContext(),null); p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,1); - p.setMargins(5,5,5,5); + p.setMargins(5, 5, 5, 5); //int width2 =width/(fixedButtonsCount); //p.width= width2-15; fixedButtons[i].setLayoutParams(p); - fixedButtons[i].setGravity(Gravity.CENTER); fixedButtons[i].setType(t); - fixedButtons[i].setText(SudokuButtonType.getName(t)); + fixedButtons[i].setImageDrawable(getResources().getDrawable(t.getResID())); + // fixedButtons[i].setText(SudokuButtonType.getName(t)); + fixedButtons[i].setScaleType(ImageView.ScaleType.CENTER); + fixedButtons[i].setAdjustViewBounds(true); fixedButtons[i].setOnClickListener(listener); fixedButtons[i].setBackgroundResource(R.drawable.numpad_highlighted_four); addView(fixedButtons[i]); diff --git a/app/src/main/res/drawable/ic_accessibility_black_48dp.png b/app/src/main/res/drawable/ic_accessibility_black_48dp.png new file mode 100644 index 0000000..46d736a Binary files /dev/null and b/app/src/main/res/drawable/ic_accessibility_black_48dp.png differ diff --git a/app/src/main/res/drawable/ic_create_black_24dp.xml b/app/src/main/res/drawable/ic_create_black_24dp.xml new file mode 100644 index 0000000..2ab2fb7 --- /dev/null +++ b/app/src/main/res/drawable/ic_create_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_create_black_48dp.png b/app/src/main/res/drawable/ic_create_black_48dp.png new file mode 100644 index 0000000..a09d362 Binary files /dev/null and b/app/src/main/res/drawable/ic_create_black_48dp.png differ diff --git a/app/src/main/res/drawable/ic_delete_black_24dp.xml b/app/src/main/res/drawable/ic_delete_black_24dp.xml new file mode 100644 index 0000000..39e64d6 --- /dev/null +++ b/app/src/main/res/drawable/ic_delete_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_delete_black_48dp.png b/app/src/main/res/drawable/ic_delete_black_48dp.png new file mode 100644 index 0000000..c259012 Binary files /dev/null and b/app/src/main/res/drawable/ic_delete_black_48dp.png differ diff --git a/app/src/main/res/drawable/ic_lightbulb_outline_black_48dp.png b/app/src/main/res/drawable/ic_lightbulb_outline_black_48dp.png new file mode 100644 index 0000000..1116049 Binary files /dev/null and b/app/src/main/res/drawable/ic_lightbulb_outline_black_48dp.png differ diff --git a/app/src/main/res/drawable/ic_redo_black_48dp.png b/app/src/main/res/drawable/ic_redo_black_48dp.png new file mode 100644 index 0000000..a8ab30c Binary files /dev/null and b/app/src/main/res/drawable/ic_redo_black_48dp.png differ diff --git a/app/src/main/res/drawable/ic_settings_backup_restore_black_48dp.png b/app/src/main/res/drawable/ic_settings_backup_restore_black_48dp.png new file mode 100644 index 0000000..be0716c Binary files /dev/null and b/app/src/main/res/drawable/ic_settings_backup_restore_black_48dp.png differ diff --git a/app/src/main/res/drawable/ic_undo_black_48dp.png b/app/src/main/res/drawable/ic_undo_black_48dp.png new file mode 100644 index 0000000..ce458bd Binary files /dev/null and b/app/src/main/res/drawable/ic_undo_black_48dp.png differ diff --git a/app/src/main/res/layout/activity_main_menu.xml b/app/src/main/res/layout/activity_main_menu.xml index 719e01e..4a0bc96 100644 --- a/app/src/main/res/layout/activity_main_menu.xml +++ b/app/src/main/res/layout/activity_main_menu.xml @@ -110,7 +110,7 @@ android:textStyle="normal" android:id="@+id/playButton" android:layout_gravity="center_horizontal" - android:layout_weight="2" + android:layout_weight="3" android:onClick="onClick" android:capitalize="none" android:clickable="false" @@ -118,7 +118,7 @@ android:background="@drawable/mnenomic_numpad_button"/>