1 /*
2  * Copyright (C) 2021 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 com.android.systemui.shared.rotation;
18 
19 import android.graphics.drawable.Drawable;
20 import android.view.View;
21 
22 /**
23  * Interface of a rotation button that interacts {@link RotationButtonController}.
24  * This interface exists because of the two different styles of rotation button in Sysui,
25  * one in contextual for 3 button nav and a floating rotation button for gestural.
26  */
27 public interface RotationButton {
setRotationButtonController(RotationButtonController rotationButtonController)28     default void setRotationButtonController(RotationButtonController rotationButtonController) { }
setUpdatesCallback(RotationButtonUpdatesCallback updatesCallback)29     default void setUpdatesCallback(RotationButtonUpdatesCallback updatesCallback) { }
30 
getCurrentView()31     default View getCurrentView() {
32         return null;
33     }
show()34     default boolean show() { return false; }
hide()35     default boolean hide() { return false; }
isVisible()36     default boolean isVisible() {
37         return false;
38     }
setCanShowRotationButton(boolean canShow)39     default void setCanShowRotationButton(boolean canShow) {}
onTaskbarStateChanged(boolean taskbarVisible, boolean taskbarStashed)40     default void onTaskbarStateChanged(boolean taskbarVisible, boolean taskbarStashed) {}
updateIcon(int lightIconColor, int darkIconColor)41     default void updateIcon(int lightIconColor, int darkIconColor) { }
setOnClickListener(View.OnClickListener onClickListener)42     default void setOnClickListener(View.OnClickListener onClickListener) { }
setOnHoverListener(View.OnHoverListener onHoverListener)43     default void setOnHoverListener(View.OnHoverListener onHoverListener) { }
getImageDrawable()44     default Drawable getImageDrawable() {
45         return null;
46     }
setDarkIntensity(float darkIntensity)47     default void setDarkIntensity(float darkIntensity) { }
acceptRotationProposal()48     default boolean acceptRotationProposal() {
49         return getCurrentView() != null;
50     }
51 
52     /**
53      * Callback for updates provided by a rotation button
54      */
55     interface RotationButtonUpdatesCallback {
onVisibilityChanged(boolean isVisible)56         default void onVisibilityChanged(boolean isVisible) {};
onPositionChanged()57         default void onPositionChanged() {};
58     }
59 }
60