Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94f988a7 authored by Archisha Baranwal's avatar Archisha Baranwal
Browse files

Modified Revert of "Adding ViewCaptureAwareWindowManager to ClipboardOverlayWindow."

This reverts commit 8843fd24.

Reason for revert: Reverting change due to the restructure of ViewCaptureAwareWindowManager ( go/wm-for-viewcapture )

Flag: com.android.systemui.enable_view_capture_tracing

Change-Id: I713a73fc3f7ca786dc9c4889ed28ef4e2d32c1ea
parent 182938dc
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.internal.policy.PhoneWindow;
import com.android.systemui.clipboardoverlay.dagger.ClipboardOverlayModule.OverlayWindowContext;
import com.android.systemui.screenshot.FloatingWindowUtil;
@@ -45,7 +44,6 @@ public class ClipboardOverlayWindow extends PhoneWindow

    private final Context mContext;
    private final WindowManager mWindowManager;
    private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager;
    private final WindowManager.LayoutParams mWindowLayoutParams;

    private boolean mKeyboardVisible;
@@ -55,7 +53,6 @@ public class ClipboardOverlayWindow extends PhoneWindow

    @Inject
    ClipboardOverlayWindow(@OverlayWindowContext Context context,
            @OverlayWindowContext ViewCaptureAwareWindowManager viewCaptureAwareWindowManager,
            @OverlayWindowContext WindowManager windowManager) {
        super(context);
        mContext = context;
@@ -66,10 +63,9 @@ public class ClipboardOverlayWindow extends PhoneWindow
        requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
        setBackgroundDrawableResource(android.R.color.transparent);
        mWindowManager = windowManager;
        mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager;
        mWindowLayoutParams = FloatingWindowUtil.getFloatingWindowParams();
        mWindowLayoutParams.setTitle("ClipboardOverlay");
        setWindowManager(windowManager, null, null);
        setWindowManager(mWindowManager, null, null);
        setWindowFocusable(false);
    }

@@ -86,12 +82,10 @@ public class ClipboardOverlayWindow extends PhoneWindow

        attach();
        withWindowAttached(() -> {
            WindowInsets currentInsets = mWindowManager.getCurrentWindowMetrics()
                    .getWindowInsets();
            WindowInsets currentInsets = mWindowManager.getCurrentWindowMetrics().getWindowInsets();
            mKeyboardVisible = currentInsets.isVisible(WindowInsets.Type.ime());
            peekDecorView().getViewTreeObserver().addOnGlobalLayoutListener(() -> {
                WindowInsets insets = mWindowManager.getCurrentWindowMetrics()
                        .getWindowInsets();
                WindowInsets insets = mWindowManager.getCurrentWindowMetrics().getWindowInsets();
                boolean keyboardVisible = insets.isVisible(WindowInsets.Type.ime());
                if (keyboardVisible != mKeyboardVisible) {
                    mKeyboardVisible = keyboardVisible;
@@ -112,7 +106,7 @@ public class ClipboardOverlayWindow extends PhoneWindow
    void remove() {
        final View decorView = peekDecorView();
        if (decorView != null && decorView.isAttachedToWindow()) {
            mViewCaptureAwareWindowManager.removeViewImmediate(decorView);
            mWindowManager.removeViewImmediate(decorView);
        }
    }

@@ -146,7 +140,7 @@ public class ClipboardOverlayWindow extends PhoneWindow
        if (decorView.isAttachedToWindow()) {
            return;
        }
        mViewCaptureAwareWindowManager.addView(decorView, mWindowLayoutParams);
        mWindowManager.addView(decorView, mWindowLayoutParams);
        decorView.requestApplyInsets();
    }

@@ -167,7 +161,7 @@ public class ClipboardOverlayWindow extends PhoneWindow
        }
        final View decorView = peekDecorView();
        if (decorView != null && decorView.isAttachedToWindow()) {
            mViewCaptureAwareWindowManager.updateViewLayout(decorView, mWindowLayoutParams);
            mWindowManager.updateViewLayout(decorView, mWindowLayoutParams);
        }
    }
}
+4 −19
Original line number Diff line number Diff line
@@ -19,9 +19,7 @@ package com.android.systemui.clipboardoverlay.dagger;
import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;

import static com.android.systemui.Flags.clipboardOverlayMultiuser;
import static com.android.systemui.Flags.enableViewCaptureTracing;
import static com.android.systemui.shared.Flags.usePreferredImageEditor;
import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@@ -31,8 +29,6 @@ import android.view.Display;
import android.view.LayoutInflater;
import android.view.WindowManager;

import com.android.app.viewcapture.ViewCapture;
import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.systemui.clipboardoverlay.ActionIntentCreator;
import com.android.systemui.clipboardoverlay.ClipboardOverlayView;
import com.android.systemui.clipboardoverlay.DefaultIntentCreator;
@@ -40,6 +36,7 @@ import com.android.systemui.clipboardoverlay.IntentCreator;
import com.android.systemui.res.R;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.utils.windowmanager.WindowManagerProvider;

import dagger.Lazy;
import dagger.Module;
@@ -89,21 +86,9 @@ public interface ClipboardOverlayModule {
     */
    @Provides
    @OverlayWindowContext
    static WindowManager provideWindowManager(@OverlayWindowContext Context context) {
        return context.getSystemService(WindowManager.class);
    }

    /**
     *
     */
    @Provides
    @OverlayWindowContext
    static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager(
            @OverlayWindowContext WindowManager windowManager,
            Lazy<ViewCapture> daggerLazyViewCapture) {
        return new ViewCaptureAwareWindowManager(windowManager,
                /* lazyViewCapture= */ toKotlinLazy(daggerLazyViewCapture),
                /* isViewCaptureEnabled= */ enableViewCaptureTracing());
    static WindowManager provideWindowManager(@OverlayWindowContext Context context,
            WindowManagerProvider windowManagerProvider) {
        return windowManagerProvider.getWindowManager(context);
    }

    @Provides