Skip to content

Commit a47a4b3

Browse files
committed
🚧 Add 4 Grid Sudoku and support level selection
Now we have 4 and 9 Sudoku avaliable and also support level selection for 9
1 parent 1ee8adf commit a47a4b3

File tree

14 files changed

+1233
-82
lines changed

14 files changed

+1233
-82
lines changed

SudokuApp-GS/Sudoku/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
12-
<activity android:name=".SudokuNine"></activity>
12+
<activity android:name=".ChooseLevel"></activity>
13+
<activity android:name=".SudokuFour" />
14+
<activity android:name=".SudokuNine" />
1315
<activity android:name=".MainActivity">
1416
<intent-filter>
1517
<action android:name="android.intent.action.MAIN" />
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.example.sudoku;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.content.Intent;
6+
import android.media.Image;
7+
import android.os.Bundle;
8+
import android.view.View;
9+
import android.widget.ImageButton;
10+
import android.widget.LinearLayout;
11+
12+
public class ChooseLevel extends AppCompatActivity {
13+
14+
private int i = 0;
15+
16+
private void disableButtons() {
17+
LinearLayout easy = (LinearLayout) findViewById(R.id.easylevel);
18+
LinearLayout medium = (LinearLayout) findViewById(R.id.mediumlevel);
19+
LinearLayout hard = (LinearLayout) findViewById(R.id.hardlevel);
20+
LinearLayout devil = (LinearLayout) findViewById(R.id.devil_level);
21+
easy.setClickable(false);
22+
easy.setFocusable(false);
23+
medium.setClickable(false);
24+
medium.setFocusable(false);
25+
hard.setClickable(false);
26+
hard.setFocusable(false);
27+
devil.setClickable(false);
28+
devil.setFocusable(false);
29+
}
30+
31+
@Override
32+
protected void onCreate(Bundle savedInstanceState) {
33+
super.onCreate(savedInstanceState);
34+
setContentView(R.layout.activity_choose_level);
35+
LinearLayout easy = findViewById(R.id.easylevel);
36+
LinearLayout medium = findViewById(R.id.mediumlevel);
37+
LinearLayout hard = findViewById(R.id.hardlevel);
38+
LinearLayout devil = findViewById(R.id.devil_level);
39+
40+
LinearLayout[] layouts = new LinearLayout[]{easy, medium, hard, devil};
41+
for (; i < layouts.length; i++) {
42+
final int value = i * 10 + 20;
43+
layouts[i].setOnClickListener(new View.OnClickListener() {
44+
@Override
45+
public void onClick(View v) {
46+
disableButtons();
47+
Intent intent = new Intent(ChooseLevel.this, SudokuNine.class);
48+
intent.putExtra("level", value);
49+
startActivity(intent);
50+
}
51+
});
52+
LinearLayout subLinear = (LinearLayout) layouts[i].getChildAt(1);
53+
for (int t = 0; t < subLinear.getChildCount(); t++) {
54+
ImageButton imageButton = (ImageButton) subLinear.getChildAt(t);
55+
imageButton.setOnClickListener(new View.OnClickListener() {
56+
@Override
57+
public void onClick(View v) {
58+
disableButtons();
59+
Intent intent = new Intent(ChooseLevel.this, SudokuNine.class);
60+
intent.putExtra("level", value);
61+
startActivity(intent);
62+
}
63+
});
64+
}
65+
}
66+
}
67+
}

SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/MainActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ protected void onCreate(Bundle savedInstanceState) {
2020
startTextView.setOnClickListener(new View.OnClickListener() {
2121
@Override
2222
public void onClick(View v) {
23-
Intent intent = new Intent(MainActivity.this, SudokuNine.class);
23+
Intent intent = new Intent(MainActivity.this, ChooseLevel.class);
24+
// intent.putExtra("level", 10);
2425
startActivity(intent);
2526
}
2627
});

0 commit comments

Comments
 (0)