mirror of
https://github.com/ProtonMail/protoncore_android.git
synced 2026-05-15 09:50:41 +00:00
feat(plan): Add support for additional plans. Default current plan layout.
This commit is contained in:
+9
-6
@@ -68,16 +68,19 @@ class PlanItemView @JvmOverloads constructor(
|
||||
private val mappedFreePlanLayouts by lazy { context.getStringArrayByName(R.array.plan_mapping_free_plan_layouts) }
|
||||
private val mappedPaidPlanLayouts by lazy { context.getStringArrayByName(R.array.plan_mapping_paid_plan_layouts) }
|
||||
|
||||
private fun getMappedLayout(plan: PlanDetailsItem, mappedPlanLayouts: Array<String>?): String {
|
||||
val indexOfPlanName = mappedPlanIds?.indexOf(plan.name) ?: return "plan_id_${plan.name}"
|
||||
return mappedPlanLayouts?.getOrNull(indexOfPlanName) ?: "plan_id_${plan.name}"
|
||||
private fun getMappedLayout(planName: String, mappedPlanLayouts: Array<String>?, defaultLayout: String): String {
|
||||
val indexOfPlanName = mappedPlanIds?.indexOf(planName) ?: return defaultLayout
|
||||
return mappedPlanLayouts?.getOrNull(indexOfPlanName) ?: defaultLayout
|
||||
}
|
||||
|
||||
private fun getCurrentLayout(plan: PlanDetailsItem) = getMappedLayout(plan, mappedCurrentPlanLayouts)
|
||||
private fun getCurrentLayout(plan: PlanDetailsItem) =
|
||||
getMappedLayout(plan.name, mappedCurrentPlanLayouts, "plan_current")
|
||||
|
||||
private fun getFreeLayout(plan: PlanDetailsItem) = getMappedLayout(plan, mappedFreePlanLayouts)
|
||||
private fun getFreeLayout(plan: PlanDetailsItem) =
|
||||
getMappedLayout(plan.name, mappedFreePlanLayouts, "plan_id_${plan.name}")
|
||||
|
||||
private fun getPaidLayout(plan: PlanDetailsItem) = getMappedLayout(plan, mappedPaidPlanLayouts)
|
||||
private fun getPaidLayout(plan: PlanDetailsItem) =
|
||||
getMappedLayout(plan.name, mappedPaidPlanLayouts, "plan_id_${plan.name}")
|
||||
|
||||
/**
|
||||
* Sets plans data and binds to according plan item UIs.
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
<item>bundle2022</item>
|
||||
<item>pass2023</item>
|
||||
<item>family2022</item>
|
||||
<item>mailpro2022</item>
|
||||
<item>bundlepro2022</item>
|
||||
<item>enterprise2022</item>
|
||||
<item>vpnpro2023</item>
|
||||
<item>vpnbiz2023</item>
|
||||
</string-array>
|
||||
<!-- region current plan mapping -->
|
||||
<string-array name="plan_mapping_current_plan_layouts">
|
||||
@@ -45,6 +50,11 @@
|
||||
<item>plan_current</item>
|
||||
<item>plan_current</item>
|
||||
<item>plan_current</item>
|
||||
<item>plan_current</item>
|
||||
<item>plan_current</item>
|
||||
<item>plan_current</item>
|
||||
<item>plan_current</item>
|
||||
<item>plan_current</item>
|
||||
</string-array>
|
||||
<!-- endregion -->
|
||||
<!-- region free plan mapping -->
|
||||
@@ -61,6 +71,12 @@
|
||||
<item>plan_id_bundle2022</item>
|
||||
<item>plan_id_pass2023</item>
|
||||
<item>plan_id_family2022</item>
|
||||
|
||||
<item>plan_id_mailpro2022</item>
|
||||
<item>plan_id_bundlepro2022</item>
|
||||
<item>plan_id_enterprise2022</item>
|
||||
<item>plan_id_vpnpro2023</item>
|
||||
<item>plan_id_vpnbiz2023</item>
|
||||
</string-array>
|
||||
<!-- endregion -->
|
||||
<!-- region paid plan mapping -->
|
||||
@@ -77,6 +93,12 @@
|
||||
<item>plan_id_bundle2022</item>
|
||||
<item>plan_id_pass2023</item>
|
||||
<item>plan_id_family2022</item>
|
||||
|
||||
<item>plan_id_mailpro2022</item>
|
||||
<item>plan_id_bundlepro2022</item>
|
||||
<item>plan_id_enterprise2022</item>
|
||||
<item>plan_id_vpnpro2023</item>
|
||||
<item>plan_id_vpnbiz2023</item>
|
||||
</string-array>
|
||||
<!-- endregion -->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user