Skip to content

Commit

Permalink
Feature/280 fix edgetoedge (#283)
Browse files Browse the repository at this point in the history
* fix edge to edge対応

* fix build versionを考慮した分岐の作成

* fix keyboard表示有無で出しわけ

* fix

* fix

* fix fitInsetsTypesを追加

* fix commentの削除

* add changelog

* run ruby scripts/bump_version.rb set-version -t inappmessaging -n 2.20.0

* fix IAM drawing area on edge to edge

* fix LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGESの削除

* fix ci update dokka version

* fix lint

* fix release note

* fix release note

---------

Co-authored-by: harukitosa <[email protected]>
Co-authored-by: Sojiro Nishimura <[email protected]>
Co-authored-by: Haruki Tosa <[email protected]>
  • Loading branch information
4 people authored Aug 5, 2024
1 parent 23b51f9 commit 2b2acf9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
20 changes: 13 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# Latest Version

| モジュール/プラグイン名 | Description | 最新のバージョン |
| :-- | :-- | :-- |
| core | イベントトラッキング機能を提供します。 | 2.25.0 |
| inappmessaging | アプリ内メッセージ機能を提供します。 | 2.19.2 |
| notifications | プッシュ通知の受信および効果測定機能を提供します。 | 2.11.0 |
| variables | 設定値配信機能を提供します。 | 2.7.0 |
| visualtracking | ビジュアルトラッキング機能を提供します。| 2.9.0 |
| Karte Gradle Plugin | ビジュアルトラッキング機能に必要なプラグインです。| 2.5.1 |
| :-- | :-- |:---------|
| core | イベントトラッキング機能を提供します。 | 2.25.0 |
| inappmessaging | アプリ内メッセージ機能を提供します。 | 2.19.3 |
| notifications | プッシュ通知の受信および効果測定機能を提供します。 | 2.11.0 |
| variables | 設定値配信機能を提供します。 | 2.7.0 |
| visualtracking | ビジュアルトラッキング機能を提供します。| 2.9.0 |
| Karte Gradle Plugin | ビジュアルトラッキング機能に必要なプラグインです。| 2.5.1 |

# Releases - xxxx.xx.xx

### InAppMessaging 2.20.0
** 🔨CHANGED**
- AndroidのEdge to Edgeによる表示に対応しました
- Edge to Edgeに対応後にKARTEの接客の表示が正しくされているか検証をお願いします
- Navigation Barに被ってしまう、接客の表示が下すぎる場合はCSS等を利用して調整してください。テンプレートによってはbottomをいじれるものもあるためそちらで設定することもできます。

### InAppMessaging 2.19.2
** 🔨CHANGED**
- IAMWebViewの初期化を、アプリがフォアグラウンドに戻った際に遅延して行うように変更しました
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ import org.json.JSONArray
import java.lang.ref.WeakReference

private const val LOG_TAG = "Karte.IAMView"

@Suppress("DEPRECATION")
private const val WINDOW_FLAGS_FOCUSED = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or
WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR

@Suppress("DEPRECATION")
private const val WINDOW_FLAGS_UNFOCUSED = (
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
Expand Down Expand Up @@ -148,6 +150,12 @@ internal open class WindowView(
PixelFormat.TRANSLUCENT
)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// NOTE: WindowManager.addViewしたViewはデフォルトでSystemBarsのInsetが考慮されるため明示的に無効化するために0を設定する
// https://developer.android.com/reference/android/view/WindowManager.LayoutParams#setFitInsetsTypes(int)
params.fitInsetsTypes = 0
}

if (appSoftInputModeIsNothing) {
// keyboard表示中に接客が配信された場合、接客のz-ordferがkeyboardより上になる。この時appWindowのsoftInputModeがSOFT_INPUT_ADJUST_NOTHINGだとkeyboardの高さを知る方法がない
// そのためこのケースでは、hideSoftInputFromWindow後にaddViewすることでz-orderをkeyboardより下にし、再度showSoftInputする。(hideSoftInputFromWindowの結果によって元々keyboardが表示されていたかどうかの判定ができる)
Expand Down Expand Up @@ -407,6 +415,26 @@ internal open class WindowView(
}
}

private val drawingHeight: Int
get() {
// NOTE: Edge to edge有効化時にcontentView.heightとcontentViewVisibleRect.bottomの値が異なる(VisibleRectにNavigationBarの高さが含まれない)ため
// diffを取って描画すべき領域の高さを決定する
// diffがNavigationBarの高さを超える場合はキーボード等が表示されていると判定しvisibleRect.bottomを下限とする
// それ以外はcontentView.height=画面の高さを下限とする
val diff = contentView.height - contentViewVisibleRect.bottom
return if (diff > navbarHeight) contentViewVisibleRect.bottom else contentView.height
}

private val navbarHeight: Int
get() {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
windowManager.currentWindowMetrics.windowInsets.getInsets(WindowInsets.Type.navigationBars()).bottom
} else {
// バージョンに依存せずにNavigationBarの高さを正確に取得する方法がないため画面下2.5%をNavigationBarの高さとして扱う
(contentView.height * 0.025).toInt()
}
}

override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
try {
val contentView = contentView
Expand All @@ -428,14 +456,14 @@ internal open class WindowView(
} else {
locationOnScreen[1]
}
childBottom = iamViewVisibleRect.bottom
childBottom = drawingHeight
} else {
childTop = if (isStatusBarOverlaid) {
contentView.top + contentView.paddingTop
} else {
contentViewVisibleRect.top
}
childBottom = contentViewVisibleRect.bottom
childBottom = drawingHeight
}

Logger.d(
Expand Down
2 changes: 1 addition & 1 deletion inappmessaging/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.19.2
2.20.0

0 comments on commit 2b2acf9

Please sign in to comment.