Loading packages/SystemUI/res/layout/screenshot_shelf.xml +1 −9 Original line number Diff line number Diff line Loading @@ -51,15 +51,7 @@ <LinearLayout android:id="@+id/screenshot_actions" android:layout_width="wrap_content" android:layout_height="wrap_content"> <include layout="@layout/overlay_action_chip" android:id="@+id/screenshot_share_chip"/> <include layout="@layout/overlay_action_chip" android:id="@+id/screenshot_edit_chip"/> <include layout="@layout/overlay_action_chip" android:id="@+id/screenshot_scroll_chip" android:visibility="gone" /> </LinearLayout> android:layout_height="wrap_content" /> </HorizontalScrollView> <View android:id="@+id/screenshot_preview_border" Loading packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionsProvider.kt +2 −2 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ constructor( ActionButtonViewModel( quickShare.getIcon().loadDrawable(context), quickShare.title, quickShare.title quickShare.title, ) { debugLog(LogConfig.DEBUG_ACTIONS) { "Quickshare tapped" } onDeferrableActionTapped { result -> Loading Loading @@ -180,7 +180,7 @@ constructor( ActionButtonViewModel( it.getIcon().loadDrawable(context), it.title, it.title it.title, ) { sendPendingIntent(it.actionIntent) } Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ActionButtonViewBinder.kt +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ object ActionButtonViewBinder { } else { view.setOnClickListener(null) } view.tag = viewModel.id view.contentDescription = viewModel.description view.visibility = View.VISIBLE view.alpha = 1f Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ScreenshotShelfViewBinder.kt +24 −10 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.screenshot.ui.binder import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup Loading Loading @@ -71,22 +70,37 @@ object ScreenshotShelfViewBinder { .requireViewById<View>(R.id.actions_container_background) .visibility = View.VISIBLE } val viewPool = actionsContainer.children.toList() actionsContainer.removeAllViews() val actionButtons = List(actions.size) { viewPool.getOrElse(it) { // Remove any buttons not in the new list, then do another pass to add // 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 } for (view in actionsContainer.children.toList()) { if (view.tag !in newIds) { actionsContainer.removeView(view) } } for ((index, action) in actions.withIndex()) { val currentView: View? = actionsContainer.getChildAt(index) if (action.id == currentView?.tag) { // Same ID, update the display ActionButtonViewBinder.bind(currentView, action) } else { // Different ID. Removals have already happened so this must // mean that the new action must be inserted here. val actionButton = layoutInflater.inflate( R.layout.overlay_action_chip, actionsContainer, false ) actionsContainer.addView(actionButton, index) ActionButtonViewBinder.bind(actionButton, action) } } actionButtons.zip(actions).forEach { actionsContainer.addView(it.first) ActionButtonViewBinder.bind(it.first, it.second) } } } } Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/viewmodel/ActionButtonViewModel.kt +10 −2 Original line number Diff line number Diff line Loading @@ -22,5 +22,13 @@ data class ActionButtonViewModel( val icon: Drawable?, val name: CharSequence?, val description: CharSequence, val onClicked: (() -> Unit)? ) val onClicked: (() -> Unit)?, ) { val id: Int = getId() companion object { private var nextId = 0 private fun getId() = nextId.also { nextId += 1 } } } Loading
packages/SystemUI/res/layout/screenshot_shelf.xml +1 −9 Original line number Diff line number Diff line Loading @@ -51,15 +51,7 @@ <LinearLayout android:id="@+id/screenshot_actions" android:layout_width="wrap_content" android:layout_height="wrap_content"> <include layout="@layout/overlay_action_chip" android:id="@+id/screenshot_share_chip"/> <include layout="@layout/overlay_action_chip" android:id="@+id/screenshot_edit_chip"/> <include layout="@layout/overlay_action_chip" android:id="@+id/screenshot_scroll_chip" android:visibility="gone" /> </LinearLayout> android:layout_height="wrap_content" /> </HorizontalScrollView> <View android:id="@+id/screenshot_preview_border" Loading
packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionsProvider.kt +2 −2 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ constructor( ActionButtonViewModel( quickShare.getIcon().loadDrawable(context), quickShare.title, quickShare.title quickShare.title, ) { debugLog(LogConfig.DEBUG_ACTIONS) { "Quickshare tapped" } onDeferrableActionTapped { result -> Loading Loading @@ -180,7 +180,7 @@ constructor( ActionButtonViewModel( it.getIcon().loadDrawable(context), it.title, it.title it.title, ) { sendPendingIntent(it.actionIntent) } Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ActionButtonViewBinder.kt +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ object ActionButtonViewBinder { } else { view.setOnClickListener(null) } view.tag = viewModel.id view.contentDescription = viewModel.description view.visibility = View.VISIBLE view.alpha = 1f Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ScreenshotShelfViewBinder.kt +24 −10 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.screenshot.ui.binder import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup Loading Loading @@ -71,22 +70,37 @@ object ScreenshotShelfViewBinder { .requireViewById<View>(R.id.actions_container_background) .visibility = View.VISIBLE } val viewPool = actionsContainer.children.toList() actionsContainer.removeAllViews() val actionButtons = List(actions.size) { viewPool.getOrElse(it) { // Remove any buttons not in the new list, then do another pass to add // 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 } for (view in actionsContainer.children.toList()) { if (view.tag !in newIds) { actionsContainer.removeView(view) } } for ((index, action) in actions.withIndex()) { val currentView: View? = actionsContainer.getChildAt(index) if (action.id == currentView?.tag) { // Same ID, update the display ActionButtonViewBinder.bind(currentView, action) } else { // Different ID. Removals have already happened so this must // mean that the new action must be inserted here. val actionButton = layoutInflater.inflate( R.layout.overlay_action_chip, actionsContainer, false ) actionsContainer.addView(actionButton, index) ActionButtonViewBinder.bind(actionButton, action) } } actionButtons.zip(actions).forEach { actionsContainer.addView(it.first) ActionButtonViewBinder.bind(it.first, it.second) } } } } Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/viewmodel/ActionButtonViewModel.kt +10 −2 Original line number Diff line number Diff line Loading @@ -22,5 +22,13 @@ data class ActionButtonViewModel( val icon: Drawable?, val name: CharSequence?, val description: CharSequence, val onClicked: (() -> Unit)? ) val onClicked: (() -> Unit)?, ) { val id: Int = getId() companion object { private var nextId = 0 private fun getId() = nextId.also { nextId += 1 } } }