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

Commit e1c4641d authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge changes Ib309e9de,Ia7cf8b99,I055b0825,Ie2ea4318,If92221d3 into nyc-dev

* changes:
  Fixing crash when focusing tasks.
  Minor tweaks to layout and visuals.
  Improving transition from paging to stack.
  Fixing issue with persistent screenshot notification
  Updating task description when activity is visible.
parents b3fdffbb c4387027
Loading
Loading
Loading
Loading
+71 −61
Original line number Diff line number Diff line
@@ -815,6 +815,9 @@ public class Activity extends ContextThemeWrapper
    private int mDefaultKeyMode = DEFAULT_KEYS_DISABLE;
    private SpannableStringBuilder mDefaultKeySsb = null;

    private ActivityManager.TaskDescription mTaskDescription =
            new ActivityManager.TaskDescription();

    protected static final int[] FOCUSED_STATE_SET = {com.android.internal.R.attr.state_focused};

    @SuppressWarnings("unused")
@@ -1115,6 +1118,34 @@ public class Activity extends ContextThemeWrapper
        return SAVED_DIALOG_ARGS_KEY_PREFIX + key;
    }

    /**
     * Attempts to extract the color from a given drawable.
     *
     * @return the extracted color or 0 if no color could be extracted.
     */
    private int tryExtractColorFromDrawable(Drawable drawable) {
        if (drawable instanceof ColorDrawable) {
            return ((ColorDrawable) drawable).getColor();
        } else if (drawable instanceof InsetDrawable) {
            return tryExtractColorFromDrawable(((InsetDrawable) drawable).getDrawable());
        } else if (drawable instanceof ShapeDrawable) {
            Paint p = ((ShapeDrawable) drawable).getPaint();
            if (p != null) {
                return p.getColor();
            }
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            int numLayers = ld.getNumberOfLayers();
            for (int i = 0; i < numLayers; i++) {
                int color = tryExtractColorFromDrawable(ld.getDrawable(i));
                if (color != 0) {
                    return color;
                }
            }
        }
        return 0;
    }

    /**
     * Called when activity start-up is complete (after {@link #onStart}
     * and {@link #onRestoreInstanceState} have been called).  Applications will
@@ -1136,6 +1167,36 @@ public class Activity extends ContextThemeWrapper
            mTitleReady = true;
            onTitleChanged(getTitle(), getTitleColor());
        }

        Resources.Theme theme = getTheme();
        if (theme != null) {
            // Get the primary color and update the TaskDescription for this activity
            TypedArray a = theme.obtainStyledAttributes(
                    com.android.internal.R.styleable.ActivityTaskDescription);
            if (mTaskDescription.getPrimaryColor() == 0) {
                int colorPrimary = a.getColor(
                        com.android.internal.R.styleable.ActivityTaskDescription_colorPrimary, 0);
                if (colorPrimary != 0 && Color.alpha(colorPrimary) == 0xFF) {
                    mTaskDescription.setPrimaryColor(colorPrimary);
                }
            }
            if (mTaskDescription.getBackgroundColor() == 0) {
                int windowBgResourceId = a.getResourceId(
                        com.android.internal.R.styleable.ActivityTaskDescription_windowBackground,
                        0);
                int windowBgFallbackResourceId = a.getResourceId(
                        com.android.internal.R.styleable.ActivityTaskDescription_windowBackgroundFallback,
                        0);
                int colorBg = tryExtractColorFromDrawable(DecorView.getResizingBackgroundDrawable(
                        this, windowBgResourceId, windowBgFallbackResourceId));
                if (colorBg != 0 && Color.alpha(colorBg) == 0xFF) {
                    mTaskDescription.setBackgroundColor(colorBg);
                }
            }
            a.recycle();
            setTaskDescription(mTaskDescription);
        }

        mCalled = true;
    }

@@ -3975,57 +4036,6 @@ public class Activity extends ContextThemeWrapper
            }
            theme.applyStyle(resid, false);
        }

        // Get the primary color and update the TaskDescription for this activity
        if (theme != null) {
            TypedArray a = theme.obtainStyledAttributes(com.android.internal.R.styleable.Theme);
            int windowBgResourceId = a.getResourceId(
                    com.android.internal.R.styleable.Window_windowBackground, 0);
            int windowBgFallbackResourceId = a.getResourceId(
                    com.android.internal.R.styleable.Window_windowBackgroundFallback, 0);
            int colorPrimary = a.getColor(com.android.internal.R.styleable.Theme_colorPrimary, 0);
            int colorBg = tryExtractColorFromDrawable(DecorView.getResizingBackgroundDrawable(this,
                    windowBgResourceId, windowBgFallbackResourceId));
            a.recycle();
            if (colorPrimary != 0) {
                ActivityManager.TaskDescription td = new ActivityManager.TaskDescription();
                if (Color.alpha(colorPrimary) == 0xFF) {
                    td.setPrimaryColor(colorPrimary);
                }
                if (Color.alpha(colorBg) == 0xFF) {
                    td.setBackgroundColor(colorBg);
                }
                setTaskDescription(td);
            }
        }
    }

    /**
     * Attempts to extract the color from a given drawable.
     *
     * @return the extracted color or 0 if no color could be extracted.
     */
    private int tryExtractColorFromDrawable(Drawable drawable) {
        if (drawable instanceof ColorDrawable) {
            return ((ColorDrawable) drawable).getColor();
        } else if (drawable instanceof InsetDrawable) {
            return tryExtractColorFromDrawable(((InsetDrawable) drawable).getDrawable());
        } else if (drawable instanceof ShapeDrawable) {
            Paint p = ((ShapeDrawable) drawable).getPaint();
            if (p != null) {
                return p.getColor();
            }
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            int numLayers = ld.getNumberOfLayers();
            for (int i = 0; i < numLayers; i++) {
                int color = tryExtractColorFromDrawable(ld.getDrawable(i));
                if (color != 0) {
                    return color;
                }
            }
        }
        return 0;
    }

    /**
@@ -5651,18 +5661,18 @@ public class Activity extends ContextThemeWrapper
     * @param taskDescription The TaskDescription properties that describe the task with this activity
     */
    public void setTaskDescription(ActivityManager.TaskDescription taskDescription) {
        ActivityManager.TaskDescription td;
        if (mTaskDescription != taskDescription) {
            mTaskDescription.copyFrom(taskDescription);
            // Scale the icon down to something reasonable if it is provided
            if (taskDescription.getIconFilename() == null && taskDescription.getIcon() != null) {
                final int size = ActivityManager.getLauncherLargeIconSizeInner(this);
            final Bitmap icon = Bitmap.createScaledBitmap(taskDescription.getIcon(), size, size, true);
            td = new ActivityManager.TaskDescription(taskDescription);
            td.setIcon(icon);
        } else {
            td = taskDescription;
                final Bitmap icon = Bitmap.createScaledBitmap(taskDescription.getIcon(), size, size,
                        true);
                mTaskDescription.setIcon(icon);
            }
        }
        try {
            ActivityManagerNative.getDefault().setTaskDescription(mToken, td);
            ActivityManagerNative.getDefault().setTaskDescription(mToken, mTaskDescription);
        } catch (RemoteException e) {
        }
    }
+13 −5
Original line number Diff line number Diff line
@@ -946,11 +946,19 @@ public class ActivityManager {
         * Creates a copy of another TaskDescription.
         */
        public TaskDescription(TaskDescription td) {
            mLabel = td.mLabel;
            mIcon = td.mIcon;
            mIconFilename = td.mIconFilename;
            mColorPrimary = td.mColorPrimary;
            mColorBackground = td.mColorBackground;
            copyFrom(td);
        }

        /**
         * Copies this the values from another TaskDescription.
         * @hide
         */
        public void copyFrom(TaskDescription other) {
            mLabel = other.mLabel;
            mIcon = other.mIcon;
            mIconFilename = other.mIconFilename;
            mColorPrimary = other.mColorPrimary;
            mColorBackground = other.mColorBackground;
        }

        private TaskDescription(Parcel source) {
+14 −0
Original line number Diff line number Diff line
@@ -8182,4 +8182,18 @@ i
        <!-- The current color for the offset inside the gradient. -->
        <attr name="color" />
    </declare-styleable>

    <!-- @hide Attributes which will be read by the Activity to intialize the 
               base activity TaskDescription. -->
    <declare-styleable name="ActivityTaskDescription">
        <!-- @hide From Theme.colorPrimary, used for the TaskDescription primary 
                   color. -->
        <attr name="colorPrimary" />
        <!-- @hide From Theme.windowBackground, used for calculating the 
                   TaskDescription background color. -->
        <attr name="windowBackground" />
        <!-- @hide From Theme.windowBackgroundFallback, used for calculating the 
                   TaskDescription background color. -->
        <attr name="windowBackgroundFallback" />
    </declare-styleable>
</resources>
+7 −4
Original line number Diff line number Diff line
@@ -26,13 +26,16 @@
        android:layout_width="@dimen/recents_task_view_header_icon_width"
        android:layout_height="@dimen/recents_task_view_header_icon_height"
        android:layout_gravity="center_vertical|start"
        android:padding="9dp" />
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:paddingStart="12dp"
        android:paddingEnd="16dp" />
    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|start"
        android:layout_marginStart="64dp"
        android:layout_marginStart="56dp"
        android:layout_marginEnd="112dp"
        android:textSize="16sp"
        android:textColor="#ffffffff"
@@ -48,7 +51,7 @@
        android:layout_height="@dimen/recents_task_view_header_button_height"
        android:layout_marginEnd="@dimen/recents_task_view_header_button_width"
        android:layout_gravity="center_vertical|end"
        android:padding="15dp"
        android:padding="13dp"
        android:src="@drawable/star"
        android:background="?android:selectableItemBackground"
        android:alpha="0"
@@ -58,7 +61,7 @@
        android:layout_width="@dimen/recents_task_view_header_button_width"
        android:layout_height="@dimen/recents_task_view_header_button_height"
        android:layout_gravity="center_vertical|end"
        android:padding="15dp"
        android:padding="13dp"
        android:src="@drawable/recents_dismiss_light"
        android:background="?android:selectableItemBackground"
        android:alpha="0"
+6 −3
Original line number Diff line number Diff line
@@ -23,13 +23,16 @@
        android:layout_width="@dimen/recents_task_view_header_icon_width"
        android:layout_height="@dimen/recents_task_view_header_icon_height"
        android:layout_gravity="center_vertical|start"
        android:padding="9dp" />
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:paddingStart="12dp"
        android:paddingEnd="16dp" />
    <TextView
        android:id="@+id/app_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|start"
        android:layout_marginStart="64dp"
        android:layout_marginStart="56dp"
        android:layout_marginEnd="112dp"
        android:textSize="16sp"
        android:textColor="#ffffffff"
@@ -44,7 +47,7 @@
        android:layout_width="@dimen/recents_task_view_header_button_width"
        android:layout_height="@dimen/recents_task_bar_height"
        android:layout_gravity="center_vertical|end"
        android:padding="15dp"
        android:padding="13dp"
        android:background="?android:selectableItemBackground"
        android:src="@drawable/recents_info_light" />
</FrameLayout>
 No newline at end of file
Loading