]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Merge pull request #26 from Kteby/master
authorReimar Döffinger <rdoeffinger@users.noreply.github.com>
Sat, 30 Jan 2016 09:36:22 +0000 (10:36 +0100)
committerReimar Döffinger <rdoeffinger@users.noreply.github.com>
Sat, 30 Jan 2016 09:36:22 +0000 (10:36 +0100)
Hide virtual keyboard if searchView text was changed programatically.

.gitignore
AndroidManifest.xml
build.gradle
readme.txt [new file with mode: 0644]
res/raw/dictionary_info.txt
res/values-de/strings.xml
res/values/strings.xml
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/DictionaryManagerActivity.java
src/com/hughes/android/dictionary/HtmlDisplayActivity.java

index 72662abe68d2c0dc916715527436cc09f75fe081..c94c0c22c44c0573e7095952a0d720c65f546fed 100644 (file)
@@ -1,5 +1,9 @@
+/.gradle
+/.idea
+/build
 /gen
 /.project
 /bin
 /lint.xml
 .DS_Store
+*.class
index f872e98a1ab42ba4337138d41c6290cde3987cc6..982b0eb5103b24b0f0b1486a73e0907131e1fc92 100644 (file)
@@ -2,8 +2,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.hughes.android.dictionary"
     android:installLocation="auto"
-    android:versionCode="53"
-    android:versionName="5.2.2" >
+    android:versionCode="54"
+    android:versionName="5.2.3" >
 
     <uses-sdk
         android:minSdkVersion="10"
