Loading core/java/android/view/WindowManager.java +0 −7 Original line number Diff line number Diff line Loading @@ -776,12 +776,6 @@ public interface WindowManager extends ViewManager { */ int TAKE_SCREENSHOT_FULLSCREEN = 1; /** * Invoke screenshot flow allowing the user to select a region. * @hide */ int TAKE_SCREENSHOT_SELECTED_REGION = 2; /** * Invoke screenshot flow with an image provided by the caller. * @hide Loading @@ -794,7 +788,6 @@ public interface WindowManager extends ViewManager { * @hide */ @IntDef({TAKE_SCREENSHOT_FULLSCREEN, TAKE_SCREENSHOT_SELECTED_REGION, TAKE_SCREENSHOT_PROVIDED_IMAGE}) @interface ScreenshotType {} Loading core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java +0 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.util; import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN; import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.fail; Loading Loading @@ -84,12 +83,6 @@ public final class ScreenshotHelperTest { WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null); } @Test public void testSelectedRegionScreenshot() { mScreenshotHelper.takeScreenshot(TAKE_SCREENSHOT_SELECTED_REGION, WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null); } @Test public void testProvidedImageScreenshot() { mScreenshotHelper.provideScreenshot( Loading packages/SystemUI/res/layout/screenshot.xml +0 −6 Original line number Diff line number Diff line Loading @@ -35,12 +35,6 @@ android:visibility="gone" android:elevation="7dp" android:src="@android:color/white"/> <com.android.systemui.screenshot.ScreenshotSelectorView android:id="@+id/screenshot_selector" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" android:pointerIcon="crosshair"/> <include layout="@layout/screenshot_static" android:id="@+id/screenshot_static"/> </com.android.systemui.screenshot.ScreenshotView> packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +0 −18 Original line number Diff line number Diff line Loading @@ -407,24 +407,6 @@ public class ScreenshotController { showFlash, UserHandle.of(userId)); } /** * Displays a screenshot selector */ @MainThread void takeScreenshotPartial(ComponentName topComponent, final Consumer<Uri> finisher, RequestCallback requestCallback) { Assert.isMainThread(); mScreenshotView.reset(); mCurrentRequestCallback = requestCallback; attachWindow(); mWindow.setContentView(mScreenshotView); mScreenshotView.requestApplyInsets(); mScreenshotView.takePartialScreenshot( rect -> takeScreenshotInternal(topComponent, finisher, rect)); } /** * Clears current screenshot */ Loading packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSelectorView.javadeleted 100644 → 0 +0 −119 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.screenshot; import android.annotation.Nullable; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import java.util.function.Consumer; /** * Draws a selection rectangle while taking screenshot */ public class ScreenshotSelectorView extends View { private Point mStartPoint; private Rect mSelectionRect; private final Paint mPaintSelection, mPaintBackground; private Consumer<Rect> mOnScreenshotSelected; public ScreenshotSelectorView(Context context) { this(context, null); } public ScreenshotSelectorView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); mPaintBackground = new Paint(Color.BLACK); mPaintBackground.setAlpha(160); mPaintSelection = new Paint(Color.TRANSPARENT); mPaintSelection.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); setOnTouchListener((v, event) -> { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startSelection((int) event.getX(), (int) event.getY()); return true; case MotionEvent.ACTION_MOVE: updateSelection((int) event.getX(), (int) event.getY()); return true; case MotionEvent.ACTION_UP: setVisibility(View.GONE); final Rect rect = getSelectionRect(); if (mOnScreenshotSelected != null && rect != null && rect.width() != 0 && rect.height() != 0) { mOnScreenshotSelected.accept(rect); } stopSelection(); return true; } return false; }); } @Override public void draw(Canvas canvas) { canvas.drawRect(mLeft, mTop, mRight, mBottom, mPaintBackground); if (mSelectionRect != null) { canvas.drawRect(mSelectionRect, mPaintSelection); } } void setOnScreenshotSelected(Consumer<Rect> onScreenshotSelected) { mOnScreenshotSelected = onScreenshotSelected; } void stop() { if (getSelectionRect() != null) { stopSelection(); } } private void startSelection(int x, int y) { mStartPoint = new Point(x, y); mSelectionRect = new Rect(x, y, x, y); } private void updateSelection(int x, int y) { if (mSelectionRect != null) { mSelectionRect.left = Math.min(mStartPoint.x, x); mSelectionRect.right = Math.max(mStartPoint.x, x); mSelectionRect.top = Math.min(mStartPoint.y, y); mSelectionRect.bottom = Math.max(mStartPoint.y, y); invalidate(); } } private Rect getSelectionRect() { return mSelectionRect; } private void stopSelection() { mStartPoint = null; mSelectionRect = null; } } Loading
core/java/android/view/WindowManager.java +0 −7 Original line number Diff line number Diff line Loading @@ -776,12 +776,6 @@ public interface WindowManager extends ViewManager { */ int TAKE_SCREENSHOT_FULLSCREEN = 1; /** * Invoke screenshot flow allowing the user to select a region. * @hide */ int TAKE_SCREENSHOT_SELECTED_REGION = 2; /** * Invoke screenshot flow with an image provided by the caller. * @hide Loading @@ -794,7 +788,6 @@ public interface WindowManager extends ViewManager { * @hide */ @IntDef({TAKE_SCREENSHOT_FULLSCREEN, TAKE_SCREENSHOT_SELECTED_REGION, TAKE_SCREENSHOT_PROVIDED_IMAGE}) @interface ScreenshotType {} Loading
core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java +0 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.util; import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN; import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.fail; Loading Loading @@ -84,12 +83,6 @@ public final class ScreenshotHelperTest { WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null); } @Test public void testSelectedRegionScreenshot() { mScreenshotHelper.takeScreenshot(TAKE_SCREENSHOT_SELECTED_REGION, WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null); } @Test public void testProvidedImageScreenshot() { mScreenshotHelper.provideScreenshot( Loading
packages/SystemUI/res/layout/screenshot.xml +0 −6 Original line number Diff line number Diff line Loading @@ -35,12 +35,6 @@ android:visibility="gone" android:elevation="7dp" android:src="@android:color/white"/> <com.android.systemui.screenshot.ScreenshotSelectorView android:id="@+id/screenshot_selector" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" android:pointerIcon="crosshair"/> <include layout="@layout/screenshot_static" android:id="@+id/screenshot_static"/> </com.android.systemui.screenshot.ScreenshotView>
packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +0 −18 Original line number Diff line number Diff line Loading @@ -407,24 +407,6 @@ public class ScreenshotController { showFlash, UserHandle.of(userId)); } /** * Displays a screenshot selector */ @MainThread void takeScreenshotPartial(ComponentName topComponent, final Consumer<Uri> finisher, RequestCallback requestCallback) { Assert.isMainThread(); mScreenshotView.reset(); mCurrentRequestCallback = requestCallback; attachWindow(); mWindow.setContentView(mScreenshotView); mScreenshotView.requestApplyInsets(); mScreenshotView.takePartialScreenshot( rect -> takeScreenshotInternal(topComponent, finisher, rect)); } /** * Clears current screenshot */ Loading
packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSelectorView.javadeleted 100644 → 0 +0 −119 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.screenshot; import android.annotation.Nullable; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import java.util.function.Consumer; /** * Draws a selection rectangle while taking screenshot */ public class ScreenshotSelectorView extends View { private Point mStartPoint; private Rect mSelectionRect; private final Paint mPaintSelection, mPaintBackground; private Consumer<Rect> mOnScreenshotSelected; public ScreenshotSelectorView(Context context) { this(context, null); } public ScreenshotSelectorView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); mPaintBackground = new Paint(Color.BLACK); mPaintBackground.setAlpha(160); mPaintSelection = new Paint(Color.TRANSPARENT); mPaintSelection.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); setOnTouchListener((v, event) -> { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startSelection((int) event.getX(), (int) event.getY()); return true; case MotionEvent.ACTION_MOVE: updateSelection((int) event.getX(), (int) event.getY()); return true; case MotionEvent.ACTION_UP: setVisibility(View.GONE); final Rect rect = getSelectionRect(); if (mOnScreenshotSelected != null && rect != null && rect.width() != 0 && rect.height() != 0) { mOnScreenshotSelected.accept(rect); } stopSelection(); return true; } return false; }); } @Override public void draw(Canvas canvas) { canvas.drawRect(mLeft, mTop, mRight, mBottom, mPaintBackground); if (mSelectionRect != null) { canvas.drawRect(mSelectionRect, mPaintSelection); } } void setOnScreenshotSelected(Consumer<Rect> onScreenshotSelected) { mOnScreenshotSelected = onScreenshotSelected; } void stop() { if (getSelectionRect() != null) { stopSelection(); } } private void startSelection(int x, int y) { mStartPoint = new Point(x, y); mSelectionRect = new Rect(x, y, x, y); } private void updateSelection(int x, int y) { if (mSelectionRect != null) { mSelectionRect.left = Math.min(mStartPoint.x, x); mSelectionRect.right = Math.max(mStartPoint.x, x); mSelectionRect.top = Math.min(mStartPoint.y, y); mSelectionRect.bottom = Math.max(mStartPoint.y, y); invalidate(); } } private Rect getSelectionRect() { return mSelectionRect; } private void stopSelection() { mStartPoint = null; mSelectionRect = null; } }