Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Unified Diff: content/browser/android/overscroll_controller_android.cc

Issue 993613007: [Android] Add slack to allow refresh after overscrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/android/edge_effect_l.cc ('k') | content/browser/android/overscroll_glow.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/overscroll_controller_android.cc
diff --git a/content/browser/android/overscroll_controller_android.cc b/content/browser/android/overscroll_controller_android.cc
index e64a1e13c7ee8df0356c0c9f5cea1c6f5e8ca73d..4548cf33ce20fba36a0dd46aecc0d50726730678 100644
--- a/content/browser/android/overscroll_controller_android.cc
+++ b/content/browser/android/overscroll_controller_android.cc
@@ -30,20 +30,31 @@ const int kAndroidLSDKVersion = 21;
// action will be activated.
const int kDefaultRefreshDragTargetDips = 64;
+// If the glow effect alpha is greater than this value, the refresh effect will
+// be suppressed. This value was experimentally determined to provide a
+// reasonable balance between avoiding accidental refresh activation and
+// minimizing the wait required to refresh after the glow has been triggered.
+const float kMinGlowAlphaToDisableRefreshOnL = 0.085f;
+
bool IsAndroidLOrNewer() {
static bool android_l_or_newer =
base::android::BuildInfo::GetInstance()->sdk_int() >= kAndroidLSDKVersion;
return android_l_or_newer;
}
-bool ShouldDisableRefreshWhenGlowActive() {
- // Suppressing refresh detection when the glow is still animating prevents
- // visual confusion and accidental activation after repeated scrolls. However,
- // only the L effect is guaranteed to be both sufficiently brief and prominent
+// Suppressing refresh detection when the glow is still animating prevents
+// visual confusion and accidental activation after repeated scrolls.
+float MinGlowAlphaToDisableRefresh() {
+ // Only the L effect is guaranteed to be both sufficiently brief and prominent
// to provide a meaningful "wait" signal. The refresh effect on previous
// Android releases can be quite faint, depending on the OEM-supplied
// overscroll resources, and lasts nearly twice as long.
- return IsAndroidLOrNewer();
+ if (IsAndroidLOrNewer())
+ return kMinGlowAlphaToDisableRefreshOnL;
+
+ // Any value greater than 1 effectively prevents the glow effect from ever
+ // suppressing the refresh effect.
+ return 1.01f;
}
scoped_ptr<EdgeEffectBase> CreateGlowEdgeEffect(
@@ -116,8 +127,9 @@ bool OverscrollControllerAndroid::WillHandleGestureEvent(
if (is_fullscreen_)
return false;
- if (glow_effect_) {
- if (glow_effect_->IsActive() && ShouldDisableRefreshWhenGlowActive())
+ // Suppress refresh detection if the glow effect is still prominent.
+ if (glow_effect_ && glow_effect_->IsActive()) {
+ if (glow_effect_->GetVisibleAlpha() > MinGlowAlphaToDisableRefresh())
return false;
}
« no previous file with comments | « content/browser/android/edge_effect_l.cc ('k') | content/browser/android/overscroll_glow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698