Skip to content

Commit

Permalink
Remove no guess from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasnlm committed Oct 9, 2021
1 parent d18a3a9 commit 4a78cce
Show file tree
Hide file tree
Showing 14 changed files with 5 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class CloudSaveManagerImpl(
stats = statsRepository.getAllStats(minId).map { it.toHashMap() },
premiumFeatures = preferencesRepository.isPremiumEnabled().toInt(),
controlStyle = preferencesRepository.controlStyle().ordinal,
noGuessing = preferencesRepository.useNoGuessingAlgorithm().toInt(),
language = preferencesRepository.getPreferredLocale() ?: "",
openDirectly = preferencesRepository.openGameDirectly().toInt(),
unlockedThemes = preferencesRepository.getUnlockedThemes().joinToString(" "),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class MainViewModel(
setSquareSize(squareSize)
setCustomLongPressTimeout(touchTiming.toLong())
setQuestionMark(questionMark != 0)
setNoGuessingAlgorithm(noGuessing != 0)
setPreferredLocale(language)
setFlagAssistant(gameAssistance != 0)
setHapticFeedback(hapticFeedback != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ class PreferencesActivity :
action = { preferenceRepository.setFlagAssistant(it) }
)

bindItem(
label = noGuessingLabel,
switch = noGuessing,
checked = preferenceRepository.useNoGuessingAlgorithm(),
action = { preferenceRepository.setNoGuessingAlgorithm(it) }
)

bindItem(
label = helpLabel,
switch = help,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:layout_marginStart="4dp"
android:textColor="?attr/colorOnBackground"
android:drawablePadding="8dp"
android:paddingStart="16dp"
android:paddingStart="8dp"
android:paddingEnd="0dp"
tools:text="@string/app_name"
app:drawableStartCompat="@drawable/mine" />
Expand Down
27 changes: 1 addition & 26 deletions app/src/main/res/layout/activity_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,31 +211,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/automaticFlagsLabel" />

<TextView
android:id="@+id/noGuessingLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:alpha="1.0"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingVertical="16dp"
android:text="@string/no_guessing_mode"
android:textColor="?attr/colorControlNormal"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/automaticFlagsLabel" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/noGuessing"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingVertical="16dp"
app:layout_constraintBottom_toBottomOf="@+id/noGuessingLabel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/noGuessingLabel" />

<TextView
android:id="@+id/allowClickNumberLabel"
android:layout_width="0dp"
Expand All @@ -250,7 +225,7 @@
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/noGuessingLabel" />
app:layout_constraintTop_toBottomOf="@+id/automaticFlagsLabel" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/clickOnNumbers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ class MockPreferencesRepository : IPreferencesRepository {

override fun setAnimations(enabled: Boolean) {}

override fun setNoGuessingAlgorithm(value: Boolean) {}

override fun useNoGuessingAlgorithm(): Boolean = true

override fun useQuestionMark(): Boolean = false

override fun setQuestionMark(value: Boolean) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class GameController {
private var gameControl: GameControl = GameControl.Standard
private var useQuestionMark = true
private var useOpenOnSwitchControl = true
private var useNoGuessing = true
private var useClickOnNumbers = true
private var errorTolerance = 0
private var useSimonTatham = true
Expand Down Expand Up @@ -98,7 +97,7 @@ class GameController {
val minefieldHandler = MinefieldHandler(fieldCopy, false)
minefieldHandler.openAt(safeId, false)
noGuessTestedLevel = useSimonTatham || solver.trySolve(minefieldHandler.result().toMutableList())
} while (useNoGuessing && !useSimonTatham && solver.keepTrying() && !noGuessTestedLevel)
} while (!useSimonTatham && solver.keepTrying() && !noGuessTestedLevel)

firstOpen = FirstOpen.Position(safeId)
}
Expand Down Expand Up @@ -384,10 +383,6 @@ class GameController {
this.useQuestionMark = useQuestionMark
}

fun useNoGuessing(noGuessing: Boolean) {
this.useNoGuessing = noGuessing
}

fun useClickOnNumbers(clickNumbers: Boolean) {
this.useClickOnNumbers = clickNumbers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ open class GameViewModel(

updateGameControl(gameControl)
useQuestionMark(preferencesRepository.useQuestionMark())
useNoGuessing(preferencesRepository.useNoGuessingAlgorithm())
useClickOnNumbers(preferencesRepository.allowTapOnNumbers())
}
}
Expand Down
2 changes: 1 addition & 1 deletion control/src/main/res/layout/activity_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
android:layout_height="wrap_content"
android:paddingHorizontal="8dp"
android:paddingVertical="12dp"
android:text="@string/haptic_feedback_level"
android:text="@string/vibration"
app:layout_constraintEnd_toStartOf="@id/hapticLevel"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/touch_sensibility" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ data class CloudSave(
val stats: List<HashMap<String, String>>,
val premiumFeatures: Int,
val controlStyle: Int,
val noGuessing: Int,
val language: String,
val openDirectly: Int,
val unlockedThemes: String,
Expand All @@ -43,7 +42,6 @@ fun CloudSave.toHashMap(): HashMap<String, Any> = hashMapOf(
"stats" to stats,
"premiumFeatures" to premiumFeatures,
"controlStyle" to controlStyle,
"noGuessing" to noGuessing,
"language" to language,
"openDirectly" to openDirectly,
"unlockedThemes" to unlockedThemes,
Expand Down Expand Up @@ -74,7 +72,6 @@ fun cloudSaveOf(id: String, data: Map<String, Any>) =
stats = data["stats"] as List<HashMap<String, String>>,
premiumFeatures = data["premiumFeatures"].parseInt(),
controlStyle = data["controlStyle"].parseInt(),
noGuessing = data["noGuessing"].parseInt(1),
language = data["language"].parseString(""),
openDirectly = data["openDirectly"].parseInt(0),
unlockedThemes = data["unlockedThemes"].parseString(""),
Expand Down
4 changes: 1 addition & 3 deletions i18n/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<string name="tutorial_text_3">If a square has the same number of flags, all other remaining squares adjacent to it aren\'t mines (the green arrow).</string>
<string name="tutorial_text_4">Review the numbers and keep opening squares.</string>
<string name="games">Games</string>
<string name="tap_to_begin">Tap to begin</string>
<string name="tap_to_begin">Tap to Begin</string>
<string name="previous_games">Previous Games</string>
<string name="minefield">Difficulty</string>
<string name="standard">Standard</string>
Expand All @@ -20,7 +20,6 @@
<string name="settings">Settings</string>
<string name="animations">Animations</string>
<string name="vibration">Haptic Feedback</string>
<string name="haptic_feedback_level">Haptic Feedback Level</string>
<string name="about">About</string>
<string name="events">Statistics</string>
<string name="custom">Custom</string>
Expand All @@ -33,7 +32,6 @@
<string name="new_game_request">Do you want to start a new game?</string>
<string name="mines_remaining">%d mines</string>
<string name="game_time">Game Time</string>
<string name="mine">Mine</string>
<string name="settings_general">General</string>
<string name="settings_gameplay">Gameplay</string>
<string name="settings_accessibility">Accessibility</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ interface IPreferencesRepository {
fun useAnimations(): Boolean
fun setAnimations(enabled: Boolean)

fun setNoGuessingAlgorithm(value: Boolean)
fun useNoGuessingAlgorithm(): Boolean

fun useQuestionMark(): Boolean
fun setQuestionMark(value: Boolean)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ object PreferenceKeys {
const val PREFERENCE_VIBRATION_LEVEL = "preference_vibration_level"
const val PREFERENCE_ASSISTANT = "preference_assistant"
const val PREFERENCE_ANIMATION = "preference_animation"
const val PREFERENCE_NO_GUESSING = "preference_no_guessing"
const val PREFERENCE_AREA_SIZE = "preference_new_area_size"
const val PREFERENCE_QUESTION_MARK = "preference_use_question_mark"
const val PREFERENCE_USE_HELP = "preference_use_help"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ class PreferencesRepository(
preferencesManager.putBoolean(PreferenceKeys.PREFERENCE_ANIMATION, enabled)
}

override fun setNoGuessingAlgorithm(value: Boolean) {
preferencesManager.putBoolean(PreferenceKeys.PREFERENCE_NO_GUESSING, value)
}

override fun useNoGuessingAlgorithm(): Boolean =
preferencesManager.getBoolean(PreferenceKeys.PREFERENCE_NO_GUESSING, true)

override fun useQuestionMark(): Boolean =
preferencesManager.getBoolean(PreferenceKeys.PREFERENCE_QUESTION_MARK, false)

Expand Down

0 comments on commit 4a78cce

Please sign in to comment.