keyboard now with linear layout
This commit is contained in:
parent
b6787846e6
commit
01b3e37ce1
5 changed files with 53 additions and 23 deletions
|
@ -105,8 +105,8 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
|
|||
keyboard = (SudokuKeyboardLayout) findViewById(R.id.sudokuKeyboardLayout);
|
||||
keyboard.removeAllViews();
|
||||
keyboard.setGameController(gameController);
|
||||
keyboard.setColumnCount((gameController.getSize() / 2) + 1);
|
||||
keyboard.setRowCount(2);
|
||||
//keyboard.setColumnCount((gameController.getSize() / 2) + 1);
|
||||
//keyboard.setRowCount(2);
|
||||
Point p = new Point();
|
||||
getWindowManager().getDefaultDisplay().getSize(p);
|
||||
|
||||
|
@ -243,6 +243,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSolved() {
|
||||
gameSolved = true;
|
||||
|
|
|
@ -210,9 +210,9 @@ public class StatsActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
private void updateGeneralIfo(int time, int games, int hints){
|
||||
totalHints =hints;
|
||||
totalGames =games;
|
||||
totalTime =time;
|
||||
totalHints +=hints;
|
||||
totalGames +=games;
|
||||
totalTime +=time;
|
||||
}
|
||||
private void setGeneralInfo(){
|
||||
TextView generalInfoView;
|
||||
|
|
|
@ -11,8 +11,13 @@ import android.graphics.Canvas;
|
|||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.GridView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
@ -26,13 +31,14 @@ import tu_darmstadt.sudoku.ui.listener.IDeleteDialogFragmentListener;
|
|||
*/
|
||||
|
||||
|
||||
public class SudokuKeyboardLayout extends GridLayout implements IHighlightChangedListener {
|
||||
public class SudokuKeyboardLayout extends LinearLayout implements IHighlightChangedListener {
|
||||
|
||||
AttributeSet attrs;
|
||||
SudokuButton [] buttons;
|
||||
GameController gameController;
|
||||
Symbol symbolsToUse = Symbol.Default;
|
||||
float normalTextSize = 0;
|
||||
LinearLayout [] layouts = new LinearLayout[2];
|
||||
|
||||
OnClickListener listener = new OnClickListener() {
|
||||
@Override
|
||||
|
@ -51,7 +57,6 @@ public class SudokuKeyboardLayout extends GridLayout implements IHighlightChange
|
|||
public SudokuKeyboardLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.attrs = attrs;
|
||||
|
||||
}
|
||||
|
||||
public void setSymbols(Symbol s) {
|
||||
|
@ -68,14 +73,33 @@ public class SudokuKeyboardLayout extends GridLayout implements IHighlightChange
|
|||
int torun = (size % 2 == 0) ? size/2 :(size+1)/2 ;
|
||||
int realSize = torun;
|
||||
|
||||
|
||||
//set layout parameters and init Layouts
|
||||
for (int i = 0; i < 2; i++) {
|
||||
p = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,0,1);
|
||||
//if (i == 0) p.bottomMargin=10; else p.topMargin=10;
|
||||
p.setMargins(0,5,0,5);
|
||||
layouts[i] = new LinearLayout(getContext(),null);
|
||||
layouts[i].setLayoutParams(p);
|
||||
layouts[i].setWeightSum(torun);
|
||||
layouts[i].setOrientation(LinearLayout.HORIZONTAL);
|
||||
addView(layouts[i]);
|
||||
}
|
||||
|
||||
//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(0, LayoutParams.MATCH_PARENT,1);
|
||||
p.setMargins(5,5,5,5);
|
||||
buttons[number].setLayoutParams(p);
|
||||
/* removed GridLayout because of bad scaling will use now a Linearlayout
|
||||
Spec rowSpec = spec(k,1);
|
||||
Spec colSpec = spec(i,1);
|
||||
|
||||
|
@ -85,17 +109,20 @@ public class SudokuKeyboardLayout extends GridLayout implements IHighlightChange
|
|||
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);
|
||||
//p.setGravity(Gravity.FILL_VERTICAL);
|
||||
//p.setGravity(Gravity.FILL);
|
||||
// p.setGravity(LayoutParams.WRAP_CONTENT);
|
||||
*/
|
||||
|
||||
|
||||
buttons[number].setLayoutParams(p);
|
||||
// buttons[number].setLayoutParams(p);
|
||||
//buttons[number].setGravity(Gravity.CENTER);
|
||||
buttons[number].setType(SudokuButtonType.Value);
|
||||
buttons[number].setTextColor(getResources().getColor(R.color.white));
|
||||
buttons[number].setBackgroundResource(R.drawable.mnenomic_numpad_button);
|
||||
buttons[number].setText(Symbol.getSymbol(symbolsToUse, number));
|
||||
buttons[number].setValue(number + 1);
|
||||
buttons[number].setOnClickListener(listener);
|
||||
addView(buttons[number]);
|
||||
layouts[k].addView(buttons[number]);
|
||||
number++;
|
||||
}
|
||||
}
|
||||
|
@ -158,4 +185,9 @@ public class SudokuKeyboardLayout extends GridLayout implements IHighlightChange
|
|||
}
|
||||
}
|
||||
}
|
||||
public void fixHeight (){
|
||||
int i = getHeight();
|
||||
i = buttons[0].getHeight();
|
||||
i = buttons[5].getHeight();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
android:stepSize="1" />
|
||||
|
||||
<Button
|
||||
android:textColor="@color/white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -116,6 +117,7 @@
|
|||
android:background="@drawable/mnenomic_numpad_button"/>
|
||||
|
||||
<Button
|
||||
android:textColor="@color/white"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
|
|
@ -25,24 +25,19 @@
|
|||
android:weightSum="3">
|
||||
|
||||
<tu_darmstadt.sudoku.ui.view.SudokuKeyboardLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/sudokuKeyboardLayout"
|
||||
android:useDefaultMargins="true"
|
||||
android:alignmentMode="alignBounds"
|
||||
android:columnOrderPreserved="false"
|
||||
android:columnCount="6"
|
||||
android:rowCount="2"
|
||||
android:alwaysDrawnWithCache="true"
|
||||
android:foregroundGravity="fill_horizontal"
|
||||
android:layout_weight="2">
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="2"
|
||||
android:weightSum="2">
|
||||
|
||||
</tu_darmstadt.sudoku.ui.view.SudokuKeyboardLayout>
|
||||
|
||||
<tu_darmstadt.sudoku.ui.view.SudokuSpecialButtonLayout
|
||||
android:id="@+id/sudokuSpecialLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
</tu_darmstadt.sudoku.ui.view.SudokuSpecialButtonLayout>
|
||||
|
|
Loading…
Reference in a new issue