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

Commit e5f08973 authored by Matt Casey's avatar Matt Casey Committed by Automerger Merge Worker
Browse files

Merge "Convert view binders to classes" into 24D1-dev am: 55b959f6

parents 9991e582 55b959f6
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -66,11 +66,11 @@ import com.android.systemui.screenshot.ui.binder.ActionButtonViewBinder;
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonAppearance;
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonAppearance;
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonViewModel;
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonViewModel;


import java.util.ArrayList;

import kotlin.Unit;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function0;


import java.util.ArrayList;

/**
/**
 * Handles the visual elements and animations for the clipboard overlay.
 * Handles the visual elements and animations for the clipboard overlay.
 */
 */
@@ -109,6 +109,7 @@ public class ClipboardOverlayView extends DraggableConstraintLayout {
    private View mDismissButton;
    private View mDismissButton;
    private LinearLayout mActionContainer;
    private LinearLayout mActionContainer;
    private ClipboardOverlayCallbacks mClipboardCallbacks;
    private ClipboardOverlayCallbacks mClipboardCallbacks;
    private ActionButtonViewBinder mActionButtonViewBinder = new ActionButtonViewBinder();


    public ClipboardOverlayView(Context context) {
    public ClipboardOverlayView(Context context) {
        this(context, null);
        this(context, null);
@@ -152,7 +153,7 @@ public class ClipboardOverlayView extends DraggableConstraintLayout {


    private void bindDefaultActionChips() {
    private void bindDefaultActionChips() {
        if (screenshotShelfUi2()) {
        if (screenshotShelfUi2()) {
            ActionButtonViewBinder.INSTANCE.bind(mRemoteCopyChip,
            mActionButtonViewBinder.bind(mRemoteCopyChip,
                    ActionButtonViewModel.Companion.withNextId(
                    ActionButtonViewModel.Companion.withNextId(
                            new ActionButtonAppearance(
                            new ActionButtonAppearance(
                                    Icon.createWithResource(mContext,
                                    Icon.createWithResource(mContext,
@@ -169,7 +170,7 @@ public class ClipboardOverlayView extends DraggableConstraintLayout {
                                    return null;
                                    return null;
                                }
                                }
                            }));
                            }));
            ActionButtonViewBinder.INSTANCE.bind(mShareChip,
            mActionButtonViewBinder.bind(mShareChip,
                    ActionButtonViewModel.Companion.withNextId(
                    ActionButtonViewModel.Companion.withNextId(
                            new ActionButtonAppearance(
                            new ActionButtonAppearance(
                                    Icon.createWithResource(mContext,
                                    Icon.createWithResource(mContext,
@@ -512,7 +513,7 @@ public class ClipboardOverlayView extends DraggableConstraintLayout {
    private View constructShelfActionChip(RemoteAction action, Runnable onFinish) {
    private View constructShelfActionChip(RemoteAction action, Runnable onFinish) {
        View chip = LayoutInflater.from(mContext).inflate(
        View chip = LayoutInflater.from(mContext).inflate(
                R.layout.shelf_action_chip, mActionContainer, false);
                R.layout.shelf_action_chip, mActionContainer, false);
        ActionButtonViewBinder.INSTANCE.bind(chip, ActionButtonViewModel.Companion.withNextId(
        mActionButtonViewBinder.bind(chip, ActionButtonViewModel.Companion.withNextId(
                new ActionButtonAppearance(action.getIcon().loadDrawable(mContext),
                new ActionButtonAppearance(action.getIcon().loadDrawable(mContext),
                        action.getTitle(), action.getTitle()), new Function0<>() {
                        action.getTitle(), action.getTitle()), new Function0<>() {
                    @Override
                    @Override
+2 −1
Original line number Original line Diff line number Diff line
@@ -59,6 +59,7 @@ constructor(
    private val logger: UiEventLogger,
    private val logger: UiEventLogger,
    private val viewModel: ScreenshotViewModel,
    private val viewModel: ScreenshotViewModel,
    private val windowManager: WindowManager,
    private val windowManager: WindowManager,
    shelfViewBinder: ScreenshotShelfViewBinder,
    private val thumbnailObserver: ThumbnailObserver,
    private val thumbnailObserver: ThumbnailObserver,
    @Assisted private val context: Context,
    @Assisted private val context: Context,
    @Assisted private val displayId: Int
    @Assisted private val displayId: Int
@@ -92,7 +93,7 @@ constructor(
    private val animationController = ScreenshotAnimationController(view)
    private val animationController = ScreenshotAnimationController(view)


    init {
    init {
        ScreenshotShelfViewBinder.bind(
        shelfViewBinder.bind(
            view,
            view,
            viewModel,
            viewModel,
            LayoutInflater.from(context),
            LayoutInflater.from(context),
+2 −1
Original line number Original line Diff line number Diff line
@@ -23,8 +23,9 @@ import android.widget.TextView
import com.android.systemui.res.R
import com.android.systemui.res.R
import com.android.systemui.screenshot.ui.TransitioningIconDrawable
import com.android.systemui.screenshot.ui.TransitioningIconDrawable
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonViewModel
import com.android.systemui.screenshot.ui.viewmodel.ActionButtonViewModel
import javax.inject.Inject


object ActionButtonViewBinder {
class ActionButtonViewBinder @Inject constructor() {
    /** Binds the given view to the given view-model */
    /** Binds the given view to the given view-model */
    fun bind(view: View, viewModel: ActionButtonViewModel) {
    fun bind(view: View, viewModel: ActionButtonViewModel) {
        val iconView = view.requireViewById<ImageView>(R.id.overlay_action_chip_icon)
        val iconView = view.requireViewById<ImageView>(R.id.overlay_action_chip_icon)
+6 −3
Original line number Original line Diff line number Diff line
@@ -35,10 +35,13 @@ import com.android.systemui.screenshot.ui.viewmodel.ActionButtonViewModel
import com.android.systemui.screenshot.ui.viewmodel.AnimationState
import com.android.systemui.screenshot.ui.viewmodel.AnimationState
import com.android.systemui.screenshot.ui.viewmodel.ScreenshotViewModel
import com.android.systemui.screenshot.ui.viewmodel.ScreenshotViewModel
import com.android.systemui.util.children
import com.android.systemui.util.children
import javax.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.launch


object ScreenshotShelfViewBinder {
class ScreenshotShelfViewBinder
@Inject
constructor(private val buttonViewBinder: ActionButtonViewBinder) {
    fun bind(
    fun bind(
        view: ScreenshotShelfView,
        view: ScreenshotShelfView,
        viewModel: ScreenshotViewModel,
        viewModel: ScreenshotViewModel,
@@ -158,14 +161,14 @@ object ScreenshotShelfViewBinder {
            val currentView: View? = actionsContainer.getChildAt(index)
            val currentView: View? = actionsContainer.getChildAt(index)
            if (action.id == currentView?.tag) {
            if (action.id == currentView?.tag) {
                // Same ID, update the display
                // Same ID, update the display
                ActionButtonViewBinder.bind(currentView, action)
                buttonViewBinder.bind(currentView, action)
            } else {
            } else {
                // Different ID. Removals have already happened so this must
                // Different ID. Removals have already happened so this must
                // mean that the new action must be inserted here.
                // mean that the new action must be inserted here.
                val actionButton =
                val actionButton =
                    layoutInflater.inflate(R.layout.shelf_action_chip, actionsContainer, false)
                    layoutInflater.inflate(R.layout.shelf_action_chip, actionsContainer, false)
                actionsContainer.addView(actionButton, index)
                actionsContainer.addView(actionButton, index)
                ActionButtonViewBinder.bind(actionButton, action)
                buttonViewBinder.bind(actionButton, action)
            }
            }
        }
        }
    }
    }