1 /* 2 * Copyright (C) 2018 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.system; 18 19 import android.annotation.IntDef; 20 import android.content.Context; 21 import android.content.res.Resources; 22 import android.util.DisplayMetrics; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 27 import sun.misc.Resource; 28 29 public class NavigationBarCompat { 30 /** 31 * Touch slopes and thresholds for quick step operations. Drag slop is the point where the 32 * home button press/long press over are ignored and will start to drag when exceeded and the 33 * touch slop is when the respected operation will occur when exceeded. Touch slop must be 34 * larger than the drag slop. 35 */ getQuickStepDragSlopPx()36 public static int getQuickStepDragSlopPx() { 37 return convertDpToPixel(10); 38 } 39 getQuickStepTouchSlopPx()40 public static int getQuickStepTouchSlopPx() { 41 return convertDpToPixel(24); 42 } 43 getQuickScrubTouchSlopPx()44 public static int getQuickScrubTouchSlopPx() { 45 return convertDpToPixel(24); 46 } 47 48 @Retention(RetentionPolicy.SOURCE) 49 @IntDef({HIT_TARGET_NONE, HIT_TARGET_BACK, HIT_TARGET_HOME, HIT_TARGET_OVERVIEW}) 50 public @interface HitTarget{} 51 52 public static final int HIT_TARGET_NONE = 0; 53 public static final int HIT_TARGET_BACK = 1; 54 public static final int HIT_TARGET_HOME = 2; 55 public static final int HIT_TARGET_OVERVIEW = 3; 56 public static final int HIT_TARGET_ROTATION = 4; 57 58 @Retention(RetentionPolicy.SOURCE) 59 @IntDef({FLAG_DISABLE_SWIPE_UP, 60 FLAG_DISABLE_QUICK_SCRUB, 61 FLAG_SHOW_OVERVIEW_BUTTON 62 }) 63 public @interface InteractionType {} 64 65 /** 66 * Interaction type: whether the gesture to swipe up from the navigation bar will trigger 67 * launcher to show overview 68 */ 69 public static final int FLAG_DISABLE_SWIPE_UP = 0x1; 70 /** 71 * Interaction type: enable quick scrub interaction on the home button 72 */ 73 public static final int FLAG_DISABLE_QUICK_SCRUB = 0x2; 74 75 /** 76 * Interaction type: show/hide the overview button while this service is connected to launcher 77 */ 78 public static final int FLAG_SHOW_OVERVIEW_BUTTON = 0x4; 79 convertDpToPixel(float dp)80 private static int convertDpToPixel(float dp){ 81 return (int) (dp * Resources.getSystem().getDisplayMetrics().density); 82 } 83 } 84