Skip to content

Commit

Permalink
Merge pull request #134 from SecUSo/development
Browse files Browse the repository at this point in the history
Deactivates 16x16 easy/moderate games
  • Loading branch information
coderPaddyS authored Jan 9, 2025
2 parents 5a14216 + 1e37cb6 commit 3cdac68
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "org.secuso.privacyfriendlysudoku"
minSdkVersion 17
targetSdkVersion 34
versionCode 16
versionName "3.2.1"
versionCode 17
versionName "3.2.2"
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private void buildGenerationList() {

for(GameType validType : GameType.getValidGameTypes()) {
for(GameDifficulty validDifficulty : GameDifficulty.getValidDifficultyList()) {
// currently it's extremely unlikely to generate 16x16 easier than hard
if (validType.equals(GameType.Default_16x16) && (validDifficulty.equals(GameDifficulty.Easy) || validDifficulty.equals(GameDifficulty.Moderate))) {
continue;
}
int levelCount = dbHelper.getLevels(validDifficulty, validType).size();
Log.d(TAG, "\tType: "+ validType.name() + " Difficulty: " + validDifficulty.name() + "\t: " + levelCount);
// add the missing levels to the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ private NewLevelManager(Context context, SharedPreferences settings) {
public boolean isLevelLoadable(GameType type, GameDifficulty diff) {
return dbHelper.getLevels(diff, type).size() > 0;
}
public int getCountAvailableLevels(GameType type, GameDifficulty diff) {
return dbHelper.getLevels(diff, type).size();
}

@Deprecated
public boolean isLevelLoadableOld(GameType type, GameDifficulty diff) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
public void onPageSelected(int position) {
arrowLeft.setVisibility((position==0)?View.INVISIBLE:View.VISIBLE);
arrowRight.setVisibility((position==mSectionsPagerAdapter.getCount()-1)?View.INVISIBLE:View.VISIBLE);

GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
int index = difficultyBar.getProgress()-1;
GameDifficulty gameDifficulty = GameDifficulty.getValidDifficultyList().get(index < 0 ? 0 : index);
((TextView) findViewById(R.id.level_count))
.setText(String.format(getString(R.string.levels_available), newLevelManager.getCountAvailableLevels(gameType, gameDifficulty)));
}

@Override
Expand All @@ -167,18 +173,42 @@ public void onPageScrollStateChanged(int state) {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
createGameBar.setChecked(false);
((Button) findViewById(R.id.playButton)).setText(R.string.new_game);
Button button = findViewById(R.id.playButton);
button.setText(R.string.new_game);

if (rating >= 1) {
GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
int index = difficultyBar.getProgress()-1;
GameDifficulty gameDifficulty = GameDifficulty.getValidDifficultyList().get(index < 0 ? 0 : index);
if (gameType == GameType.Default_16x16 && rating <= 2) {
button.setEnabled(false);
button.setText(R.string.game_config_unsupported);
button.setBackgroundResource(R.drawable.button_inactive);
} else {
button.setEnabled(true);
button.setText(R.string.new_game);
button.setBackgroundResource(R.drawable.button_standalone);
}

((TextView) findViewById(R.id.level_count))
.setText(String.format(getString(R.string.levels_available), newLevelManager.getCountAvailableLevels(gameType, gameDifficulty)));

difficultyText.setText(getString(difficultyList.get((int) ratingBar.getRating() - 1).getStringResID()));
} else {
button.setEnabled(true);
button.setBackgroundResource(R.drawable.button_standalone);
difficultyText.setText(R.string.difficulty_custom);
createGameBar.setChecked(true);
((Button)findViewById(R.id.playButton)).setText(R.string.create_game);
}
}
});

GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
GameDifficulty gameDifficulty = GameDifficulty.getValidDifficultyList().get(index < 0 ? 0 : index);
((TextView) findViewById(R.id.level_count))
.setText(String.format(getString(R.string.levels_available), newLevelManager.getCountAvailableLevels(gameType, gameDifficulty)));

createGameBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
android:layout_width="wrap_content"
android:text="@string/difficulty_easy"
android:textSize="@dimen/main_text_difficulty"/>
<TextView android:id="@+id/level_count"
android:text="Levels available:"
android:textStyle="bold"
android:textSize="14dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<string name="help_delete_summary">Löscht das ausgewählte Feld</string>
<string name="help_delete">Löschen</string>
<string name="help_privacyInfo">Privatsphäre Information</string>
<string name="pref_deactivate_timer_summary">Zeit deaktivieren</string>
<string name="pref_deactivate_timer_summary">Deaktiviere die Zeitmessung beim Spielen. Spiele ohne Zeitmessung werden nicht in die Statistiken aufgenommen.</string>
<string name="pref_timer_reset">Zeit zurücksetzen</string>
<string name="pref_timer_reset_summary">Beim zurücksetzen des Spielfeldes wird die Zeit auch zurückgesetzt.</string>
<string name="okay">Okay</string>
Expand Down Expand Up @@ -129,5 +129,7 @@
<string name="finished_verifying_custom_sudoku_toast">Verifizierung abgeschlossen!</string>
<string name="failed_to_verify_custom_sudoku_toast">Verifizierung fehlgeschlagen: Dein Sudoku kann nicht gelöst werden.</string>
<string name="pref_deactivate_timer">Zeit deaktivieren</string>
<string name="game_config_unsupported">Diese Spielkombination ist momentan nicht unterstützt.</string>
<string name="levels_available">Levels verfügbar: %d</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,7 @@
</string>
<string name="attachment_summary_off">Only download attachments when manually requested</string>
<string name="gametype_default_16x16" translatable="false">Sudoku 16x16</string>
<string name="game_config_unsupported">This game combination is currently not supported.</string>
<string name="levels_available">Levels available: %d</string>

</resources>

0 comments on commit 3cdac68

Please sign in to comment.