From fddd7d742b6c8e495f7809b85e0531758b81223a Mon Sep 17 00:00:00 2001 From: Gongxter Date: Sun, 15 Nov 2015 13:10:29 +0100 Subject: [PATCH] =?UTF-8?q?Hotfix=20f=C3=BCr=20Fixed=20Button=20Row=20now?= =?UTF-8?q?=20only=20available=20buttons=20are=20shown=20height=20fixed=20?= =?UTF-8?q?by=20Chris?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java | 2 -- .../java/tu_darmstadt/sudoku/ui/view/SudokuFieldLayout.java | 2 +- .../tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java | 6 +++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java index c7efdf1..06cbca3 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/GameActivity.java @@ -68,8 +68,6 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On keyboard.setColumnCount(Math.max(((gameController.getSize() / 2) + 1),keyboard.fixedButtonsCount)); keyboard.setRowCount(3); Point p = new Point(); - getWindowManager().getDefaultDisplay().getSize(p); - keyboard.getLayoutParams().height = (int)(p.y*0.3); //int width = p.x; keyboard.setKeyBoard(gameController.getSize(), p.x); /* diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuFieldLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuFieldLayout.java index b4c6493..7482b98 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuFieldLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuFieldLayout.java @@ -20,7 +20,7 @@ public class SudokuFieldLayout extends RelativeLayout { private GameController gameController; private int sectionHeight; - private int sectionWidth; + public int sectionWidth; private int gameCellWidth; private int gameCellHeight; private SharedPreferences settings; diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java index 7785c09..412c8cc 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java @@ -84,13 +84,14 @@ public class SudokuKeyboardLayout extends GridLayout { int row = 0; int number = 0; int torun = ((size)%2==0) ? (size)/2 :(size+1)/2 ; + int realSize = Math.max(torun,fixedButtonsCount); for (int k = 0; k<2;k++){ for (int i = 0; i< torun; i++){ buttons[i] = new SudokuButton(getContext(),null); p = new LayoutParams(GridLayout.spec(k,1),GridLayout.spec(i, 1)); p.setMargins(0,0,0,0); - int width2 =width/(torun); + int width2 =width/(realSize); p.width= width2-15; buttons[i].setLayoutParams(p); buttons[i].setGravity(Gravity.CENTER); @@ -100,6 +101,9 @@ public class SudokuKeyboardLayout extends GridLayout { buttons[i].setOnClickListener(listener); number++; + if (number > size) { + break; + } addView(buttons[i]); } }