Default to 'Name your price' screen

pull/1305/head
Alex Baker 4 years ago
parent d5354af20a
commit cd1e129386

@ -66,7 +66,9 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
binding = ActivityPurchaseBinding.inflate(layoutInflater) binding = ActivityPurchaseBinding.inflate(layoutInflater)
ButterKnife.bind(this, binding.root) ButterKnife.bind(this, binding.root)
if (savedInstanceState != null) { if (savedInstanceState == null) {
nameYourPrice = !isTasksPayment
} else {
binding.slider.value = savedInstanceState.getFloat(EXTRA_PRICE) binding.slider.value = savedInstanceState.getFloat(EXTRA_PRICE)
priceChanged = savedInstanceState.getBoolean(EXTRA_PRICE_CHANGED) priceChanged = savedInstanceState.getBoolean(EXTRA_PRICE_CHANGED)
nameYourPrice = savedInstanceState.getBoolean(EXTRA_NAME_YOUR_PRICE) nameYourPrice = savedInstanceState.getBoolean(EXTRA_NAME_YOUR_PRICE)
@ -195,11 +197,15 @@ _${getString(R.string.upgrade_tasks_no_account)}_
@OnClick(R.id.pay_other) @OnClick(R.id.pay_other)
fun nameYourPrice() { fun nameYourPrice() {
if (isTasksPayment) {
dismiss()
} else {
nameYourPrice = !nameYourPrice nameYourPrice = !nameYourPrice
setWaitScreen(false) setWaitScreen(false)
binding.scroll.scrollTo(0, 0) binding.scroll.scrollTo(0, 0)
updateSubscribeButton() updateSubscribeButton()
} }
}
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
@ -213,13 +219,11 @@ _${getString(R.string.upgrade_tasks_no_account)}_
val generic = BuildConfig.FLAVOR == "generic" val generic = BuildConfig.FLAVOR == "generic"
binding.sliderContainer.isVisible = !isWaitScreen && nameYourPrice binding.sliderContainer.isVisible = !isWaitScreen && nameYourPrice
binding.payOther.isVisible = !isWaitScreen binding.payOther.isVisible = !isWaitScreen
if (nameYourPrice) { binding.payOther.setText(when {
binding.payOther.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) isTasksPayment -> R.string.cancel
binding.payOther.setText(R.string.back) nameYourPrice -> R.string.upgrade_tasks_account
} else { else -> R.string.back
binding.payOther.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_keyboard_arrow_right_24px, 0) })
binding.payOther.setText(R.string.more_options)
}
binding.tasksOrgButtonPanel.isVisible = !isWaitScreen && !generic binding.tasksOrgButtonPanel.isVisible = !isWaitScreen && !generic
binding.screenWait.isVisible = isWaitScreen && !generic binding.screenWait.isVisible = isWaitScreen && !generic
binding.sponsor.isVisible = generic binding.sponsor.isVisible = generic
@ -359,8 +363,12 @@ _${getString(R.string.upgrade_tasks_no_account)}_
return dialog return dialog
} }
fun newPurchaseDialog(target: Fragment, rc: Int): PurchaseDialog { fun newPurchaseDialog(
val dialog = PurchaseDialog() target: Fragment,
rc: Int,
tasksPayment: Boolean = false
): PurchaseDialog {
val dialog = newPurchaseDialog(tasksPayment)
dialog.setTargetFragment(target, rc) dialog.setTargetFragment(target, rc)
return dialog return dialog
} }

