Skip to content

Commit

Permalink
Merge pull request #353 from lucasnlm/improve-help
Browse files Browse the repository at this point in the history
Improve help
  • Loading branch information
lucasnlm committed Dec 25, 2021
2 parents 04f92e0 + bf043d4 commit 3d2e781
Show file tree
Hide file tree
Showing 53 changed files with 155 additions and 48 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 {

defaultConfig {
// versionCode and versionName must be hardcoded to support F-droid
versionCode 1502001
versionName '15.2.0'
versionCode 1503001
versionName '15.3.0'
minSdkVersion 21
targetSdkVersion 31
multiDexEnabled true
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/dev/lucasnlm/antimine/main/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.lucasnlm.antimine.main

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.View
Expand Down Expand Up @@ -312,6 +313,22 @@ class MainActivity : ThematicActivity(R.layout.activity_main) {
}
)

val moreGamesDeeplink = playGamesManager.moreGameDeeplink()
if (moreGamesDeeplink.isNotBlank()) {
moreGames.bind(
theme = usingTheme,
text = R.string.more_games,
startIcon = R.drawable.more_games,
onAction = {
analyticsManager.sentEvent(Analytics.MoreGames)
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(moreGamesDeeplink))
startActivity(browserIntent)
}
)
} else {
moreGames.visibility = View.GONE
}

translation.bind(
theme = usingTheme,
text = R.string.translation,
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/more_games.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,17.27l4.15,2.51c0.76,0.46 1.69,-0.22 1.49,-1.08l-1.1,-4.72l3.67,-3.18c0.67,-0.58 0.31,-1.68 -0.57,-1.75l-4.83,-0.41l-1.89,-4.46c-0.34,-0.81 -1.5,-0.81 -1.84,0L9.19,8.63L4.36,9.04c-0.88,0.07 -1.24,1.17 -0.57,1.75l3.67,3.18l-1.1,4.72c-0.2,0.86 0.73,1.54 1.49,1.08L12,17.27z"/>
</vector>
24 changes: 21 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,16 @@
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<Space
android:layout_width="match_parent"
android:layout_height="8dp" />

<dev.lucasnlm.antimine.ui.view.CardButtonView
android:id="@+id/tutorial"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="16dp"/>
android:layout_marginBottom="8dp"/>

<dev.lucasnlm.antimine.ui.view.CardButtonView
android:id="@+id/themes"
Expand All @@ -161,23 +165,37 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"/>

<Space
android:layout_width="match_parent"
android:layout_height="8dp" />

<dev.lucasnlm.antimine.ui.view.CardButtonView
android:id="@+id/stats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>
android:layout_marginTop="8dp"/>

<dev.lucasnlm.antimine.ui.view.CardButtonView
android:id="@+id/previousGames"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"/>

<Space
android:layout_width="match_parent"
android:layout_height="8dp" />

<dev.lucasnlm.antimine.ui.view.CardButtonView
android:id="@+id/moreGames"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>

<dev.lucasnlm.antimine.ui.view.CardButtonView
android:id="@+id/translation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>
android:layout_marginTop="8dp"/>

<dev.lucasnlm.antimine.ui.view.CardButtonView
android:id="@+id/play_games"
Expand Down
2 changes: 2 additions & 0 deletions app/src/test/java/dev/lucasnlm/antimine/di/TestAppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ val AppModule = module {
override fun shouldRequestLogin(): Boolean = false

override fun signInToFirebase(activity: Activity) {}

override fun moreGameDeeplink(): String = ""
}
} bind IPlayGamesManager::class

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class GameController {
private var errorTolerance = 0
private var useSimonTatham = true

private var lastIdInteractionX: Int? = null
private var lastIdInteractionY: Int? = null

val seed: Long

private val minefieldCreator: MinefieldCreator
Expand Down Expand Up @@ -167,6 +170,9 @@ class GameController {
}
}

lastIdInteractionX = target.posX
lastIdInteractionY = target.posY

field = minefieldHandler.result()
}

