]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryManagerActivity.java
Fix DictionaryManager search keyboard as well.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryManagerActivity.java
index 159a7f0abf5037a9516e65e6bf4536c8ee4411f0..399005fbfacd9348e1c682eebb28698c9de6f95a 100644 (file)
@@ -43,6 +43,7 @@ import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.BaseAdapter;
 import android.widget.Button;
@@ -131,7 +132,7 @@ public class DictionaryManagerActivity extends ActionBarActivity {
                 final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
                 final Cursor cursor = downloadManager.query(query);
 
-                if (!cursor.moveToFirst()) {
+                if (cursor == null || !cursor.moveToFirst()) {
                     Log.e(LOG, "Couldn't find download.");
                     return;
                 }
@@ -282,18 +283,17 @@ public class DictionaryManagerActivity extends ActionBarActivity {
                 FrameLayout.LayoutParams.WRAP_CONTENT);
         filterSearchView.setLayoutParams(lp);
         filterSearchView.setImeOptions(
-                EditorInfo.IME_ACTION_SEARCH |
+                EditorInfo.IME_ACTION_DONE |
                         EditorInfo.IME_FLAG_NO_EXTRACT_UI |
-                        EditorInfo.IME_FLAG_NO_ENTER_ACTION |
                         // EditorInfo.IME_FLAG_NO_FULLSCREEN | // Requires API
                         // 11
-                        EditorInfo.IME_MASK_ACTION |
                         EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
 
         filterSearchView.setOnQueryTextListener(new OnQueryTextListener() {
             @Override
             public boolean onQueryTextSubmit(String query) {
-                return true;
+                filterSearchView.clearFocus();
+                return false;
             }
 
             @Override
@@ -616,6 +616,16 @@ public class DictionaryManagerActivity extends ActionBarActivity {
         final DownloadManager.Query query = new DownloadManager.Query();
         query.setFilterByStatus(DownloadManager.STATUS_PAUSED | DownloadManager.STATUS_PENDING | DownloadManager.STATUS_RUNNING);
         final Cursor cursor = downloadManager.query(query);
+
+        // Due to a bug, cursor is null instead of empty when
+        // the download manager is disabled.
+        if (cursor == null) {
+            new AlertDialog.Builder(DictionaryManagerActivity.this).setTitle(getString(R.string.error))
+                    .setMessage(getString(R.string.downloadFailed, R.string.downloadManagerQueryFailed))
+                    .setNeutralButton("Close", null).show();
+            return;
+        }
+
         while (cursor.moveToNext()) {
             if (downloadUrl.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI))))
                 break;