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

Commit 7a965943 authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Fix recents related bug

parent abd486af
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -54,11 +54,12 @@
            android:clearTaskOnLaunch="true"
            android:clearTaskOnLaunch="true"
            android:stateNotNeeded="true"
            android:stateNotNeeded="true"
            android:windowSoftInputMode="adjustPan"
            android:windowSoftInputMode="adjustPan"
            android:screenOrientation="unspecified"
            android:screenOrientation="portrait"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
            android:resizeableActivity="true"
            android:resizeableActivity="true"
            android:resumeWhilePausing="true"
            android:resumeWhilePausing="true"
            android:taskAffinity=""
            android:taskAffinity=""
            android:exported="true"
            android:enabled="true">
            android:enabled="true">
            <intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.MAIN" />
@@ -193,6 +194,18 @@
            android:resizeableActivity="true"
            android:resizeableActivity="true"
            android:resumeWhilePausing="true"
            android:resumeWhilePausing="true"
            android:taskAffinity="" />
            android:taskAffinity="" />

        <activity
            android:name=".proxy.ProxyActivityStarter"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
            android:launchMode="singleTask"
            android:clearTaskOnLaunch="true"
            android:exported="false" />

        <activity android:name=".quickstep.LockScreenRecentsActivity"
            android:theme="@android:style/Theme.NoDisplay"
            android:showOnLockScreen="true"
            android:directBootAware="true" />
    </application>
    </application>


</manifest>
</manifest>
 No newline at end of file
