Loading core/java/android/widget/Magnifier.java +38 −19 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.annotation.TestApi; import android.annotation.UiThread; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Outline; Loading @@ -34,6 +35,7 @@ import android.graphics.Rect; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.view.ContextThemeWrapper; import android.view.Display; import android.view.DisplayListCanvas; import android.view.LayoutInflater; Loading @@ -49,6 +51,7 @@ import android.view.View; import android.view.ViewParent; import android.view.ViewRootImpl; import com.android.internal.R; import com.android.internal.util.Preconditions; /** Loading Loading @@ -83,6 +86,8 @@ public final class Magnifier { private final int mBitmapHeight; // The elevation of the window containing the magnifier. private final float mWindowElevation; // The corner radius of the window containing the magnifier. private final float mWindowCornerRadius; // The center coordinates of the content that is to be magnified. private final Point mCenterZoomCoords = new Point(); // Variables holding previous states, used for detecting redundant calls and invalidation. Loading @@ -104,17 +109,13 @@ public final class Magnifier { public Magnifier(@NonNull View view) { mView = Preconditions.checkNotNull(view); final Context context = mView.getContext(); final View content = LayoutInflater.from(context).inflate( com.android.internal.R.layout.magnifier, null); content.findViewById(com.android.internal.R.id.magnifier_inner).setClipToOutline(true); mWindowWidth = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.magnifier_width); mWindowHeight = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.magnifier_height); mWindowElevation = context.getResources().getDimension( com.android.internal.R.dimen.magnifier_elevation); mZoom = context.getResources().getFloat( com.android.internal.R.dimen.magnifier_zoom_scale); final View content = LayoutInflater.from(context).inflate(R.layout.magnifier, null); content.findViewById(R.id.magnifier_inner).setClipToOutline(true); mWindowWidth = context.getResources().getDimensionPixelSize(R.dimen.magnifier_width); mWindowHeight = context.getResources().getDimensionPixelSize(R.dimen.magnifier_height); mWindowElevation = context.getResources().getDimension(R.dimen.magnifier_elevation); mWindowCornerRadius = getDeviceDefaultDialogCornerRadius(); mZoom = context.getResources().getFloat(R.dimen.magnifier_zoom_scale); mBitmapWidth = Math.round(mWindowWidth / mZoom); mBitmapHeight = Math.round(mWindowHeight / mZoom); // The view's surface coordinates will not be updated until the magnifier is first shown. Loading @@ -125,6 +126,21 @@ public final class Magnifier { sPixelCopyHandlerThread.start(); } /** * Returns the device default theme dialog corner radius attribute. * We retrieve this from the device default theme to avoid * using the values set in the custom application themes. */ private float getDeviceDefaultDialogCornerRadius() { final Context deviceDefaultContext = new ContextThemeWrapper(mView.getContext(), R.style.Theme_DeviceDefault); final TypedArray ta = deviceDefaultContext.obtainStyledAttributes( new int[]{android.R.attr.dialogCornerRadius}); final float dialogCornerRadius = ta.getDimension(0, 0); ta.recycle(); return dialogCornerRadius; } /** * Shows the magnifier on the screen. * Loading Loading @@ -178,7 +194,8 @@ public final class Magnifier { if (mWindow == null) { synchronized (mLock) { mWindow = new InternalPopupWindow(mView.getContext(), mView.getDisplay(), getValidViewSurface(), mWindowWidth, mWindowHeight, mWindowElevation, getValidViewSurface(), mWindowWidth, mWindowHeight, mWindowElevation, mWindowCornerRadius, Handler.getMain() /* draw the magnifier on the UI thread */, mLock, mCallback); } Loading Loading @@ -271,7 +288,7 @@ public final class Magnifier { // Compute the position of the magnifier window. Again, this has to be relative to the // surface of the magnified view, as this surface is the parent of the magnifier surface. final int verticalOffset = mView.getContext().getResources().getDimensionPixelSize( com.android.internal.R.dimen.magnifier_offset); R.dimen.magnifier_offset); mWindowCoords.x = mCenterZoomCoords.x - mWindowWidth / 2; mWindowCoords.y = mCenterZoomCoords.y - mWindowHeight / 2 - verticalOffset; } Loading Loading @@ -393,7 +410,7 @@ public final class Magnifier { InternalPopupWindow(final Context context, final Display display, final Surface parentSurface, final int width, final int height, final float elevation, final int width, final int height, final float elevation, final float cornerRadius, final Handler handler, final Object lock, final Callback callback) { mDisplay = display; mLock = lock; Loading Loading @@ -424,7 +441,8 @@ public final class Magnifier { ); mBitmapRenderNode = createRenderNodeForBitmap( "magnifier content", elevation elevation, cornerRadius ); final DisplayListCanvas canvas = mRenderer.getRootNode().start(width, height); Loading @@ -442,7 +460,8 @@ public final class Magnifier { mFrameDrawScheduled = false; } private RenderNode createRenderNodeForBitmap(final String name, final float elevation) { private RenderNode createRenderNodeForBitmap(final String name, final float elevation, final float cornerRadius) { final RenderNode bitmapRenderNode = RenderNode.create(name, null); // Define the position of the bitmap in the parent render node. The surface regions Loading @@ -452,7 +471,7 @@ public final class Magnifier { bitmapRenderNode.setElevation(elevation); final Outline outline = new Outline(); outline.setRoundRect(0, 0, mContentWidth, mContentHeight, 3); outline.setRoundRect(0, 0, mContentWidth, mContentHeight, cornerRadius); outline.setAlpha(1.0f); bitmapRenderNode.setOutline(outline); bitmapRenderNode.setClipToOutline(true); Loading Loading @@ -658,8 +677,8 @@ public final class Magnifier { final Resources resources = Resources.getSystem(); final float density = resources.getDisplayMetrics().density; final PointF size = new PointF(); size.x = resources.getDimension(com.android.internal.R.dimen.magnifier_width) / density; size.y = resources.getDimension(com.android.internal.R.dimen.magnifier_height) / density; size.x = resources.getDimension(R.dimen.magnifier_width) / density; size.y = resources.getDimension(R.dimen.magnifier_height) / density; return size; } Loading core/java/com/android/internal/widget/FloatingToolbar.java +2 −1 Original line number Diff line number Diff line Loading @@ -1784,7 +1784,8 @@ public final class FloatingToolbar { private static Context applyDefaultTheme(Context originalContext) { TypedArray a = originalContext.obtainStyledAttributes(new int[]{R.attr.isLightTheme}); boolean isLightTheme = a.getBoolean(0, true); int themeId = isLightTheme ? R.style.Theme_Material_Light : R.style.Theme_Material; int themeId = isLightTheme ? R.style.Theme_DeviceDefault_Light : R.style.Theme_DeviceDefault; a.recycle(); return new ContextThemeWrapper(originalContext, themeId); } Loading core/res/res/drawable/floating_popup_background_dark.xml +2 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,6 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/background_floating_material_dark" /> <corners android:radius="2dp" /> <corners android:radius="?android:attr/dialogCornerRadius" /> </shape> core/res/res/drawable/floating_popup_background_light.xml +1 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,6 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/background_floating_material_light" /> <corners android:radius="2dp" /> <corners android:radius="?android:attr/dialogCornerRadius" /> </shape> Loading
core/java/android/widget/Magnifier.java +38 −19 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.annotation.TestApi; import android.annotation.UiThread; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Outline; Loading @@ -34,6 +35,7 @@ import android.graphics.Rect; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.view.ContextThemeWrapper; import android.view.Display; import android.view.DisplayListCanvas; import android.view.LayoutInflater; Loading @@ -49,6 +51,7 @@ import android.view.View; import android.view.ViewParent; import android.view.ViewRootImpl; import com.android.internal.R; import com.android.internal.util.Preconditions; /** Loading Loading @@ -83,6 +86,8 @@ public final class Magnifier { private final int mBitmapHeight; // The elevation of the window containing the magnifier. private final float mWindowElevation; // The corner radius of the window containing the magnifier. private final float mWindowCornerRadius; // The center coordinates of the content that is to be magnified. private final Point mCenterZoomCoords = new Point(); // Variables holding previous states, used for detecting redundant calls and invalidation. Loading @@ -104,17 +109,13 @@ public final class Magnifier { public Magnifier(@NonNull View view) { mView = Preconditions.checkNotNull(view); final Context context = mView.getContext(); final View content = LayoutInflater.from(context).inflate( com.android.internal.R.layout.magnifier, null); content.findViewById(com.android.internal.R.id.magnifier_inner).setClipToOutline(true); mWindowWidth = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.magnifier_width); mWindowHeight = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.magnifier_height); mWindowElevation = context.getResources().getDimension( com.android.internal.R.dimen.magnifier_elevation); mZoom = context.getResources().getFloat( com.android.internal.R.dimen.magnifier_zoom_scale); final View content = LayoutInflater.from(context).inflate(R.layout.magnifier, null); content.findViewById(R.id.magnifier_inner).setClipToOutline(true); mWindowWidth = context.getResources().getDimensionPixelSize(R.dimen.magnifier_width); mWindowHeight = context.getResources().getDimensionPixelSize(R.dimen.magnifier_height); mWindowElevation = context.getResources().getDimension(R.dimen.magnifier_elevation); mWindowCornerRadius = getDeviceDefaultDialogCornerRadius(); mZoom = context.getResources().getFloat(R.dimen.magnifier_zoom_scale); mBitmapWidth = Math.round(mWindowWidth / mZoom); mBitmapHeight = Math.round(mWindowHeight / mZoom); // The view's surface coordinates will not be updated until the magnifier is first shown. Loading @@ -125,6 +126,21 @@ public final class Magnifier { sPixelCopyHandlerThread.start(); } /** * Returns the device default theme dialog corner radius attribute. * We retrieve this from the device default theme to avoid * using the values set in the custom application themes. */ private float getDeviceDefaultDialogCornerRadius() { final Context deviceDefaultContext = new ContextThemeWrapper(mView.getContext(), R.style.Theme_DeviceDefault); final TypedArray ta = deviceDefaultContext.obtainStyledAttributes( new int[]{android.R.attr.dialogCornerRadius}); final float dialogCornerRadius = ta.getDimension(0, 0); ta.recycle(); return dialogCornerRadius; } /** * Shows the magnifier on the screen. * Loading Loading @@ -178,7 +194,8 @@ public final class Magnifier { if (mWindow == null) { synchronized (mLock) { mWindow = new InternalPopupWindow(mView.getContext(), mView.getDisplay(), getValidViewSurface(), mWindowWidth, mWindowHeight, mWindowElevation, getValidViewSurface(), mWindowWidth, mWindowHeight, mWindowElevation, mWindowCornerRadius, Handler.getMain() /* draw the magnifier on the UI thread */, mLock, mCallback); } Loading Loading @@ -271,7 +288,7 @@ public final class Magnifier { // Compute the position of the magnifier window. Again, this has to be relative to the // surface of the magnified view, as this surface is the parent of the magnifier surface. final int verticalOffset = mView.getContext().getResources().getDimensionPixelSize( com.android.internal.R.dimen.magnifier_offset); R.dimen.magnifier_offset); mWindowCoords.x = mCenterZoomCoords.x - mWindowWidth / 2; mWindowCoords.y = mCenterZoomCoords.y - mWindowHeight / 2 - verticalOffset; } Loading Loading @@ -393,7 +410,7 @@ public final class Magnifier { InternalPopupWindow(final Context context, final Display display, final Surface parentSurface, final int width, final int height, final float elevation, final int width, final int height, final float elevation, final float cornerRadius, final Handler handler, final Object lock, final Callback callback) { mDisplay = display; mLock = lock; Loading Loading @@ -424,7 +441,8 @@ public final class Magnifier { ); mBitmapRenderNode = createRenderNodeForBitmap( "magnifier content", elevation elevation, cornerRadius ); final DisplayListCanvas canvas = mRenderer.getRootNode().start(width, height); Loading @@ -442,7 +460,8 @@ public final class Magnifier { mFrameDrawScheduled = false; } private RenderNode createRenderNodeForBitmap(final String name, final float elevation) { private RenderNode createRenderNodeForBitmap(final String name, final float elevation, final float cornerRadius) { final RenderNode bitmapRenderNode = RenderNode.create(name, null); // Define the position of the bitmap in the parent render node. The surface regions Loading @@ -452,7 +471,7 @@ public final class Magnifier { bitmapRenderNode.setElevation(elevation); final Outline outline = new Outline(); outline.setRoundRect(0, 0, mContentWidth, mContentHeight, 3); outline.setRoundRect(0, 0, mContentWidth, mContentHeight, cornerRadius); outline.setAlpha(1.0f); bitmapRenderNode.setOutline(outline); bitmapRenderNode.setClipToOutline(true); Loading Loading @@ -658,8 +677,8 @@ public final class Magnifier { final Resources resources = Resources.getSystem(); final float density = resources.getDisplayMetrics().density; final PointF size = new PointF(); size.x = resources.getDimension(com.android.internal.R.dimen.magnifier_width) / density; size.y = resources.getDimension(com.android.internal.R.dimen.magnifier_height) / density; size.x = resources.getDimension(R.dimen.magnifier_width) / density; size.y = resources.getDimension(R.dimen.magnifier_height) / density; return size; } Loading
core/java/com/android/internal/widget/FloatingToolbar.java +2 −1 Original line number Diff line number Diff line Loading @@ -1784,7 +1784,8 @@ public final class FloatingToolbar { private static Context applyDefaultTheme(Context originalContext) { TypedArray a = originalContext.obtainStyledAttributes(new int[]{R.attr.isLightTheme}); boolean isLightTheme = a.getBoolean(0, true); int themeId = isLightTheme ? R.style.Theme_Material_Light : R.style.Theme_Material; int themeId = isLightTheme ? R.style.Theme_DeviceDefault_Light : R.style.Theme_DeviceDefault; a.recycle(); return new ContextThemeWrapper(originalContext, themeId); } Loading
core/res/res/drawable/floating_popup_background_dark.xml +2 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,6 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/background_floating_material_dark" /> <corners android:radius="2dp" /> <corners android:radius="?android:attr/dialogCornerRadius" /> </shape>
core/res/res/drawable/floating_popup_background_light.xml +1 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,6 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/background_floating_material_light" /> <corners android:radius="2dp" /> <corners android:radius="?android:attr/dialogCornerRadius" /> </shape>