mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 08:13:35 +00:00
Bug 1786449 - Revert overscroll support part of bug 1724480. r=geckoview-reviewers,calu
To support overscroll drawing on old Andorid (9 or early), we use the reflection to access `Paint` object. But this is removed by bug 1724480. So I would like to revert overscroll part for Android 9 or early. I tested on old Galaxy S7 (Android 9). Differential Revision: https://phabricator.services.mozilla.com/D155716
This commit is contained in:
parent
d8cc4c76c9
commit
3577ed2643
@ -8,6 +8,9 @@ package org.mozilla.geckoview;
|
||||
import android.content.Context;
|
||||
import android.graphics.BlendMode;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.widget.EdgeEffect;
|
||||
@ -43,6 +46,25 @@ public final class OverscrollEdgeEffect {
|
||||
private void setBlendMode(final EdgeEffect edgeEffect) {
|
||||
if (Build.VERSION.SDK_INT < 29) {
|
||||
// setBlendMode is only supported on SDK_INT >= 29 and above.
|
||||
|
||||
if (sPaintField == null) {
|
||||
try {
|
||||
sPaintField = EdgeEffect.class.getDeclaredField("mPaint");
|
||||
sPaintField.setAccessible(true);
|
||||
} catch (final NoSuchFieldException e) {
|
||||
// Cannot get the field, nothing we can do here
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final Paint paint = (Paint) sPaintField.get(edgeEffect);
|
||||
final PorterDuffXfermode mode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
|
||||
paint.setXfermode(mode);
|
||||
} catch (final IllegalAccessException ex) {
|
||||
// Nothing we can do
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user