Refactor: accessibility actions and helper methods
This commit refactors the accessibility actions in MyAccessibilityService.kt and updates corresponding invocations in AppHelper.kt to use the new methods. Specifically, the following changes were made: - Introduced separate methods for various accessibility actions such as showing recent apps, opening notifications, opening quick settings, opening the power dialog, and taking a screenshot in MyAccessibilityService.kt. - Updated the calls in AppHelper.kt to use these new methods instead of directly calling performGlobalAction. - Removed commented-out code related to accessibility actions in AppHelper.kt.
This commit is contained in:
@@ -12,4 +12,8 @@ All notable changes to this project will be documented in this file. See [conven
|
|||||||
|
|
||||||
- Fixed Others Text/Links - ([e91771f](https://github.com/DroidWorksStudio/mLauncher/commit/e91771f4bbf92915e98f758cfb2d261a12cd9adc))
|
- Fixed Others Text/Links - ([e91771f](https://github.com/DroidWorksStudio/mLauncher/commit/e91771f4bbf92915e98f758cfb2d261a12cd9adc))
|
||||||
|
|
||||||
|
### Refactoring:
|
||||||
|
|
||||||
|
- Accessibility actions and helper methods - ([e4dab29](https://github.com/DroidWorksStudio/mLauncher/commit/e4dab299574a9bd26eb0b7f7d786464c0ef75a1f))
|
||||||
|
|
||||||
<!-- Generated by DroidWorks Studio -->
|
<!-- Generated by DroidWorks Studio -->
|
||||||
|
|||||||
@@ -37,7 +37,33 @@ class MyAccessibilityService : AccessibilityService() {
|
|||||||
override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
|
override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.P)
|
@RequiresApi(Build.VERSION_CODES.P)
|
||||||
fun lockScreen(): Boolean = performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN)
|
fun lockScreen(): Boolean {
|
||||||
|
return performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN)
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.P)
|
||||||
|
fun showRecents(): Boolean {
|
||||||
|
return performGlobalAction(GLOBAL_ACTION_RECENTS)
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.P)
|
||||||
|
fun openNotifications(): Boolean {
|
||||||
|
return performGlobalAction(GLOBAL_ACTION_NOTIFICATIONS)
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.P)
|
||||||
|
fun openQuickSettings(): Boolean {
|
||||||
|
return performGlobalAction(GLOBAL_ACTION_QUICK_SETTINGS)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openPowerDialog(): Boolean {
|
||||||
|
return performGlobalAction(GLOBAL_ACTION_POWER_DIALOG)
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.P)
|
||||||
|
fun takeScreenShot(): Boolean {
|
||||||
|
return performGlobalAction(GLOBAL_ACTION_TAKE_SCREENSHOT)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var mInstance: WeakReference<MyAccessibilityService> = WeakReference(null)
|
private var mInstance: WeakReference<MyAccessibilityService> = WeakReference(null)
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ class AppHelper @Inject constructor() {
|
|||||||
val method = statusBarManager.getMethod(Constants.NOTIFICATION_METHOD)
|
val method = statusBarManager.getMethod(Constants.NOTIFICATION_METHOD)
|
||||||
method.invoke(statusBarService)
|
method.invoke(statusBarService)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
// initActionService(context)?.openNotifications()
|
MyAccessibilityService.instance()?.openNotifications()
|
||||||
// }
|
}
|
||||||
exception.printStackTrace()
|
exception.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,9 +81,9 @@ class AppHelper @Inject constructor() {
|
|||||||
val method = statusBarManager.getMethod(Constants.QUICKSETTINGS_METHOD)
|
val method = statusBarManager.getMethod(Constants.QUICKSETTINGS_METHOD)
|
||||||
method.invoke(statusBarService)
|
method.invoke(statusBarService)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
// initActionService(context)?.openQuickSettings()
|
MyAccessibilityService.instance()?.openQuickSettings()
|
||||||
// }
|
}
|
||||||
exception.printStackTrace()
|
exception.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,14 +94,6 @@ class AppHelper @Inject constructor() {
|
|||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun darkThemes(darkThemes: Boolean){
|
|
||||||
if (darkThemes){
|
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
|
||||||
}else{
|
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun dayNightMod(context: Context, view: View) {
|
fun dayNightMod(context: Context, view: View) {
|
||||||
when (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
|
when (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
|
||||||
Configuration.UI_MODE_NIGHT_YES -> {
|
Configuration.UI_MODE_NIGHT_YES -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user