Skip to content

Commit

Permalink
Fix custom bluetooth tile crashing on click
Browse files Browse the repository at this point in the history
Used in OP QS header and lockscreen widgets

Signed-off-by: DrDisagree <[email protected]>
  • Loading branch information
Mahmud0808 committed Oct 25, 2024
1 parent 29b4c8b commit 1c36cae
Showing 1 changed file with 47 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,40 +579,55 @@ class ControllersProvider(context: Context?) : ModPack(context!!) {
}

fun showBluetoothDialog(context: Context, view: View): Boolean {
if (instance?.mBluetoothTileDialogViewModel != null) {
try {
callMethod(
instance!!.mBluetoothTileDialogViewModel,
"showDialog",
context,
view
)
return true
} catch (ignored: Throwable) {
val isAutoOn = Settings.System.getInt(
context.contentResolver,
"qs_bt_auto_on", 0
) == 1
callMethod(
instance!!.mBluetoothTileDialogViewModel,
"showDialog",
context,
view,
isAutoOn
)
return true
}
} else if (instance?.mBluetoothTile != null) {
if (isMethodAvailable(instance!!.mBluetoothTile, "handleClick", View::class.java)) {
callMethod(instance!!.mBluetoothTile, "handleClick", view)
return true
} else {
log(TAG + "No bluetooth dialog available")
}
val btTileAvailable = instance?.mBluetoothTile != null
val btTileDialogAvailable = instance?.mBluetoothTileDialogViewModel != null

if (btTileDialogAvailable && isMethodAvailable(
instance!!.mBluetoothTileDialogViewModel,
"showDialog",
Context::class.java,
View::class.java
)
) {
callMethod(
instance!!.mBluetoothTileDialogViewModel,
"showDialog",
context,
view
)
return true
} else if (btTileDialogAvailable && isMethodAvailable(
instance!!.mBluetoothTileDialogViewModel,
"showDialog",
Context::class.java,
View::class.java,
Boolean::class.java
)
) {
val isAutoOn = Settings.System.getInt(
context.contentResolver,
"qs_bt_auto_on", 0
) == 1
callMethod(
instance!!.mBluetoothTileDialogViewModel,
"showDialog",
context,
view,
isAutoOn
)
return true
} else if (btTileAvailable && isMethodAvailable(
instance!!.mBluetoothTile,
"handleClick",
View::class.java
)
) {
callMethod(instance!!.mBluetoothTile, "handleClick", view)
return true
} else {
log(TAG + "No bluetooth dialog available")
}
return false
}

}

}

0 comments on commit 1c36cae

Please sign in to comment.