mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-05 10:49:26 +02:00
Add support for servers with unlimited premium version
This commit is contained in:
parent
18a7438bd0
commit
c260a03c24
8 changed files with 36 additions and 16 deletions
|
@ -87,7 +87,7 @@ class SyncNotificationLogic (private val appLogic: AppLogic) {
|
|||
currentWarnings.addAll(manipulatedDevices.map { NotificationTypes.MANIPULATION to it })
|
||||
currentWarnings.addAll(outdatedDevices.map { NotificationTypes.UPDATE_MISSING to it })
|
||||
|
||||
if (fullVersionEndTime != null && fullVersionEndTime > now && !isChildDevice) {
|
||||
if (fullVersionEndTime != null && fullVersionEndTime != 1L && fullVersionEndTime > now && !isChildDevice) {
|
||||
currentWarnings.add(NotificationTypes.PREMIUM_EXPIRES to "")
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,15 @@ import android.util.JsonReader
|
|||
data class StatusOfMailAddressResponse(
|
||||
val mail: String,
|
||||
val status: StatusOfMailAddress,
|
||||
val canCreateFamily: Boolean
|
||||
val canCreateFamily: Boolean,
|
||||
val alwaysPro: Boolean
|
||||
) {
|
||||
companion object {
|
||||
fun parse(reader: JsonReader): StatusOfMailAddressResponse {
|
||||
var mail: String? = null
|
||||
var status: StatusOfMailAddress? = null
|
||||
var canCreateFamily = true
|
||||
var alwaysPro = false
|
||||
|
||||
reader.beginObject()
|
||||
while (reader.hasNext()) {
|
||||
|
@ -38,6 +40,7 @@ data class StatusOfMailAddressResponse(
|
|||
}
|
||||
"mail" -> mail = reader.nextString()
|
||||
"canCreateFamily" -> canCreateFamily = reader.nextBoolean()
|
||||
"alwaysPro" -> alwaysPro = reader.nextBoolean()
|
||||
else -> reader.skipValue()
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +49,8 @@ data class StatusOfMailAddressResponse(
|
|||
return StatusOfMailAddressResponse(
|
||||
mail = mail!!,
|
||||
status = status!!,
|
||||
canCreateFamily = canCreateFamily
|
||||
canCreateFamily = canCreateFamily,
|
||||
alwaysPro = alwaysPro
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ class AboutFragment : Fragment() {
|
|||
} else if (fullVersionUntil != null) {
|
||||
if (fullVersionUntil == 0L) {
|
||||
binding.fullVersionStatus = FullVersionStatus.Expired
|
||||
} else if (fullVersionUntil == 1L) {
|
||||
binding.fullVersionStatus = FullVersionStatus.AlwaysAvailable
|
||||
} else {
|
||||
binding.fullVersionStatus = FullVersionStatus.Available
|
||||
binding.fullVersionEndDate = DateUtils.formatDateTime(
|
||||
|
@ -69,7 +71,7 @@ class AboutFragment : Fragment() {
|
|||
}
|
||||
})
|
||||
|
||||
logic.database.config().getCustomServerUrlAsync().observe(this, Observer {
|
||||
logic.database.config().getCustomServerUrlAsync().observe(viewLifecycleOwner, Observer {
|
||||
binding.customServerUrl = it
|
||||
})
|
||||
|
||||
|
@ -79,7 +81,7 @@ class AboutFragment : Fragment() {
|
|||
|
||||
if (status == FullVersionStatus.Expired || status == FullVersionStatus.Available) {
|
||||
listener.onShowPurchaseScreen()
|
||||
} else if (status == FullVersionStatus.InLocalMode) {
|
||||
} else if (status == FullVersionStatus.InLocalMode || status == FullVersionStatus.AlwaysAvailable) {
|
||||
listener.onShowStayAwesomeScreen()
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +125,7 @@ interface AboutFragmentHandlers {
|
|||
}
|
||||
|
||||
enum class FullVersionStatus {
|
||||
InLocalMode, Available, Expired
|
||||
InLocalMode, Available, Expired, AlwaysAvailable
|
||||
}
|
||||
|
||||
interface AboutFragmentParentHandlers {
|
||||
|
|
|
@ -66,26 +66,22 @@ class SetupParentModeFragment : Fragment(), AuthenticateByMailFragmentListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
}.observe(this, Observer {
|
||||
}.observe(viewLifecycleOwner, Observer {
|
||||
binding.switcher.displayedChild = it!!
|
||||
})
|
||||
|
||||
val isNewFamily = model.statusOfMailAddress.map {
|
||||
it == null || it.status == StatusOfMailAddress.MailAddressWithoutFamily
|
||||
}
|
||||
|
||||
model.statusOfMailAddress.observe(this, Observer {
|
||||
model.statusOfMailAddress.observe(viewLifecycleOwner, Observer {
|
||||
if (it != null) {
|
||||
binding.isNewFamily = when (it.status) {
|
||||
StatusOfMailAddress.MailAddressWithoutFamily -> true
|
||||
StatusOfMailAddress.MailAddressWithFamily -> false
|
||||
}
|
||||
|
||||
binding.showLimitedProInfo = !it.alwaysPro
|
||||
binding.mail = it.mail
|
||||
}
|
||||
})
|
||||
|
||||
isNewFamily.observe(this, Observer { binding.isNewFamily = it })
|
||||
|
||||
// TODO: require that an device name and an parent name are set
|
||||
val isInputValid = model.statusOfMailAddress.switchMap {
|
||||
if (it == null) {
|
||||
|
@ -98,7 +94,7 @@ class SetupParentModeFragment : Fragment(), AuthenticateByMailFragmentListener {
|
|||
}
|
||||
}
|
||||
|
||||
isInputValid.observe(this, Observer {
|
||||
isInputValid.observe(viewLifecycleOwner, Observer {
|
||||
binding.enableOkButton = it!!
|
||||
})
|
||||
|
||||
|
|
|
@ -138,9 +138,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:visibility="@{fullVersionStatus == FullVersionStatus.AlwaysAvailable ? View.VISIBLE : View.GONE}"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:text="@string/about_full_version_always"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
tools:text="@string/about_full_version_tap_hint"
|
||||
android:text="@{fullVersionStatus == FullVersionStatus.InLocalMode ? @string/about_sal_tap_hint : @string/about_full_version_tap_hint}"
|
||||
android:text="@{fullVersionStatus == FullVersionStatus.InLocalMode || fullVersionStatus == FullVersionStatus.AlwaysAvailable ? @string/about_sal_tap_hint : @string/about_full_version_tap_hint}"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
name="enableOkButton"
|
||||
type="Boolean" />
|
||||
|
||||
<variable
|
||||
name="showLimitedProInfo"
|
||||
type="boolean" />
|
||||
|
||||
<import type="android.view.View" />
|
||||
</data>
|
||||
|
||||
|
@ -121,6 +125,7 @@
|
|||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:visibility="@{showLimitedProInfo ? View.VISIBLE : View.GONE}"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:text="@string/purchase_demo_temporarily_notice"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
<string name="about_full_version_until">
|
||||
Die Vollversion ist gültig bis %s.
|
||||
</string>
|
||||
<string name="about_full_version_always">
|
||||
Der von Ihnen verwendete Server schränkt den Zugang zu den Funktionen der Vollversion nicht ein.
|
||||
</string>
|
||||
<string name="about_full_version_tap_hint">
|
||||
Zum Erwerben oder Verlängern der Vollversion hier tippen.
|
||||
</string>
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
<string name="about_full_version_until">
|
||||
You have got the premium version until %s.
|
||||
</string>
|
||||
<string name="about_full_version_always">
|
||||
The server you are using does not limit the access to the features of the premium version.
|
||||
</string>
|
||||
<string name="about_full_version_tap_hint">
|
||||
Tap here to buy or extend the premium version.
|
||||
</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue