• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 package com.android.launcher3.logging;
17 
18 import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.NO_IME_ACTION;
19 
20 import android.os.SystemClock;
21 
22 /**
23  * Class to maintain keyboard states.
24  */
25 public class KeyboardStateManager {
26     private long mUpdatedTime;
27     private int mImeHeight;
28 
29     public enum KeyboardState {
30         NO_IME_ACTION,
31         SHOW,
32         HIDE,
33     }
34 
35     private KeyboardState mKeyboardState;
36 
KeyboardStateManager()37     public KeyboardStateManager() {
38         mKeyboardState = NO_IME_ACTION;
39     }
40 
41     /**
42      * Returns time when keyboard state was updated.
43      */
getLastUpdatedTime()44     public long getLastUpdatedTime() {
45         return mUpdatedTime;
46     }
47 
48     /**
49      * Returns current keyboard state.
50      */
getKeyboardState()51     public KeyboardState getKeyboardState() {
52         return mKeyboardState;
53     }
54 
55     /**
56      * Setter method to set keyboard state.
57      */
setKeyboardState(KeyboardState keyboardState)58     public void setKeyboardState(KeyboardState keyboardState) {
59         mUpdatedTime = SystemClock.elapsedRealtime();
60         mKeyboardState = keyboardState;
61     }
62 
63     /**
64      * Returns keyboard's current height.
65      */
getImeHeight()66     public int getImeHeight() {
67         return mImeHeight;
68     }
69 
70     /**
71      * Setter method to set keyboard height.
72      */
setImeHeight(int imeHeight)73     public void setImeHeight(int imeHeight) {
74         mImeHeight = imeHeight;
75     }
76 }
77