Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import fr.angel.dynamicisland.R
import fr.angel.dynamicisland.island.Island
import fr.angel.dynamicisland.island.IslandState
import fr.angel.dynamicisland.island.IslandViewState
import fr.angel.dynamicisland.island.IslandSettings
import fr.angel.dynamicisland.model.*
import fr.angel.dynamicisland.plugins.BasePlugin
import fr.angel.dynamicisland.plugins.ExportedPlugins
Expand All @@ -39,11 +40,11 @@ import kotlinx.coroutines.launch
class IslandOverlayService : AccessibilityService(), PluginHost {

private val params = WindowManager.LayoutParams(
MATCH_PARENT,
WRAP_CONTENT,
TYPE_ACCESSIBILITY_OVERLAY,
FLAG_LAYOUT_IN_SCREEN or FLAG_LAYOUT_NO_LIMITS or FLAG_NOT_TOUCH_MODAL or FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
WRAP_CONTENT,
TYPE_APPLICATION_OVERLAY,
FLAG_LAYOUT_IN_SCREEN or FLAG_LAYOUT_NO_LIMITS or FLAG_NOT_FOCUSABLE or FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSPARENT
).apply {
gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
}
Expand Down Expand Up @@ -110,6 +111,13 @@ class IslandOverlayService : AccessibilityService(), PluginHost {
init()

val windowManager = getSystemService(WINDOW_SERVICE) as WindowManager
try {
// Apply user offset (positionY is in dp). Use absolute offset so island can reach very top.
val userOffsetPx = (IslandSettings.instance.positionY * resources.displayMetrics.density).toInt()
params.y = userOffsetPx
} catch (e: Exception) {
Log.w("OverlayService", "Failed to compute user offset: ${e.message}")
}
showOverlay(windowManager, params)
}

Expand Down Expand Up @@ -146,13 +154,20 @@ class IslandOverlayService : AccessibilityService(), PluginHost {
)
}

// TODO: Find a way to detect when a click is performed outside of the overlay (to close it)
/*composeView.setOnTouchListener { view: View?, event: MotionEvent ->
if (event.action == MotionEvent.ACTION_DOWN) {
Log.d("OverlayService", "Touch event")
// Handle clicks outside the overlay to close/shrink it
composeView.setOnTouchListener { view: View?, event: MotionEvent ->
if (event.action == MotionEvent.ACTION_OUTSIDE) {
// Click is outside the overlay bounds, shrink/close the island
if (islandState is IslandViewState.Expanded) {
shrink()
} else if (islandState is IslandViewState.Opened) {
// Dismiss the active plugin
pluginManager.requestDismiss(pluginManager.activePlugins.firstOrNull() ?: return@setOnTouchListener false)
}
Log.d("OverlayService", "Click outside overlay detected")
}
false
}*/
}

// Trick The ComposeView into thinking we are tracking lifecycle
/*val viewModelStore = ViewModelStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import fr.angel.dynamicisland.island.Island
Expand Down Expand Up @@ -119,7 +120,12 @@ fun IslandApp(
modifier = Modifier.fillMaxWidth()
) {
Box(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.pointerInput(Unit) {
// This modifier allows touch events to pass through to the background
// The island will handle its own touches via combinedClickable
},
contentAlignment = when (IslandSettings.instance.gravity) {
IslandGravity.Center -> Alignment.TopCenter
IslandGravity.Left -> Alignment.TopStart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fun PositionSizeSettingsScreen() {
title = "Position Y",
extension = ".dp",
value = IslandSettings.instance.positionY.toFloat(),
range = 0f..50f
range = -50f..50f
)
}
item {
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/res/xml/accessibility_service_config.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/overlay_service_description"
android:packageNames="fr.angel.dynamicisland"
android:accessibilityEventTypes=""
android:accessibilityFlags=""
android:accessibilityFeedbackType=""
android:accessibilityEventTypes="typeNotificationStateChanged|typeWindowStateChanged"
android:accessibilityFlags="flagDefault|flagReportViewIds"
android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="100"
android:canRetrieveWindowContent="false"
android:canRetrieveWindowContent="true"
android:settingsActivity="fr.angel.dynamicisland.MainActivity"
/>
Empty file modified gradlew
100644 → 100755
Empty file.