@@ -39,20 +39,29 @@ public int resolveKeyUnicode(int deviceID, int metaState, int keyCode){
3939 return 0 ;//could not load char map, thus could not resolve character
4040 }
4141 }
42-
42+
4343 return this .curCharMap .get (keyCode , metaState );
4444 }
45-
45+
4646 public float getDotsPerInch (){
4747 Display d = ((WindowManager )getSystemService (Context .WINDOW_SERVICE )).getDefaultDisplay ();
4848 DisplayMetrics m = new DisplayMetrics ();
4949 d .getMetrics (m );
5050 Log .d (LOGTAG , "getDotsPerInch(): xdpi = " + m .xdpi + " ydpi = " + m .ydpi + " density = " + m .density );
5151 return (m .xdpi + m .ydpi ) / 2.0f ;
5252 }
53-
53+
54+ public int [] getScreenDims (){
55+ DisplayMetrics metrics = new DisplayMetrics ();
56+ getWindowManager ().getDefaultDisplay ().getRealMetrics (metrics );
57+ int width = metrics .widthPixels ;
58+ int height = metrics .heightPixels ;
59+ Log .d (LOGTAG , "getScreenDims(): width = " + width + ", height = " + height );
60+ return new int [] {width , height };
61+ }
62+
5463 private static native void handleCharacterStringInput (String str );
55-
64+
5665 @ Override
5766 public boolean dispatchKeyEvent (KeyEvent event ) {
5867 Log .d (LOGTAG , "dispatchKeyEvent(): invoked" );
@@ -66,28 +75,28 @@ public boolean dispatchKeyEvent(KeyEvent event) {
6675 return super .dispatchKeyEvent (event );
6776 }
6877
69- //Override the Back button handler to prevent activity from automatically closing by Back key.
78+ // Override the Back button handler to prevent activity from automatically closing by Back key.
7079 @ Override
7180 public void onBackPressed () {
7281 }
73-
82+
7483 private InputMethodManager imm ;
75-
84+
7685 @ Override
7786 protected void onCreate (Bundle savedInstanceState ){
7887 super .onCreate (savedInstanceState );
7988
8089 this .imm = (InputMethodManager )this .getSystemService (Service .INPUT_METHOD_SERVICE );
8190 }
82-
83-
91+
92+
8493 public void showVirtualKeyboard (){
8594 this .imm .showSoftInput (this .getWindow ().getDecorView (), InputMethodManager .SHOW_FORCED );
8695 Rect r = new Rect ();
8796 this .getWindow ().getDecorView ().getWindowVisibleDisplayFrame (r );
8897 Log .d (LOGTAG , "showVirtualKeyboard(): visible rect = " + r .left + ", " + r .right + ", " + r .top + ", " + r .bottom );
8998 }
90-
99+
91100 public void hideVirtualKeyboard (){
92101 this .imm .hideSoftInputFromWindow (this .getWindow ().getDecorView ().getWindowToken (), InputMethodManager .HIDE_IMPLICIT_ONLY );
93102 }
@@ -110,7 +119,7 @@ public String[] listDirContents(String path){
110119 }
111120 return null ;
112121 }
113-
122+
114123 public String getStorageDir (){
115124 return this .getFilesDir ().getPath ();
116125 }
0 commit comments