mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-05 18:36:49 +00:00
Merge "Migrate from InsetsInfo.contentInsets to WindowManager.LayoutParams#providedInternalInsets" into tm-dev
This commit is contained in:
@@ -176,7 +176,8 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
|
||||
return revealAnim;
|
||||
}
|
||||
|
||||
public void onIsStashed(boolean isStashed) {
|
||||
/** Called when taskbar is stashed or unstashed. */
|
||||
public void onIsStashedChanged(boolean isStashed) {
|
||||
mRegionSamplingHelper.setWindowVisible(isStashed);
|
||||
if (isStashed) {
|
||||
mStashedHandleView.updateSampledRegion(mStashedHandleBounds);
|
||||
|
||||
@@ -559,7 +559,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
}
|
||||
mWindowLayoutParams.height = height;
|
||||
mControllers.taskbarInsetsController.onTaskbarWindowHeightChanged();
|
||||
mControllers.taskbarInsetsController.onTaskbarWindowHeightOrInsetsChanged();
|
||||
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||
private void onComputeTaskbarInsets(InsetsInfo insetsInfo) {
|
||||
if (mControllerCallbacks != null) {
|
||||
mControllerCallbacks.updateInsetsTouchability(insetsInfo);
|
||||
mControllerCallbacks.updateContentInsets(insetsInfo.contentInsets);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,16 +163,6 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
mControllers.taskbarInsetsController.updateInsetsTouchability(insetsInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the {@link InsetsInfo#contentInsets}. This is reported to apps but our
|
||||
* internal launcher will ignore these insets.
|
||||
*/
|
||||
public void updateContentInsets(Rect outContentInsets) {
|
||||
int contentHeight = mControllers.taskbarStashController
|
||||
.getContentHeightToReportToApps();
|
||||
outContentInsets.top = mTaskbarDragLayer.getHeight() - contentHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a child is removed from TaskbarDragLayer.
|
||||
*/
|
||||
|
||||
@@ -53,19 +53,37 @@ class TaskbarInsetsController(val context: TaskbarActivityContext): LoggableTask
|
||||
)
|
||||
)
|
||||
|
||||
windowLayoutParams.providedInternalInsets = arrayOfNulls<Insets>(ITYPE_SIZE)
|
||||
windowLayoutParams.providedInternalImeInsets = arrayOfNulls<Insets>(ITYPE_SIZE)
|
||||
|
||||
onTaskbarWindowHeightChanged()
|
||||
onTaskbarWindowHeightOrInsetsChanged()
|
||||
|
||||
windowLayoutParams.insetsRoundedCornerFrame = true
|
||||
}
|
||||
|
||||
fun onTaskbarWindowHeightChanged() {
|
||||
val reducingSize = Insets.of(0, windowLayoutParams.height - taskbarHeightForIme, 0, 0)
|
||||
fun onTaskbarWindowHeightOrInsetsChanged() {
|
||||
var reducingSize = getReducingInsetsForTaskbarInsetsHeight(
|
||||
controllers.taskbarStashController.contentHeightToReportToApps)
|
||||
windowLayoutParams.providedInternalInsets[ITYPE_EXTRA_NAVIGATION_BAR] = reducingSize
|
||||
reducingSize = getReducingInsetsForTaskbarInsetsHeight(
|
||||
controllers.taskbarStashController.tappableHeightToReportToApps)
|
||||
windowLayoutParams.providedInternalInsets[ITYPE_BOTTOM_TAPPABLE_ELEMENT] = reducingSize
|
||||
|
||||
reducingSize = getReducingInsetsForTaskbarInsetsHeight(taskbarHeightForIme)
|
||||
windowLayoutParams.providedInternalImeInsets[ITYPE_EXTRA_NAVIGATION_BAR] = reducingSize
|
||||
windowLayoutParams.providedInternalImeInsets[ITYPE_BOTTOM_TAPPABLE_ELEMENT] = reducingSize
|
||||
}
|
||||
|
||||
/**
|
||||
* WindowLayoutParams.providedInternal*Insets expects Insets that subtract from the window frame
|
||||
* height (i.e. WindowLayoutParams#height). So for Taskbar to report bottom insets to apps, it
|
||||
* actually provides insets from the top of its window frame.
|
||||
* @param height The number of pixels from the bottom of the screen that Taskbar insets.
|
||||
*/
|
||||
private fun getReducingInsetsForTaskbarInsetsHeight(height: Int): Insets {
|
||||
return Insets.of(0, windowLayoutParams.height - height, 0, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the touchable insets.
|
||||
* @see InsetsInfo.setTouchableInsets
|
||||
@@ -120,6 +138,10 @@ class TaskbarInsetsController(val context: TaskbarActivityContext): LoggableTask
|
||||
override fun dumpLogs(prefix: String, pw: PrintWriter) {
|
||||
pw.println(prefix + "TaskbarInsetsController:")
|
||||
pw.println("$prefix\twindowHeight=${windowLayoutParams.height}")
|
||||
pw.println("$prefix\tprovidedInternalInsets[ITYPE_EXTRA_NAVIGATION_BAR]=" +
|
||||
"${windowLayoutParams.providedInternalInsets[ITYPE_EXTRA_NAVIGATION_BAR]}")
|
||||
pw.println("$prefix\tprovidedInternalInsets[ITYPE_BOTTOM_TAPPABLE_ELEMENT]=" +
|
||||
"${windowLayoutParams.providedInternalInsets[ITYPE_BOTTOM_TAPPABLE_ELEMENT]}")
|
||||
pw.println("$prefix\tprovidedInternalImeInsets[ITYPE_EXTRA_NAVIGATION_BAR]=" +
|
||||
"${windowLayoutParams.providedInternalImeInsets[ITYPE_EXTRA_NAVIGATION_BAR]}")
|
||||
pw.println("$prefix\tprovidedInternalImeInsets[ITYPE_BOTTOM_TAPPABLE_ELEMENT]=" +
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.annotation.Nullable;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Utilities;
|
||||
@@ -280,6 +281,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
|
||||
/**
|
||||
* Returns the height that taskbar will inset when inside apps.
|
||||
* @see WindowInsets.Type#navigationBars()
|
||||
* @see WindowInsets.Type#systemBars()
|
||||
*/
|
||||
public int getContentHeightToReportToApps() {
|
||||
if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) {
|
||||
@@ -304,6 +307,15 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
return mUnstashedHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height that taskbar will inset when inside apps.
|
||||
* @see WindowInsets.Type#tappableElement()
|
||||
*/
|
||||
public int getTappableHeightToReportToApps() {
|
||||
int contentHeight = getContentHeightToReportToApps();
|
||||
return contentHeight <= mStashedHeight ? 0 : contentHeight;
|
||||
}
|
||||
|
||||
public int getStashedHeight() {
|
||||
return mStashedHeight;
|
||||
}
|
||||
@@ -442,7 +454,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mIsStashed = isStashed;
|
||||
onIsStashed(mIsStashed);
|
||||
onIsStashedChanged(mIsStashed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -489,8 +501,9 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
.setDuration(TASKBAR_HINT_STASH_DURATION).start();
|
||||
}
|
||||
|
||||
private void onIsStashed(boolean isStashed) {
|
||||
mControllers.stashedHandleViewController.onIsStashed(isStashed);
|
||||
private void onIsStashedChanged(boolean isStashed) {
|
||||
mControllers.stashedHandleViewController.onIsStashedChanged(isStashed);
|
||||
mControllers.taskbarInsetsController.onTaskbarWindowHeightOrInsetsChanged();
|
||||
}
|
||||
|
||||
public void applyState() {
|
||||
|
||||
Reference in New Issue
Block a user