Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:修复浮窗位置的初始化逻辑 #186

Merged
merged 4 commits into from
Nov 26, 2024
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

```groovy
dependencies {
implementation 'io.github.petterpx:floatingx:2.3.0'
implementation 'io.github.petterpx:floatingx:2.3.1'

// system浮窗&&compose时需要导入
// 记得AppHelper里调用 enableComposeSupport()
implementation 'io.github.petterpx:floatingx-compose:2.3.0'
implementation 'io.github.petterpx:floatingx-compose:2.3.1'
}
```

Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

```groovy
dependencies {
implementation 'io.github.petterpx:floatingx:2.3.0'
implementation 'io.github.petterpx:floatingx:2.3.1'

// System floating window && need to be imported when compose
// AppHelper invoke enableComposeSupport()
implementation 'io.github.petterpx:floatingx-compose:2.3.0'
implementation 'io.github.petterpx:floatingx-compose:2.3.1'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.petterp.floatingx.app.BuildConfig
import com.petterp.floatingx.app.MainActivity
import com.petterp.floatingx.app.R
import com.petterp.floatingx.app.simple.FxAnimationImpl
import com.petterp.floatingx.app.simple.FxConfigStorageToSpImpl
import com.petterp.floatingx.app.test.BlackActivity
import com.petterp.floatingx.app.test.ImmersedActivity
import com.petterp.floatingx.app.test.MultipleFxActivity
Expand All @@ -34,6 +35,7 @@ object FxSystemSimple {
setLayout(R.layout.item_floating)
setScopeType(FxScopeType.SYSTEM_AUTO)
// 设置浮窗展示类型,默认可移动可点击,无需配置
setSaveDirectionImpl(FxConfigStorageToSpImpl(context))
setDisplayMode(FxDisplayMode.Normal)
// 设置权限拦截器
setPermissionInterceptor { activity, controller ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class FxViewLocationHelper : FxViewBasicHelper(), View.OnLayoutChangeListener {
}

override fun onInit() {
// 先刷新一下view大小,避免有时候sizeChanged没测量
updateViewSize()
val hasHistory = config.enableSaveDirection && config.iFxConfigStorage?.hasConfig() == true
val locationFrom: String
val (defaultX, defaultY) = if (hasHistory) {
Expand All @@ -70,9 +72,10 @@ class FxViewLocationHelper : FxViewBasicHelper(), View.OnLayoutChangeListener {
getDefaultXY(parentW, parentH, viewW, viewH)
}
// 判断坐标应该准确在哪里
basicView?.updateXY(safeX(defaultX), safeY(defaultY))
val (safeX, safeY) = safeX(defaultX) to safeY(defaultY)
basicView?.updateXY(safeX, safeY)
isInitLocation = false
config.fxLog.d("fxView -> initLocation: x:$defaultX,y:$defaultY,way:[$locationFrom]")
config.fxLog.d("fxView -> initLocation: x:$safeX,y:$safeY,way:[$locationFrom]")
}

override fun onSizeChanged(w: Int, h: Int, oldW: Int, oldH: Int) {
Expand Down
1 change: 1 addition & 0 deletions gradle/dev_compose.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
implementation platform("androidx.compose:compose-bom:2023.06.01")
implementation "androidx.compose.ui:ui:1.3.3"
implementation "androidx.compose.ui:ui-graphics"
implementation "androidx.compose.runtime:runtime-livedata"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation "androidx.compose.material3:material3"
debugImplementation 'androidx.compose.ui:ui-tooling'
Expand Down
Loading