This commit is contained in:
Lucas Lima 2020-08-24 21:01:06 -03:00 committed by Lucas Lima
parent a771b5efad
commit 272f87cfa6
9 changed files with 29 additions and 14 deletions

View file

@ -9,8 +9,8 @@ class IapHandler(
private val context: Context,
private val preferencesManager: IPreferencesRepository
) : UnlockAppListener {
override fun onLockStatusChanged(status: Boolean) {
preferencesManager.unlockExtras()
override fun onLockStatusChanged(isFreeUnlock: Boolean, status: Boolean) {
preferencesManager.setLockExtras(status, isFreeUnlock)
}
override fun showFailToConnectFeedback() {

View file

@ -36,7 +36,7 @@ class AboutViewModel(
"Portuguese (BR)" to sequenceOf("Lucas Lima"),
"Russian" to sequenceOf("gaich@xda", "ask45t", "Ekaterina543"),
"Spanish" to sequenceOf("Alfredo Jara", "Aldo Rodriguez", "Inail"),
"Turkish" to sequenceOf("Fatih Fırıncı"),
"Turkish" to sequenceOf("creuzwagen", "Fatih Fırıncı"),
"Ukrainian" to sequenceOf("Dmitry Shuba"),
"Vietnamese" to sequenceOf("pnhpnh")
).map {

View file

@ -7,11 +7,14 @@ import dev.lucasnlm.antimine.BuildConfig
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.viewmodel.AboutEvent
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import kotlinx.android.synthetic.main.fragment_about_info.*
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
private val aboutViewModel: AboutViewModel by sharedViewModel()
private val preferencesRepository: IPreferencesRepository by inject()
override fun onResume() {
super.onResume()
@ -23,9 +26,13 @@ class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
version.text = getString(R.string.version_s, BuildConfig.VERSION_NAME)
if (preferencesRepository.showSupport()) {
supportUs.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.SupportUs)
}
} else {
supportUs.visibility = View.GONE
}
thirdsParties.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.ThirdPartyLicenses)

View file

@ -81,11 +81,13 @@
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?selectableItemBackgroundBorderless"
android:visibility="gone"
android:contentDescription="@string/new_game"
android:padding="14dp"
ads:layout_constraintRight_toRightOf="parent"
ads:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/retry" />
app:srcCompat="@drawable/retry"
tools:visibility="visible"/>
<FrameLayout
android:id="@+id/levelContainer"

View file

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?selectableItemBackgroundBorderless"
android:background="?android:attr/selectableItemBackground"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"

View file

@ -32,8 +32,9 @@ interface IPreferencesRepository {
fun isRequestRatingEnabled(): Boolean
fun disableRequestRating()
fun unlockExtras()
fun setLockExtras(lock: Boolean, keepShowingSupportButton: Boolean)
fun areExtrasUnlocked(): Boolean
fun showSupport(): Boolean
fun useFlagAssistant(): Boolean
fun useHapticFeedback(): Boolean
@ -173,13 +174,18 @@ class PreferencesRepository(
}
}
override fun unlockExtras() {
preferencesManager.putBoolean(PREFERENCE_UNLOCK_EXTRAS, true)
override fun setLockExtras(lock: Boolean, keepShowingSupportButton: Boolean) {
preferencesManager.putBoolean(PREFERENCE_UNLOCK_EXTRAS, !lock)
preferencesManager.putBoolean(PREFERENCE_SHOW_SUPPORT, !lock || keepShowingSupportButton)
}
override fun areExtrasUnlocked(): Boolean =
preferencesManager.getBoolean(PREFERENCE_UNLOCK_EXTRAS, false)
override fun showSupport(): Boolean {
return preferencesManager.getBoolean(PREFERENCE_SHOW_SUPPORT, true)
}
private companion object {
private const val PREFERENCE_VIBRATION = "preference_vibration"
private const val PREFERENCE_ASSISTANT = "preference_assistant"
@ -201,5 +207,6 @@ class PreferencesRepository(
private const val PREFERENCE_USE_COUNT = "preference_use_count"
private const val PREFERENCE_REQUEST_RATING = "preference_request_rating"
private const val PREFERENCE_UNLOCK_EXTRAS = "preference_unlock_extras"
private const val PREFERENCE_SHOW_SUPPORT = "preference_show_support"
}
}

View file

@ -29,7 +29,6 @@
<string name="settings_general">General</string>
<string name="settings_gameplay">Gameplay</string>
<string name="settings_accessibility">Accessibility</string>
<string name="settings_large_areas">Use Large Areas</string>
<string name="size">Size</string>
<string name="system">System</string>
<string name="amoled" translatable="false">AMOLED</string>

View file

@ -9,7 +9,7 @@ interface IBillingManager {
}
interface UnlockAppListener {
fun onLockStatusChanged(status: Boolean)
fun onLockStatusChanged(isFreeUnlock: Boolean, status: Boolean)
fun showFailToConnectFeedback()
}

View file

@ -28,7 +28,7 @@ class BillingManager(
it.sku == BASIC_SUPPORT
}?.let {
if (it.purchaseState == Purchase.PurchaseState.PURCHASED) {
unlockAppListener?.onLockStatusChanged(true)
unlockAppListener?.onLockStatusChanged(isFreeUnlock = false, status = true)
}
}
}
@ -55,7 +55,7 @@ class BillingManager(
handlePurchases(it.toList())
}
} else {
unlockAppListener?.onLockStatusChanged(false)
unlockAppListener?.onLockStatusChanged(isFreeUnlock = false, status = false)
}
}