Edit Buttons and slideshow with arrows

This commit is contained in:
Gongxter 2015-11-30 18:02:00 +01:00
parent f28217bf46
commit 7242345a21
16 changed files with 152 additions and 28 deletions

View file

@ -1,8 +0,0 @@
package tu_darmstadt.sudoku.game.listeners;
/**
* Created by TMZ_LToP on 25.11.2015.
*/
public interface IStatsListener {
public void refresh();
}

View file

@ -98,8 +98,9 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
keyboard.setRowCount(2);
Point p = new Point();
getWindowManager().getDefaultDisplay().getSize(p);
//int width = p.x;
keyboard.setKeyBoard(gameController.getSize(), p.x);
keyboard.setKeyBoard(gameController.getSize(), p.x,layout.getHeight()-p.y);
//set Special keys

View file

@ -4,9 +4,9 @@ import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.widget.GridLayout;
import android.support.v7.widget.GridLayoutManager;
import tu_darmstadt.sudoku.controller.GameController;
import tu_darmstadt.sudoku.controller.Symbol;
@ -46,30 +46,43 @@ public class SudokuKeyboardLayout extends GridLayout {
public SudokuKeyboardLayout(Context context, AttributeSet attrs) {
super(context, attrs);
this.attrs = attrs;
}
public void setKeyBoard(int size,int width) {
public void setKeyBoard(int size,int width, int height) {
LayoutParams p ;
buttons = new SudokuButton[size];
int number = 0;
int torun = ((size)%2==0) ? (size)/2 :(size+1)/2 ;
int realSize = torun;
int width2 =(width-(realSize*30))/(realSize);
for (int k = 0; k<2;k++){
for (int i = 0; i< torun; i++){
if (number == size) {
break;
}
buttons[number] = new SudokuButton(getContext(),null);
p = new LayoutParams(GridLayout.spec(k,1),GridLayout.spec(i, 1));
p.setMargins(0,0,0,0);
int width2 =width/(realSize);
p.width= width2-15;
Spec rowSpec = spec(k,1);
Spec colSpec = spec(i,1);
p = (new LayoutParams(rowSpec,colSpec));
//p = new LayoutParams(rowSpec,colSpec);
p.setMargins((i == 0)?0:5,5,5,5);
p.width= (width-(int)((getResources().getDimension(R.dimen.activity_horizontal_margin))*2))/realSize;
p.width= p.width-10;
p.setGravity(LayoutParams.WRAP_CONTENT);
buttons[number].setLayoutParams(p);
buttons[number].setGravity(Gravity.CENTER);
//buttons[number].setGravity(Gravity.CENTER);
buttons[number].setType(SudokuButtonType.Value);
// TODO settings: get SymbolEnum from settings
buttons[number].setBackgroundResource(R.drawable.mnenomic_numpad_button);
buttons[number].setText(Symbol.getSymbol(symbolsToUse, number));
buttons[number].setValue(number + 1);
buttons[number].setOnClickListener(listener);
@ -81,6 +94,7 @@ public class SudokuKeyboardLayout extends GridLayout {
public void setGameController(GameController gc){
gameController=gc;
}
public void toggleNotesEnabled() {

View file

@ -81,14 +81,16 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
for (SudokuButtonType t : SudokuButtonType.getSpecialButtons()){
fixedButtons[i] = new SudokuButton(getContext(),null);
p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,1);
p.setMargins(0,0,0,0);
int width2 =width/(fixedButtonsCount);
p.width= width2-15;
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].setOnClickListener(listener);
fixedButtons[i].setBackgroundResource(R.drawable.numpad_highlighted_four);
addView(fixedButtons[i]);
i++;

View 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="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
</vector>

View 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="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"/>
</vector>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"
>
<gradient android:endColor="@color/middleblue" android:startColor="@color/middleblue" />
<corners android:radius="6dp" />
</shape>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@color/transparent"
android:endColor="@color/transparent"
android:angle="270" />
<corners android:radius="3dp" />
<stroke android:width="10px" android:color="@color/colorPrimaryDark" />
</shape>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"
>
<gradient android:endColor="@color/lightblue" android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="@color/colorPrimaryDark" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="@color/black" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="@color/yellow" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="@color/middleblue" />
</shape>

View file

@ -33,14 +33,30 @@
android:weightSum="10"
android:layout_marginTop="?attr/actionBarSize"
style="?android:buttonBarStyle">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4">
<android.support.v4.view.ViewPager
android:id="@+id/scroller"
android:layout_weight="4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_arrow_left_black_24dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -89,9 +105,11 @@
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"
android:elevation="10dp"/>
android:elevation="10dp"
android:background="@drawable/mnenomic_numpad_button"/>
<Button
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="30dp"
@ -103,7 +121,8 @@
android:layout_weight="2"
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"/>
android:clickable="false"
android:background="@drawable/mnenomic_numpad_button"/>
<LinearLayout
android:layout_width="match_parent"

View file

@ -18,14 +18,21 @@
android:clickable="true"
android:gravity="center" />
<tu_darmstadt.sudoku.ui.view.SudokuKeyboardLayout
android:layout_width="fill_parent"
android:minHeight="100dp"
android:layout_height="wrap_content"
android:layout_below="@+id/sudokuLayout"
android:id="@+id/sudokuKeyboardLayout"
android:layout_centerVertical="true">
android:layout_centerVertical="true"
android:useDefaultMargins="true"
android:alignmentMode="alignBounds"
android:columnOrderPreserved="false"
android:columnCount="6"
android:rowCount="2"
android:alwaysDrawnWithCache="true"
android:foregroundGravity="fill_horizontal"
android:layout_marginTop="5dp">
</tu_darmstadt.sudoku.ui.view.SudokuKeyboardLayout>
<tu_darmstadt.sudoku.ui.view.SudokuSpecialButtonLayout
@ -36,5 +43,4 @@
</tu_darmstadt.sudoku.ui.view.SudokuSpecialButtonLayout>
</RelativeLayout>

View file

@ -3,4 +3,11 @@
<color name="colorPrimary">#024265</color>
<color name="colorPrimaryDark">#024265</color>
<color name="colorAccent">#AA0000</color>
<color name="transparent">#00000000</color>
<color name="lightblue">#0274B2</color>
<color name="middleblue">#8aa5ce</color>
<color name="middlegrey">#A8A8A8</color>
<color name="yellow">#f6d126</color>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
</resources>