OSDN Git Service

[WIP] Support Android 10 desktop mode
[android-x86/packages-apps-Taskbar.git] / app / src / main / java / com / farmerbb / taskbar / util / LauncherHelper.java
1 /* Copyright 2016 Braden Farmer
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 package com.farmerbb.taskbar.util;
17
18 public class LauncherHelper {
19
20     private boolean onPrimaryHomeScreen = false;
21     private boolean onSecondaryHomeScreen = false;
22
23     private static LauncherHelper theInstance;
24
25     private LauncherHelper() {}
26
27     public static LauncherHelper getInstance() {
28         if(theInstance == null) theInstance = new LauncherHelper();
29
30         return theInstance;
31     }
32
33     public boolean isOnHomeScreen() {
34         return isOnHomeScreen(true, true);
35     }
36
37     public boolean isOnHomeScreen(boolean checkPrimary, boolean checkSecondary) {
38         if(checkPrimary && checkSecondary)
39             return onPrimaryHomeScreen || onSecondaryHomeScreen;
40
41         if(!checkPrimary && checkSecondary)
42             return onSecondaryHomeScreen;
43
44         if(checkPrimary)
45             return onPrimaryHomeScreen;
46
47         return false;
48     }
49
50     public void setOnPrimaryHomeScreen(boolean value) {
51         onPrimaryHomeScreen = value;
52     }
53
54     public void setOnSecondaryHomeScreen(boolean value) {
55         onSecondaryHomeScreen = value;
56     }
57 }