mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
incorporate androidlib
This commit is contained in:
parent
20cf3f0825
commit
5eb5cd1421
63 changed files with 1451 additions and 108 deletions
|
|
@ -0,0 +1,39 @@
|
|||
package com.geeksville.mesh.android
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Created by kevinh on 1/13/16.
|
||||
*/
|
||||
class ExpireChecker(val context: Activity) : Logging {
|
||||
|
||||
fun check(year: Int, month: Int, day: Int) {
|
||||
val expireDate = DateUtils.dateUTC(year, month, day)
|
||||
val now = Date()
|
||||
|
||||
debug("Expire check $now vs $expireDate")
|
||||
if (now.after(expireDate))
|
||||
doExpire()
|
||||
}
|
||||
|
||||
private fun doExpire() {
|
||||
val packageName = context.packageName
|
||||
errormsg("$packageName is too old and must be updated at the Play store")
|
||||
|
||||
Toast.makeText(
|
||||
context,
|
||||
"This application is out of date and must be updated",
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
val i = Intent(Intent.ACTION_VIEW)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
i.setData(Uri.parse("market://details?id=$packageName&referrer=utm_source%3Dexpired"))
|
||||
context.startActivity(i)
|
||||
context.finish()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue