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

Commit 931c51f5 authored by Winson Chung's avatar Winson Chung
Browse files

Refactoring lock-to-task state out of Task

- Moving the logic out of Task to the stack view which is more logical
  and easier to manage
- This also includes a fix for the issue of the screen pinning not 
  showing up immediately after toggling it in Settings

Change-Id: I0357d59fc30b0327bbe6eeca10b310911aba3cc4
parent 24145bf1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -34,9 +34,10 @@
            android:layout_gravity="bottom|right"
            android:layout_marginRight="15dp"
            android:layout_marginBottom="15dp"
            android:translationZ="2dp"
            android:translationZ="4dp"
            android:contentDescription="@string/recents_lock_to_app_button_label"
            android:background="@drawable/recents_lock_to_task_button_bg">
            android:background="@drawable/recents_lock_to_task_button_bg"
            android:visibility="invisible">
            <ImageView
                android:layout_width="@dimen/recents_lock_to_app_icon_size"
                android:layout_height="@dimen/recents_lock_to_app_icon_size"
+1 −9
Original line number Diff line number Diff line
@@ -74,9 +74,6 @@ public class RecentsConfiguration {
    public int svelteLevel;
    public int searchBarSpaceHeightPx;

    /** Dev options and global settings */
    public boolean lockToAppEnabled;

    public RecentsConfiguration(Context context) {
        // Load only resources that can not change after the first load either through developer
        // settings or via multi window
@@ -106,12 +103,7 @@ public class RecentsConfiguration {
    /**
     * Updates the configuration based on the current state of the system
     */
    void update(Context context, SystemServicesProxy ssp, Rect windowRect) {
        // Only update resources that can change after the first load, either through developer
        // settings or via multi window
        lockToAppEnabled = !ssp.hasFreeformWorkspaceSupport() &&
                ssp.getSystemSetting(context, Settings.System.LOCK_TO_APP_ENABLED) != 0;

    void update(Rect windowRect) {
        // Recompute some values based on the given state, since we can not rely on the resource
        // system to get certain values.
        boolean isLandscape = windowRect.width() > windowRect.height();
+1 −1
Original line number Diff line number Diff line
@@ -572,7 +572,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        Rect windowRect = ssp.getWindowRect();

        // Update the configuration for the current state
        config.update(mContext, ssp, ssp.getWindowRect());
        config.update(windowRect);

        if (!RecentsDebugFlags.Static.DisableSearchBar && tryAndBindSearchWidget) {
            // Try and pre-emptively bind the search widget on startup to ensure that we
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ public class RecentsTaskLoadPlan {
            // Add the task to the stack
            Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon,
                    thumbnail, title, contentDescription, activityColor, !isStackTask,
                    (i == (taskCount - 1)), config.lockToAppEnabled, t.bounds, t.taskDescription);
                    t.bounds, t.taskDescription);

            allTasks.add(task);
        }
+2 −8
Original line number Diff line number Diff line
@@ -131,8 +131,6 @@ public class Task {
     */
    public boolean isLaunchTarget;
    public boolean isHistorical;
    public boolean lockToThisTask;
    public boolean lockToTaskEnabled;

    private ArrayList<TaskCallbacks> mCallbacks = new ArrayList<>();

@@ -142,8 +140,8 @@ public class Task {

    public Task(TaskKey key, int affiliationTaskId, int affiliationColor, Drawable icon,
                Bitmap thumbnail, String title, String contentDescription, int colorPrimary,
                boolean isHistorical, boolean lockToThisTask, boolean lockToTaskEnabled,
                Rect bounds, ActivityManager.TaskDescription taskDescription) {
                boolean isHistorical, Rect bounds,
                ActivityManager.TaskDescription taskDescription) {
        boolean isInAffiliationGroup = (affiliationTaskId != key.id);
        boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0);
        this.key = key;
@@ -159,8 +157,6 @@ public class Task {
        this.bounds = bounds;
        this.taskDescription = taskDescription;
        this.isHistorical = isHistorical;
        this.lockToThisTask = lockToTaskEnabled && lockToThisTask;
        this.lockToTaskEnabled = lockToTaskEnabled;
    }

    /** Copies the other task. */
@@ -178,8 +174,6 @@ public class Task {
        this.bounds = o.bounds;
        this.isLaunchTarget = o.isLaunchTarget;
        this.isHistorical = o.isHistorical;
        this.lockToThisTask = o.lockToThisTask;
        this.lockToTaskEnabled = o.lockToTaskEnabled;
    }

    /**
Loading