Subscription window update

dev
Laurent 7 years ago
parent 8c1f230054
commit d37fa1737b
  1. 3
      app/src/main/java/net/pokeranalytics/android/PokerAnalyticsApplication.kt
  2. 36
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SubscriptionFragment.kt
  3. 28
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/ScreenSlidePageFragment.kt
  4. 9
      app/src/main/res/drawable/ic_baseline_all_inclusive_24px.xml
  5. 9
      app/src/main/res/drawable/ic_baseline_email_24px.xml
  6. 9
      app/src/main/res/drawable/ic_baseline_vpn_key_24px.xml
  7. 9
      app/src/main/res/drawable/ic_baseline_wifi_off_24px.xml
  8. 49
      app/src/main/res/layout/fragment_screen_slide_page.xml
  9. 72
      app/src/main/res/layout/fragment_subscription.xml
  10. 9
      app/src/main/res/values/strings.xml
  11. 21
      app/src/main/res/values/styles.xml

@ -48,7 +48,6 @@ class PokerAnalyticsApplication : Application() {
// Initialize Fabric with the debug-disabled crashlytics.
Fabric.with(this, crashlyticsKit)
if (BuildConfig.DEBUG) {
// Logs
Timber.plant(PokerAnalyticsLogs())
@ -56,7 +55,7 @@ class PokerAnalyticsApplication : Application() {
if (BuildConfig.DEBUG) {
Timber.d("UserPreferences.defaultCurrency: ${UserDefaults.currency.symbol}")
// this.createFakeSessions()
this.createFakeSessions()
}
Patcher.patchBreaks()

@ -10,6 +10,9 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.android.billingclient.api.BillingClient
import com.android.billingclient.api.Purchase
import com.android.billingclient.api.SkuDetails
@ -17,6 +20,7 @@ import com.android.billingclient.api.SkuDetailsResponseListener
import kotlinx.android.synthetic.main.fragment_subscription.*
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment
import net.pokeranalytics.android.ui.fragment.components.ScreenSlidePageFragment
import net.pokeranalytics.android.util.Preferences
import net.pokeranalytics.android.util.billing.AppGuard
import net.pokeranalytics.android.util.billing.IAPProducts
@ -24,6 +28,8 @@ import net.pokeranalytics.android.util.billing.PurchaseDelegate
import java.time.Period
data class FeatureDescriptor(var iconResId: Int, var titleResId: Int, var descResId: Int)
class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListener, PurchaseDelegate {
private var selectedProduct: SkuDetails? = null
@ -31,7 +37,9 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.showLoader(R.string.loading_please_wait)
if (!AppGuard.requestProducts(this)) {
this.hideLoader()
Toast.makeText(requireContext(), R.string.billingclient_unavailable, Toast.LENGTH_LONG).show()
}
}
@ -71,6 +79,12 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene
this.title.text = upgradeString
}
// Pager
// The pager adapter, which provides the pages to the view pager widget.
val pagerAdapter = ScreenSlidePagerAdapter(requireFragmentManager())
this.pager.adapter = pagerAdapter
this.purchase.isEnabled = false
this.purchase.setOnClickListener {
@ -82,10 +96,32 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene
}
}
/**
* A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in
* sequence.
*/
private inner class ScreenSlidePagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
private val dataSource: List<FeatureDescriptor> = listOf(
FeatureDescriptor(R.drawable.ic_baseline_all_inclusive_24px, R.string.f_unlimited, R.string.f_unlimited_desc),
FeatureDescriptor(R.drawable.ic_baseline_wifi_off_24px, R.string.f_offline, R.string.f_offline_desc),
FeatureDescriptor(R.drawable.ic_baseline_vpn_key_24px, R.string.f_privacy, R.string.f_privacy_desc),
FeatureDescriptor(R.drawable.ic_baseline_email_24px, R.string.f_support, R.string.f_support_desc)
)
override fun getCount(): Int = this.dataSource.size
override fun getItem(position: Int): Fragment {
val d = this.dataSource[position]
return ScreenSlidePageFragment(d.iconResId, d.titleResId, d.descResId)
}
}
// SkuDetailsResponseListener
override fun onSkuDetailsResponse(responseCode: Int, skuDetailsList: MutableList<SkuDetails>?) {
if (responseCode == BillingClient.BillingResponse.OK && skuDetailsList != null) {
this.hideLoader()
selectedProduct = skuDetailsList.first { it.sku == IAPProducts.PRO.identifier }
updateUI()
}

@ -0,0 +1,28 @@
package net.pokeranalytics.android.ui.fragment.components
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.fragment_screen_slide_page.*
import net.pokeranalytics.android.R
class ScreenSlidePageFragment(var iconResId: Int, var titleResId: Int, var descriptionResId: Int) : PokerAnalyticsFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = inflater.inflate(R.layout.fragment_screen_slide_page, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
this.icon.setImageResource(this.iconResId)
this.title.text = requireContext().getString(this.titleResId)
this.description.text = requireContext().getString(this.descriptionResId)
}
}

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M18.6,6.62c-1.44,0 -2.8,0.56 -3.77,1.53L12,10.66 10.48,12h0.01L7.8,14.39c-0.64,0.64 -1.49,0.99 -2.4,0.99 -1.87,0 -3.39,-1.51 -3.39,-3.38S3.53,8.62 5.4,8.62c0.91,0 1.76,0.35 2.44,1.03l1.13,1 1.51,-1.34L9.22,8.2C8.2,7.18 6.84,6.62 5.4,6.62 2.42,6.62 0,9.04 0,12s2.42,5.38 5.4,5.38c1.44,0 2.8,-0.56 3.77,-1.53l2.83,-2.5 0.01,0.01L13.52,12h-0.01l2.69,-2.39c0.64,-0.64 1.49,-0.99 2.4,-0.99 1.87,0 3.39,1.51 3.39,3.38s-1.52,3.38 -3.39,3.38c-0.9,0 -1.76,-0.35 -2.44,-1.03l-1.14,-1.01 -1.51,1.34 1.27,1.12c1.02,1.01 2.37,1.57 3.82,1.57 2.98,0 5.4,-2.41 5.4,-5.38s-2.42,-5.37 -5.4,-5.37z"/>
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M22.99,9C19.15,5.16 13.8,3.76 8.84,4.78l2.52,2.52c3.47,-0.17 6.99,1.05 9.63,3.7l2,-2zM18.99,13c-1.29,-1.29 -2.84,-2.13 -4.49,-2.56l3.53,3.53 0.96,-0.97zM2,3.05L5.07,6.1C3.6,6.82 2.22,7.78 1,9l1.99,2c1.24,-1.24 2.67,-2.16 4.2,-2.77l2.24,2.24C7.81,10.89 6.27,11.73 5,13v0.01L6.99,15c1.36,-1.36 3.14,-2.04 4.92,-2.06L18.98,20l1.27,-1.26L3.29,1.79 2,3.05zM9,17l3,3 3,-3c-1.65,-1.66 -4.34,-1.66 -6,0z"/>
</vector>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
style="@style/PokerAnalyticsTheme.TextView.SubscriptionFeatureTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Title"/>
<ImageView
android:id="@+id/icon"
android:tint="@color/green"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:src="@drawable/ic_baseline_all_inclusive_24px"
android:layout_marginTop="8dp"
android:layout_width="48dp"
android:layout_height="48dp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
style="@style/PokerAnalyticsTheme.TextView.SubscriptionFeature"
app:layout_constraintTop_toBottomOf="@id/icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"
android:maxLines="5"
tools:text="Description qui va avec le text youpi. Il peut y avoir plusieurs ligne de texte oui tout a fait."/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

