-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
289c1f0
commit 45b646b
Showing
4 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
app/src/main/java/com/insightsurfface/stylelibrary/keyboard/KeyBoardDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package com.insightsurfface.stylelibrary.keyboard; | ||
|
||
import android.app.Activity; | ||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.Display; | ||
import android.view.Gravity; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
import android.widget.EditText; | ||
|
||
import com.insightsurfface.stylelibrary.R; | ||
import com.insightsurfface.stylelibrary.listener.OnKeyboardChangeListener; | ||
import com.insightsurfface.stylelibrary.listener.OnKeyboardListener; | ||
|
||
|
||
public class KeyBoardDialog extends Dialog { | ||
protected Context context; | ||
protected English9KeyBoardView englishKeyboardView; | ||
private EditText dialogEt; | ||
protected OnKeyboardListener mOnKeyboardListener; | ||
protected OnKeyboardChangeListener mOnKeyboardChangeListener; | ||
|
||
|
||
public KeyBoardDialog(Context context) { | ||
super(context); | ||
// 閺夆晜鐟ч~鎺楀棘閻熸壆纭�闁告瑯鍨禍鎺旀媼閳哄伅顓㈠触閹存繂寮块悘鐑囨嫹 濞达絽妫欏Σ鎼佸极閸喓浜☉鎾崇Т閵囧﹥绺介敓锟� | ||
// super(context, android.R.style.Theme); | ||
// setOwnerActivity((Activity) context); | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
setContentView(getLayoutId()); | ||
init(); | ||
|
||
windowSet(); | ||
} | ||
|
||
protected int getLayoutId() { | ||
return R.layout.dialog_keyboard; | ||
} | ||
|
||
protected void windowSet() { | ||
Window window = this.getWindow(); | ||
WindowManager.LayoutParams lp = window.getAttributes(); | ||
WindowManager wm = ((Activity) context).getWindowManager(); | ||
Display d = wm.getDefaultDisplay(); // 闁兼儳鍢茶ぐ鍥╀沪韫囨挾顔庨悗鐟邦潟閿熸垝绶氶悵顕�鎮介敓锟� | ||
// lp.height = (int) (d.getHeight() * 0.4); // 濡ゅ倹锚鐎瑰磭鎷嬮崜褏鏋� | ||
lp.width = (int) (d.getWidth() * 1); // 閻庣妫勭�瑰磭鎷嬮崜褏鏋� | ||
// window.setGravity(Gravity.LEFT | Gravity.TOP); | ||
window.setGravity(Gravity.BOTTOM); | ||
// dialog濮掓稒顭堥鑽や焊鏉堛劍绠抪adding 閻庝絻澹堥崵褎淇婇崒娑氫函濞戞挸绉风换鏍ㄧ▕閸綆鍟庣紓鍐惧枤濞堟垹鎷犻敓锟� | ||
// dialog婵ɑ鐡曠换娆愮▔瀹ュ牆鍘撮柛蹇嬪妼閻拷 | ||
window.getDecorView().setPadding(0, 0, 0, 0); | ||
// lp.x = 100; // 闁哄倿顣︾紞鍛磾閻㈡棃宕搁幇顓犲灱 | ||
// lp.y = 100; // 闁哄倿顣︾紞鍛磾閻㈡洟宕搁幇顓犲灱 | ||
// lp.height = 30; | ||
// lp.width = 20; | ||
window.setAttributes(lp); | ||
window.setDimAmount(0.2f);//去掉蒙层 | ||
window.setBackgroundDrawableResource(android.R.color.transparent); | ||
} | ||
|
||
protected void init() { | ||
dialogEt = (EditText)findViewById( R.id.dialog_et ); | ||
englishKeyboardView = (English9KeyBoardView) findViewById(R.id.english_keyboard_view); | ||
englishKeyboardView.attachTo(dialogEt); | ||
englishKeyboardView.setOnKeyboardChangeListener(new OnKeyboardChangeListener() { | ||
@Override | ||
public void onChange(String res) { | ||
if (null != mOnKeyboardChangeListener) { | ||
mOnKeyboardChangeListener.onChange(res); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFinish(String res) { | ||
if (null != mOnKeyboardChangeListener) { | ||
mOnKeyboardChangeListener.onFinish(res); | ||
} | ||
} | ||
}); | ||
englishKeyboardView.setOnKeyboardListener(new OnKeyboardListener() { | ||
@Override | ||
public void onOptionsClick() { | ||
if (null != mOnKeyboardListener) { | ||
mOnKeyboardListener.onOptionsClick(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onQuestionClick() { | ||
if (null != mOnKeyboardListener) { | ||
mOnKeyboardListener.onQuestionClick(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public void setOnKeyboardListener(OnKeyboardListener onKeyboardListener) { | ||
mOnKeyboardListener = onKeyboardListener; | ||
} | ||
|
||
public void setOnKeyboardChangeListener(OnKeyboardChangeListener onKeyboardChangeListener) { | ||
mOnKeyboardChangeListener = onKeyboardChangeListener; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@color/transparency"> | ||
|
||
<EditText | ||
android:id="@+id/dialog_et" | ||
android:layout_width="match_parent" | ||
android:layout_height="40dp" | ||
android:hint="点按后滑动输入" | ||
android:gravity="center" | ||
android:textColor="@color/main_text_color" | ||
android:textColorHint="@color/main_text_color_gray" | ||
android:textSize="15sp" | ||
android:background="@null"/> | ||
|
||
<com.insightsurfface.stylelibrary.keyboard.English9KeyBoardView | ||
android:id="@+id/english_keyboard_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="1dp" | ||
android:layout_below="@+id/dialog_et"></com.insightsurfface.stylelibrary.keyboard.English9KeyBoardView> | ||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters