mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Merge "Set the original drawable for floating widget view" into tm-qpr-dev am: 792dda2344
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20899726 Change-Id: I345f74a393fb994b7b83ccde884263c8a43b4678 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -27,8 +27,10 @@ import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.RemoteViews.RemoteViewOutlineProvider;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetHostView;
|
||||
import com.android.launcher3.widget.RoundedCornerEnforcement;
|
||||
|
||||
@@ -65,14 +67,20 @@ final class FloatingWidgetBackgroundView extends View {
|
||||
setClipToOutline(true);
|
||||
}
|
||||
|
||||
void init(LauncherAppWidgetHostView hostView, View backgroundView, float finalRadius,
|
||||
int fallbackBackgroundColor) {
|
||||
void init(LauncherAppWidgetHostView hostView, @NonNull View backgroundView,
|
||||
float finalRadius, int fallbackBackgroundColor) {
|
||||
mFinalRadius = finalRadius;
|
||||
mSourceView = backgroundView;
|
||||
mInitialOutlineRadius = getOutlineRadius(hostView, backgroundView);
|
||||
mIsUsingFallback = false;
|
||||
if (isSupportedDrawable(backgroundView.getForeground())) {
|
||||
mOriginalForeground = backgroundView.getForeground();
|
||||
if (backgroundView.getTag(R.id.saved_floating_widget_foreground) == null) {
|
||||
mOriginalForeground = backgroundView.getForeground();
|
||||
backgroundView.setTag(R.id.saved_floating_widget_foreground, mOriginalForeground);
|
||||
} else {
|
||||
mOriginalForeground = (Drawable) backgroundView.getTag(
|
||||
R.id.saved_floating_widget_foreground);
|
||||
}
|
||||
mForegroundProperties.init(
|
||||
mOriginalForeground.getConstantState().newDrawable().mutate());
|
||||
setForeground(mForegroundProperties.mDrawable);
|
||||
@@ -82,7 +90,13 @@ final class FloatingWidgetBackgroundView extends View {
|
||||
mSourceView.setForeground(clipPlaceholder);
|
||||
}
|
||||
if (isSupportedDrawable(backgroundView.getBackground())) {
|
||||
mOriginalBackground = backgroundView.getBackground();
|
||||
if (backgroundView.getTag(R.id.saved_floating_widget_background) == null) {
|
||||
mOriginalBackground = backgroundView.getBackground();
|
||||
backgroundView.setTag(R.id.saved_floating_widget_background, mOriginalBackground);
|
||||
} else {
|
||||
mOriginalBackground = (Drawable) backgroundView.getTag(
|
||||
R.id.saved_floating_widget_background);
|
||||
}
|
||||
mBackgroundProperties.init(
|
||||
mOriginalBackground.getConstantState().newDrawable().mutate());
|
||||
setBackground(mBackgroundProperties.mDrawable);
|
||||
@@ -115,6 +129,10 @@ final class FloatingWidgetBackgroundView extends View {
|
||||
}
|
||||
|
||||
void recycle() {
|
||||
if (mSourceView != null) {
|
||||
mSourceView.setTag(R.id.saved_floating_widget_foreground, null);
|
||||
mSourceView.setTag(R.id.saved_floating_widget_background, null);
|
||||
}
|
||||
mSourceView = null;
|
||||
mOriginalForeground = null;
|
||||
mOriginalBackground = null;
|
||||
|
||||
@@ -38,4 +38,7 @@
|
||||
<item type="id" name="cache_entry_tag_id" />
|
||||
|
||||
<item type="id" name="saved_clip_children_tag_id" />
|
||||
|
||||
<item type="id" name="saved_floating_widget_foreground" />
|
||||
<item type="id" name="saved_floating_widget_background" />
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user