@ -1,64 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
android:layout_marginTop="24dp"
style="@style/PokerAnalyticsTheme.TextView.SubscriptionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="24dp"
android:layout_marginRight="16dp"
android:text="@string/pro_upgrade"
style="@style/PokerAnalyticsTheme.TextView.SubscriptionTitle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center"
app:autoSizeTextType="uniform"
app:autoSizeMinTextSize="24sp"
android:text="@string/pro_upgrade"
app:autoSizeMaxTextSize="36sp"
app:autoSizeMinTextSize="24sp"
app:autoSizeStepGranularity="2sp"
app:autoSizeTextType="uniform"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/freetrial"
style="@style/PokerAnalyticsTheme.TextView.SubscriptionSubTitle"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/container"
tools:text="30 day free trial" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/freetrial">
</androidx.viewpager.widget.ViewPager>
<!-- -->
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/price"
style="@style/PokerAnalyticsTheme.TextView.SubscriptionPrice"
app:layout_constraintBottom_toTopOf="@id/purchase"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@id/purchase"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="$29.99 / year" />
<com.google.android.material.button.MaterialButton
android:id="@+id/purchase"
style="@style/PokerAnalyticsTheme.Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="42dp"
android:text="@string/pro_purchase" />
android:layout_marginBottom="32dp"
android:text="@string/pro_purchase"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -15,6 +15,15 @@
<string name="pro_upgrade">Upgrade to Pro</string>
<string name="pro_purchase">Go Pro</string>
<string name="free_trial">free trial</string>
<string name="f_unlimited">Unlimited</string>
<string name="f_unlimited_desc">Track all your poker life by adding as many data as you want</string>
<string name="f_offline">Offline first</string>
<string name="f_offline_desc">Poker Analytics is available at all times. You’re currently in charge of backups, but that will change soon!</string>
<string name="f_privacy">Private</string>
<string name="f_privacy_desc">We do not own servers. We do not know anything about your wins and losses.</string>
<string name="f_support">Support</string>
<string name="f_support_desc">We try to answer as quickly as we can, in english or french !</string>
<string name="loading_please_wait">Loading, please wait&#8230;</string>
<string name="address">Address</string>
<string name="suggestions">Naming suggestions</string>

@ -318,9 +318,26 @@
<item name="android:maxLines">1</item>
<item name="android:ellipsize">end</item>
<item name="android:fontFamily">@font/roboto_light</item>
<item name="android:textSize">18sp</item>
<item name="android:textSize">16sp</item>
</style>
<style name="PokerAnalyticsTheme.TextView.SubscriptionFeatureTitle">
<item name="android:textColor">@color/white</item>
<item name="android:maxLines">1</item>
<item name="android:ellipsize">end</item>
<item name="android:fontFamily">@font/roboto_medium</item>
<item name="android:textSize">24sp</item>
</style>
<style name="PokerAnalyticsTheme.TextView.SubscriptionFeature">
<item name="android:textColor">@color/white</item>
<item name="android:maxLines">1</item>
<item name="android:ellipsize">end</item>
<item name="android:fontFamily">@font/roboto</item>
<item name="android:textSize">16sp</item>
</style>
<style name="PokerAnalyticsTheme.TextView.SubscriptionPrice">
<item name="android:textColor">@color/white</item>
<item name="android:maxLines">1</item>
@ -329,6 +346,4 @@
<item name="android:textSize">28sp</item>
</style>
</resources>

Loading…
Cancel
Save