Skip to content

Commit

Permalink
Make paid limitation warning more visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Nain57 committed Nov 24, 2024
1 parent 73940c7 commit 560de07
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,18 @@ class ScenarioCreationDialog : DialogFragment() {
viewBinding.apply {
scenarioTypeDumb.setState(state.dumbItem, state.selectedItem, ScenarioTypeSelection.DUMB)
scenarioTypeSmart.setState(state.smartItem, state.selectedItem, ScenarioTypeSelection.SMART)
scenarioTypeDescription.setText(
when (state.selectedItem) {
ScenarioTypeSelection.DUMB -> state.dumbItem.descriptionText
ScenarioTypeSelection.SMART -> state.smartItem.descriptionText

when (state.selectedItem) {
ScenarioTypeSelection.DUMB -> {
scenarioTypeDescription.setText(state.dumbItem.descriptionText)
scenarioTypeDescriptionNotPurchased.visibility = View.GONE
}
ScenarioTypeSelection.SMART -> {
scenarioTypeDescription.setText(state.smartItem.descriptionText)
scenarioTypeDescriptionNotPurchased.visibility =
if (state.showPaidLimitationWarning) View.VISIBLE else View.GONE
}
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class ScenarioCreationViewModel @Inject constructor(
combine(_selectedType, revenueRepository.userBillingState) { selectedType, billingState ->
ScenarioTypeSelectionState(
dumbItem = ScenarioTypeItem.Dumb,
smartItem = ScenarioTypeItem.Smart(isProModeEnabled = billingState == UserBillingState.PURCHASED),
smartItem = ScenarioTypeItem.Smart,
selectedItem = selectedType,
showPaidLimitationWarning =
billingState == UserBillingState.PURCHASED && selectedType == ScenarioTypeSelection.SMART
)
}

Expand Down Expand Up @@ -133,6 +135,7 @@ data class ScenarioTypeSelectionState(
val dumbItem: ScenarioTypeItem.Dumb,
val smartItem: ScenarioTypeItem.Smart,
val selectedItem: ScenarioTypeSelection,
val showPaidLimitationWarning: Boolean,
)

sealed class ScenarioTypeItem(val titleRes: Int, val iconRes: Int, val descriptionText: Int) {
Expand All @@ -143,12 +146,10 @@ sealed class ScenarioTypeItem(val titleRes: Int, val iconRes: Int, val descripti
descriptionText = R.string.item_desc_dumb_scenario,
)

data class Smart(val isProModeEnabled: Boolean): ScenarioTypeItem(
data object Smart: ScenarioTypeItem(
titleRes = R.string.item_title_smart_scenario,
iconRes = R.drawable.ic_smart,
descriptionText =
if (isProModeEnabled) R.string.item_desc_smart_scenario_pro_mode
else R.string.item_desc_smart_scenario,
descriptionText = R.string.item_desc_smart_scenario,
)
}
enum class ScenarioTypeSelection {
Expand Down
15 changes: 15 additions & 0 deletions smartautoclicker/src/main/res/layout/dialog_scenario_creation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,24 @@
android:layout_height="wrap_content"
android:gravity="center"
android:lines="3"
android:layout_marginTop="@dimen/margin_vertical_default"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/scenario_type_dumb"
app:layout_constraintBottom_toTopOf="@id/scenario_type_description_not_purchased"
android:text="@string/item_desc_smart_scenario"/>

<com.google.android.material.textview.MaterialTextView
android:id="@+id/scenario_type_description_not_purchased"
style="@style/AppTheme.TextAppearance.Body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_vertical_default"
android:gravity="center"
android:textColor="?attr/colorError"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/scenario_type_description"
app:layout_constraintBottom_toBottomOf="parent"
android:text="@string/item_desc_smart_scenario_pro_mode"/>

Expand Down
4 changes: 2 additions & 2 deletions smartautoclicker/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
<string name="item_desc_dumb_scenario_max_duration_infinite">Pas de durée maximum</string>
<string name="item_desc_dumb_scenario_repeat_count">Répéter %1$d fois</string>
<string name="item_desc_dumb_scenario_repeat_infinite">Répéter à l\'infini</string>
<string name="item_desc_smart_scenario">Utilise la détéction d\'image pour créer des scénarios complexes.\nContient des limitations payantes.</string>
<string name="item_desc_smart_scenario_pro_mode">Utilise la détéction d\'image pour créer des scénarios complexes.</string>
<string name="item_desc_smart_scenario">Utilise la détéction d\'image pour créer des scénarios complexes.</string>
<string name="item_desc_smart_scenario_pro_mode">Nécessite de regarder une publicité ou d\'acheter le mode pro</string>
<string name="item_title_dumb_scenario">Simple</string>
<string name="item_title_smart_scenario">Intelligente</string>

Expand Down
4 changes: 2 additions & 2 deletions smartautoclicker/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
<string name="item_desc_dumb_scenario_max_duration_infinite">Nessuna durata massima</string>
<string name="item_desc_dumb_scenario_repeat_count">Ripetere %1$d volte</string>
<string name="item_desc_dumb_scenario_repeat_infinite">Ripetizione infinita</string>
<string name="item_desc_smart_scenario">Utilizzate il rilevamento delle immagini per creare casi d\'uso complessi.\nContiene limitazioni a pagamento.</string>
<string name="item_desc_smart_scenario_pro_mode">Utilizzate il rilevamento delle immagini per creare casi d\'uso complessi.</string>
<string name="item_desc_smart_scenario">Utilizzate il rilevamento delle immagini per creare casi d\'uso complessi.</string>
<string name="item_desc_smart_scenario_pro_mode">Richiede la visione di un annuncio o l\'acquisto della modalità pro</string>
<string name="item_title_dumb_scenario">Semplice</string>
<string name="item_title_smart_scenario">Intelligente</string>

Expand Down
4 changes: 2 additions & 2 deletions smartautoclicker/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
<string name="item_desc_dumb_scenario_max_duration_infinite">Sem duração máxima</string>
<string name="item_desc_dumb_scenario_repeat_count">Repetir %1$d vezes</string>
<string name="item_desc_dumb_scenario_repeat_infinite">Repetição infinita</string>
<string name="item_desc_smart_scenario">Use a detecção de imagem para criar casos de uso complexos.\nContém limitações pagas.</string>
<string name="item_desc_smart_scenario_pro_mode">Use a detecção de imagem para criar casos de uso complexos.</string>
<string name="item_desc_smart_scenario">Use a detecção de imagem para criar casos de uso complexos.</string>
<string name="item_desc_smart_scenario_pro_mode">É necessário assistir a um anúncio ou comprar o modo profissional</string>
<string name="item_title_dumb_scenario">Simples</string>
<string name="item_title_smart_scenario">Inteligente</string>

Expand Down
4 changes: 2 additions & 2 deletions smartautoclicker/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
<string name="item_desc_dumb_scenario_max_duration_infinite">无最长持续时间</string>
<string name="item_desc_dumb_scenario_repeat_count">重复 %1$d 次</string>
<string name="item_desc_dumb_scenario_repeat_infinite">无限重复</string>
<string name="item_desc_smart_scenario">使用图像检测创建复杂的用例\n包含付费限制。</string>
<string name="item_desc_smart_scenario_pro_mode">使用图像检测创建复杂的用例</string>
<string name="item_desc_smart_scenario">使用图像检测创建复杂的用例。</string>
<string name="item_desc_smart_scenario_pro_mode">需要观看广告或购买专业模式</string>
<string name="item_title_dumb_scenario">简单</string>
<string name="item_title_smart_scenario">智能</string>

Expand Down
4 changes: 2 additions & 2 deletions smartautoclicker/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
<string name="item_desc_dumb_scenario_max_duration_infinite">No max duration</string>
<string name="item_desc_dumb_scenario_repeat_count">Repeat %1$d times</string>
<string name="item_desc_dumb_scenario_repeat_infinite">Infinite repeat</string>
<string name="item_desc_smart_scenario">Use image detection to create complex use cases.\nContains paid limitations.</string>
<string name="item_desc_smart_scenario_pro_mode">Use image detection to create complex use cases.</string>
<string name="item_desc_smart_scenario">Use image detection to create complex use cases.</string>
<string name="item_desc_smart_scenario_pro_mode">Requires to watch an ad or buy pro mode</string>
<string name="item_title_dumb_scenario">Simple</string>
<string name="item_title_smart_scenario">Smart</string>

Expand Down

0 comments on commit 560de07

Please sign in to comment.