+1 −1
Original line number Original line Diff line number Diff line
@@ -906,7 +906,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
        }
        }
    }
    }


    void moveToDefaultScreen() {
   public void moveToDefaultScreen() {
        int page = DEFAULT_PAGE;
        int page = DEFAULT_PAGE;
        if (getNextPage() != page) {
        if (getNextPage() != page) {
            snapToPage(page);
            snapToPage(page);
+1 −1
Original line number Original line Diff line number Diff line
@@ -40,7 +40,7 @@ public class SystemUiController {
    public static final int FLAG_DARK_STATUS = 1 << 3;
    public static final int FLAG_DARK_STATUS = 1 << 3;


    private final Window mWindow;
    private final Window mWindow;
    private final int[] mStates = new int[2];
    private final int[] mStates = new int[3];


    public SystemUiController(Window window) {
    public SystemUiController(Window window) {
        mWindow = window;
        mWindow = window;
+199 −1
Original line number Original line Diff line number Diff line
@@ -3,7 +3,10 @@ package foundation.e.blisslauncher.features.test
import android.app.ActivityOptions
import android.app.ActivityOptions
import android.content.Context
import android.content.Context
import android.content.ContextWrapper
import android.content.ContextWrapper
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.content.res.Configuration
import android.graphics.Point
import android.os.Bundle
import android.os.Bundle
import android.os.StrictMode
import android.os.StrictMode
import android.os.StrictMode.VmPolicy
import android.os.StrictMode.VmPolicy
@@ -11,12 +14,16 @@ import android.view.LayoutInflater
import android.view.View
import android.view.View
import foundation.e.blisslauncher.BlissLauncher
import foundation.e.blisslauncher.BlissLauncher
import foundation.e.blisslauncher.R
import foundation.e.blisslauncher.R
import foundation.e.blisslauncher.core.customviews.AbstractFloatingView
import foundation.e.blisslauncher.core.customviews.LauncherPagedView
import foundation.e.blisslauncher.core.customviews.LauncherPagedView
import foundation.e.blisslauncher.core.database.model.LauncherItem
import foundation.e.blisslauncher.core.database.model.LauncherItem
import foundation.e.blisslauncher.core.utils.Constants
import foundation.e.blisslauncher.core.utils.Constants
import foundation.e.blisslauncher.features.launcher.Hotseat
import foundation.e.blisslauncher.features.launcher.Hotseat
import foundation.e.blisslauncher.features.test.LauncherState.*
import foundation.e.blisslauncher.features.test.RotationHelper.REQUEST_NONE
import foundation.e.blisslauncher.features.test.dragndrop.DragController
import foundation.e.blisslauncher.features.test.dragndrop.DragController
import foundation.e.blisslauncher.features.test.dragndrop.DragLayer
import foundation.e.blisslauncher.features.test.dragndrop.DragLayer
import foundation.e.blisslauncher.features.test.graphics.RotationMode
import foundation.e.blisslauncher.uioverrides.UiFactory
import foundation.e.blisslauncher.uioverrides.UiFactory
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.CompositeDisposable
@@ -32,12 +39,28 @@ class TestActivity : BaseDraggingActivity() {
    private lateinit var mOldConfig: Configuration
    private lateinit var mOldConfig: Configuration
    private var mCompositeDisposable: CompositeDisposable? = null
    private var mCompositeDisposable: CompositeDisposable? = null


    // Type: int
    private val RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen"

    // Type: int
    private val RUNTIME_STATE = "launcher.state"

    // Type: PendingRequestArgs
    private val RUNTIME_STATE_PENDING_REQUEST_ARGS = "launcher.request_args"

    // Type: int
    private val RUNTIME_STATE_PENDING_REQUEST_CODE = "launcher.request_code"

    // Type: ActivityResultInfo
    private val RUNTIME_STATE_PENDING_ACTIVITY_RESULT = "launcher.activity_result"

    private lateinit var launcherView: View
    private lateinit var launcherView: View
    private lateinit var dragLayer: DragLayer
    private lateinit var dragLayer: DragLayer
    private lateinit var workspace: LauncherPagedView
    private lateinit var workspace: LauncherPagedView
    private lateinit var hotseat: Hotseat
    private lateinit var hotseat: Hotseat


    private lateinit var rotationHelper: RotationHelper
    private lateinit var rotationHelper: RotationHelper
    private var mRotationMode = RotationMode.NORMAL
    private lateinit var mStateManager: LauncherStateManager
    private lateinit var mStateManager: LauncherStateManager


    // UI and state for the overview panel
    // UI and state for the overview panel
@@ -71,6 +94,8 @@ class TestActivity : BaseDraggingActivity() {
        super.onCreate(savedInstanceState)
        super.onCreate(savedInstanceState)
        TraceHelper.partitionSection("Launcher-onCreate", "super call")
        TraceHelper.partitionSection("Launcher-onCreate", "super call")


        val app = LauncherAppState.getInstance(this)
        app.launcher = this
        mOldConfig = Configuration(resources.configuration)
        mOldConfig = Configuration(resources.configuration)
        initDeviceProfile(BlissLauncher.getApplication(this).invariantDeviceProfile)
        initDeviceProfile(BlissLauncher.getApplication(this).invariantDeviceProfile)
        dragController = DragController(this)
        dragController = DragController(this)
@@ -78,12 +103,82 @@ class TestActivity : BaseDraggingActivity() {
        mStateManager = LauncherStateManager(this)
        mStateManager = LauncherStateManager(this)
        launcherView = LayoutInflater.from(this).inflate(R.layout.activity_test, null)
        launcherView = LayoutInflater.from(this).inflate(R.layout.activity_test, null)
        setupViews()
        setupViews()

        mAppTransitionManager = LauncherAppTransitionManager.newInstance(this)
        mAppTransitionManager = LauncherAppTransitionManager.newInstance(this)


        val internalStateHandled = InternalStateHandler.handleCreate(this, intent)
        if (internalStateHandled) {
            savedInstanceState?.remove(RUNTIME_STATE)
        }
        restoreState(savedInstanceState)
        mStateManager.reapplyState()

        setContentView(launcherView)
        setContentView(launcherView)
        rootView.dispatchInsets()

        systemUiController.updateUiState(
            SystemUiController.UI_STATE_BASE_WINDOW,
            false
        )
        rotationHelper.initialize()
        TraceHelper.endSection("Launcher-onCreate")
        mStateManager.addStateListener(object : LauncherStateManager.StateListener {
            override fun onStateTransitionStart(toState: LauncherState?) {}
            override fun onStateTransitionComplete(finalState: LauncherState) {
                if (finalState === NORMAL) {
                    // TODO: may use later
                } else if (finalState === OVERVIEW || finalState === OVERVIEW_PEEK) {
                    // TODO: may use later
                } else {
                    // TODO: may use later
                }
            }
        })
        createOrUpdateIconGrid()
        createOrUpdateIconGrid()
    }
    }


    /**
     * Restores the previous state, if it exists.
     *
     * @param savedState The previous state.
     */
    private fun restoreState(savedState: Bundle?) {
        if (savedState == null) {
            return
        }
        val stateOrdinal =
            savedState.getInt(RUNTIME_STATE, NORMAL.ordinal)
        val stateValues = LauncherState.values()
        val state = stateValues[stateOrdinal]
        if (!state.disableRestore) {
            mStateManager.goToState(state, false /* animated */)
        }
    }

    override fun onEnterAnimationComplete() {
        super.onEnterAnimationComplete()
        UiFactory.onEnterAnimationComplete(this)
        rotationHelper.setCurrentTransitionRequest(REQUEST_NONE)
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
        val diff = newConfig.diff(mOldConfig)

        if (diff and ActivityInfo.CONFIG_LOCALE != 0) {
            //Folder.setLocaleDependentFields(resources, true /* force */)
            // TODO: Update folder here.
        }

        if (diff and (ActivityInfo.CONFIG_ORIENTATION or ActivityInfo.CONFIG_SCREEN_SIZE) != 0) {
            //onIdpChanged(mDeviceProfile.inv)
            // TODO: update device profile here.
        }

        mOldConfig.setTo(newConfig)
        UiFactory.onLauncherStateOrResumeChanged(this)
        super.onConfigurationChanged(newConfig)
    }

    private fun setupViews() {
    private fun setupViews() {
        dragLayer = findViewById(R.id.drag_layer)
        dragLayer = findViewById(R.id.drag_layer)
        workspace = dragLayer.findViewById(R.id.workspace)
        workspace = dragLayer.findViewById(R.id.workspace)
@@ -99,6 +194,11 @@ class TestActivity : BaseDraggingActivity() {
        workspace.bindAndInitFirstScreen(null)
        workspace.bindAndInitFirstScreen(null)
        dragController.addDragListener(workspace)
        dragController.addDragListener(workspace)
        dragController.addDropTarget(workspace)
        dragController.addDropTarget(workspace)

        // Setup the drag controller (drop targets have to be added in reverse order in priority)

        // Setup the drag controller (drop targets have to be added in reverse order in priority)
        dragController.setMoveTarget(workspace)
    }
    }


    override fun <T : View> findViewById(id: Int): T {
    override fun <T : View> findViewById(id: Int): T {
@@ -110,9 +210,22 @@ class TestActivity : BaseDraggingActivity() {
    private fun initDeviceProfile(idp: InvariantDeviceProfile) {
    private fun initDeviceProfile(idp: InvariantDeviceProfile) {
        // Load device specific profile
        // Load device specific profile
        mDeviceProfile = idp.getDeviceProfile(this)
        mDeviceProfile = idp.getDeviceProfile(this)
        if (isInMultiWindowMode) {
            val display = windowManager.defaultDisplay
            val mwSize = Point()
            display.getSize(mwSize)
            mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize)
        }
        mRotationMode = RotationMode.NORMAL
        onDeviceProfileInitiated()
        onDeviceProfileInitiated()
    }
    }


    override fun onPause() {
        super.onPause()
        dragController.cancelDrag()
        dragController.resetLastGestureUpTime()
    }

    override fun onResume() {
    override fun onResume() {
        super.onResume()
        super.onResume()
        if (mOnResumeCallbacks.isNotEmpty()) {
        if (mOnResumeCallbacks.isNotEmpty()) {
@@ -131,6 +244,22 @@ class TestActivity : BaseDraggingActivity() {
            mCancelTouchController!!.run()
            mCancelTouchController!!.run()
            mCancelTouchController = null
            mCancelTouchController = null
        }
        }

        rotationHelper.destroy()
    }

    override fun onUserLeaveHint() {
        super.onUserLeaveHint()
        UiFactory.onLauncherStateOrResumeChanged(this)
    }

    override fun onWindowFocusChanged(hasFocus: Boolean) {
        super.onWindowFocusChanged(hasFocus)
        mStateManager.onWindowFocusChanged()
    }

    fun getRotationMode(): RotationMode {
        return mRotationMode
    }
    }


    fun getHotseat() = hotseat
    fun getHotseat() = hotseat
@@ -139,7 +268,7 @@ class TestActivity : BaseDraggingActivity() {


    override fun getDragLayer(): DragLayer = dragLayer
    override fun getDragLayer(): DragLayer = dragLayer


    override fun <T : View?> getOverviewPanel(): T = overviewPanel as T
    override fun <T : View> getOverviewPanel(): T = overviewPanel as T


    override fun getRootView(): LauncherRootView = launcherView as LauncherRootView
    override fun getRootView(): LauncherRootView = launcherView as LauncherRootView


@@ -154,6 +283,8 @@ class TestActivity : BaseDraggingActivity() {
    fun getAppTransitionManager() = mAppTransitionManager
    fun getAppTransitionManager() = mAppTransitionManager


    override fun reapplyUi() {
    override fun reapplyUi() {
        rootView.dispatchInsets()
        getStateManager().reapplyState(true /* cancelCurrentAnimation */)
    }
    }


    fun isWorkspaceLocked() = false
    fun isWorkspaceLocked() = false
@@ -228,6 +359,73 @@ class TestActivity : BaseDraggingActivity() {
        mOnResumeCallbacks.add(callback)
        mOnResumeCallbacks.add(callback)
    }
    }


    override fun onNewIntent(intent: Intent?) {
        TraceHelper.beginSection("NEW_INTENT")
        super.onNewIntent(intent)
        val alreadyOnHome = hasWindowFocus() && (intent!!.flags and
            Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
            != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)

        // Check this condition before handling isActionMain, as this will get reset.
        val shouldMoveToDefaultScreen = (alreadyOnHome && isInState(NORMAL)
            && AbstractFloatingView.getTopOpenView(this) == null)
        val isActionMain = Intent.ACTION_MAIN == intent!!.action
        val internalStateHandled = InternalStateHandler
            .handleNewIntent(this, intent, isStarted)

        if (isActionMain) {
            if (!internalStateHandled) {
                // In all these cases, only animate if we're already on home
                AbstractFloatingView.closeAllOpenViews(this, isStarted)
                if (!isInState(NORMAL)) {
                    // Only change state, if not already the same. This prevents cancelling any
                    // animations running as part of resume
                    mStateManager.goToState(NORMAL)
                }

                // Reset the apps view
                if (!alreadyOnHome) {
                    // TODO: maybe stop icon giggling or search view here.
                }
                if (shouldMoveToDefaultScreen && !workspace.isHandlingTouch) {
                    workspace.post(workspace::moveToDefaultScreen)
                }
            }

            val v = window.peekDecorView()
            if (v != null && v.windowToken != null) {
                UiThreadHelper.hideKeyboardAsync(this, v.windowToken)
            }
        }

        TraceHelper.endSection("NEW_INTENT")
    }

    override fun onBackPressed() {
        if (finishAutoCancelActionMode()) {
            return
        }

        if (dragController.isDragging()) {
            dragController.cancelDrag()
            return
        }

        // Note: There should be at most one log per method call. This is enforced implicitly
        // by using if-else statements.
        val topView = AbstractFloatingView.getTopOpenView(this)
        if (topView != null && topView.onBackPressed()) {
            // Handled by the floating view.
        } else {
            mStateManager.state.onBackPressed(this)
        }
    }

    override fun onTrimMemory(level: Int) {
        super.onTrimMemory(level)
        UiFactory.onTrimMemory(this, level)
    }

    companion object {
    companion object {
        const val TAG = "Launcher"
        const val TAG = "Launcher"
        const val LOGD = false
        const val LOGD = false
+8 −6
Original line number Original line Diff line number Diff line
@@ -350,13 +350,15 @@ class VariantDeviceProfile(
        )
        )
    }
    }


    fun updateInsets(windowInsets: WindowInsets) {
    fun updateInsets(windowInsets: WindowInsets?) {
        windowInsets?.let {
            insets.set(
            insets.set(
                Rect(
                Rect(
                windowInsets.systemWindowInsetLeft, windowInsets.systemWindowInsetTop,
                    it.systemWindowInsetLeft, it.systemWindowInsetTop,
                windowInsets.systemWindowInsetRight, windowInsets.systemWindowInsetBottom
                    it.systemWindowInsetRight, it.systemWindowInsetBottom
                )
                )
            )
            )
        }
        updateWorkspacePadding()
        updateWorkspacePadding()
    }
    }


Loading