Added premium show

This commit is contained in:
h4h13 2020-05-06 18:16:07 +05:30
parent 58e29691cb
commit 21d59f0274
2 changed files with 39 additions and 0 deletions

View file

@ -93,6 +93,7 @@ import code.name.monkey.retromusic.service.MusicService;
import code.name.monkey.retromusic.util.AppRater;
import code.name.monkey.retromusic.util.NavigationUtil;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.PremiumShow;
import code.name.monkey.retromusic.util.RetroColorUtil;
import code.name.monkey.retromusic.util.RetroUtil;
@ -184,6 +185,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
//checkShowChangelog();
AppRater.appLaunched(this);
//PremiumShow.launch(this);
setupToolbar();
checkUpdate();
}

View file

@ -0,0 +1,37 @@
package code.name.monkey.retromusic.util
import android.content.Context
import android.content.Intent
import androidx.core.app.ActivityCompat
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.activities.PurchaseActivity
object PremiumShow {
private const val PREF_NAME = "premium_show"
private const val LAUNCH_COUNT = "launch_count"
private const val DATE_FIRST_LAUNCH = "date_first_launch"
@JvmStatic
fun launch(context: Context) {
val pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
if (App.isProVersion()) {
return
}
val prefEditor = pref.edit()
val launchCount = pref.getLong(LAUNCH_COUNT, 0) + 1
prefEditor.putLong(LAUNCH_COUNT, launchCount)
var dateLaunched = pref.getLong(DATE_FIRST_LAUNCH, 0)
if (dateLaunched == 0L) {
dateLaunched = System.currentTimeMillis()
prefEditor.putLong(DATE_FIRST_LAUNCH, dateLaunched)
}
if (System.currentTimeMillis() >= dateLaunched + 2 * 24 * 60 * 60 * 1000) {
ActivityCompat.startActivity(
context,
Intent(context, PurchaseActivity::class.java),
null
)
}
prefEditor.apply()
}
}