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(manipulatedDevices.map { NotificationTypes.MANIPULATION to it })
|
||||||
currentWarnings.addAll(outdatedDevices.map { NotificationTypes.UPDATE_MISSING 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 "")
|
currentWarnings.add(NotificationTypes.PREMIUM_EXPIRES to "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,15 @@ import android.util.JsonReader
|
||||||
data class StatusOfMailAddressResponse(
|
data class StatusOfMailAddressResponse(
|
||||||
val mail: String,
|
val mail: String,
|
||||||
val status: StatusOfMailAddress,
|
val status: StatusOfMailAddress,
|
||||||
val canCreateFamily: Boolean
|
val canCreateFamily: Boolean,
|
||||||
|
val alwaysPro: Boolean
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
fun parse(reader: JsonReader): StatusOfMailAddressResponse {
|
fun parse(reader: JsonReader): StatusOfMailAddressResponse {
|
||||||
var mail: String? = null
|
var mail: String? = null
|
||||||
var status: StatusOfMailAddress? = null
|
var status: StatusOfMailAddress? = null
|
||||||
var canCreateFamily = true
|
var canCreateFamily = true
|
||||||
|
var alwaysPro = false
|
||||||
|
|
||||||
reader.beginObject()
|
reader.beginObject()
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
|
@ -38,6 +40,7 @@ data class StatusOfMailAddressResponse(
|
||||||
}
|
}
|
||||||
"mail" -> mail = reader.nextString()
|
"mail" -> mail = reader.nextString()
|
||||||
"canCreateFamily" -> canCreateFamily = reader.nextBoolean()
|
"canCreateFamily" -> canCreateFamily = reader.nextBoolean()
|
||||||
|
"alwaysPro" -> alwaysPro = reader.nextBoolean()
|
||||||
else -> reader.skipValue()
|
else -> reader.skipValue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +49,8 @@ data class StatusOfMailAddressResponse(
|
||||||
return StatusOfMailAddressResponse(
|
return StatusOfMailAddressResponse(
|
||||||
mail = mail!!,
|
mail = mail!!,
|
||||||
status = status!!,
|
status = status!!,
|
||||||
canCreateFamily = canCreateFamily
|
canCreateFamily = canCreateFamily,
|
||||||
|
alwaysPro = alwaysPro
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,8 @@ class AboutFragment : Fragment() {
|
||||||
} else if (fullVersionUntil != null) {
|
} else if (fullVersionUntil != null) {
|
||||||
if (fullVersionUntil == 0L) {
|
if (fullVersionUntil == 0L) {
|
||||||
binding.fullVersionStatus = FullVersionStatus.Expired
|
binding.fullVersionStatus = FullVersionStatus.Expired
|
||||||
|
} else if (fullVersionUntil == 1L) {
|
||||||
|
binding.fullVersionStatus = FullVersionStatus.AlwaysAvailable
|
||||||
} else {
|
} else {
|
||||||
binding.fullVersionStatus = FullVersionStatus.Available
|
binding.fullVersionStatus = FullVersionStatus.Available
|
||||||
binding.fullVersionEndDate = DateUtils.formatDateTime(
|
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
|
binding.customServerUrl = it
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ class AboutFragment : Fragment() {
|
||||||
|
|
||||||
if (status == FullVersionStatus.Expired || status == FullVersionStatus.Available) {
|
if (status == FullVersionStatus.Expired || status == FullVersionStatus.Available) {
|
||||||
listener.onShowPurchaseScreen()
|
listener.onShowPurchaseScreen()
|
||||||
} else if (status == FullVersionStatus.InLocalMode) {
|
} else if (status == FullVersionStatus.InLocalMode || status == FullVersionStatus.AlwaysAvailable) {
|
||||||
listener.onShowStayAwesomeScreen()
|
listener.onShowStayAwesomeScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +125,7 @@ interface AboutFragmentHandlers {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class FullVersionStatus {
|
enum class FullVersionStatus {
|
||||||
InLocalMode, Available, Expired
|
InLocalMode, Available, Expired, AlwaysAvailable
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AboutFragmentParentHandlers {
|
interface AboutFragmentParentHandlers {
|
||||||
|
|
|
@ -66,26 +66,22 @@ class SetupParentModeFragment : Fragment(), AuthenticateByMailFragmentListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.observe(this, Observer {
|
}.observe(viewLifecycleOwner, Observer {
|
||||||
binding.switcher.displayedChild = it!!
|
binding.switcher.displayedChild = it!!
|
||||||
})
|
})
|
||||||
|
|
||||||
val isNewFamily = model.statusOfMailAddress.map {
|
model.statusOfMailAddress.observe(viewLifecycleOwner, Observer {
|
||||||
it == null || it.status == StatusOfMailAddress.MailAddressWithoutFamily
|
|
||||||
}
|
|
||||||
|
|
||||||
model.statusOfMailAddress.observe(this, Observer {
|
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
binding.isNewFamily = when (it.status) {
|
binding.isNewFamily = when (it.status) {
|
||||||
StatusOfMailAddress.MailAddressWithoutFamily -> true
|
StatusOfMailAddress.MailAddressWithoutFamily -> true
|
||||||
StatusOfMailAddress.MailAddressWithFamily -> false
|
StatusOfMailAddress.MailAddressWithFamily -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.showLimitedProInfo = !it.alwaysPro
|
||||||
binding.mail = it.mail
|
binding.mail = it.mail
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
isNewFamily.observe(this, Observer { binding.isNewFamily = it })
|
|
||||||
|
|
||||||
// TODO: require that an device name and an parent name are set
|
// TODO: require that an device name and an parent name are set
|
||||||
val isInputValid = model.statusOfMailAddress.switchMap {
|
val isInputValid = model.statusOfMailAddress.switchMap {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
|
@ -98,7 +94,7 @@ class SetupParentModeFragment : Fragment(), AuthenticateByMailFragmentListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isInputValid.observe(this, Observer {
|
isInputValid.observe(viewLifecycleOwner, Observer {
|
||||||
binding.enableOkButton = it!!
|
binding.enableOkButton = it!!
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -138,9 +138,16 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
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
|
<TextView
|
||||||
tools:text="@string/about_full_version_tap_hint"
|
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:textAppearance="?android:textAppearanceSmall"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
name="enableOkButton"
|
name="enableOkButton"
|
||||||
type="Boolean" />
|
type="Boolean" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="showLimitedProInfo"
|
||||||
|
type="boolean" />
|
||||||
|
|
||||||
<import type="android.view.View" />
|
<import type="android.view.View" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
|
@ -121,6 +125,7 @@
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:visibility="@{showLimitedProInfo ? View.VISIBLE : View.GONE}"
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
android:text="@string/purchase_demo_temporarily_notice"
|
android:text="@string/purchase_demo_temporarily_notice"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
<string name="about_full_version_until">
|
<string name="about_full_version_until">
|
||||||
Die Vollversion ist gültig bis %s.
|
Die Vollversion ist gültig bis %s.
|
||||||
</string>
|
</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">
|
<string name="about_full_version_tap_hint">
|
||||||
Zum Erwerben oder Verlängern der Vollversion hier tippen.
|
Zum Erwerben oder Verlängern der Vollversion hier tippen.
|
||||||
</string>
|
</string>
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
<string name="about_full_version_until">
|
<string name="about_full_version_until">
|
||||||
You have got the premium version until %s.
|
You have got the premium version until %s.
|
||||||
</string>
|
</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">
|
<string name="about_full_version_tap_hint">
|
||||||
Tap here to buy or extend the premium version.
|
Tap here to buy or extend the premium version.
|
||||||
</string>
|
</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue