Manual cherry-pick of two androidx.pdf commits
- http://aosp/3471470 - http://aosp/3491411 Bug: 396239227 Change-Id: Iff8ffc7f128b171660d5ca7523cd5d5f8f3ad2d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6262110 Reviewed-by: Andrew Grieve <agrieve@chromium.org> Commit-Queue: Shu Yang <shuyng@google.com> Cr-Commit-Position: refs/heads/main@{#1419919}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
4cc64aafb1
commit
19e14a8997
build/config/android
chrome/browser/ui/android/pdf
third_party/androidx
@ -4016,6 +4016,7 @@ if (enable_java_templates) {
|
||||
"*/AsyncTabParamsManagerImpl.kt",
|
||||
"//third_party/androidx/*",
|
||||
"*/webengine_shell_apk/*",
|
||||
"local_modifications/pdf/java/androidx/pdf/viewer/fragment/PdfViewerFragment.kt",
|
||||
]
|
||||
_found_kt = filter_exclude(_abs_kt_files, _kt_allowlist)
|
||||
assert(
|
||||
|
@ -46,6 +46,7 @@ android_library("java") {
|
||||
"//third_party/androidx:androidx_core_core_java",
|
||||
"//third_party/androidx:androidx_fragment_fragment_java",
|
||||
"//third_party/androidx:androidx_pdf_pdf_viewer_fragment_java",
|
||||
"//third_party/androidx:pdf_cherry_pick_crbug_394147799_java",
|
||||
"//third_party/jni_zero:jni_zero_java",
|
||||
"//ui/android:ui_java",
|
||||
"//url:url_java",
|
||||
|
26
third_party/androidx/BUILD.gn
vendored
26
third_party/androidx/BUILD.gn
vendored
@ -68,3 +68,29 @@ android_library("core_overrides_java") {
|
||||
"//third_party/kotlin_stdlib:kotlin_stdlib_java",
|
||||
]
|
||||
}
|
||||
|
||||
android_library("pdf_cherry_pick_crbug_394147799_java") {
|
||||
resources_package = "androidx.pdf"
|
||||
sources = [
|
||||
"local_modifications/pdf/java/androidx/pdf/viewer/fragment/PdfViewerFragment.kt",
|
||||
|
||||
# Need to include this due to "internal" visibilty.
|
||||
"local_modifications/pdf/java/androidx/pdf/viewer/fragment/insets/TranslateInsetsAnimationCallback.kt",
|
||||
]
|
||||
|
||||
jar_excluded_patterns = [ "*TranslateInsetsAnimationCallback*" ]
|
||||
|
||||
deps = [
|
||||
":androidx_annotation_annotation_jvm_java",
|
||||
":androidx_core_core_java",
|
||||
":androidx_fragment_fragment_ktx_java",
|
||||
":androidx_pdf_pdf_viewer_fragment_java",
|
||||
":androidx_pdf_pdf_viewer_java",
|
||||
"//third_party/android_deps:material_design_java",
|
||||
"//third_party/android_deps:org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm_java",
|
||||
"//third_party/androidx:androidx_fragment_fragment_java",
|
||||
"//third_party/androidx:androidx_lifecycle_lifecycle_common_jvm_java",
|
||||
"//third_party/androidx:androidx_lifecycle_lifecycle_viewmodel_android_java",
|
||||
"//third_party/kotlin_stdlib:kotlin_stdlib_java",
|
||||
]
|
||||
}
|
||||
|
5
third_party/androidx/customizations.gni
vendored
5
third_party/androidx/customizations.gni
vendored
@ -149,6 +149,11 @@ template("androidx_android_aar_prebuilt") {
|
||||
# Target has AIDL, but we do not support it yet: http://crbug.com/644439
|
||||
ignore_aidl = true
|
||||
}
|
||||
|
||||
if (target_name == "androidx_pdf_pdf_viewer_fragment_java") {
|
||||
jar_excluded_patterns =
|
||||
[ "androidx/pdf/viewer/fragment/PdfViewerFragment*" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
1060
third_party/androidx/local_modifications/pdf/java/androidx/pdf/viewer/fragment/PdfViewerFragment.kt
vendored
Normal file
1060
third_party/androidx/local_modifications/pdf/java/androidx/pdf/viewer/fragment/PdfViewerFragment.kt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
84
third_party/androidx/local_modifications/pdf/java/androidx/pdf/viewer/fragment/insets/TranslateInsetsAnimationCallback.kt
vendored
Normal file
84
third_party/androidx/local_modifications/pdf/java/androidx/pdf/viewer/fragment/insets/TranslateInsetsAnimationCallback.kt
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package androidx.pdf.viewer.fragment.insets
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.WindowInsetsAnimationCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
|
||||
/**
|
||||
* A callback that will update bottom margin for provided view as per keyboard visibility.
|
||||
*
|
||||
* @param view: A view whose bottom margin needs to be updated with keyboard.
|
||||
* @param windowManager: An interface to interact with window params, here helps to fetch screen
|
||||
* height.
|
||||
* @param pdfContainer: Container view where PDF is hosted.
|
||||
* @param dispatchMode: Specifies whether children view should get callback, by default callback
|
||||
* will be propagated.
|
||||
*/
|
||||
internal class TranslateInsetsAnimationCallback(
|
||||
private val view: View,
|
||||
private val windowManager: WindowManager?,
|
||||
private val pdfContainer: View?,
|
||||
dispatchMode: Int = DISPATCH_MODE_CONTINUE_ON_SUBTREE
|
||||
) : WindowInsetsAnimationCompat.Callback(dispatchMode) {
|
||||
|
||||
override fun onProgress(
|
||||
insets: WindowInsetsCompat,
|
||||
runningAnimations: List<WindowInsetsAnimationCompat>
|
||||
): WindowInsetsCompat {
|
||||
// onProgress() is called when any of the running animations progress...
|
||||
|
||||
var absoluteContainerBottom = 0
|
||||
/*
|
||||
Calculate absolute pdfContainer bottom on screen
|
||||
This is necessary as our fragment may not span the complete screen
|
||||
*/
|
||||
pdfContainer?.let {
|
||||
val containerLocation = IntArray(2)
|
||||
pdfContainer.getLocationInWindow(containerLocation)
|
||||
absoluteContainerBottom = pdfContainer.height + containerLocation[1]
|
||||
}
|
||||
|
||||
// Extract keyboard insets
|
||||
val keyboardInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
|
||||
|
||||
/*
|
||||
By default the keyboard top should be aligned with container bottom;
|
||||
This is same as keyboard is in closed state
|
||||
*/
|
||||
var keyboardTop = absoluteContainerBottom
|
||||
|
||||
// Calculate keyboard top wrt screen height
|
||||
windowManager?.let {
|
||||
val screenHeight = windowManager.currentWindowMetrics.bounds.height()
|
||||
keyboardTop = screenHeight - keyboardInsets.bottom
|
||||
}
|
||||
|
||||
// Net margin wrt pdf container bottom
|
||||
val margin =
|
||||
if (absoluteContainerBottom >= keyboardTop) absoluteContainerBottom - keyboardTop else 0
|
||||
|
||||
// Update bottom margin for view
|
||||
view.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin = margin }
|
||||
|
||||
return insets
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user