index 0f6d7782c7d9619a3ed41a0283d88049ff9b4e9a..0794423503bec651c699f5d4502e64c340420fe5 100644 (file)
@@ -40,7 +40,10 @@ def utildir = hasProperty("quickdicUtilDir") ? quickdicUtilDir : "../Util"
 
 android {
     compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    buildToolsVersion "23.0.2"
+    lintOptions {
+        disable "MissingTranslation"
+    }
     buildTypes {
         debug {
             applicationIdSuffix ".debug"
diff --git a/readme.txt b/readme.txt
new file mode 100644 (file)
index 0000000..4d18cc9
--- /dev/null
@@ -0,0 +1,23 @@
+Make sure you also checked out the Util repository,
+and if you want to generate dictionaries also the DictionaryPC
+repository.
+They need to be at the same level as this one, not inside it.
+
+To compile the APK, just open this repository in Android Studio.
+You can also use gradle directly.
+
+And approximation of the steps for generating dictionaries:
+- go into the DictionaryPC repository
+- run data/downloadInputs.sh to get the data
+- run ./compile.sh (probably needs quite a few things to be installed or paths in it configured)
+- run ./WiktionarySplitter.sh
+- run ./generate_dictionaries.sh.
+  You might want to edit the settings at the start of the file
+  so it does not generate all dictionaries, and edit its input files
+  like EN-trans-dictlist.txt to add new dictionaries.
+  For a more manual approach, the commands it runs are something like
+ ./run.sh --lang1=ES --lang2=PT --lang1Stoplist=data/inputs/stoplists/es.txt \
+ --dictOut=data/outputs/ES-PT.quickdic \
+ --dictInfo="(EN)Wiktionary-based ES-PT dictionary. --input1=data/inputs/wikiSplit/en/EN.data" \
+ --input1Name=enwikitionary --input1Format=EnTranslationToTranslation \
+ --input1LangPattern1=es --input1LangPattern2=pt
index 91939df4f69c921365bf2ad7ccdd6f6834bf4434..5ac34ee51bc5f65d2b109d527017a608b2292fcf 100644 (file)
@@ -96,6 +96,7 @@ EN-grc.quickdic       http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-
 EN-haw.quickdic        http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/EN-haw.quickdic.v007.zip   1450306121065   295800  275409  2       EN      3847    1099    haw     1737    1546    (EN)Wiktionary-based EN-haw dictionary.
 EN-yue.quickdic        http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/EN-yue.quickdic.v007.zip   1450306146319   1784435 1726130 2       EN      4506    1407    yue     21736   20940   (EN)Wiktionary-based EN-yue dictionary.
 EN.quickdic    http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/EN.quickdic.v007.zip       1450142478375   92606781        91833088        1       EN      616698  610998  Wiktionary-based EN dictionary.
+ES-PT.quickdic http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/ES-PT.quickdic.v007.zip    1452541238755   1466971 1327281 2       ES      25546   23376   PT      24058   22224   (EN)Wiktionary-based ES-PT dictionary.
 ES-RU.quickdic http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/ES-RU.quickdic.v006.zip    1357253815481   6682120 2135784 2       ES      19517   17692   RU      50993   21891   Wikitionary-based ES-RU dictionary.
 ES-cmn.quickdic        http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/ES-cmn.quickdic.v006.zip   1357257626909   4437355 1502694 2       ES      13698   12252   cmn     42183   27263   Wikitionary-based ES-cmn dictionary.
 FR-BG.quickdic http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/FR-BG.quickdic.v007.zip    1450155696184   8470115 8159443 2       FR      12330   11577   BG      169951  164827  (FR)Wiktionary-based FR-BG dictionary.
index c2c01c2d3cf8b43b0728ce5b622a898ab7378f7b..88971b20c0aabea4317f3cb7810c772d7e16de4b 100644 (file)
@@ -41,8 +41,9 @@
     <string name="fontFailure">Font failure: %s</string>
     <string name="seeAlso">vgl.: %1$s (%2$s)</string>
     <string name="speak">Sprechen</string>
-    <string name="nextWord">Next word</string>
-    <string name="previousWord">Previous word</string>
+    <string name="nextWord">Nächstes Wort</string>
+    <string name="previousWord">Voriges Wort</string>
+    <string name="randomWord">Zufälliges Wort</string>
     
     <!-- About dictionary. -->
     <string name="dictionaryPath">Datei: %s</string>
index cab5f71476fcaa7a19c21783cc4a7258fc1bd396..a1bc4df6099419c469006553f1ce2537dd4c741e 100644 (file)
@@ -27,6 +27,7 @@
 
     <!-- Download. -->
     <string name="downloadFailed">Download failed: \n%s.</string>
+    <string name="downloadManagerQueryFailed">Could not query download manager.\nIs it disabled or missing?</string>
     <string name="unzippingDictionary">Unzipping dictionary: \n%s</string>
     <string name="unzippingFailed">Unzipping failed: \n%s</string>
     <string name="installationFinished">Installation finished: \n%s.</string>
@@ -46,6 +47,7 @@
     <string name="speak">Speak</string>
     <string name="nextWord">Next word</string>
     <string name="previousWord">Previous word</string>
+    <string name="randomWord">Random word</string>
 
     <!-- About dictionary. -->
     <string name="dictionaryPath">File: %s</string>
index c8d99e4f60328e4b440b1c9d280b08b9828b91b7..f8cca586e94f6e6cb7cb27a01a184a7570a84bb4 100644 (file)
@@ -129,6 +129,8 @@ public class DictionaryActivity extends ActionBarActivity {
 
     List<RowBase> rowsToShow = null; // if not null, just show these rows.
 
+    final Random rand = new Random();
+
     final Handler uiHandler = new Handler();
 
     private final Executor searchExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() {
@@ -168,7 +170,7 @@ public class DictionaryActivity extends ActionBarActivity {
     ImageButton languageButton;
     SearchView.OnQueryTextListener onQueryTextListener;
 
-    MenuItem nextWordMenuItem, previousWordMenuItem;
+    MenuItem nextWordMenuItem, previousWordMenuItem, randomWordMenuItem;
 
     // Never null.
     private File wordList = null;
@@ -782,7 +784,7 @@ public class DictionaryActivity extends ActionBarActivity {
             }
         } else {
             // Down
-            destIndexEntry = Math.min(tokenRow.referenceIndex + 1, index.sortedIndexEntries.size());
+            destIndexEntry = Math.min(tokenRow.referenceIndex + 1, index.sortedIndexEntries.size() - 1);
         }
         final Index.IndexEntry dest = index.sortedIndexEntries.get(destIndexEntry);
         Log.d(LOG, "onUpDownButton, destIndexEntry=" + dest.token);
@@ -791,6 +793,14 @@ public class DictionaryActivity extends ActionBarActivity {
         defocusSearchText();
     }
 
+    void onRandomWordButton() {
+        int destIndexEntry = rand.nextInt(index.sortedIndexEntries.size());
+        final Index.IndexEntry dest = index.sortedIndexEntries.get(destIndexEntry);
+        setSearchText(dest.token, false);
+        jumpToRow(index.sortedIndexEntries.get(destIndexEntry).startRow);
+        defocusSearchText();
+    }
+
     // --------------------------------------------------------------------------
     // Options Menu
     // --------------------------------------------------------------------------
@@ -827,6 +837,15 @@ public class DictionaryActivity extends ActionBarActivity {
             });
         }
 
+        randomWordMenuItem = menu.add(getString(R.string.randomWord));
+        randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+            @Override
+            public boolean onMenuItemClick(MenuItem item) {
+                onRandomWordButton();
+                return true;
+            }
+        });
+
         application.onCreateGlobalOptionsMenu(this, menu);
 
         {
index 159a7f0abf5037a9516e65e6bf4536c8ee4411f0..dacc6d75cd2c806fc72317d2c96b78cec0a9731c 100644 (file)
@@ -131,7 +131,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;
                 }
@@ -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;
index b99f55bc6f7beb21d9696a793d8c251af2b69325..dd07c4e7dd975a88b4d11459f433afa2c929b67a 100644 (file)
@@ -21,6 +21,7 @@ import android.support.v7.app.ActionBar;
 import android.support.v7.app.ActionBarActivity;\r
 import android.util.Base64;\r
 import android.util.Log;\r
+import android.view.MenuItem;\r
 import android.view.View;\r
 import android.view.View.OnClickListener;\r
 import android.widget.Button;\r
@@ -108,4 +109,22 @@ public final class HtmlDisplayActivity extends ActionBarActivity {
         }\r
     }\r
 \r
+    @Override\r
+    public void onBackPressed() {\r
+        final MyWebView webView = (MyWebView)findViewById(R.id.webView);\r
+        if (webView.canGoBack()) webView.goBack();\r
+        else super.onBackPressed();\r
+    }\r
+\r
+    @Override\r
+    public boolean onOptionsItemSelected(MenuItem item) {\r
+        // Explicitly handle the up button press so\r
+        // we return to the dictionary.\r
+        if (item.getItemId() == android.R.id.home)\r
+        {\r
+            finish();\r
+            return true;\r
+        }\r
+        return super.onOptionsItemSelected(item);\r
+    }\r
 }\r