1 /*
2  * Copyright (C) 2014 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.appcompat.app;
18 
19 import androidx.appcompat.view.ActionMode;
20 
21 import org.jspecify.annotations.Nullable;
22 
23 /**
24  * Implemented this in order for AppCompat to be able to callback in certain situations.
25  * <p>
26  * This should be provided to
27  * {@link AppCompatDelegate#create(android.app.Activity, AppCompatCallback)}.
28  */
29 public interface AppCompatCallback {
30 
31     /**
32      * Called when a support action mode has been started.
33      *
34      * @param mode The new action mode.
35      */
onSupportActionModeStarted(ActionMode mode)36     void onSupportActionModeStarted(ActionMode mode);
37 
38     /**
39      * Called when a support action mode has finished.
40      *
41      * @param mode The action mode that just finished.
42      */
onSupportActionModeFinished(ActionMode mode)43     void onSupportActionModeFinished(ActionMode mode);
44 
45     /**
46      * Called when a support action mode is being started for this window. Gives the
47      * callback an opportunity to handle the action mode in its own unique and
48      * beautiful way. If this method returns null the system can choose a way
49      * to present the mode or choose not to start the mode at all.
50      *
51      * @param callback Callback to control the lifecycle of this action mode
52      * @return The ActionMode that was started, or null if the system should present it
53      */
onWindowStartingSupportActionMode(ActionMode.Callback callback)54     @Nullable ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback);
55 }
56