Commit d88e98c9 authored by Mehran Mahmoudi's avatar Mehran Mahmoudi Committed by Commit Bot

[Touchless] Fix key functions IPH problem on quick cursor visibility changes

This fixes an issue with key functions In-Product Help which caused it
to show the incurrect view on quick changes in cursor visibility.

Bug: 962683
Change-Id: Ibc86a91a877e42ceab69bbf133db07b8ff0f78d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1617718Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661008}
parent c988f0be
...@@ -27,6 +27,7 @@ public class KeyFunctionsIPHMediator implements CursorObserver { ...@@ -27,6 +27,7 @@ public class KeyFunctionsIPHMediator implements CursorObserver {
private final KeyFunctionsIPHTabObserver mKeyFunctionsIPHTabObserver; private final KeyFunctionsIPHTabObserver mKeyFunctionsIPHTabObserver;
private FutureTask mHideTask; private FutureTask mHideTask;
private int mPageLoadCount; private int mPageLoadCount;
private DisplayLockHandle mDisplayLockHandle;
private static final long DISPLAY_DURATION_MS = 3000; private static final long DISPLAY_DURATION_MS = 3000;
...@@ -62,16 +63,18 @@ public class KeyFunctionsIPHMediator implements CursorObserver { ...@@ -62,16 +63,18 @@ public class KeyFunctionsIPHMediator implements CursorObserver {
if (totalSessionCount > INTRODUCTORY_SESSIONS && mPageLoadCount > 1) return; if (totalSessionCount > INTRODUCTORY_SESSIONS && mPageLoadCount > 1) return;
} }
// This ensures that no other in-product help UI is currently shown. // If we are already showing this IPH, we should release the lock.
DisplayLockHandle displayLockHandle = if (mDisplayLockHandle != null) mDisplayLockHandle.release();
TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile()) mDisplayLockHandle = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile())
.acquireDisplayLock(); .acquireDisplayLock();
if (displayLockHandle == null) return; // If another IPH UI is currently shown, return.
if (mDisplayLockHandle == null) return;
if (mHideTask != null) mHideTask.cancel(false); if (mHideTask != null) mHideTask.cancel(false);
mHideTask = new FutureTask<Void>(() -> { mHideTask = new FutureTask<Void>(() -> {
mModel.set(KeyFunctionsIPHProperties.IS_VISIBLE, false); mModel.set(KeyFunctionsIPHProperties.IS_VISIBLE, false);
displayLockHandle.release(); mDisplayLockHandle.release();
mDisplayLockHandle = null;
return null; return null;
}); });
PostTask.postDelayedTask(UiThreadTaskTraits.DEFAULT, mHideTask, DISPLAY_DURATION_MS); PostTask.postDelayedTask(UiThreadTaskTraits.DEFAULT, mHideTask, DISPLAY_DURATION_MS);
......
...@@ -37,15 +37,16 @@ public class KeyFunctionsIPHView extends FrameLayout { ...@@ -37,15 +37,16 @@ public class KeyFunctionsIPHView extends FrameLayout {
mTooltipView = hostView; mTooltipView = hostView;
} }
void show(boolean isCursorVisible) { void show() {
if (isCursorVisible) {
mNavigationModeImageView.setImageResource(R.drawable.ic_spatial_navigation);
} else {
mNavigationModeImageView.setImageResource(R.drawable.ic_cursor_navigation);
}
mTooltipView.show(this); mTooltipView.show(this);
} }
void setCursorVisibility(boolean isCursorVisible) {
mNavigationModeImageView.setImageResource(isCursorVisible
? R.drawable.ic_spatial_navigation
: R.drawable.ic_cursor_navigation);
}
void hide() { void hide() {
mTooltipView.hide(); mTooltipView.hide();
} }
......
...@@ -16,10 +16,14 @@ public class KeyFunctionsIPHViewBinder { ...@@ -16,10 +16,14 @@ public class KeyFunctionsIPHViewBinder {
if (KeyFunctionsIPHProperties.TOOLTIP_VIEW == propertyKey) { if (KeyFunctionsIPHProperties.TOOLTIP_VIEW == propertyKey) {
keyFunctionsIPHView.setTooltipView(model.get(KeyFunctionsIPHProperties.TOOLTIP_VIEW)); keyFunctionsIPHView.setTooltipView(model.get(KeyFunctionsIPHProperties.TOOLTIP_VIEW));
} else if (KeyFunctionsIPHProperties.IS_VISIBLE == propertyKey) { } else if (KeyFunctionsIPHProperties.IS_VISIBLE == propertyKey) {
if (model.get(KeyFunctionsIPHProperties.IS_VISIBLE)) if (model.get(KeyFunctionsIPHProperties.IS_VISIBLE)) {
keyFunctionsIPHView.show(model.get(KeyFunctionsIPHProperties.IS_CURSOR_VISIBLE)); keyFunctionsIPHView.show();
else } else {
keyFunctionsIPHView.hide(); keyFunctionsIPHView.hide();
}
} else if (KeyFunctionsIPHProperties.IS_CURSOR_VISIBLE == propertyKey) {
keyFunctionsIPHView.setCursorVisibility(
model.get(KeyFunctionsIPHProperties.IS_CURSOR_VISIBLE));
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment