Add GitHub Sponsor button to generic build

pull/1230/head
Alex Baker 5 years ago
parent 5621a268d0
commit 33403b269a

@ -1,3 +0,0 @@
package org.tasks.auth
class SignInActivity

@ -4,21 +4,17 @@ package org.tasks.billing
class Purchase(json: String?) {
val sku: String = ""
fun toJson(): String? {
return null
}
fun toJson(): String? = null
val isCanceled: Boolean
get() = false
val isCanceled = false
val subscriptionPrice: Int
get() = 0
val subscriptionPrice = 0
val isMonthly: Boolean
get() = false
val isMonthly = false
val isProSubscription: Boolean
get() = false
val isProSubscription = false
val isTasksSubscription = false
val purchaseToken = ""
}

@ -6,6 +6,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.method.LinkMovementMethod
import androidx.core.view.isVisible
@ -17,6 +18,7 @@ import com.google.android.material.slider.Slider
import dagger.hilt.android.AndroidEntryPoint
import io.noties.markwon.Markwon
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin
import org.tasks.BuildConfig
import org.tasks.LocalBroadcastManager
import org.tasks.R
import org.tasks.databinding.ActivityPurchaseBinding
@ -73,7 +75,15 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
.usePlugin(StrikethroughPlugin.create())
.build()
setWaitScreen(true)
if (BuildConfig.FLAVOR != "generic") {
setWaitScreen(true)
} else {
setWaitScreen(false)
binding.payAnnually.isVisible = false
binding.payMonthly.isVisible = false
binding.payOther.isVisible = false
binding.sponsor.isVisible = true
}
return dialogBuilder.newDialog()
.setView(binding.root)
@ -82,13 +92,13 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
private fun updateText() {
var benefits = "### ${getString(R.string.upgrade_header)}"
if (nameYourPrice) {
benefits += """
benefits += if (nameYourPrice) {
"""
---
#### ~~${getString(R.string.upgrade_sync_with_tasks)}~~
"""
} else {
benefits += """
"""
---
#### [${getString(R.string.upgrade_sync_with_tasks)} (BETA)](${getString(R.string.help_url_sync)})
* **${getString(R.string.upgrade_no_platform_lock_in)}** ${getString(R.string.upgrade_open_internet_standards)}
@ -96,7 +106,13 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
* ${getString(R.string.upgrade_coming_soon)}
"""
}
benefits += """
benefits += if (BuildConfig.FLAVOR == "generic") {
"""
---
**${getString(R.string.upgrade_previous_donors)}** - [${getString(R.string.contact_developer)}](mailto:${getString(R.string.support_email)}) ${getString(R.string.upgrade_previous_donors_contact)}
"""
} else {
"""
---
#### ${getString(R.string.upgrade_synchronization)}
* [${getString(R.string.davx5)}](${getString(R.string.url_davx5)})
@ -113,7 +129,7 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
* **${getString(R.string.upgrade_downgrade)}** ${getString(R.string.upgrade_balance)}
* **${getString(R.string.upgrade_cancel)}** ${getString(R.string.upgrade_benefits_retained)}
"""
}
binding.text.text = markwon.toMarkdown(benefits)
}
@ -126,6 +142,11 @@ class PurchaseDialog : DialogFragment(), OnPurchasesUpdated {
fun subscribeMonthly() {
initiatePurchase(true, 3)
}
@OnClick(R.id.sponsor)
fun sponsor() {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_sponsor))))
}
private fun initiatePurchase(isMonthly: Boolean, price: Int) {
val newSku = String.format("%s_%02d", if (isMonthly) "monthly" else "annual", price)

@ -6,6 +6,7 @@
xmlns:tools="http://schemas.android.com/tools">
<ScrollView
android:id="@+id/scroll"
android:layout_alignParentTop="true"
android:layout_above="@id/bottom_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -102,6 +103,20 @@
app:layout_constraintTop_toBottomOf="@+id/pay_annually"
tools:text="@string/back"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/sponsor"
style="@style/OutlineButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/github_sponsor"
android:textColor="@color/text_secondary"
android:visibility="gone"
app:icon="@drawable/ic_outline_favorite_border_24px"
app:iconTint="@color/github_sponsor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pay_annually"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

@ -151,5 +151,7 @@
<color name="default_chip_background">@color/grey_300</color>
<color name="default_chip_text_color">@color/black_87</color>
<color name="github_sponsor">#eb52ae</color>
</resources>

@ -23,9 +23,10 @@
<string name="url_tasker">https://tasks.org/help/tasker</string>
<string name="url_donate">https://tasks.org/donate</string>
<string name="url_reddit">https://reddit.com/r/tasks</string>
<string name="url_sponsor">https://github.com/sponsors/abaker</string>
<!-- Eventually these should be moved to strings.xml for translation -->
<string name="upgrade_header">Subscribe to unlock additional features and support open source software!</string>
<string name="upgrade_header">Unlock additional features and support open source software!</string>
<string name="upgrade_sync_with_tasks">Sync with Tasks.org</string>
<string name="upgrade_no_platform_lock_in">No platform lock-in</string>
<string name="upgrade_open_internet_standards">Tasks.org is based on open internet standards</string>
@ -44,6 +45,8 @@
<string name="upgrade_balance">Your remaining balance will apply to your new subscription</string>
<string name="upgrade_cancel">Cancel at any time</string>
<string name="upgrade_benefits_retained">benefits are retained until the end of your billing period</string>
<string name="upgrade_previous_donors">Previous donors</string>
<string name="upgrade_previous_donors_contact">to receive one month credit for every $3 in past donations</string>
<string name="p_date_shortcut_morning">date_shortcut_morning</string>
<string name="p_date_shortcut_afternoon">date_shortcut_afternoon</string>

@ -668,4 +668,5 @@ File %1$s contained %2$s.\n\n
<string name="authorization_cancelled">Authorization cancelled</string>
<string name="sign_in_with_google">Sign in with Google</string>
<string name="authentication_required">Authentication required</string>
<string name="github_sponsor">Sponsor</string>
</resources>

Loading…
Cancel
Save