UI KeyBoard
This commit is contained in:
parent
fcf095c3dd
commit
96a0b1d7ba
6 changed files with 154 additions and 6 deletions
|
@ -24,6 +24,7 @@
|
||||||
android:value="tu_darmstadt.sudoku.view.MainActivity" />
|
android:value="tu_darmstadt.sudoku.view.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
android:screenOrientation="portrait"
|
||||||
android:name=".GameActivity"
|
android:name=".GameActivity"
|
||||||
android:label="@string/title_activity_game_view"
|
android:label="@string/title_activity_game_view"
|
||||||
android:theme="@style/AppTheme.NoActionBar" >
|
android:theme="@style/AppTheme.NoActionBar" >
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import tu_darmstadt.sudoku.controller.GameController;
|
import tu_darmstadt.sudoku.controller.GameController;
|
||||||
|
@ -20,7 +21,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
|
||||||
|
|
||||||
GameController gameController = new GameController(GameType.Default_9x9);
|
GameController gameController = new GameController(GameType.Default_9x9);
|
||||||
SudokuFieldLayout layout;
|
SudokuFieldLayout layout;
|
||||||
|
SudokuButton [] buttons;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,6 +32,8 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
layout = (SudokuFieldLayout)findViewById(R.id.sudokuLayout);
|
layout = (SudokuFieldLayout)findViewById(R.id.sudokuLayout);
|
||||||
layout.setGame(gameController);
|
layout.setGame(gameController);
|
||||||
|
buttons = new SudokuButton[12];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// DEBUG
|
// DEBUG
|
||||||
String debug = gameController.getFieldAsString();
|
String debug = gameController.getFieldAsString();
|
||||||
|
|
14
app/src/main/java/tu_darmstadt/sudoku/view/SudokuButton.java
Normal file
14
app/src/main/java/tu_darmstadt/sudoku/view/SudokuButton.java
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package tu_darmstadt.sudoku.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by TMZ_LToP on 12.11.2015.
|
||||||
|
*/
|
||||||
|
public class SudokuButton extends Button {
|
||||||
|
public SudokuButton(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
}
|
|
@ -131,15 +131,15 @@ public class SudokuCellView extends View {
|
||||||
p.setTextSize(mWidth * 3 / 12);
|
p.setTextSize(mWidth * 3 / 12);
|
||||||
p.setTextAlign(Paint.Align.RIGHT);
|
p.setTextAlign(Paint.Align.RIGHT);
|
||||||
canvas.drawText(String.valueOf(i+1),(mWidth*1/12)*k,(mWidth*1/12)*j,p);
|
canvas.drawText(String.valueOf(i+1),(mWidth*1/12)*k,(mWidth*1/12)*j,p);
|
||||||
|
/*canvas.drawText(String.valueOf(1), (mWidth * 1 / 12)*3, (mWidth* 1 / 12)*3, p);
|
||||||
|
canvas.drawText(String.valueOf(2),(mWidth*1/12)*7, (mWidth* 1 / 12)*7,p );
|
||||||
|
canvas.drawText(String.valueOf(3),(mWidth*1/12)*11, (mWidth* 1 / 12)*11,p );*/
|
||||||
|
}
|
||||||
k+=4;
|
k+=4;
|
||||||
if (k > 11) {
|
if (k > 11) {
|
||||||
k = 3;
|
k = 3;
|
||||||
j +=4;
|
j +=4;
|
||||||
}
|
}
|
||||||
/*canvas.drawText(String.valueOf(1), (mWidth * 1 / 12)*3, (mWidth* 1 / 12)*3, p);
|
|
||||||
canvas.drawText(String.valueOf(2),(mWidth*1/12)*7, (mWidth* 1 / 12)*7,p );
|
|
||||||
canvas.drawText(String.valueOf(3),(mWidth*1/12)*11, (mWidth* 1 / 12)*11,p );*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package tu_darmstadt.sudoku.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by TMZ_LToP on 12.11.2015.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class SudokuKeyboardLayout extends RelativeLayout {
|
||||||
|
|
||||||
|
public SudokuKeyboardLayout(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,4 +16,109 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuKeyboardLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:id="@+id/sudokuKeyboardLayout"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="top"
|
||||||
|
>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuKeyboardLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center">
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button1"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="1"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button2"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="2"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button3"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="3"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button4"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="4"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button5"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="5"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button6"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="6"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</tu_darmstadt.sudoku.view.SudokuKeyboardLayout>
|
||||||
|
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuKeyboardLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="top"
|
||||||
|
android:layout_weight="1">
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button7"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="7"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button8"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="8"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/button9"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="9"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/buttonNote"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="not"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/buttonDel"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="Del"/>
|
||||||
|
<tu_darmstadt.sudoku.view.SudokuButton
|
||||||
|
android:id="@+id/buttonDum"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="6"
|
||||||
|
android:text="dum"/>
|
||||||
|
|
||||||
|
</tu_darmstadt.sudoku.view.SudokuKeyboardLayout>
|
||||||
|
|
||||||
|
</tu_darmstadt.sudoku.view.SudokuKeyboardLayout>
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue