-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2086 from Infomaniak/display-message-zero-width-s…
…entry Add some sentry to better understand message display improvements that still leave some overscroll
- Loading branch information
Showing
4 changed files
with
88 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/src/main/java/com/infomaniak/mail/utils/WebViewVersionUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Infomaniak Mail - Android | ||
* Copyright (C) 2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.mail.utils | ||
|
||
import android.content.Context | ||
import android.content.pm.PackageInfo | ||
import androidx.webkit.WebViewCompat | ||
|
||
object WebViewVersionUtils { | ||
private const val DEFAULT_WEBVIEW_VERSION = 0 | ||
|
||
fun getWebViewVersionData(context: Context): WebViewVersionData? { | ||
val webViewPackage = WebViewCompat.getCurrentWebViewPackage(context) ?: return null | ||
val webViewPackageName = webViewPackage.packageName | ||
val (versionName, majorVersion) = webViewPackage.getWebViewVersions() | ||
|
||
return WebViewVersionData(versionName, majorVersion, webViewPackageName) | ||
} | ||
|
||
private fun PackageInfo.getWebViewVersions(): Pair<String, Int> { | ||
val majorVersion = runCatching { | ||
versionName.substringBefore('.').toInt() | ||
}.getOrDefault(defaultValue = DEFAULT_WEBVIEW_VERSION) | ||
|
||
return versionName to majorVersion | ||
} | ||
|
||
data class WebViewVersionData( | ||
val versionName: String, | ||
val majorVersion: Int, | ||
val webViewPackageName: String, | ||
) | ||
} |