Merge "Fix triggering One-handed mode introduces gesture conflict issues (2/n)"
This commit is contained in:
commit
cfbfea9172
|
@ -66,6 +66,7 @@ class OrientationTouchTransformer {
|
|||
private final RectF mOneHandedModeRegion = new RectF();
|
||||
private int mCurrentDisplayRotation;
|
||||
private int mNavBarGesturalHeight;
|
||||
private int mNavBarLargerGesturalHeight;
|
||||
private boolean mEnableMultipleRegions;
|
||||
private Resources mResources;
|
||||
private OrientationRectF mLastRectTouched;
|
||||
|
@ -106,6 +107,9 @@ class OrientationTouchTransformer {
|
|||
mMode = mode;
|
||||
mContractInfo = contractInfo;
|
||||
mNavBarGesturalHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
|
||||
mNavBarLargerGesturalHeight = ResourceUtils.getDimenByName(
|
||||
ResourceUtils.NAVBAR_BOTTOM_GESTURE_LARGER_SIZE, resources,
|
||||
mNavBarGesturalHeight);
|
||||
}
|
||||
|
||||
private void refreshTouchRegion(Info info, Resources newRes) {
|
||||
|
@ -234,6 +238,7 @@ class OrientationTouchTransformer {
|
|||
Point size = display.realSize;
|
||||
int rotation = display.rotation;
|
||||
int touchHeight = mNavBarGesturalHeight;
|
||||
int largerGesturalHeight = mNavBarLargerGesturalHeight;
|
||||
OrientationRectF orientationRectF =
|
||||
new OrientationRectF(0, 0, size.x, size.y, rotation);
|
||||
if (mMode == SysUINavigationMode.Mode.NO_BUTTON) {
|
||||
|
@ -256,7 +261,8 @@ class OrientationTouchTransformer {
|
|||
}
|
||||
}
|
||||
// One handed gestural only active on portrait mode
|
||||
mOneHandedModeRegion.set(0, orientationRectF.bottom - touchHeight, size.x, size.y);
|
||||
mOneHandedModeRegion.set(0, orientationRectF.bottom - mNavBarLargerGesturalHeight,
|
||||
size.x, size.y);
|
||||
|
||||
return orientationRectF;
|
||||
}
|
||||
|
@ -378,6 +384,7 @@ class OrientationTouchTransformer {
|
|||
}
|
||||
pw.println(regions.toString());
|
||||
pw.println(" mNavBarGesturalHeight=" + mNavBarGesturalHeight);
|
||||
pw.println(" mNavBarLargerGesturalHeight=" + mNavBarLargerGesturalHeight);
|
||||
pw.println(" mOneHandedModeRegion=" + mOneHandedModeRegion);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ public class SysUINavigationMode {
|
|||
private Mode mMode;
|
||||
|
||||
private int mNavBarGesturalHeight;
|
||||
private int mNavBarLargerGesturalHeight;
|
||||
|
||||
private final List<NavigationModeChangeListener> mChangeListeners = new ArrayList<>();
|
||||
private final List<OneHandedModeChangeListener> mOneHandedOverlayChangeListeners =
|
||||
|
@ -112,6 +113,17 @@ public class SysUINavigationMode {
|
|||
|
||||
if (mNavBarGesturalHeight != newGesturalHeight) {
|
||||
mNavBarGesturalHeight = newGesturalHeight;
|
||||
}
|
||||
|
||||
int newLargerGesturalHeight = ResourceUtils.getDimenByName(
|
||||
ResourceUtils.NAVBAR_BOTTOM_GESTURE_LARGER_SIZE, mContext.getResources(),
|
||||
INVALID_RESOURCE_HANDLE);
|
||||
if (newLargerGesturalHeight == INVALID_RESOURCE_HANDLE) {
|
||||
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
|
||||
return;
|
||||
}
|
||||
if (mNavBarLargerGesturalHeight != newLargerGesturalHeight) {
|
||||
mNavBarLargerGesturalHeight = newLargerGesturalHeight;
|
||||
dispatchOneHandedOverlayChange();
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +134,9 @@ public class SysUINavigationMode {
|
|||
mNavBarGesturalHeight = ResourceUtils.getDimenByName(
|
||||
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mContext.getResources(),
|
||||
INVALID_RESOURCE_HANDLE);
|
||||
mNavBarLargerGesturalHeight = ResourceUtils.getDimenByName(
|
||||
ResourceUtils.NAVBAR_BOTTOM_GESTURE_LARGER_SIZE, mContext.getResources(),
|
||||
mNavBarGesturalHeight);
|
||||
|
||||
if (modeInt == INVALID_RESOURCE_HANDLE) {
|
||||
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
|
||||
|
@ -143,7 +158,7 @@ public class SysUINavigationMode {
|
|||
|
||||
private void dispatchOneHandedOverlayChange() {
|
||||
for (OneHandedModeChangeListener listener : mOneHandedOverlayChangeListeners) {
|
||||
listener.onOneHandedModeChanged(mNavBarGesturalHeight);
|
||||
listener.onOneHandedModeChanged(mNavBarLargerGesturalHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +173,7 @@ public class SysUINavigationMode {
|
|||
|
||||
public int addOneHandedOverlayChangeListener(OneHandedModeChangeListener listener) {
|
||||
mOneHandedOverlayChangeListeners.add(listener);
|
||||
return mNavBarGesturalHeight;
|
||||
return mNavBarLargerGesturalHeight;
|
||||
}
|
||||
|
||||
public void removeOneHandedOverlayChangeListener(OneHandedModeChangeListener listener) {
|
||||
|
@ -182,4 +197,4 @@ public class SysUINavigationMode {
|
|||
public interface OneHandedModeChangeListener {
|
||||
void onOneHandedModeChanged(int newGesturalHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ public class ResourceUtils {
|
|||
public static final int INVALID_RESOURCE_HANDLE = -1;
|
||||
public static final String NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE = "navigation_bar_width";
|
||||
public static final String NAVBAR_BOTTOM_GESTURE_SIZE = "navigation_bar_gesture_height";
|
||||
public static final String NAVBAR_BOTTOM_GESTURE_LARGER_SIZE =
|
||||
"navigation_bar_gesture_larger_height";
|
||||
|
||||
public static int getNavbarSize(String resName, Resources res) {
|
||||
return getDimenByName(resName, res, DEFAULT_NAVBAR_VALUE);
|
||||
|
|
Loading…
Reference in New Issue