better miui detection
This commit is contained in:
parent
fad94279a5
commit
15443e9afd
|
@ -65,26 +65,29 @@ open class Home : BaseFragment(), View.OnClickListener {
|
||||||
when (v?.id) {
|
when (v?.id) {
|
||||||
R.id.vanced_installbtn -> {
|
R.id.vanced_installbtn -> {
|
||||||
if (!isVancedDownloading!!) {
|
if (!isVancedDownloading!!) {
|
||||||
if (!MiuiHelper.isMiuiOptimisationsDisabled()) {
|
|
||||||
activity?.let {
|
|
||||||
secondMiuiDialog(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
activity?.cacheDir?.deleteRecursively()
|
activity?.cacheDir?.deleteRecursively()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d("VMCache", "Unable to delete cacheDir")
|
Log.d("VMCache", "Unable to delete cacheDir")
|
||||||
}
|
}
|
||||||
if (prefs.getBoolean("valuesModified", false)) {
|
if (prefs.getBoolean("valuesModified", false)) {
|
||||||
|
if (!MiuiHelper.isMiuiOptimisationsDisabled()) {
|
||||||
|
activity?.let { view?.let { it1 -> secondMiuiDialog(it, it1) } }
|
||||||
|
} else {
|
||||||
activity?.startService(
|
activity?.startService(
|
||||||
Intent(
|
Intent(
|
||||||
activity,
|
activity,
|
||||||
VancedDownloadService::class.java
|
VancedDownloadService::class.java
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
prefs.edit().putBoolean("isInstalling", false).apply()
|
}
|
||||||
|
} else {
|
||||||
|
if (!MiuiHelper.isMiuiOptimisationsDisabled()) {
|
||||||
|
activity?.let { view?.let { it1 -> secondMiuiDialog(it, it1) } }
|
||||||
} else
|
} else
|
||||||
view?.findNavController()?.navigate(R.id.toInstallThemeFragment)
|
view?.findNavController()?.navigate(R.id.toInstallThemeFragment)
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
|
|
|
@ -4,10 +4,13 @@ import android.app.Activity
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.view.View
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.content.ContextCompat.startActivity
|
import androidx.core.content.ContextCompat.startActivity
|
||||||
|
import androidx.navigation.findNavController
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
|
import com.vanced.manager.core.downloader.VancedDownloadService
|
||||||
import com.vanced.manager.ui.MainActivity
|
import com.vanced.manager.ui.MainActivity
|
||||||
import com.vanced.manager.utils.InternetTools.openUrl
|
import com.vanced.manager.utils.InternetTools.openUrl
|
||||||
import com.vanced.manager.utils.MiuiHelper
|
import com.vanced.manager.utils.MiuiHelper
|
||||||
|
@ -61,11 +64,17 @@ object DialogContainer {
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun secondMiuiDialog(context: Context) {
|
fun secondMiuiDialog(context: Context, view: View) {
|
||||||
AlertDialog.Builder(context)
|
AlertDialog.Builder(context)
|
||||||
.setTitle(context.getString(R.string.miui_two_title))
|
.setTitle(context.getString(R.string.miui_two_title))
|
||||||
.setMessage(context.getString(R.string.miui_two))
|
.setMessage(context.getString(R.string.miui_two))
|
||||||
.setPositiveButton(context.getString(R.string.button_fine)) { dialog, _ -> dialog.dismiss() }
|
.setPositiveButton(context.getString(R.string.button_fine)) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
if (context.getSharedPreferences("installPrefs", Context.MODE_PRIVATE).getBoolean("valuesModified", false))
|
||||||
|
context.startService(Intent(context, VancedDownloadService::class.java))
|
||||||
|
else
|
||||||
|
view.findNavController().navigate(R.id.toInstallThemeFragment)
|
||||||
|
}
|
||||||
.setNeutralButton(context.getString(R.string.guide)) { _, _ ->
|
.setNeutralButton(context.getString(R.string.guide)) { _, _ ->
|
||||||
openUrl("https://telegra.ph/How-to-install-v15-on-MIUI-02-11", R.color.Telegram, context)
|
openUrl("https://telegra.ph/How-to-install-v15-on-MIUI-02-11", R.color.Telegram, context)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ object MiuiHelper {
|
||||||
|
|
||||||
fun isMiui(): Boolean = !TextUtils.isEmpty(getSystemProps("ro.miui.ui.version.name"))
|
fun isMiui(): Boolean = !TextUtils.isEmpty(getSystemProps("ro.miui.ui.version.name"))
|
||||||
|
|
||||||
fun isMiuiOptimisationsDisabled(): Boolean = getSystemProps("persist.sys.miui_optimization") == "0"
|
fun isMiuiOptimisationsDisabled(): Boolean = isMiui() && getSystemProps("persist.sys.miui_optimization") == "0"
|
||||||
|
|
||||||
private fun getSystemProps(propname: String): String? {
|
private fun getSystemProps(propname: String): String? {
|
||||||
val line: String
|
val line: String
|
||||||
|
|
|
@ -59,8 +59,7 @@
|
||||||
android:layout_marginEnd="4dp"
|
android:layout_marginEnd="4dp"
|
||||||
android:layout_marginStart="2dp"
|
android:layout_marginStart="2dp"
|
||||||
android:text="@string/save"
|
android:text="@string/save"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true" />
|
||||||
android:layout_alignStart="@id/url_reset"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue