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

Commit 5616feab authored by Austin Tankiang's avatar Austin Tankiang
Browse files

Rename state to menuIconState to better reflect its purpose

Bug: 385840940
Test: atest -c 'DocumentsUIGoogleTests:com.android.documentsui.JobPanelControllerTest'
Flag: com.android.documentsui.flags.visual_signals_ro
Change-Id: Ia215a5c9051ad1289386d5aa195062a0ad190d91
parent 78b00d13
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -240,12 +240,12 @@ class JobPanelController(private val activityContext: Context) : BroadcastReceiv
        }
    }

    private enum class State {
    private enum class MenuIconState {
        INVISIBLE, INDETERMINATE, VISIBLE
    }

    /** The current state of the menu progress item. */
    private var state = State.INVISIBLE
    private var menuIconState = MenuIconState.INVISIBLE

    /** The total progress from 0 to MAX_PROGRESS. */
    private var totalProgress = 0
@@ -268,20 +268,20 @@ class JobPanelController(private val activityContext: Context) : BroadcastReceiv
    }

    private fun updateMenuItem(animate: Boolean) {
        if (state == State.INVISIBLE) {
        if (menuIconState == MenuIconState.INVISIBLE) {
            popup?.dismiss()
        }

        menuItem?.let {
            Menus.setEnabledAndVisible(it, state != State.INVISIBLE)
            Menus.setEnabledAndVisible(it, menuIconState != MenuIconState.INVISIBLE)
            val icon = it.actionView as ProgressBar
            when (state) {
                State.INDETERMINATE -> icon.isIndeterminate = true
                State.VISIBLE -> icon.apply {
            when (menuIconState) {
                MenuIconState.INDETERMINATE -> icon.isIndeterminate = true
                MenuIconState.VISIBLE -> icon.apply {
                    isIndeterminate = false
                    setProgress(totalProgress, animate)
                }
                State.INVISIBLE -> {}
                MenuIconState.INVISIBLE -> {}
            }
        }
    }
@@ -360,15 +360,15 @@ class JobPanelController(private val activityContext: Context) : BroadcastReceiv
        }

        if (currentJobs.isEmpty()) {
            state = State.INVISIBLE
            menuIconState = MenuIconState.INVISIBLE
        } else if (requiredBytes != 0L) {
            state = State.VISIBLE
            menuIconState = MenuIconState.VISIBLE
            totalProgress = (MAX_PROGRESS * currentBytes / requiredBytes).toInt()
        } else if (allFinished) {
            state = State.VISIBLE
            menuIconState = MenuIconState.VISIBLE
            totalProgress = MAX_PROGRESS
        } else {
            state = State.INDETERMINATE
            menuIconState = MenuIconState.INDETERMINATE
        }
        updateMenuItem(animate = true)
        progressListAdapter?.submitList(ArrayList(currentJobs.values))