add OI File Manager and AndroidSupportV2 used by it
[android_pandora.git] / apps / oi-filemanager / FileManager / src / org / openintents / filemanager / compatibility / SoftKeyboard.java
diff --git a/apps/oi-filemanager/FileManager/src/org/openintents/filemanager/compatibility/SoftKeyboard.java b/apps/oi-filemanager/FileManager/src/org/openintents/filemanager/compatibility/SoftKeyboard.java
new file mode 100644 (file)
index 0000000..4e997a3
--- /dev/null
@@ -0,0 +1,34 @@
+package org.openintents.filemanager.compatibility;\r
+\r
+import android.content.Context;\r
+import android.os.IBinder;\r
+import android.view.inputmethod.InputMethodManager;\r
+\r
+/*\r
+ * Wraper class for closing the software keyboard, which appeared in API 3.\r
+ */\r
+\r
+public class SoftKeyboard {\r
+    /* class initialization fails when this throws an exception */\r
+    static {\r
+            try {\r
+                    Class.forName("android.view.inputmethod.InputMethodManager");\r
+            } catch (Exception ex) {\r
+                    throw new RuntimeException(ex);\r
+            }\r
+    }\r
+\r
+    /* calling here forces class initialization */\r
+    public static void checkAvailable() {}\r
+    \r
+    private InputMethodManager inputMethodManager;\r
+    \r
+    public SoftKeyboard(Context ctx){\r
+       inputMethodManager = (InputMethodManager) ctx.getSystemService(\r
+                       Context.INPUT_METHOD_SERVICE);\r
+    }\r
+    \r
+    public boolean hideSoftInputFromWindow(IBinder windowToken, int flags){\r
+       return inputMethodManager.hideSoftInputFromWindow(windowToken, flags);\r
+    }\r
+}
\ No newline at end of file