From 54bf935685d232e5aee1e06ff5c1d0fecfeb04be Mon Sep 17 00:00:00 2001 From: Christopher Beckmann Date: Sun, 31 Jan 2016 01:06:34 +0100 Subject: [PATCH] Modified the Landscape GameView a bit. Looks a lot cleaner now. Not tested on smaller and bigger devices yet. Also added the landscape version of the stats page. --- .../ui/GameActivity.java | 4 +- .../ui/view/SudokuSpecialButtonLayout.java | 9 +- .../res/layout-land/content_game_view.xml | 70 ++-- .../main/res/layout-land/fragment_stats.xml | 202 +++++------ .../res/layout-xlarge-land/fragment_stats.xml | 316 ++++++++++++++++++ .../main/res/layout-xlarge/fragment_stats.xml | 316 ++++++++++++++++++ 6 files changed, 786 insertions(+), 131 deletions(-) create mode 100644 app/src/main/res/layout-xlarge-land/fragment_stats.xml create mode 100644 app/src/main/res/layout-xlarge/fragment_stats.xml diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java index 6451142..b8606c2 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -100,6 +100,8 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On } } else { gameController = savedInstanceState.getParcelable("gameController"); + // in case we get the same object back + // because parceling the Object does not always parcel it. Only if needed. gameController.removeAllListeners(); gameSolved = savedInstanceState.getInt("gameSolved") == 1; } @@ -136,7 +138,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On //set Special keys specialButtonLayout = (SudokuSpecialButtonLayout) findViewById(R.id.sudokuSpecialLayout); - specialButtonLayout.setButtons(p.x, gameController, keyboard, getFragmentManager()); + specialButtonLayout.setButtons(p.x, gameController, keyboard, getFragmentManager(), orientation); //set TimerView timerView = (TextView)findViewById(R.id.timerView); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java index fd229b9..f431f55 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java @@ -103,7 +103,7 @@ public class SudokuSpecialButtonLayout extends LinearLayout implements IHighligh } } - public void setButtons(int width, GameController gc, SudokuKeyboardLayout key, FragmentManager fm) { + public void setButtons(int width, GameController gc, SudokuKeyboardLayout key, FragmentManager fm, int orientation) { fragmentManager = fm; keyboard=key; gameController = gc; @@ -116,7 +116,12 @@ public class SudokuSpecialButtonLayout extends LinearLayout implements IHighligh //ArrayList type = (ArrayList) SudokuButtonType.getSpecialButtons(); for (SudokuButtonType t : getSpecialButtons()){ fixedButtons[i] = new SudokuSpecialButton(getContext(),null); - p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,1); + if(orientation == LinearLayout.HORIZONTAL) { + p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1); + } else { + p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1); + fixedButtons[i].setPadding(25, 0, 25, 0); + } p.setMargins(5, 5, 5, 5); //int width2 =width/(fixedButtonsCount); diff --git a/app/src/main/res/layout-land/content_game_view.xml b/app/src/main/res/layout-land/content_game_view.xml index 58929cb..619a7ff 100644 --- a/app/src/main/res/layout-land/content_game_view.xml +++ b/app/src/main/res/layout-land/content_game_view.xml @@ -11,42 +11,42 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="tu_darmstadt.sudoku.activity.GameActivity"> - + - + - - - - - - + diff --git a/app/src/main/res/layout-land/fragment_stats.xml b/app/src/main/res/layout-land/fragment_stats.xml index 34a4496..bc719a9 100644 --- a/app/src/main/res/layout-land/fragment_stats.xml +++ b/app/src/main/res/layout-land/fragment_stats.xml @@ -1,20 +1,104 @@ + + + + + + + + + + + + + + + + android:layout_weight="0.5"> + + + + + + + + - - - - - - - - - - - - - - - - - + + - - + - - - - - - - + + - + + - - diff --git a/app/src/main/res/layout-xlarge-land/fragment_stats.xml b/app/src/main/res/layout-xlarge-land/fragment_stats.xml new file mode 100644 index 0000000..34a4496 --- /dev/null +++ b/app/src/main/res/layout-xlarge-land/fragment_stats.xml @@ -0,0 +1,316 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-xlarge/fragment_stats.xml b/app/src/main/res/layout-xlarge/fragment_stats.xml new file mode 100644 index 0000000..34a4496 --- /dev/null +++ b/app/src/main/res/layout-xlarge/fragment_stats.xml @@ -0,0 +1,316 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +