Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ScreenshotShelfViewBinder.kt +5 −3 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ object ScreenshotShelfViewBinder { } launch { viewModel.actions.collect { actions -> if (actions.isNotEmpty()) { val visibleActions = actions.filter { it.visible } if (visibleActions.isNotEmpty()) { view .requireViewById<View>(R.id.actions_container_background) .visibility = View.VISIBLE Loading @@ -75,7 +77,7 @@ object ScreenshotShelfViewBinder { // any new actions and update any that are already there. // This assumes that actions can never change order and that each action // ID is unique. val newIds = actions.map { it.id } val newIds = visibleActions.map { it.id } for (view in actionsContainer.children.toList()) { if (view.tag !in newIds) { Loading @@ -83,7 +85,7 @@ object ScreenshotShelfViewBinder { } } for ((index, action) in actions.withIndex()) { for ((index, action) in visibleActions.withIndex()) { val currentView: View? = actionsContainer.getChildAt(index) if (action.id == currentView?.tag) { // Same ID, update the display Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/viewmodel/ActionButtonViewModel.kt +2 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.screenshot.ui.viewmodel data class ActionButtonViewModel( val appearance: ActionButtonAppearance, val id: Int, val visible: Boolean, val onClicked: (() -> Unit)?, ) { companion object { Loading @@ -29,6 +30,6 @@ data class ActionButtonViewModel( fun withNextId( appearance: ActionButtonAppearance, onClicked: (() -> Unit)? ): ActionButtonViewModel = ActionButtonViewModel(appearance, getId(), onClicked) ): ActionButtonViewModel = ActionButtonViewModel(appearance, getId(), true, onClicked) } } packages/SystemUI/src/com/android/systemui/screenshot/ui/viewmodel/ScreenshotViewModel.kt +23 −1 Original line number Diff line number Diff line Loading @@ -48,12 +48,34 @@ class ScreenshotViewModel(private val accessibilityManager: AccessibilityManager return action.id } fun setActionVisibility(actionId: Int, visible: Boolean) { val actionList = _actions.value.toMutableList() val index = actionList.indexOfFirst { it.id == actionId } if (index >= 0) { actionList[index] = ActionButtonViewModel( actionList[index].appearance, actionId, visible, actionList[index].onClicked ) _actions.value = actionList } else { Log.w(TAG, "Attempted to update unknown action id $actionId") } } fun updateActionAppearance(actionId: Int, appearance: ActionButtonAppearance) { val actionList = _actions.value.toMutableList() val index = actionList.indexOfFirst { it.id == actionId } if (index >= 0) { actionList[index] = ActionButtonViewModel(appearance, actionId, actionList[index].onClicked) ActionButtonViewModel( appearance, actionId, actionList[index].visible, actionList[index].onClicked ) _actions.value = actionList } else { Log.w(TAG, "Attempted to update unknown action id $actionId") Loading Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ScreenshotShelfViewBinder.kt +5 −3 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ object ScreenshotShelfViewBinder { } launch { viewModel.actions.collect { actions -> if (actions.isNotEmpty()) { val visibleActions = actions.filter { it.visible } if (visibleActions.isNotEmpty()) { view .requireViewById<View>(R.id.actions_container_background) .visibility = View.VISIBLE Loading @@ -75,7 +77,7 @@ object ScreenshotShelfViewBinder { // any new actions and update any that are already there. // This assumes that actions can never change order and that each action // ID is unique. val newIds = actions.map { it.id } val newIds = visibleActions.map { it.id } for (view in actionsContainer.children.toList()) { if (view.tag !in newIds) { Loading @@ -83,7 +85,7 @@ object ScreenshotShelfViewBinder { } } for ((index, action) in actions.withIndex()) { for ((index, action) in visibleActions.withIndex()) { val currentView: View? = actionsContainer.getChildAt(index) if (action.id == currentView?.tag) { // Same ID, update the display Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/viewmodel/ActionButtonViewModel.kt +2 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.screenshot.ui.viewmodel data class ActionButtonViewModel( val appearance: ActionButtonAppearance, val id: Int, val visible: Boolean, val onClicked: (() -> Unit)?, ) { companion object { Loading @@ -29,6 +30,6 @@ data class ActionButtonViewModel( fun withNextId( appearance: ActionButtonAppearance, onClicked: (() -> Unit)? ): ActionButtonViewModel = ActionButtonViewModel(appearance, getId(), onClicked) ): ActionButtonViewModel = ActionButtonViewModel(appearance, getId(), true, onClicked) } }
packages/SystemUI/src/com/android/systemui/screenshot/ui/viewmodel/ScreenshotViewModel.kt +23 −1 Original line number Diff line number Diff line Loading @@ -48,12 +48,34 @@ class ScreenshotViewModel(private val accessibilityManager: AccessibilityManager return action.id } fun setActionVisibility(actionId: Int, visible: Boolean) { val actionList = _actions.value.toMutableList() val index = actionList.indexOfFirst { it.id == actionId } if (index >= 0) { actionList[index] = ActionButtonViewModel( actionList[index].appearance, actionId, visible, actionList[index].onClicked ) _actions.value = actionList } else { Log.w(TAG, "Attempted to update unknown action id $actionId") } } fun updateActionAppearance(actionId: Int, appearance: ActionButtonAppearance) { val actionList = _actions.value.toMutableList() val index = actionList.indexOfFirst { it.id == actionId } if (index >= 0) { actionList[index] = ActionButtonViewModel(appearance, actionId, actionList[index].onClicked) ActionButtonViewModel( appearance, actionId, actionList[index].visible, actionList[index].onClicked ) _actions.value = actionList } else { Log.w(TAG, "Attempted to update unknown action id $actionId") Loading