From 96a0b1d7ba89b0edf8d5628683b3f156317d39d8 Mon Sep 17 00:00:00 2001 From: Gongxter Date: Fri, 13 Nov 2015 13:40:36 +0100 Subject: [PATCH] UI KeyBoard --- app/src/main/AndroidManifest.xml | 1 + .../sudoku/view/GameActivity.java | 5 +- .../sudoku/view/SudokuButton.java | 14 +++ .../sudoku/view/SudokuCellView.java | 10 +- .../sudoku/view/SudokuKeyboardLayout.java | 25 +++++ app/src/main/res/layout/content_game_view.xml | 105 ++++++++++++++++++ 6 files changed, 154 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/tu_darmstadt/sudoku/view/SudokuButton.java create mode 100644 app/src/main/java/tu_darmstadt/sudoku/view/SudokuKeyboardLayout.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5aedd69..d7551eb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ android:value="tu_darmstadt.sudoku.view.MainActivity" /> diff --git a/app/src/main/java/tu_darmstadt/sudoku/view/GameActivity.java b/app/src/main/java/tu_darmstadt/sudoku/view/GameActivity.java index 738a416..1ab0557 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/view/GameActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/view/GameActivity.java @@ -11,6 +11,7 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import android.view.ViewGroup; 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); SudokuFieldLayout layout; - + SudokuButton [] buttons; @Override @@ -31,6 +32,8 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On setSupportActionBar(toolbar); layout = (SudokuFieldLayout)findViewById(R.id.sudokuLayout); layout.setGame(gameController); + buttons = new SudokuButton[12]; + /* // DEBUG String debug = gameController.getFieldAsString(); diff --git a/app/src/main/java/tu_darmstadt/sudoku/view/SudokuButton.java b/app/src/main/java/tu_darmstadt/sudoku/view/SudokuButton.java new file mode 100644 index 0000000..c785e18 --- /dev/null +++ b/app/src/main/java/tu_darmstadt/sudoku/view/SudokuButton.java @@ -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); + } +} diff --git a/app/src/main/java/tu_darmstadt/sudoku/view/SudokuCellView.java b/app/src/main/java/tu_darmstadt/sudoku/view/SudokuCellView.java index afdebcf..26c9ba3 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/view/SudokuCellView.java +++ b/app/src/main/java/tu_darmstadt/sudoku/view/SudokuCellView.java @@ -131,15 +131,15 @@ public class SudokuCellView extends View { p.setTextSize(mWidth * 3 / 12); p.setTextAlign(Paint.Align.RIGHT); canvas.drawText(String.valueOf(i+1),(mWidth*1/12)*k,(mWidth*1/12)*j,p); - k+=4; - if (k > 11) { - k = 3; - 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 );*/ } + k+=4; + if (k > 11) { + k = 3; + j +=4; + } } return; } diff --git a/app/src/main/java/tu_darmstadt/sudoku/view/SudokuKeyboardLayout.java b/app/src/main/java/tu_darmstadt/sudoku/view/SudokuKeyboardLayout.java new file mode 100644 index 0000000..172fd24 --- /dev/null +++ b/app/src/main/java/tu_darmstadt/sudoku/view/SudokuKeyboardLayout.java @@ -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); + } +} diff --git a/app/src/main/res/layout/content_game_view.xml b/app/src/main/res/layout/content_game_view.xml index fc2461d..35eb88d 100644 --- a/app/src/main/res/layout/content_game_view.xml +++ b/app/src/main/res/layout/content_game_view.xml @@ -16,4 +16,109 @@ android:layout_height="wrap_content" android:clickable="true" android:gravity="center"/> + + + + + + + + + + + + + + + + + + + + + + + + + + +