Skip to content

Commit

Permalink
fix: SDK req for secondary displays
Browse files Browse the repository at this point in the history
  • Loading branch information
axel358 committed Feb 15, 2024
1 parent aba497b commit 6544bbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
21 changes: 8 additions & 13 deletions app/src/main/java/cu/axel/smartdock/services/DockService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -740,47 +740,42 @@ class DockService : AccessibilityService(), OnSharedPreferenceChangeListener, On
toggleSoftKeyboard()
} else if (event.keyCode == KeyEvent.KEYCODE_F12)
DeviceUtils.softReboot()
/*else if (event.keyCode == KeyEvent.KEYCODE_F3) {
else if (event.keyCode == KeyEvent.KEYCODE_F3) {
if (tasks.size > 0) {
val task = tasks[0]
AppUtils.resizeTask(
context, "portrait", task.id, dockHeight,
secondary
context, "portrait", task.id, dockHeight
)
}
} else if (event.keyCode == KeyEvent.KEYCODE_DPAD_UP) {
if (tasks.size > 0) {
val task = tasks[0]
AppUtils.resizeTask(
context, "maximized", task.id, dockHeight,
secondary
context, "maximized", task.id, dockHeight
)
}
} else if (event.keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
if (tasks.size > 0) {
val task = tasks[0]
AppUtils.resizeTask(
context, "tiled-left", task.id, dockHeight,
secondary
context, "tiled-left", task.id, dockHeight
)
}
} else if (event.keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
if (tasks.size > 0) {
val task = tasks[0]
AppUtils.resizeTask(
context, "tiled-right", task.id, dockHeight,
secondary
context, "tiled-right", task.id, dockHeight
)
}
} else if (event.keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
if (tasks.size > 0) {
val task = tasks[0]
AppUtils.resizeTask(
context, "standard", task.id, dockHeight,
secondary
context, "standard", task.id, dockHeight
)
}
}*/
}
} else if (event.action == KeyEvent.ACTION_UP) {
val menuKey = sharedPreferences.getString("menu_key", "3")!!.toInt()
if (event.keyCode == KeyEvent.KEYCODE_CTRL_RIGHT && sharedPreferences.getBoolean(
Expand Down Expand Up @@ -1245,7 +1240,7 @@ class DockService : AccessibilityService(), OnSharedPreferenceChangeListener, On
val shortcut = adapterView.getItemAtPosition(position) as ShortcutInfo
windowManager.removeView(view)
DeepShortcutManager.startShortcut(shortcut, context)
}else if(Build.VERSION.SDK_INT > 27 && adapterView.getItemAtPosition(position) is Display){
}else if(Build.VERSION.SDK_INT > 28 && adapterView.getItemAtPosition(position) is Display){
val display = adapterView.getItemAtPosition(position) as Display
windowManager.removeView(view)
launchApp(null, app.packageName, null, app, display.displayId)
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/cu/axel/smartdock/utils/AppUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.graphics.drawable.Drawable
import android.os.Build
import android.os.SystemClock
import android.os.UserManager
import android.view.Display
import androidx.appcompat.content.res.AppCompatResources
import androidx.preference.PreferenceManager
import cu.axel.smartdock.models.App
Expand Down Expand Up @@ -229,7 +230,7 @@ object AppUtils {
}
}

fun makeLaunchBounds(context: Context, mode: String, dockHeight: Int, displayId: Int): Rect {
fun makeLaunchBounds(context: Context, mode: String, dockHeight: Int, displayId: Int = Display.DEFAULT_DISPLAY): Rect {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
var left = 0
var top = 0
Expand Down Expand Up @@ -291,10 +292,10 @@ object AppUtils {
return Rect(left, top, right, bottom)
}

fun resizeTask(context: Context, mode: String, taskId: Int, dockHeight: Int, displayId: Int) {
fun resizeTask(context: Context, mode: String, taskId: Int, dockHeight: Int) {
if (taskId < 0)
return
val bounds = makeLaunchBounds(context, mode, dockHeight, displayId)
val bounds = makeLaunchBounds(context, mode, dockHeight)
DeviceUtils.runAsRoot("am task resize " + taskId + " " + bounds.left + " " + bounds.top + " " + bounds.right
+ " " + bounds.bottom)
}
Expand Down

0 comments on commit 6544bbd

Please sign in to comment.