Hide virtual keyboard if searchView text was changed programatically.
+/.gradle
+/.idea
+/build
/gen
/.project
/bin
/lint.xml
.DS_Store
+*.class
<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"
android {
compileSdkVersion 23
- buildToolsVersion "23.0.1"
+ buildToolsVersion "23.0.2"
+ lintOptions {
+ disable "MissingTranslation"
+ }
buildTypes {
debug {
applicationIdSuffix ".debug"
--- /dev/null
+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
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.
<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>
<!-- 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>
<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>
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() {
ImageButton languageButton;
SearchView.OnQueryTextListener onQueryTextListener;
- MenuItem nextWordMenuItem, previousWordMenuItem;
+ MenuItem nextWordMenuItem, previousWordMenuItem, randomWordMenuItem;
// Never null.
private File wordList = null;
}
} 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);
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
// --------------------------------------------------------------------------
});
}
+ randomWordMenuItem = menu.add(getString(R.string.randomWord));
+ randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ onRandomWordButton();
+ return true;
+ }
+ });
+
application.onCreateGlobalOptionsMenu(this, menu);
{
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;
}
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;
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
}\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