1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.core.view;
18 
19 import org.jspecify.annotations.NonNull;
20 import org.jspecify.annotations.Nullable;
21 
22 /**
23  * Interface for widgets to implement default behavior for receiving content. Content may be both
24  * text and non-text (plain/styled text, HTML, images, videos, audio files, etc).
25  *
26  * <p>Widgets should implement this interface to define the default behavior for receiving content
27  * when the SDK is <= 30. When doing so, widgets should also override
28  * {@link android.view.View#onReceiveContent} for SDK > 30.
29  *
30  * <p>Apps wishing to provide custom behavior for receiving content should not implement this
31  * interface but rather set a listener via {@link ViewCompat#setOnReceiveContentListener}. See
32  * {@link ViewCompat#performReceiveContent} for more info.
33  */
34 public interface OnReceiveContentViewBehavior {
35     /**
36      * Implements a view's default behavior for receiving content.
37      *
38      * @param payload The content to insert and related metadata.
39      *
40      * @return The portion of the passed-in content that was not handled (may be all, some, or none
41      * of the passed-in content).
42      */
onReceiveContent(@onNull ContentInfoCompat payload)43     @Nullable ContentInfoCompat onReceiveContent(@NonNull ContentInfoCompat payload);
44 }
45