|
|
|
|
@ -25,6 +25,7 @@ import com.android.billingclient.api.BillingClient |
|
|
|
|
import com.android.billingclient.api.Purchase |
|
|
|
|
import com.android.billingclient.api.SkuDetails |
|
|
|
|
import com.android.billingclient.api.SkuDetailsResponseListener |
|
|
|
|
import com.crashlytics.android.Crashlytics |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_subscription.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
@ -37,6 +38,7 @@ import net.pokeranalytics.android.util.billing.IAPProducts |
|
|
|
|
import net.pokeranalytics.android.util.billing.PurchaseDelegate |
|
|
|
|
import java.lang.ref.WeakReference |
|
|
|
|
import java.time.Period |
|
|
|
|
import java.time.format.DateTimeParseException |
|
|
|
|
|
|
|
|
|
class SubscriptionFragment : BaseFragment(), SkuDetailsResponseListener, PurchaseDelegate, ViewPager.OnPageChangeListener { |
|
|
|
|
|
|
|
|
|
@ -200,8 +202,12 @@ class SubscriptionFragment : BaseFragment(), SkuDetailsResponseListener, Purchas |
|
|
|
|
|
|
|
|
|
var freeTrialDays = 30 // initial, should be more, no less |
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { |
|
|
|
|
val p = Period.parse(it.freeTrialPeriod) |
|
|
|
|
freeTrialDays = p.days |
|
|
|
|
try { |
|
|
|
|
val p = Period.parse(it.freeTrialPeriod) |
|
|
|
|
freeTrialDays = p.days |
|
|
|
|
} catch (e: DateTimeParseException) { |
|
|
|
|
Crashlytics.log("Error parsing period with value: ${it.freeTrialPeriod}") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
val formattedFreeTrial = |
|
|
|
|
"$freeTrialDays " + requireContext().getString(R.string.days) + " " + requireContext().getString(R.string.free_trial) |
|
|
|
|
|