Expand Down Expand Up @@ -280,7 +286,7 @@ class GameController {
fun revealRandomMine(): Boolean {
val result: Boolean
field = MinefieldHandler(field.toMutableList(), false).run {
result = revealRandomMineNearUncoveredArea()
result = revealRandomMineNearUncoveredArea(lastIdInteractionX, lastIdInteractionY)
result()
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.lucasnlm.antimine.common.level.logic

import dev.lucasnlm.antimine.core.models.Area
import dev.lucasnlm.antimine.core.models.Mark
import kotlin.math.absoluteValue

class MinefieldHandler(
private val field: MutableList<Area>,
Expand All @@ -27,23 +28,24 @@ class MinefieldHandler(
.forEach { field[it.id] = it.copy(isCovered = false) }
}

fun revealRandomMineNearUncoveredArea(): Boolean {
fun revealRandomMineNearUncoveredArea(lastX: Int? = null, lastY: Int? = null): Boolean {
val unrevealedMines = field.filter { it.hasMine && it.mark.isNone() && !it.revealed }
val unrevealedMinesWithUncovered = unrevealedMines.filter {
it.neighborsIds
.map { areaId -> field[areaId] }
.firstOrNull { area -> !area.isCovered && !area.hasMine } != null
}
val nearestTarget = if (lastX != null && lastY != null) {
unrevealedMines.filter {
(lastX - it.posX).absoluteValue < 3 && (lastY - it.posY).absoluteValue < 3
}.shuffled().firstOrNull()
} else null

val result = if (unrevealedMinesWithUncovered.isNotEmpty()) {
unrevealedMinesWithUncovered.shuffled().firstOrNull()?.run {
field[this.id] = this.copy(revealed = true)
val result = when {
nearestTarget != null -> {
field[nearestTarget.id] = nearestTarget.copy(revealed = true)
true
}
} else {
unrevealedMines.shuffled().firstOrNull()?.run {
field[this.id] = this.copy(revealed = true)
true
else -> {
unrevealedMines.shuffled().firstOrNull()?.run {
field[this.id] = this.copy(revealed = true)
true
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ sealed class Analytics(

object OpenAbout : Analytics("Open About")

object MoreGames : Analytics("Open More Games")

object OpenStats : Analytics("Open Stats")

object OpenTranslations : Analytics("Open Translations")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ interface IPlayGamesManager {
fun keepRequestingLogin(status: Boolean)
fun shouldRequestLogin(): Boolean
fun signInToFirebase(activity: Activity)
fun moreGameDeeplink(): String
}
2 changes: 2 additions & 0 deletions foss/src/main/java/dev/lucasnlm/external/PlayGamesManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ class PlayGamesManager(
override fun signInToFirebase(activity: Activity) {
// F-droid build doesn't have Google Play Games
}

override fun moreGameDeeplink(): String = ""
}
1 change: 1 addition & 0 deletions i18n/src/main/res/values-af-rZA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">More games</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">الجم الثابت</string>
<string name="progressive">التقدمي</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">المزيد من الألعاب</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-bg-rBG/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Фиксиран размер</string>
<string name="progressive">Прогресивен</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">More games</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-ca-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Mida Fixa</string>
<string name="progressive">Progressiu</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">Més jocs</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Pevná velikost</string>
<string name="progressive">Progresivní</string>
<string name="highlight_unsolved_numbers">Zvýraznit nevyřešená čísla</string>
<string name="more_games">Další hry</string>
</resources>
11 changes: 6 additions & 5 deletions i18n/src/main/res/values-da-rDK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@
<string name="close">Luk</string>
<string name="open_tutorial">Åben vejledning</string>
<string name="click_numbers">Tillad tryk på numre</string>
<string name="tap_to_customize">Tap to customize</string>
<string name="toggle_button_top">Show \"Toggle Button\" on top bar</string>
<string name="tap_to_customize">Tryk for at tilpasse</string>
<string name="toggle_button_top">Vis \"Skift knap\" på øverste bjælke</string>
<string name="no_guess_fail_warning">The current minefield may not be guess-free!</string>
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="fixed_size">Fast Størrelse</string>
<string name="progressive">Fremskridt</string>
<string name="highlight_unsolved_numbers">Fremhæv uløste tal</string>
<string name="more_games">Flere spil</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Feste Größe</string>
<string name="progressive">Fortschrittlich</string>
<string name="highlight_unsolved_numbers">Ungelöste Zahlen hervorheben</string>
<string name="more_games">Mehr Spiele</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-el-rGR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Προεπιλεγμένο Μέγεθος</string>
<string name="progressive">Προοδευτικό</string>
<string name="highlight_unsolved_numbers">Επισήμανση άλυτων αριθμών</string>
<string name="more_games">Περισσότερα παιχνίδια</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-en-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">More Games</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-eo-rUY/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">More games</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Tamaño fijo</string>
<string name="progressive">Progresivo</string>
<string name="highlight_unsolved_numbers">Resaltar números sin completar</string>
<string name="more_games">Más juegos</string>
</resources>
3 changes: 2 additions & 1 deletion i18n/src/main/res/values-fa-rIR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="tutorial_text_2">After mark your first flag, review the numbers and analyze the next square.</string>
<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="games">بازی‌ها</string>
<string name="tap_to_begin">Tap to Begin</string>
<string name="previous_games">Previous Games</string>
<string name="minefield">Difficulty</string>
Expand Down Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">More games</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-fi-rFI/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Kiinteä koko</string>
<string name="progressive">Edistyvä</string>
<string name="highlight_unsolved_numbers">Korosta ratkaisemattomat numerot</string>
<string name="more_games">Lisää pelejä</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Taille fixe</string>
<string name="progressive">Progressif</string>
<string name="highlight_unsolved_numbers">Mettre en évidence les nombres non résolus</string>
<string name="more_games">Plus de Jeux</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-hi-rIN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">निर्धारित आकार</string>
<string name="progressive">प्रोग्रेसिव</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">अन्य गेम्स</string>
</resources>
5 changes: 3 additions & 2 deletions i18n/src/main/res/values-hu-rHU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
<string name="tap_to_customize">Koppintson a testreszabáshoz</string>
<string name="toggle_button_top">Mutassa a Kapcsolót a felső sávon</string>
<string name="no_guess_fail_warning">A jelenlegi szint lehet nem tipp mentes!</string>
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="fixed_size">Rögzített méret</string>
<string name="progressive">Előrehaladás</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">More games</string>
</resources>
3 changes: 2 additions & 1 deletion i18n/src/main/res/values-in-rID/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@
<string name="no_guess_fail_warning">Ladang Ranjau saat ini kemungkinan tidak dapat diselesaikan tanpa menebak!</string>
<string name="fixed_size">Ukuran tetap</string>
<string name="progressive">Progresif</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="highlight_unsolved_numbers">Soroti nomor yang belum diselesaikan</string>
<string name="more_games">Game Lain</string>
</resources>
1 change: 1 addition & 0 deletions i18n/src/main/res/values-it-rIT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@
<string name="fixed_size">Dimensione Fissa</string>
<string name="progressive">Progressivo</string>
<string name="highlight_unsolved_numbers">Evidenzia numeri non risolti</string>
<string name="more_games">Altri Giochi</string>
</resources>
9 changes: 5 additions & 4 deletions i18n/src/main/res/values-iw-rIL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<string name="beginner">רמת התחלה</string>
<string name="intermediate">רמה בינונית</string>
<string name="expert">רמה גבוהה</string>
<string name="master">Master</string>
<string name="legend">Legend</string>
<string name="master">רב-אמן</string>
<string name="legend">אגדה</string>
<string name="open">פתיחה</string>
<string name="settings">הגדרות</string>
<string name="animations">אנימציות</string>
Expand Down Expand Up @@ -118,7 +118,8 @@
<string name="tap_to_customize">Tap to customize</string>
<string name="toggle_button_top">Show \"Toggle Button\" on top bar</string>
<string name="no_guess_fail_warning">The current minefield may not be guess-free!</string>
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="fixed_size">גודל קבוע</string>
<string name="progressive">התקדמות</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="more_games">משחקים נוספים</string>
</resources>
13 changes: 7 additions & 6 deletions i18n/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@
<string name="switch_control_desc">旗と開くを切り替えるにはボタンを使用します</string>
<string name="app_description">地雷が隠された長方形から1つも爆発させることなくクリアしましょう。</string>
<string name="app_name">Antimine</string>
<string name="do_you_know_how_to_play">Do you know how to play minesweeper?</string>
<string name="do_you_know_how_to_play">「マインスイーパー」の遊び方がわかりませんか?</string>
<string name="close">閉じる</string>
<string name="open_tutorial">チュートリアルを開く</string>
<string name="click_numbers">Allow tap on numbers</string>
<string name="click_numbers">番号のタップを許可する</string>
<string name="tap_to_customize">タップしてカスタマイズ</string>
<string name="toggle_button_top">Show \"Toggle Button\" on top bar</string>
<string name="toggle_button_top">上部バーに「トグルボタン」を表示する</string>
<string name="no_guess_fail_warning">The current minefield may not be guess-free!</string>
<string name="fixed_size">Fixed Size</string>
<string name="progressive">Progressive</string>
<string name="highlight_unsolved_numbers">Highlight unsolved numbers</string>
<string name="fixed_size">固定サイズ</string>
<string name="progressive">プログレッシブ</string>
<string name="highlight_unsolved_numbers">未解決の数字をハイライト表示</string>
<string name="more_games">その他のゲーム</string>
</resources>
Loading

0 comments on commit 3d2e781

Please sign in to comment.