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

Commit 9e8cbcc6 authored by yuanjiahsu's avatar yuanjiahsu Committed by Yuanjia Hsu
Browse files

Add clipboard indication text view

Fork system toast layout to show indication under clipboard overlay and
allow override to provide different indication text.

Bug: 361199935
Flag: com.android.systemui.show_clipboard_indication
Test: atest ClipboardOverlayControllerTest
Change-Id: I6e38d386e94fdbcbaf4101676aec6abdead2c3bb
parent 4b4e3d50
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1558,6 +1558,13 @@ flag {
   bug: "358473717"
}

flag {
   name: "show_clipboard_indication"
   namespace: "systemui"
   description: "Show indication text under the clipboard overlay when copied something"
   bug: "361199935"
}

flag {
   name: "media_projection_dialog_behind_lockscreen"
   namespace: "systemui"
+30 −2
Original line number Diff line number Diff line
@@ -32,6 +32,34 @@
        android:id="@+id/min_edge_guideline"
        app:layout_constraintGuide_begin="@dimen/overlay_action_container_minimum_edge_spacing"
        android:orientation="vertical"/>
    <!-- This toast-like indication layout was forked from text_toast.xml and will have the same
         appearance as system toast. -->
    <FrameLayout
        android:id="@+id/indication_container"
        android:visibility="gone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:maxWidth="@*android:dimen/toast_width"
        android:background="@android:drawable/toast_frame"
        android:elevation="@*android:dimen/toast_elevation"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
        android:layout_marginEnd="@dimen/overlay_action_container_margin_horizontal"
        android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
        android:layout_marginBottom="@dimen/overlay_action_container_margin_bottom"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">
        <TextView
            android:id="@+id/indication_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:maxLines="2"
            android:paddingTop="12dp"
            android:paddingBottom="12dp"
            android:textAppearance="@*android:style/TextAppearance.Toast"/>
    </FrameLayout>
    <!-- Negative horizontal margin because this container background must render beyond the thing
         it's constrained by (the actions themselves). -->
    <FrameLayout
@@ -47,7 +75,7 @@
        app:layout_constraintStart_toStartOf="@id/min_edge_guideline"
        app:layout_constraintTop_toTopOf="@id/actions_container"
        app:layout_constraintEnd_toEndOf="@id/actions_container"
        app:layout_constraintBottom_toBottomOf="parent"/>
        app:layout_constraintBottom_toTopOf="@id/indication_container"/>
    <HorizontalScrollView
        android:id="@+id/actions_container"
        android:layout_width="0dp"
@@ -144,7 +172,7 @@
        android:visibility="gone"
        android:elevation="7dp"
        android:padding="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintBottom_toTopOf="@id/indication_container"
        app:layout_constraintStart_toStartOf="parent"
        android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
        android:layout_marginBottom="@dimen/overlay_action_container_margin_bottom"
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.clipboardoverlay

/** Interface for listening to indication text changed from [ClipboardIndicationProvider]. */
interface ClipboardIndicationCallback {

    /** Notifies the indication text changed. */
    fun onIndicationTextChanged(text: CharSequence)
}
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.clipboardoverlay

/** Interface to provide the clipboard indication to be shown under the overlay. */
interface ClipboardIndicationProvider {

    /**
     * Gets the indication text async.
     *
     * @param callback callback for getting the indication text.
     */
    fun getIndicationText(callback: ClipboardIndicationCallback)
}
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.clipboardoverlay

import com.android.systemui.dagger.SysUISingleton
import javax.inject.Inject

@SysUISingleton
open class ClipboardIndicationProviderImpl @Inject constructor() : ClipboardIndicationProvider {

    override fun getIndicationText(callback: ClipboardIndicationCallback) {}
}
Loading