KeyboardUtil.smali
.class public Lcn/dreamtobe/kpswitch/util/KeyboardUtil;
.super Ljava/lang/Object;
.source "KeyboardUtil.java"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcn/dreamtobe/kpswitch/util/KeyboardUtil$OnKeyboardShowingListener;,
Lcn/dreamtobe/kpswitch/util/KeyboardUtil$KeyboardStatusListener;
}
.end annotation
# static fields
.field private static LAST_SAVE_KEYBOARD_HEIGHT:I
.field private static MAX_PANEL_HEIGHT:I
.field private static MIN_KEYBOARD_HEIGHT:I
.field private static MIN_PANEL_HEIGHT:I
# direct methods
.method static constructor <clinit>()V
.registers 1
.line 65
const/4 v0, 0x0
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->LAST_SAVE_KEYBOARD_HEIGHT:I
.line 122
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MAX_PANEL_HEIGHT:I
.line 123
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_PANEL_HEIGHT:I
.line 124
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_KEYBOARD_HEIGHT:I
return-void
.end method
.method public constructor <init>()V
.registers 1
.line 47
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method static synthetic access$000(Landroid/content/Context;I)Z
.registers 3
.param p0, "x0" # Landroid/content/Context;
.param p1, "x1" # I
.line 47
invoke-static {p0, p1}, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->saveKeyboardHeight(Landroid/content/Context;I)Z
move-result v0
return v0
.end method
.method public static attach(Landroid/app/Activity;Lcn/dreamtobe/kpswitch/IPanelHeightTarget;)Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;
.registers 3
.param p0, "activity" # Landroid/app/Activity;
.param p1, "target" # Lcn/dreamtobe/kpswitch/IPanelHeightTarget;
.line 201
const/4 v0, 0x0
invoke-static {p0, p1, v0}, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->attach(Landroid/app/Activity;Lcn/dreamtobe/kpswitch/IPanelHeightTarget;Lcn/dreamtobe/kpswitch/util/KeyboardUtil$OnKeyboardShowingListener;)Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;
move-result-object v0
return-object v0
.end method
.method public static attach(Landroid/app/Activity;Lcn/dreamtobe/kpswitch/IPanelHeightTarget;Lcn/dreamtobe/kpswitch/util/KeyboardUtil$OnKeyboardShowingListener;)Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;
.registers 19
.param p0, "activity" # Landroid/app/Activity;
.param p1, "target" # Lcn/dreamtobe/kpswitch/IPanelHeightTarget;
.param p2, "lis" # Lcn/dreamtobe/kpswitch/util/KeyboardUtil$OnKeyboardShowingListener;
.line 166
const v0, 0x1020002
move-object/from16 v1, p0
invoke-virtual {v1, v0}, Landroid/app/Activity;->findViewById(I)Landroid/view/View;
move-result-object v0
check-cast v0, Landroid/view/ViewGroup;
.line 167
.local v0, "contentView":Landroid/view/ViewGroup;
invoke-static/range {p0 .. p0}, Lcn/dreamtobe/kpswitch/util/ViewUtil;->isFullScreen(Landroid/app/Activity;)Z
move-result v10
.line 168
.local v10, "isFullScreen":Z
invoke-static/range {p0 .. p0}, Lcn/dreamtobe/kpswitch/util/ViewUtil;->isTranslucentStatus(Landroid/app/Activity;)Z
move-result v11
.line 169
.local v11, "isTranslucentStatus":Z
invoke-static/range {p0 .. p0}, Lcn/dreamtobe/kpswitch/util/ViewUtil;->isFitsSystemWindows(Landroid/app/Activity;)Z
move-result v12
.line 172
.local v12, "isFitSystemWindows":Z
invoke-virtual/range {p0 .. p0}, Landroid/app/Activity;->getWindowManager()Landroid/view/WindowManager;
move-result-object v2
invoke-interface {v2}, Landroid/view/WindowManager;->getDefaultDisplay()Landroid/view/Display;
move-result-object v13
.line 174
.local v13, "display":Landroid/view/Display;
sget v2, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v3, 0xd
if-lt v2, v3, :cond_31
.line 175
new-instance v2, Landroid/graphics/Point;
invoke-direct {v2}, Landroid/graphics/Point;-><init>()V
.line 176
.local v2, "screenSize":Landroid/graphics/Point;
invoke-virtual {v13, v2}, Landroid/view/Display;->getSize(Landroid/graphics/Point;)V
.line 177
iget v2, v2, Landroid/graphics/Point;->y:I
.line 178
.local v2, "screenHeight":I
move v14, v2
goto :goto_36
.line 180
.end local v2 # "screenHeight":I
:cond_31
invoke-virtual {v13}, Landroid/view/Display;->getHeight()I
move-result v2
move v14, v2
.line 183
.local v14, "screenHeight":I
:goto_36
new-instance v15, Lcn/dreamtobe/kpswitch/util/KeyboardUtil$KeyboardStatusListener;
move-object v2, v15
move v3, v10
move v4, v11
move v5, v12
move-object v6, v0
move-object/from16 v7, p1
move-object/from16 v8, p2
move v9, v14
invoke-direct/range {v2 .. v9}, Lcn/dreamtobe/kpswitch/util/KeyboardUtil$KeyboardStatusListener;-><init>(ZZZLandroid/view/ViewGroup;Lcn/dreamtobe/kpswitch/IPanelHeightTarget;Lcn/dreamtobe/kpswitch/util/KeyboardUtil$OnKeyboardShowingListener;I)V
.line 192
.local v2, "globalLayoutListener":Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;
invoke-virtual {v0}, Landroid/view/ViewGroup;->getViewTreeObserver()Landroid/view/ViewTreeObserver;
move-result-object v3
invoke-virtual {v3, v2}, Landroid/view/ViewTreeObserver;->addOnGlobalLayoutListener(Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;)V
.line 193
return-object v2
.end method
.method public static detach(Landroid/app/Activity;Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;)V
.registers 5
.param p0, "activity" # Landroid/app/Activity;
.param p1, "l" # Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;
.line 212
const v0, 0x1020002
invoke-virtual {p0, v0}, Landroid/app/Activity;->findViewById(I)Landroid/view/View;
move-result-object v0
check-cast v0, Landroid/view/ViewGroup;
.line 213
.local v0, "contentView":Landroid/view/ViewGroup;
sget v1, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v2, 0x10
if-lt v1, v2, :cond_17
.line 214
invoke-virtual {v0}, Landroid/view/ViewGroup;->getViewTreeObserver()Landroid/view/ViewTreeObserver;
move-result-object v1
invoke-virtual {v1, p1}, Landroid/view/ViewTreeObserver;->removeOnGlobalLayoutListener(Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;)V
goto :goto_1e
.line 217
:cond_17
invoke-virtual {v0}, Landroid/view/ViewGroup;->getViewTreeObserver()Landroid/view/ViewTreeObserver;
move-result-object v1
invoke-virtual {v1, p1}, Landroid/view/ViewTreeObserver;->removeGlobalOnLayoutListener(Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;)V
.line 219
:goto_1e
return-void
.end method
.method public static getKeyboardHeight(Landroid/content/Context;)I
.registers 2
.param p0, "context" # Landroid/content/Context;
.line 91
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->LAST_SAVE_KEYBOARD_HEIGHT:I
if-nez v0, :cond_13
.line 92
nop
.line 93
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v0
invoke-static {v0}, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->getMinPanelHeight(Landroid/content/res/Resources;)I
move-result v0
invoke-static {p0, v0}, Lcn/dreamtobe/kpswitch/util/KeyBoardSharedPreferences;->get(Landroid/content/Context;I)I
move-result v0
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->LAST_SAVE_KEYBOARD_HEIGHT:I
.line 96
:cond_13
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->LAST_SAVE_KEYBOARD_HEIGHT:I
return v0
.end method
.method public static getMaxPanelHeight(Landroid/content/res/Resources;)I
.registers 2
.param p0, "res" # Landroid/content/res/Resources;
.line 127
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MAX_PANEL_HEIGHT:I
if-nez v0, :cond_c
.line 128
sget v0, Lcn/dreamtobe/kpswitch/R$dimen;->max_panel_height:I
invoke-virtual {p0, v0}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
move-result v0
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MAX_PANEL_HEIGHT:I
.line 131
:cond_c
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MAX_PANEL_HEIGHT:I
return v0
.end method
.method public static getMinKeyboardHeight(Landroid/content/Context;)I
.registers 3
.param p0, "context" # Landroid/content/Context;
.line 143
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_KEYBOARD_HEIGHT:I
if-nez v0, :cond_10
.line 144
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v0
sget v1, Lcn/dreamtobe/kpswitch/R$dimen;->min_keyboard_height:I
.line 145
invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
move-result v0
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_KEYBOARD_HEIGHT:I
.line 147
:cond_10
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_KEYBOARD_HEIGHT:I
return v0
.end method
.method public static getMinPanelHeight(Landroid/content/res/Resources;)I
.registers 2
.param p0, "res" # Landroid/content/res/Resources;
.line 135
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_PANEL_HEIGHT:I
if-nez v0, :cond_c
.line 136
sget v0, Lcn/dreamtobe/kpswitch/R$dimen;->min_panel_height:I
invoke-virtual {p0, v0}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
move-result v0
sput v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_PANEL_HEIGHT:I
.line 139
:cond_c
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->MIN_PANEL_HEIGHT:I
return v0
.end method
.method public static getValidPanelHeight(Landroid/content/Context;)I
.registers 4
.param p0, "context" # Landroid/content/Context;
.line 111
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v0
invoke-static {v0}, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->getMaxPanelHeight(Landroid/content/res/Resources;)I
move-result v0
.line 112
.local v0, "maxPanelHeight":I
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v1
invoke-static {v1}, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->getMinPanelHeight(Landroid/content/res/Resources;)I
move-result v1
.line 114
.local v1, "minPanelHeight":I
invoke-static {p0}, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->getKeyboardHeight(Landroid/content/Context;)I
move-result v2
.line 116
.local v2, "validPanelHeight":I
invoke-static {v1, v2}, Ljava/lang/Math;->max(II)I
move-result v2
.line 117
invoke-static {v0, v2}, Ljava/lang/Math;->min(II)I
move-result v2
.line 118
return v2
.end method
.method public static hideKeyboard(Landroid/view/View;)V
.registers 4
.param p0, "view" # Landroid/view/View;
.line 58
nop
.line 59
invoke-virtual {p0}, Landroid/view/View;->getContext()Landroid/content/Context;
move-result-object v0
.line 60
const-string v1, "input_method"
invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/view/inputmethod/InputMethodManager;
.line 61
.local v0, "imm":Landroid/view/inputmethod/InputMethodManager;
invoke-virtual {p0}, Landroid/view/View;->getWindowToken()Landroid/os/IBinder;
move-result-object v1
const/4 v2, 0x0
invoke-virtual {v0, v1, v2}, Landroid/view/inputmethod/InputMethodManager;->hideSoftInputFromWindow(Landroid/os/IBinder;I)Z
.line 62
return-void
.end method
.method private static saveKeyboardHeight(Landroid/content/Context;I)Z
.registers 5
.param p0, "context" # Landroid/content/Context;
.param p1, "keyboardHeight" # I
.line 68
sget v0, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->LAST_SAVE_KEYBOARD_HEIGHT:I
const/4 v1, 0x0
if-ne v0, p1, :cond_6
.line 69
return v1
.line 72
:cond_6
if-gez p1, :cond_9
.line 73
return v1
.line 76
:cond_9
sput p1, Lcn/dreamtobe/kpswitch/util/KeyboardUtil;->LAST_SAVE_KEYBOARD_HEIGHT:I
.line 77
const/4 v0, 0x1
new-array v0, v0, [Ljava/lang/Object;
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
aput-object v2, v0, v1
const-string v1, "save keyboard: %d"
invoke-static {v1, v0}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
const-string v1, "KeyBordUtil"
invoke-static {v1, v0}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
.line 79
invoke-static {p0, p1}, Lcn/dreamtobe/kpswitch/util/KeyBoardSharedPreferences;->save(Landroid/content/Context;I)Z
move-result v0
return v0
.end method
.method public static showKeyboard(Landroid/view/View;)V
.registers 3
.param p0, "view" # Landroid/view/View;
.line 50
invoke-virtual {p0}, Landroid/view/View;->requestFocus()Z
.line 51
nop
.line 52
invoke-virtual {p0}, Landroid/view/View;->getContext()Landroid/content/Context;
move-result-object v0
const-string v1, "input_method"
invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/view/inputmethod/InputMethodManager;
.line 54
.local v0, "inputManager":Landroid/view/inputmethod/InputMethodManager;
const/4 v1, 0x0
invoke-virtual {v0, p0, v1}, Landroid/view/inputmethod/InputMethodManager;->showSoftInput(Landroid/view/View;I)Z
.line 55
return-void
.end method