mirror of https://github.com/x13a/Wasted.git
hide tile on old devices
This commit is contained in:
parent
b12ddc11d5
commit
41a59319c1
|
@ -8,7 +8,6 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
@ -153,16 +152,18 @@ open class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private fun showLaunchersSettings() {
|
private fun showLaunchersSettings() {
|
||||||
var launchers = prefs.launchers
|
var launchers = prefs.launchers
|
||||||
val checkedLaunchers = mutableListOf<Boolean>()
|
val launchersValues = Launcher.values().toMutableList()
|
||||||
for (launcher in Launcher.values()) {
|
val launchersStrings = resources.getStringArray(R.array.launchers).toMutableList()
|
||||||
checkedLaunchers.add(launchers.and(launcher.flag) != 0)
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
|
launchersStrings.removeAt(launchersValues.indexOf(Launcher.TILE))
|
||||||
|
launchersValues.remove(Launcher.TILE)
|
||||||
}
|
}
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
.setMultiChoiceItems(
|
.setMultiChoiceItems(
|
||||||
resources.getStringArray(R.array.launchers),
|
launchersStrings.toTypedArray(),
|
||||||
checkedLaunchers.toBooleanArray(),
|
launchersValues.map { launchers.and(it.flag) != 0 }.toBooleanArray(),
|
||||||
) { _, index, isChecked ->
|
) { _, index, isChecked ->
|
||||||
val value = Launcher.values()[index]
|
val value = launchersValues[index]
|
||||||
launchers = when (isChecked) {
|
launchers = when (isChecked) {
|
||||||
true -> launchers.or(value.flag)
|
true -> launchers.or(value.flag)
|
||||||
false -> launchers.and(value.flag.inv())
|
false -> launchers.and(value.flag.inv())
|
||||||
|
@ -214,14 +215,13 @@ open class MainActivity : AppCompatActivity() {
|
||||||
if (value) {
|
if (value) {
|
||||||
val launchers = prefs.launchers
|
val launchers = prefs.launchers
|
||||||
setPanicKitState(launchers.and(Launcher.PANIC_KIT.flag) != 0)
|
setPanicKitState(launchers.and(Launcher.PANIC_KIT.flag) != 0)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
||||||
setQSTileState(launchers.and(Launcher.TILE.flag) != 0)
|
setQSTileState(launchers.and(Launcher.TILE.flag) != 0)
|
||||||
shortcut.setState(launchers.and(Launcher.SHORTCUT.flag) != 0)
|
shortcut.setState(launchers.and(Launcher.SHORTCUT.flag) != 0)
|
||||||
setCodeReceiverState(launchers.and(Launcher.BROADCAST.flag) != 0)
|
setCodeReceiverState(launchers.and(Launcher.BROADCAST.flag) != 0)
|
||||||
setNotificationListenerState(launchers.and(Launcher.NOTIFICATION.flag) != 0)
|
setNotificationListenerState(launchers.and(Launcher.NOTIFICATION.flag) != 0)
|
||||||
} else {
|
} else {
|
||||||
setPanicKitState(false)
|
setPanicKitState(false)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) setQSTileState(false)
|
setQSTileState(false)
|
||||||
shortcut.setState(false)
|
shortcut.setState(false)
|
||||||
setCodeReceiverState(false)
|
setCodeReceiverState(false)
|
||||||
setNotificationListenerState(false)
|
setNotificationListenerState(false)
|
||||||
|
@ -250,9 +250,10 @@ open class MainActivity : AppCompatActivity() {
|
||||||
setComponentState(CodeReceiver::class.java, value)
|
setComponentState(CodeReceiver::class.java, value)
|
||||||
private fun setRestartReceiverState(value: Boolean) =
|
private fun setRestartReceiverState(value: Boolean) =
|
||||||
setComponentState(RestartReceiver::class.java, value)
|
setComponentState(RestartReceiver::class.java, value)
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
private fun setQSTileState(value: Boolean) {
|
||||||
private fun setQSTileState(value: Boolean) =
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
setComponentState(QSTileService::class.java, value)
|
setComponentState(QSTileService::class.java, value)
|
||||||
|
}
|
||||||
private fun setNotificationListenerState(value: Boolean) =
|
private fun setNotificationListenerState(value: Boolean) =
|
||||||
setComponentState(NotificationListenerService::class.java, value)
|
setComponentState(NotificationListenerService::class.java, value)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue