Blue TU Theme added and drawables with first attempt to add animation to drawable
|
@ -130,7 +130,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
if(view instanceof Button) {
|
if(view instanceof Button) {
|
||||||
Button b = (Button)view;
|
Button b = (Button)view;
|
||||||
switch(b.getId()) {
|
switch(b.getId()) {
|
||||||
case R.id.aboutButton:
|
/**case R.id.aboutButton:
|
||||||
i = new Intent(this, AboutActivity.class);
|
i = new Intent(this, AboutActivity.class);
|
||||||
break;
|
break;
|
||||||
case R.id.continueButton:
|
case R.id.continueButton:
|
||||||
|
@ -144,7 +144,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
break;
|
break;
|
||||||
case R.id.helpButton:
|
case R.id.helpButton:
|
||||||
// TODO: create help page.. what is supposed to be in there?!
|
// TODO: create help page.. what is supposed to be in there?!
|
||||||
break;
|
break;*/
|
||||||
case R.id.playButton:
|
case R.id.playButton:
|
||||||
GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
|
GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
|
||||||
int index = difficultyBar.getProgress()-1;
|
int index = difficultyBar.getProgress()-1;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package tu_darmstadt.sudoku.ui.view;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package tu_darmstadt.sudoku.ui.view;
|
package tu_darmstadt.sudoku.ui.view;
|
||||||
|
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -7,15 +10,25 @@ import java.util.List;
|
||||||
* Created by Chris on 15.11.2015.
|
* Created by Chris on 15.11.2015.
|
||||||
*/
|
*/
|
||||||
public enum SudokuButtonType {
|
public enum SudokuButtonType {
|
||||||
Unspecified,
|
Unspecified(R.drawable.ic_accessibility_black_48dp),// placeholder
|
||||||
Value,
|
Value(R.drawable.ic_accessibility_black_48dp), // should be non picture
|
||||||
Do,
|
Do(R.drawable.ic_redo_black_48dp),
|
||||||
Undo,
|
Undo(R.drawable.ic_undo_black_48dp),
|
||||||
Hint,
|
Hint(R.drawable.ic_lightbulb_outline_black_48dp),
|
||||||
NoteToggle,
|
NoteToggle(R.drawable.ic_create_black_48dp),
|
||||||
NumberOrCellFirst,
|
NumberOrCellFirst(R.drawable.ic_accessibility_black_48dp),//placeholder
|
||||||
Delete,
|
Delete(R.drawable.ic_delete_black_48dp),
|
||||||
Reset;
|
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<SudokuButtonType> getSpecialButtons() {
|
public static List<SudokuButtonType> getSpecialButtons() {
|
||||||
ArrayList<SudokuButtonType> result = new ArrayList<SudokuButtonType>();
|
ArrayList<SudokuButtonType> result = new ArrayList<SudokuButtonType>();
|
||||||
|
|
|
@ -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; }
|
||||||
|
}
|
|
@ -1,10 +1,22 @@
|
||||||
package tu_darmstadt.sudoku.ui.view;
|
package tu_darmstadt.sudoku.ui.view;
|
||||||
|
|
||||||
import android.content.Context;
|
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.util.AttributeSet;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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 android.widget.LinearLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -18,7 +30,7 @@ import tu_darmstadt.sudoku.game.GameBoard;
|
||||||
*/
|
*/
|
||||||
public class SudokuSpecialButtonLayout extends LinearLayout {
|
public class SudokuSpecialButtonLayout extends LinearLayout {
|
||||||
|
|
||||||
SudokuButton [] fixedButtons;
|
SudokuSpecialButton[] fixedButtons;
|
||||||
public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size();
|
public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size();
|
||||||
GameController gameController;
|
GameController gameController;
|
||||||
SudokuKeyboardLayout keyboard;
|
SudokuKeyboardLayout keyboard;
|
||||||
|
@ -27,8 +39,8 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
|
||||||
OnClickListener listener = new OnClickListener() {
|
OnClickListener listener = new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(v instanceof SudokuButton) {
|
if(v instanceof SudokuSpecialButton) {
|
||||||
SudokuButton btn = (SudokuButton)v;
|
SudokuSpecialButton btn = (SudokuSpecialButton)v;
|
||||||
|
|
||||||
int row = gameController.getSelectedRow();
|
int row = gameController.getSelectedRow();
|
||||||
int col = gameController.getSelectedCol();
|
int col = gameController.getSelectedCol();
|
||||||
|
@ -38,7 +50,22 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
|
||||||
gameController.deleteSelectedValue();
|
gameController.deleteSelectedValue();
|
||||||
break;
|
break;
|
||||||
case NoteToggle:
|
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();
|
keyboard.toggleNotesEnabled();
|
||||||
break;
|
break;
|
||||||
case Do:
|
case Do:
|
||||||
|
@ -74,21 +101,23 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
|
||||||
public void setButtons(int width, GameController gc,SudokuKeyboardLayout key) {
|
public void setButtons(int width, GameController gc,SudokuKeyboardLayout key) {
|
||||||
keyboard=key;
|
keyboard=key;
|
||||||
gameController = gc;
|
gameController = gc;
|
||||||
fixedButtons = new SudokuButton[fixedButtonsCount];
|
fixedButtons = new SudokuSpecialButton[fixedButtonsCount];
|
||||||
LayoutParams p;
|
LayoutParams p;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
//ArrayList<SudokuButtonType> type = (ArrayList<SudokuButtonType>) SudokuButtonType.getSpecialButtons();
|
//ArrayList<SudokuButtonType> type = (ArrayList<SudokuButtonType>) SudokuButtonType.getSpecialButtons();
|
||||||
for (SudokuButtonType t : 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 = 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);
|
//int width2 =width/(fixedButtonsCount);
|
||||||
//p.width= width2-15;
|
//p.width= width2-15;
|
||||||
fixedButtons[i].setLayoutParams(p);
|
fixedButtons[i].setLayoutParams(p);
|
||||||
fixedButtons[i].setGravity(Gravity.CENTER);
|
|
||||||
fixedButtons[i].setType(t);
|
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].setOnClickListener(listener);
|
||||||
fixedButtons[i].setBackgroundResource(R.drawable.numpad_highlighted_four);
|
fixedButtons[i].setBackgroundResource(R.drawable.numpad_highlighted_four);
|
||||||
addView(fixedButtons[i]);
|
addView(fixedButtons[i]);
|
||||||
|
|
BIN
app/src/main/res/drawable/ic_accessibility_black_48dp.png
Normal file
After Width: | Height: | Size: 572 B |
9
app/src/main/res/drawable/ic_create_black_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
|
||||||
|
</vector>
|
BIN
app/src/main/res/drawable/ic_create_black_48dp.png
Normal file
After Width: | Height: | Size: 578 B |
9
app/src/main/res/drawable/ic_delete_black_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
||||||
|
</vector>
|
BIN
app/src/main/res/drawable/ic_delete_black_48dp.png
Normal file
After Width: | Height: | Size: 498 B |
BIN
app/src/main/res/drawable/ic_lightbulb_outline_black_48dp.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable/ic_redo_black_48dp.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/main/res/drawable/ic_undo_black_48dp.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
|
@ -110,7 +110,7 @@
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
android:id="@+id/playButton"
|
android:id="@+id/playButton"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_weight="2"
|
android:layout_weight="3"
|
||||||
android:onClick="onClick"
|
android:onClick="onClick"
|
||||||
android:capitalize="none"
|
android:capitalize="none"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
android:background="@drawable/mnenomic_numpad_button"/>
|
android:background="@drawable/mnenomic_numpad_button"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="20dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginLeft="30dp"
|
android:layout_marginLeft="30dp"
|
||||||
|
@ -127,12 +127,12 @@
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
android:id="@+id/continueButton"
|
android:id="@+id/continueButton"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_weight="2"
|
android:layout_weight="3"
|
||||||
android:onClick="onClick"
|
android:onClick="onClick"
|
||||||
android:capitalize="none"
|
android:capitalize="none"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:background="@drawable/mnenomic_numpad_button"/>
|
android:background="@drawable/mnenomic_numpad_button"/>
|
||||||
|
<!--
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
@ -197,6 +197,7 @@
|
||||||
android:capitalize="none"
|
android:capitalize="none"
|
||||||
android:clickable="false"/>
|
android:clickable="false"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
-->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|