@ -107,7 +107,7 @@ class ColorPalettePicker : DialogFragment() {
if (inventory.purchasedThemes()) { if (inventory.purchasedThemes()) {
builder.setNegativeButton(R.string.cancel, null) builder.setNegativeButton(R.string.cancel, null)
} else { } else {
builder.setPositiveButton(R.string.button_subscribe) { _: DialogInterface?, _: Int -> builder.setPositiveButton(R.string.upgrade_to_pro) { _: DialogInterface?, _: Int ->
newPurchaseDialog().show(parentFragmentManager, FRAG_TAG_PURCHASE_DIALOG) newPurchaseDialog().show(parentFragmentManager, FRAG_TAG_PURCHASE_DIALOG)
} }
} }

@ -49,7 +49,7 @@ class ColorWheelPicker : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: requireArguments().getInt(EXTRA_SELECTED, 0) selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: requireArguments().getInt(EXTRA_SELECTED, 0)
val button = if (inventory.purchasedThemes()) R.string.ok else R.string.button_subscribe val button = if (inventory.purchasedThemes()) R.string.ok else R.string.upgrade_to_pro
val builder = ColorPickerDialogBuilder val builder = ColorPickerDialogBuilder
.with(activity) .with(activity)
.wheelType(ColorPickerView.WHEEL_TYPE.CIRCLE) .wheelType(ColorPickerView.WHEEL_TYPE.CIRCLE)

@ -64,7 +64,7 @@ public class IconPickerDialog extends DialogFragment {
dialogBuilder.newDialog().setNegativeButton(R.string.cancel, null).setView(view); dialogBuilder.newDialog().setNegativeButton(R.string.cancel, null).setView(view);
if (!inventory.getHasPro()) { if (!inventory.getHasPro()) {
builder.setPositiveButton( builder.setPositiveButton(
R.string.button_subscribe, R.string.upgrade_to_pro,
(dialog, which) -> newPurchaseDialog() (dialog, which) -> newPurchaseDialog()
.show(getParentFragmentManager(), PurchaseDialog.getFRAG_TAG_PURCHASE_DIALOG())); .show(getParentFragmentManager(), PurchaseDialog.getFRAG_TAG_PURCHASE_DIALOG()));
} }

@ -123,7 +123,7 @@ class ThemePickerDialog : DialogFragment() {
val stringRes = if (available()) { val stringRes = if (available()) {
R.string.cancel R.string.cancel
} else { } else {
R.string.button_subscribe R.string.upgrade_to_pro
} }
dialog?.getButton(AlertDialog.BUTTON_POSITIVE)?.text = getString(stringRes) dialog?.getButton(AlertDialog.BUTTON_POSITIVE)?.text = getString(stringRes)

@ -26,6 +26,7 @@ import org.tasks.billing.PurchaseDialog.Companion.newPurchaseDialog
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import java.io.BufferedReader import java.io.BufferedReader
import javax.inject.Inject import javax.inject.Inject
import kotlin.random.Random
@AndroidEntryPoint @AndroidEntryPoint
class WhatsNewDialog : DialogFragment() { class WhatsNewDialog : DialogFragment() {
@ -56,9 +57,10 @@ class WhatsNewDialog : DialogFragment() {
changelog.movementMethod = LinkMovementMethod.getInstance() changelog.movementMethod = LinkMovementMethod.getInstance()
changelog.text = markwon.toMarkdown(text) changelog.text = markwon.toMarkdown(text)
val begForSubscription = firebase.noChurn() && !inventory.hasPro
val begForRating = !preferences.getBoolean(R.string.p_clicked_rate, false) val begForRating = !preferences.getBoolean(R.string.p_clicked_rate, false)
&& (inventory.purchasedThemes() || firebase.noChurn()) && (inventory.purchasedThemes() || firebase.noChurn())
val begForSubscription = firebase.noChurn() && !inventory.hasPro && (!begForSubscription || Random.nextBoolean())
when { when {
BuildConfig.FLAVOR == "generic" -> { BuildConfig.FLAVOR == "generic" -> {
@ -74,7 +76,7 @@ class WhatsNewDialog : DialogFragment() {
begForSubscription -> { begForSubscription -> {
displayedSubscribe = true displayedSubscribe = true
actionText.text = getString(R.string.support_development_subscribe) actionText.text = getString(R.string.support_development_subscribe)
actionButton.text = getString(R.string.button_subscribe) actionButton.text = getString(R.string.name_your_price)
actionButton.setOnClickListener { onSubscribeClick() } actionButton.setOnClickListener { onSubscribeClick() }
} }
else -> { else -> {

@ -179,7 +179,7 @@ class FilterProvider @Inject constructor(
} }
.plusIf(!inventory.hasPro) { .plusIf(!inventory.hasPro) {
NavigationDrawerAction( NavigationDrawerAction(
context.getString(R.string.upgrade_to_pro), context.getString(R.string.name_your_price),
R.drawable.ic_outline_attach_money_24px, R.drawable.ic_outline_attach_money_24px,
NavigationDrawerFragment.REQUEST_PURCHASE) NavigationDrawerFragment.REQUEST_PURCHASE)
} }

@ -122,7 +122,7 @@ class TasksAccount : InjectingPreferenceFragment() {
private fun showPurchaseDialog(): Boolean { private fun showPurchaseDialog(): Boolean {
PurchaseDialog PurchaseDialog
.newPurchaseDialog(this, REQUEST_PURCHASE) .newPurchaseDialog(this, REQUEST_PURCHASE, tasksPayment = true)
.show(parentFragmentManager, PurchaseDialog.FRAG_TAG_PURCHASE_DIALOG) .show(parentFragmentManager, PurchaseDialog.FRAG_TAG_PURCHASE_DIALOG)
return false return false
} }

@ -32,7 +32,7 @@
<!-- Eventually these should be moved to strings.xml for translation --> <!-- Eventually these should be moved to strings.xml for translation -->
<string name="upgrade_tasks_account">Tasks.org account</string> <string name="upgrade_tasks_account">Tasks.org account</string>
<string name="upgrade_tasks_no_account">Tasks.org account not included with \'Name your price\' subscriptions</string> <string name="upgrade_tasks_no_account">Not included with \'Name your price\' subscriptions</string>
<string name="upgrade_sync_self_hosted">Sync with third-party apps and services</string> <string name="upgrade_sync_self_hosted">Sync with third-party apps and services</string>
<string name="upgrade_third_party_apps">Compatible with Outlook, Thunderbird, Apple Reminders, and more</string> <string name="upgrade_third_party_apps">Compatible with Outlook, Thunderbird, Apple Reminders, and more</string>
<string name="upgrade_coming_soon">Many new features coming soon!</string> <string name="upgrade_coming_soon">Many new features coming soon!</string>

Loading…
Cancel
Save