diff --git a/CHANGELOG.md b/CHANGELOG.md index 523f92d..37e8987 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) +### Refactoring: + +- Accessibility actions and helper methods - ([e4dab29](https://github.com/DroidWorksStudio/mLauncher/commit/e4dab299574a9bd26eb0b7f7d786464c0ef75a1f)) + diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/MyAccessibilityService.kt b/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/MyAccessibilityService.kt index b3e48c9..a9d7b42 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/MyAccessibilityService.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/MyAccessibilityService.kt @@ -37,7 +37,33 @@ class MyAccessibilityService : AccessibilityService() { override fun onAccessibilityEvent(event: AccessibilityEvent?) {} @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 { private var mInstance: WeakReference = WeakReference(null) diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt index fa32e18..7a5e148 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt @@ -66,9 +66,9 @@ class AppHelper @Inject constructor() { val method = statusBarManager.getMethod(Constants.NOTIFICATION_METHOD) method.invoke(statusBarService) } catch (exception: Exception) { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { -// initActionService(context)?.openNotifications() -// } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + MyAccessibilityService.instance()?.openNotifications() + } exception.printStackTrace() } } @@ -81,9 +81,9 @@ class AppHelper @Inject constructor() { val method = statusBarManager.getMethod(Constants.QUICKSETTINGS_METHOD) method.invoke(statusBarService) } catch (exception: Exception) { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { -// initActionService(context)?.openQuickSettings() -// } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + MyAccessibilityService.instance()?.openQuickSettings() + } exception.printStackTrace() } } @@ -94,14 +94,6 @@ class AppHelper @Inject constructor() { 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) { when (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) { Configuration.UI_MODE_NIGHT_YES -> {