From d357f8c8b4da9cff1d5bf54a74fd7a58a590fb27 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 17 Jun 2019 16:58:55 +0200 Subject: [PATCH] Added message in subscription window when reaching the max number of sessions + strings update --- .../android/ui/activity/BillingActivity.kt | 26 +++++++++++++++++-- .../android/ui/activity/ImportActivity.kt | 2 +- .../android/ui/fragment/FeedFragment.kt | 2 +- .../android/ui/fragment/SettingsFragment.kt | 2 +- .../ui/fragment/SubscriptionFragment.kt | 19 +++++++++----- app/src/main/res/layout/activity_billing.xml | 17 +++--------- .../main/res/layout/fragment_subscription.xml | 25 +++++++++++++----- app/src/main/res/values/strings.xml | 4 +-- 8 files changed, 64 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/activity/BillingActivity.kt b/app/src/main/java/net/pokeranalytics/android/ui/activity/BillingActivity.kt index c60cfd9c..39db989a 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/activity/BillingActivity.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/activity/BillingActivity.kt @@ -7,18 +7,25 @@ import androidx.fragment.app.Fragment import net.pokeranalytics.android.R import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity import net.pokeranalytics.android.ui.activity.components.RequestCode +import net.pokeranalytics.android.ui.fragment.SubscriptionFragment class BillingActivity : PokerAnalyticsActivity() { + private enum class IntentKey(val keyName: String) { + SHOW_MESSAGE("showMessage"), + } + companion object { - fun newInstanceForResult(activity: Activity) { + fun newInstanceForResult(activity: Activity, showSessionMessage: Boolean) { val intent = Intent(activity, BillingActivity::class.java) + intent.putExtra(IntentKey.SHOW_MESSAGE.keyName, showSessionMessage) activity.startActivityForResult(intent, RequestCode.SUBSCRIPTION.value) } - fun newInstanceForResult(fragment: Fragment) { + fun newInstanceForResult(fragment: Fragment, showSessionMessage: Boolean) { val intent = Intent(fragment.requireContext(), BillingActivity::class.java) + intent.putExtra(IntentKey.SHOW_MESSAGE.keyName, showSessionMessage) fragment.startActivityForResult(intent, RequestCode.SUBSCRIPTION.value) } } @@ -26,6 +33,21 @@ class BillingActivity : PokerAnalyticsActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_billing) + initUI() + } + + private fun initUI() { + + val fragmentManager = supportFragmentManager + val fragmentTransaction = fragmentManager.beginTransaction() + val fragment = SubscriptionFragment() + + val showSessionMessage = intent.getBooleanExtra(IntentKey.SHOW_MESSAGE.keyName, false) + + fragmentTransaction.add(R.id.container, fragment) + fragmentTransaction.commit() + fragment.setData(showSessionMessage) + } } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/activity/ImportActivity.kt b/app/src/main/java/net/pokeranalytics/android/ui/activity/ImportActivity.kt index 498a5f86..2a83c802 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/activity/ImportActivity.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/activity/ImportActivity.kt @@ -118,7 +118,7 @@ class ImportActivity : PokerAnalyticsActivity() { if (!AppGuard.isProUser && sessionCount >= AppGuard.MAX_SESSIONS_BEFORE_REQUESTING_SUBSCRIPTION) { // && !BuildConfig.DEBUG Toast.makeText(this, "Please subscribe!", Toast.LENGTH_LONG).show() - BillingActivity.newInstanceForResult(this) + BillingActivity.newInstanceForResult(this, true) return } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt index 82db898e..e860198e 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt @@ -275,7 +275,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { val sessionCount = this.feedSessionAdapter.realmResults.size if (!AppGuard.isProUser && sessionCount >= AppGuard.MAX_SESSIONS_BEFORE_REQUESTING_SUBSCRIPTION) { // && !BuildConfig.DEBUG // Toast.makeText(context, "Please subscribe!", Toast.LENGTH_LONG).show() - BillingActivity.newInstanceForResult(this) + BillingActivity.newInstanceForResult(this, true) return } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/SettingsFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/SettingsFragment.kt index 364a50fc..f2d79b2d 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/SettingsFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/SettingsFragment.kt @@ -113,7 +113,7 @@ class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Sta when (row) { SettingRow.SUBSCRIPTION -> { if (!AppGuard.isProUser) { - BillingActivity.newInstanceForResult(this) + BillingActivity.newInstanceForResult(this, false) } else { this.openPlaystoreAccount() } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/SubscriptionFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/SubscriptionFragment.kt index a5b20860..7ebb4063 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/SubscriptionFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/SubscriptionFragment.kt @@ -43,6 +43,7 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene private var pagerAdapter: ScreenSlidePagerAdapter? = null private var selectedProduct: SkuDetails? = null + private var showSessionMessage = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -54,6 +55,10 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene } } + fun setData(showSessionMessage: Boolean) { + this.showSessionMessage = showSessionMessage + } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_subscription, container, false) } @@ -89,6 +94,10 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene this.title.text = upgradeString } + if (showSessionMessage) { + this.message.text = getString(R.string.iap_session_message) + } + // Pager // The pager adapter, which provides the pages to the view pager widget. @@ -110,7 +119,7 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene for (i in 1..count) { val view = View(requireContext()) view.background = requireContext().getDrawable(R.drawable.circle_green) - val layoutParam = LinearLayout.LayoutParams(10.px, 10.px) + val layoutParam = LinearLayout.LayoutParams(8.px, 8.px) layoutParam.setMargins(6.px) this.pageIndicator.addView(view, layoutParam) } @@ -202,12 +211,8 @@ class SubscriptionFragment : PokerAnalyticsFragment(), SkuDetailsResponseListene override fun onPageScrollStateChanged(state: Int) {} override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { - pagerAdapter?.getFragment(position)?.let { - it.updateViewsPosition(-positionOffset * parallax) - } - pagerAdapter?.getFragment(position + 1)?.let { - it.updateViewsPosition((1 - positionOffset) * parallax) - } + pagerAdapter?.getFragment(position)?.updateViewsPosition(-positionOffset * parallax) + pagerAdapter?.getFragment(position + 1)?.updateViewsPosition((1 - positionOffset) * parallax) } override fun onPageSelected(position: Int) { diff --git a/app/src/main/res/layout/activity_billing.xml b/app/src/main/res/layout/activity_billing.xml index 08d1f651..e1701185 100644 --- a/app/src/main/res/layout/activity_billing.xml +++ b/app/src/main/res/layout/activity_billing.xml @@ -1,15 +1,6 @@ - - + android:layout_height="match_parent"> - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_subscription.xml b/app/src/main/res/layout/fragment_subscription.xml index 7791cfb8..e281aa06 100644 --- a/app/src/main/res/layout/fragment_subscription.xml +++ b/app/src/main/res/layout/fragment_subscription.xml @@ -50,37 +50,50 @@ app:layout_constraintTop_toBottomOf="@id/title" tools:text="30 day free trial" /> + + + app:layout_constraintStart_toStartOf="parent" /> Unlimited Track all your poker life by adding as many data as you want Offline first - Poker Analytics is available at all times and the data is yours. Export it at any times. Note: You’re currently in charge of backups, but that will change soon! + Poker Analytics is available at all times and the data is yours. Note: We will soon add exporting capabilities and you’re currently in charge of backups. Thanks for your patience! Private We do not own servers. We do not know anything about your wins and losses. Support @@ -38,6 +38,7 @@ Custom field The item is used in one or more transactions…Please delete the linked transactions first Imported + You\'ve reached the maximum number of free sessions. Please subscribe for unlimited use and don\'t hesitate to tell us how you feel about your current experience! Address Naming suggestions @@ -285,7 +286,6 @@ Net hourly rate Range Export your data to iCloud, get the Pro version, open it, import your data from iCloud. - You\'ve reached the maximum number of sessions. Get a new subscription to get more sessions! iCloud iCloud settings were modified, please wait for synchronization. A backup of your data was found on iCloud, do you want to use it on this device? If yes, the local data from this device will be replaced by the backup and if no, you will keep using the local data from this device and your iCloud account won\'t be modified.