allow triggering the Sideloading dialog from any activity

This commit is contained in:
tibbi 2019-02-27 22:01:35 +01:00
parent 8749177688
commit d0aafb5908
4 changed files with 12 additions and 11 deletions

View file

@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 21
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.9.16'
propVersionName = '5.9.18'
kotlin_version = '1.3.21'
}

View file

@ -3,10 +3,10 @@ package com.simplemobiletools.commons.activities
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.dialogs.AppSideloadedDialog
import com.simplemobiletools.commons.extensions.baseConfig
import com.simplemobiletools.commons.extensions.getSharedTheme
import com.simplemobiletools.commons.extensions.isThankYouInstalled
import com.simplemobiletools.commons.extensions.showSideloadingDialog
import com.simplemobiletools.commons.helpers.SIDELOADING_FALSE
import com.simplemobiletools.commons.helpers.SIDELOADING_TRUE
import com.simplemobiletools.commons.helpers.SIDELOADING_UNCHECKED
@ -23,6 +23,7 @@ abstract class BaseSplashActivity : AppCompatActivity() {
val isSideloaded = isAppSideloaded()
baseConfig.appSideloadingStatus = if (isSideloaded) SIDELOADING_TRUE else SIDELOADING_FALSE
if (isSideloaded) {
baseConfig.appId = getAppPackageName()
showSideloadingDialog()
return
}
@ -60,11 +61,4 @@ abstract class BaseSplashActivity : AppCompatActivity() {
true
}
}
private fun showSideloadingDialog() {
val packageName = getAppPackageName()
AppSideloadedDialog(this, packageName) {
finish()
}
}
}

View file

@ -5,13 +5,14 @@ import android.text.Html
import android.text.method.LinkMovementMethod
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.extensions.baseConfig
import com.simplemobiletools.commons.extensions.launchViewIntent
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_textview.view.*
class AppSideloadedDialog(val activity: Activity, packageName: String, val callback: () -> Unit) {
class AppSideloadedDialog(val activity: Activity, val callback: () -> Unit) {
var dialog: AlertDialog
val url = "https://play.google.com/store/apps/details?id=$packageName"
val url = "https://play.google.com/store/apps/details?id=${activity.baseConfig.appId.removeSuffix(".debug")}"
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_textview, null).apply {

View file

@ -891,3 +891,9 @@ fun BaseSimpleActivity.getAlarmSounds(type: Int, callback: (ArrayList<AlarmSound
}
}
}
fun AppCompatActivity.showSideloadingDialog() {
AppSideloadedDialog(this) {
finish()
}
}