removing the free Pro upgrade mentions from the Upgrade dialog

This commit is contained in:
tibbi 2018-11-29 13:28:48 +01:00
parent 44437d8d5c
commit 6d43630cb9

View file

@ -3,44 +3,16 @@ package com.simplemobiletools.commons.dialogs
import android.app.Activity
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.extensions.baseConfig
import com.simplemobiletools.commons.extensions.launchUpgradeToProIntent
import com.simplemobiletools.commons.extensions.launchViewIntent
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_upgrade_to_pro.view.*
class UpgradeToProDialog(val activity: Activity) {
private val packageName = activity.baseConfig.appId.removeSuffix(".debug")
private val FIRST_APPS_FREE_TILL = 1541980800000L // November 12
private val NOV_12 = "Nov 12 2018"
private val CONTACTS_FREE_TILL = 1542153600000L // November 14
private val NOV_14 = "Nov 14 2018"
private val NOTES_FREE_TILL = 1542326400000L // November 16
private val NOV_16 = "Nov 16 2018"
private val CALENDAR_FREE_TILL = 1543017600000L // November 24
private val NOV_24 = "Nov 24 2018"
init {
var text = activity.getString(R.string.upgrade_to_pro_long)
if ((packageName.endsWith("draw") || packageName.endsWith("gallery") || packageName.endsWith("filemanager")) && System.currentTimeMillis() < FIRST_APPS_FREE_TILL) {
val freeTill = String.format(activity.getString(R.string.it_is_free), NOV_12)
text += "\n$freeTill"
} else if (packageName.endsWith("contacts") && System.currentTimeMillis() < CONTACTS_FREE_TILL) {
val freeTill = String.format(activity.getString(R.string.it_is_free), NOV_14)
text += "\n$freeTill"
} else if (packageName.endsWith("notes") && System.currentTimeMillis() < NOTES_FREE_TILL) {
val freeTill = String.format(activity.getString(R.string.it_is_free), NOV_16)
text += "\n$freeTill"
} else if (packageName.endsWith("calendar") && System.currentTimeMillis() < CALENDAR_FREE_TILL) {
val freeTill = String.format(activity.getString(R.string.it_is_free), NOV_24)
text += "\n$freeTill"
}
val view = activity.layoutInflater.inflate(R.layout.dialog_upgrade_to_pro, null).apply {
upgrade_to_pro.text = text
upgrade_to_pro.text = activity.getString(R.string.upgrade_to_pro_long)
}
AlertDialog.Builder(activity)