Skip to content

Commit

Permalink
Merge pull request #361 from lucasnlm/update-16
Browse files Browse the repository at this point in the history
Update 16
  • Loading branch information
lucasnlm authored Jan 30, 2022
2 parents a4c4022 + 4e45c8f commit da036c4
Show file tree
Hide file tree
Showing 84 changed files with 485 additions and 135 deletions.
2 changes: 1 addition & 1 deletion about/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies {
implementation project(':tutorial')

// Google
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.material:material:1.5.0'

// AndroidX
implementation 'androidx.appcompat:appcompat:1.4.1'
Expand Down
7 changes: 4 additions & 3 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 1505001
versionName '15.5.0'
versionCode 1506001
versionName '15.6.0'
minSdkVersion 21
targetSdkVersion 31
multiDexEnabled true
Expand Down Expand Up @@ -91,6 +91,7 @@ android {
googleInstant {
dimension 'version'
applicationId 'dev.lucasnlm.antimine'
versionNameSuffix "-inst"
}

foss {
Expand Down Expand Up @@ -146,7 +147,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'

// Google
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.material:material:1.5.0'

// Koin
implementation 'io.insert-koin:koin-android:3.1.2'
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
android:theme="@style/AppTheme"
tools:targetApi="lollipop">

<!-- <meta-data-->
<!-- android:name="com.google.android.gms.instant.flavor"-->
<!-- android:value="1337" />-->

<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/dev/lucasnlm/antimine/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ open class MainApplication : MultiDexApplication() {
sentEvent(Analytics.Open)
}

if (featureFlagManager.isFoos) {
if (featureFlagManager.isFoss) {
preferencesRepository.setPremiumFeatures(true)
} else {
adsManager.start(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,28 @@ class GameOverDialogFragment : AppCompatDialogFragment() {
dismissAllowingStateLoss()
}

if (!preferencesRepository.isPremiumEnabled() &&
if (featureFlagManager.isFoss && preferencesRepository.requestDonation()) {
adFrame.visibility = View.VISIBLE

val view = View.inflate(context, R.layout.donation_request, null)
view.setOnClickListener {
activity?.let {
lifecycleScope.launch {
billingManager.charge(it)
preferencesRepository.setRequestDonation(false)
}
}
}

adFrame.addView(
view,
FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL
)
)
} else if (!preferencesRepository.isPremiumEnabled() &&
featureFlagManager.isBannerAdEnabled
) {
adFrame.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,28 @@ class WinGameDialogFragment : AppCompatDialogFragment() {
)
}

if (!preferencesRepository.isPremiumEnabled() &&
if (featureFlagManager.isFoss && preferencesRepository.requestDonation()) {
adFrame.visibility = View.VISIBLE

val view = View.inflate(context, R.layout.donation_request, null)
view.setOnClickListener {
activity?.let {
lifecycleScope.launch {
billingManager.charge(it)
preferencesRepository.setRequestDonation(false)
}
}
}

adFrame.addView(
view,
FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL
)
)
} else if (!preferencesRepository.isPremiumEnabled() &&
featureFlagManager.isBannerAdEnabled
) {
adFrame.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class MainActivity : ThematicActivity(R.layout.activity_main) {
)

removeAds.visibility = View.GONE
if (featureFlagManager.isFoos) {
if (featureFlagManager.isFoss) {
removeAds.apply {
visibility = View.VISIBLE
bind(
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/money.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M11.8,10.9c-2.27,-0.59 -3,-1.2 -3,-2.15 0,-1.09 1.01,-1.85 2.7,-1.85 1.42,0 2.13,0.54 2.39,1.4 0.12,0.4 0.45,0.7 0.87,0.7h0.3c0.66,0 1.13,-0.65 0.9,-1.27 -0.42,-1.18 -1.4,-2.16 -2.96,-2.54V4.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,3.67 10,4.5v0.66c-1.94,0.42 -3.5,1.68 -3.5,3.61 0,2.31 1.91,3.46 4.7,4.13 2.5,0.6 3,1.48 3,2.41 0,0.69 -0.49,1.79 -2.7,1.79 -1.65,0 -2.5,-0.59 -2.83,-1.43 -0.15,-0.39 -0.49,-0.67 -0.9,-0.67h-0.28c-0.67,0 -1.14,0.68 -0.89,1.3 0.57,1.39 1.9,2.21 3.4,2.53v0.67c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-0.65c1.95,-0.37 3.5,-1.5 3.5,-3.55 0,-2.84 -2.43,-3.81 -4.7,-4.4z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/round_play_arrow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M8,6.82v10.36c0,0.79 0.87,1.27 1.54,0.84l8.14,-5.18c0.62,-0.39 0.62,-1.29 0,-1.69L9.54,5.98C8.87,5.55 8,6.03 8,6.82z"/>
</vector>
48 changes: 48 additions & 0 deletions app/src/main/res/layout/donation_request.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/donation"
android:focusable="true"
android:padding="16dp">

<ImageView
android:id="@+id/money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:src="@drawable/money"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/accent" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:importantForAccessibility="no"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/money"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/donate_request"
android:textColor="?colorOnBackground" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/donate_help"
android:textColor="?colorOnBackground" />
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,8 @@ class MockPreferencesRepository : IPreferencesRepository {
override fun setLeftHandedMode(enabled: Boolean) {}

override fun leftHandedMode(): Boolean = false

override fun setRequestDonation(request: Boolean) {}

override fun requestDonation(): Boolean = true
}
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
implementation 'androidx.fragment:fragment-ktx:1.4.0'

// Google
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.material:material:1.5.0'

// Constraint
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ class GameController {
fun isGameOver(): Boolean =
hasIsolatedAllMines() || (explodedMinesCount() > errorTolerance)

fun hasOpenMines(): Boolean =
mines().firstOrNull { it.hasMine && !it.isCovered } != null

fun remainingMines(): Int {
val flagsCount = field.count { it.isCovered && it.mark.isFlag() }
val minesCount = mines().count()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ val LevelModule = module {
} bind IMinefieldRepository::class

single {
TipRepository(get())
TipRepository(get(), get())
} bind ITipRepository::class
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.lucasnlm.antimine.common.level.repository

import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.external.IFeatureFlagManager

interface ITipRepository {
fun setExtraTips(amount: Int)
Expand All @@ -10,7 +11,8 @@ interface ITipRepository {
}

class TipRepository(
private val preferencesRepository: IPreferencesRepository
private val preferencesRepository: IPreferencesRepository,
private val featureFlagManager: IFeatureFlagManager,
) : ITipRepository {
override fun setExtraTips(amount: Int) {
preferencesRepository.setExtraTips(amount)
Expand All @@ -37,15 +39,18 @@ class TipRepository(
}

override fun increaseTip(amount: Int) {
val newValue = (preferencesRepository.getTips() + amount).coerceAtMost(MAX_TIPS).coerceAtLeast(0)
val newValue =
(preferencesRepository.getTips() + amount)
.coerceAtMost(getMaxTips())
.coerceAtLeast(0)
preferencesRepository.setTips(newValue)
}

override fun getTotalTips(): Int {
return preferencesRepository.getExtraTips() + preferencesRepository.getTips()
}

companion object {
const val MAX_TIPS = 25
private fun getMaxTips(): Int {
return if (featureFlagManager.isFoss) 100 else 25
}
}
Loading

0 comments on commit da036c4

Please sign in to comment.