Skip to content

Commit

Permalink
Merge pull request #145 from axel358/running_tasks
Browse files Browse the repository at this point in the history
Running tasks improvements
  • Loading branch information
axel358 authored Mar 12, 2024
2 parents 5f21b21 + 6b0852f commit 15e5d4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
29 changes: 15 additions & 14 deletions app/src/main/java/cu/axel/smartdock/services/DockService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class DockService : AccessibilityService(), OnSharedPreferenceChangeListener, On
private lateinit var context: Context
private lateinit var tasks: ArrayList<AppTask>
private var lastUpdate: Long = 0
private var previousActivity: String? = null
private var dockHeight: Int = 0
private lateinit var handleLayoutParams: WindowManager.LayoutParams
private lateinit var launcherApps: LauncherApps
Expand Down Expand Up @@ -564,7 +563,7 @@ class DockService : AccessibilityService(), OnSharedPreferenceChangeListener, On
if (tasks.size == 1) {
val taskId = tasks[0].id
if (taskId == -1)
launchApp(getDefaultLaunchMode(app.packageName), app.packageName)
launchApp(null, app.packageName)
else
activityManager.moveTaskToFront(taskId, 0)
} else if (tasks.size > 1) {
Expand Down Expand Up @@ -624,19 +623,21 @@ class DockService : AccessibilityService(), OnSharedPreferenceChangeListener, On
}

override fun onAccessibilityEvent(event: AccessibilityEvent) {
if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
val currentActivity = event.className.toString()
if (currentActivity == "null" || currentActivity.contains("android.app.")
|| currentActivity.contains("android.widget.")
) return
if (currentActivity != previousActivity) {
// Activity changed
//TODO: Filter current input method
previousActivity = currentActivity
if (isPinned)
if (!isPinned)
return

if (event.eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED) {
if (Build.VERSION.SDK_INT >= 28)
if (event.windowChanges.and(AccessibilityEvent.WINDOWS_CHANGE_REMOVED) == AccessibilityEvent.WINDOWS_CHANGE_REMOVED ||
event.windowChanges.and(
AccessibilityEvent.WINDOWS_CHANGE_ADDED
) == AccessibilityEvent.WINDOWS_CHANGE_ADDED
)
updateRunningTasks()
}
} else if (isPinned && sharedPreferences.getBoolean(
else
updateRunningTasks()

} else if (sharedPreferences.getBoolean(
"custom_toasts",
false
) && event.eventType == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED && event.parcelableData !is Notification && event.text.size > 0
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/cu/axel/smartdock/utils/AppUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ object AppUtils {
//Exclude systemui, launcher and other system apps from the tasklist
if (taskInfo.baseActivity!!.packageName.contains("com.android.systemui")
|| taskInfo.baseActivity!!.packageName.contains("com.google.android.packageinstaller")
|| taskInfo.baseActivity!!.className == "com.android.quickstep.RecentsActivity"
) continue

//Hack to save Dock settings activity ftom being excluded
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/accessibility_service.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/accessibility_service_description"
android:accessibilityEventTypes="typeNotificationStateChanged|typeWindowStateChanged"
android:accessibilityEventTypes="typeNotificationStateChanged|typeWindowsChanged"
android:accessibilityFeedbackType="feedbackAllMask"
android:canRetrieveWindowContent="true"
android:canRequestFilterKeyEvents="true"
Expand Down

0 comments on commit 15e5d4e

Please sign in to comment.