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 {
private final KeyFunctionsIPHTabObserver mKeyFunctionsIPHTabObserver;
private FutureTask mHideTask;
private int mPageLoadCount;
private DisplayLockHandle mDisplayLockHandle;
private static final long DISPLAY_DURATION_MS = 3000;
......@@ -62,16 +63,18 @@ public class KeyFunctionsIPHMediator implements CursorObserver {
if (totalSessionCount > INTRODUCTORY_SESSIONS && mPageLoadCount > 1) return;
}
// This ensures that no other in-product help UI is currently shown.
DisplayLockHandle displayLockHandle =
TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile())
.acquireDisplayLock();
if (displayLockHandle == null) return;
// If we are already showing this IPH, we should release the lock.
if (mDisplayLockHandle != null) mDisplayLockHandle.release();
mDisplayLockHandle = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile())
.acquireDisplayLock();
// If another IPH UI is currently shown, return.
if (mDisplayLockHandle == null) return;
if (mHideTask != null) mHideTask.cancel(false);
mHideTask = new FutureTask<Void>(() -> {
mModel.set(KeyFunctionsIPHProperties.IS_VISIBLE, false);
displayLockHandle.release();
mDisplayLockHandle.release();
mDisplayLockHandle = null;
return null;
});
PostTask.postDelayedTask(UiThreadTaskTraits.DEFAULT, mHideTask, DISPLAY_DURATION_MS);
......
......@@ -37,15 +37,16 @@ public class KeyFunctionsIPHView extends FrameLayout {
mTooltipView = hostView;
}
void show(boolean isCursorVisible) {
if (isCursorVisible) {
mNavigationModeImageView.setImageResource(R.drawable.ic_spatial_navigation);
} else {
mNavigationModeImageView.setImageResource(R.drawable.ic_cursor_navigation);
}
void show() {
mTooltipView.show(this);
}
void setCursorVisibility(boolean isCursorVisible) {
mNavigationModeImageView.setImageResource(isCursorVisible
? R.drawable.ic_spatial_navigation
: R.drawable.ic_cursor_navigation);
}
void hide() {
mTooltipView.hide();
}
......
......@@ -16,10 +16,14 @@ public class KeyFunctionsIPHViewBinder {
if (KeyFunctionsIPHProperties.TOOLTIP_VIEW == propertyKey) {
keyFunctionsIPHView.setTooltipView(model.get(KeyFunctionsIPHProperties.TOOLTIP_VIEW));
} else if (KeyFunctionsIPHProperties.IS_VISIBLE == propertyKey) {
if (model.get(KeyFunctionsIPHProperties.IS_VISIBLE))
keyFunctionsIPHView.show(model.get(KeyFunctionsIPHProperties.IS_CURSOR_VISIBLE));
else
if (model.get(KeyFunctionsIPHProperties.IS_VISIBLE)) {
keyFunctionsIPHView.show();
} else {
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