Skip to content

Commit

Permalink
Merge pull request #273 from lucasnlm/update-strings
Browse files Browse the repository at this point in the history
Update offer icon
  • Loading branch information
lucasnlm authored Apr 28, 2021
2 parents 346cd28 + b1b4561 commit 173b09a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 41 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {

defaultConfig {
// versionCode and versionName must be hardcoded to support F-droid
versionCode 1001001
versionName '10.1.0'
versionCode 1001021
versionName '10.1.2'
minSdkVersion 21
targetSdkVersion 30
multiDexEnabled true
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/dev/lucasnlm/antimine/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@ class MainActivity : ThematicActivity(R.layout.activity_main) {
}
}

private fun bindRemoveAds(price: String? = null, offerText: String? = null) {
private fun bindRemoveAds(price: String? = null, showOffer: Boolean = false) {
removeAds.apply {
visibility = View.VISIBLE
bind(
theme = usingTheme,
text = getString(R.string.remove_ad),
startIcon = R.drawable.remove_ads,
price = price,
offerText = offerText,
showOffer = showOffer,
onAction = {
lifecycleScope.launch {
billingManager.charge(this@MainActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package dev.lucasnlm.external.model

data class Price(
val price: String,
val offer: String?,
val offer: Boolean,
)
14 changes: 7 additions & 7 deletions i18n/src/main/res/values-fi-rFI/strings.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:locale="fi">
<string name="tutorial">Opetusohjelma</string>
<string name="tutorial">Johdanto</string>
<string name="tutorial_basic">The rule of the game is simple, the number on a square shows the number of mines adjacent to it and you have to flag all the mines.</string>
<string name="tutorial_text_1">If a number is touching the same number of squares, then the squares are all mines.</string>
<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="tutorial_text_4">Tarkista numerot ja avaa neliöitä.</string>
<string name="games">Pelit</string>
<string name="tap_to_begin">Aloita napauttamalla</string>
<string name="previous_games">Edelliset pelit</string>
Expand Down Expand Up @@ -46,7 +46,7 @@
<string name="you_finished">Olet valmis!</string>
<string name="defeats">Tappioita</string>
<string name="generic_game_over">Onnea seuraavaan peliisi.</string>
<string name="generic_win">Löysit %1$d miinoja %2$d sekunnin kuluttua.</string>
<string name="generic_win">Löysit %1$d miinaa %2$d sekuntissa.</string>
<string name="fail_to_share">Jakaminen epäonnistui</string>
<string name="version_s">Versio %1$s</string>
<string name="sound_effects">Äänitehosteet</string>
Expand Down Expand Up @@ -112,8 +112,8 @@
<string name="switch_control_desc">Käytä painiketta vaihtaaksesi lipun ja avaamisen välillä</string>
<string name="app_description">Sinun täytyy tyhjentää piileskeleviä miinoja sisältävä suorakulmainen taulu räjäyttämättä miinoja kertaakaan.</string>
<string name="app_name">Antimine</string>
<string name="do_you_know_how_to_play" comment="It will be shown in a window before show or not the tutorial.&#13;&#10;May also be translated as &quot;Do you want to read the tutorial?&quot;">Do you know how to play minesweeper?</string>
<string name="close">Close</string>
<string name="open_tutorial">Open Tutorial</string>
<string name="master" comment="new level difficulty">Master</string>
<string name="do_you_know_how_to_play" comment="It will be shown in a window before show or not the tutorial.&#13;&#10;May also be translated as &quot;Do you want to read the tutorial?&quot;">Tiedätkö miten pelata miinanharavaa?</string>
<string name="close">Sulje</string>
<string name="open_tutorial">Avaa Johdanto</string>
<string name="master" comment="new level difficulty">Mestari</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.filterNotNull
import java.util.Calendar
import kotlin.math.roundToInt

class BillingManager(
private val context: Context,
Expand Down Expand Up @@ -110,19 +109,15 @@ class BillingManager(
}

if (fullPrice != null && halfSize != null) {
val percent = halfSize.priceAmountMicros.toFloat() / fullPrice.priceAmountMicros.toFloat()
val percentInt = 5 * ((percent * 100.0f / 5f).roundToInt())
val percentText = "$percentInt\nOFF"

val price = if (giveOffer) {
Price(
halfSize.price,
percentText,
true,
)
} else {
Price(
fullPrice.price,
null,
false,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ThemeActivity : ThematicActivity(R.layout.activity_theme), SeekBar.OnSeekB
invert = true,
text = getString(R.string.remove_ad),
price = it.price,
offerText = it.offer,
showOffer = it.offer,
onAction = {
lifecycleScope.launch {
billingManager.charge(this@ThemeActivity)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.lucasnlm.antimine.ui.view

import android.content.Context
import android.content.res.ColorStateList
import android.util.AttributeSet
import android.view.Gravity
import android.view.LayoutInflater
Expand All @@ -9,6 +10,7 @@ import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.appcompat.widget.AppCompatImageView
import com.google.android.material.card.MaterialCardView
import dev.lucasnlm.antimine.ui.R
import dev.lucasnlm.antimine.ui.ext.toAndroidColor
Expand All @@ -30,7 +32,7 @@ class OfferCardButtonView : FrameLayout {
invert: Boolean = false,
text: String,
price: String? = null,
offerText: String? = null,
showOffer: Boolean = false,
onAction: (View) -> Unit,
centralize: Boolean = false,
@DrawableRes startIcon: Int? = null,
Expand All @@ -40,7 +42,7 @@ class OfferCardButtonView : FrameLayout {
invert = invert,
text = text,
price = price,
offerText = offerText,
showOffer = showOffer,
centralize = centralize,
onAction = onAction,
startIcon = startIcon,
Expand All @@ -52,7 +54,7 @@ class OfferCardButtonView : FrameLayout {
invert: Boolean = false,
text: String,
price: String? = null,
offerText: String? = null,
showOffer: Boolean,
centralize: Boolean = false,
onAction: (View) -> Unit,
@DrawableRes startIcon: Int? = null,
Expand Down Expand Up @@ -90,16 +92,15 @@ class OfferCardButtonView : FrameLayout {
}
}

val offerView = findViewById<TextView>(R.id.priceOff).apply {
if (offerText == null) {
visibility = View.GONE
val offerView = findViewById<AppCompatImageView>(R.id.priceOff).apply {
visibility = if (showOffer) {
View.VISIBLE
} else {
visibility = View.VISIBLE
this.text = offerText
View.GONE
}

if (invert) {
setTextColor(color)
imageTintList = ColorStateList.valueOf(color)
}
}

Expand Down Expand Up @@ -138,7 +139,7 @@ class OfferCardButtonView : FrameLayout {
priceView.setTextColor(inverted)
iconView.setColorFilter(inverted)
setCardBackgroundColor(focusedBackgroundColor)
offerView.setTextColor(inverted)
offerView.imageTintList = ColorStateList.valueOf(inverted)
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions ui/src/main/res/drawable/offer.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="M21.41,11.58l-9,-9C12.05,2.22 11.55,2 11,2H4c-1.1,0 -2,0.9 -2,2v7c0,0.55 0.22,1.05 0.59,1.42l9,9c0.36,0.36 0.86,0.58 1.41,0.58s1.05,-0.22 1.41,-0.59l7,-7c0.37,-0.36 0.59,-0.86 0.59,-1.41s-0.23,-1.06 -0.59,-1.42zM5.5,7C4.67,7 4,6.33 4,5.5S4.67,4 5.5,4 7,4.67 7,5.5 6.33,7 5.5,7z"/>
</vector>
17 changes: 6 additions & 11 deletions ui/src/main/res/layout/view_offer_card_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
android:layout_height="wrap_content"
android:alpha="0.9"
android:includeFontPadding="false"
android:paddingHorizontal="8dp"
android:paddingHorizontal="4dp"
android:textColor="@color/accent"
android:textSize="14sp"
android:textStyle="bold"
Expand All @@ -61,21 +61,16 @@
app:layout_constraintTop_toTopOf="parent"
tools:text="$ 1,00" />

<TextView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/priceOff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.9"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:lineHeight="12sp"
android:textColor="@color/accent"
android:textSize="14sp"
android:textStyle="bold"
android:src="@drawable/offer"
android:importantForAccessibility="no"
app:tint="@color/accent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="50\nOFF" />
app:layout_constraintTop_toTopOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
Expand Down

0 comments on commit 173b09a

Please sign in to comment.