diff --git a/app/src/main/assets/data.db b/app/src/main/assets/data.db index 086ce8f..bb2d7fa 100644 Binary files a/app/src/main/assets/data.db and b/app/src/main/assets/data.db differ diff --git a/app/src/main/java/org/mcxa/vortaro/AboutActivity.kt b/app/src/main/java/org/mcxa/vortaro/AboutActivity.kt index 4593916..f1176e4 100644 --- a/app/src/main/java/org/mcxa/vortaro/AboutActivity.kt +++ b/app/src/main/java/org/mcxa/vortaro/AboutActivity.kt @@ -2,6 +2,7 @@ package org.mcxa.vortaro import android.support.v7.app.AppCompatActivity import android.os.Bundle +import android.text.method.LinkMovementMethod import android.view.MenuItem import kotlinx.android.synthetic.main.activity_about.* @@ -19,6 +20,7 @@ class AboutActivity : AppCompatActivity() { supportActionBar?.setDisplayShowHomeEnabled(true) } + about_content.movementMethod = LinkMovementMethod.getInstance() } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/org/mcxa/vortaro/DatabaseHelper.kt b/app/src/main/java/org/mcxa/vortaro/DatabaseHelper.kt index b597840..e6a2050 100644 --- a/app/src/main/java/org/mcxa/vortaro/DatabaseHelper.kt +++ b/app/src/main/java/org/mcxa/vortaro/DatabaseHelper.kt @@ -72,38 +72,38 @@ class DatabaseHelper(private val context: Context) : object: AsyncTask>() { override fun doInBackground(vararg p0: Void?): HashMap { val wordmap = HashMap() - db.rawQuery("SELECT * FROM es " + - "INNER JOIN en ON es.rowid=en.esrow " + - "LEFT JOIN trans ON es.esword=trans.verb " + - "LEFT JOIN ety ON es.esword=ety.word " + - "WHERE es.esword=? OR es.esword=? OR es.rowid IN " + - "(SELECT es.rowid FROM es INNER JOIN en ON es.rowid=en.esrow WHERE en.enword=? OR en.enword=?)", + db.rawQuery("SELECT * FROM eo " + + "INNER JOIN en ON eo.rowid=en.eorow " + + "LEFT JOIN trans ON eo.eoword=trans.verb " + + "LEFT JOIN ety ON eo.eoword=ety.word " + + "WHERE eo.eoword=? OR eo.eoword=? OR eo.rowid IN " + + "(SELECT eo.rowid FROM eo INNER JOIN en ON eo.rowid=en.eorow WHERE en.enword=? OR en.enword=?)", arrayOf(exactTerm, normalizedTerm, exactTerm, "to " + exactTerm) ).use { cursor -> while (cursor.moveToNext()) { - val esrow = cursor.getInt(cursor.getColumnIndexOrThrow("esrow")) + val eorow = cursor.getInt(cursor.getColumnIndexOrThrow("eorow")) // if the wordmap already has the Esperanto word, then just add the english def - if (wordmap.containsKey(esrow)) { + if (wordmap.containsKey(eorow)) { // grab the english values val word = cursor.getString(cursor.getColumnIndexOrThrow("enword")) val elaboration = cursor.getString(cursor.getColumnIndexOrThrow("el")) val elbefore = cursor.getInt(cursor.getColumnIndexOrThrow("elbefore")) - wordmap.get(esrow)?.en?.add(EnModel(word, elaboration, when(elbefore) { + wordmap.get(eorow)?.en?.add(EnModel(word, elaboration, when(elbefore) { 0 -> false 1 -> true else -> null })) // add a new word model and english definition } else { - val esword = cursor.getString(cursor.getColumnIndexOrThrow("esword")) + val eoword = cursor.getString(cursor.getColumnIndexOrThrow("eoword")) val enword = cursor.getString(cursor.getColumnIndexOrThrow("enword")) val elaboration = cursor.getString(cursor.getColumnIndexOrThrow("el")) val elbefore = cursor.getInt(cursor.getColumnIndexOrThrow("elbefore")) val etymology = cursor.getString(cursor.getColumnIndexOrThrow("ety")) val trans = cursor.getInt(cursor.getColumnIndexOrThrow("trans")) - Log.d(TAG, "found $esword, $enword, $elaboration, $elbefore, $etymology, $trans") + Log.d(TAG, "found $eoword, $enword, $elaboration, $elbefore, $etymology, $trans") val enmodels = LinkedList() enmodels.add(EnModel(enword, elaboration, when(elbefore) { @@ -112,7 +112,7 @@ class DatabaseHelper(private val context: Context) : else -> null })) - wordmap.put(esrow, WordModel(esword, enmodels, etymology ?: "",when(trans) { + wordmap.put(eorow, WordModel(eoword, enmodels, etymology ?: "",when(trans) { 2 -> true 1 -> false else -> null diff --git a/app/src/main/java/org/mcxa/vortaro/MainActivity.kt b/app/src/main/java/org/mcxa/vortaro/MainActivity.kt index 9349e05..f6ba7ae 100644 --- a/app/src/main/java/org/mcxa/vortaro/MainActivity.kt +++ b/app/src/main/java/org/mcxa/vortaro/MainActivity.kt @@ -37,8 +37,16 @@ class MainActivity : AppCompatActivity() { override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + val w = word_view.adapter as WordAdapter if (!s.isNullOrEmpty()) { - dbHelper?.search(s.toString(), word_view.adapter as WordAdapter) + dbHelper?.search(s.toString(), w) + } else { + w.words.beginBatchedUpdates(); + // remove items at end, to avoid unnecessary array shifting + while (w.words.size() > 0) { + w.words.removeItemAt(w.words.size() - 1); + } + w.words.endBatchedUpdates() } } diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 15022f0..ae64dc4 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -37,6 +37,7 @@ android:textSize="20sp"/> About About Senreta Vortaro - Senreta Vortaro (Offline Dictionary) is an english-esperanto dictionary app inspired by the + En: Senreta Vortaro (offline dictionary) is an English-Esperanto dictionary app inspired by the web page Tuja Vortaro. It is designed to be easy to use for beginners.\n\n - This app is open source under the Apache2 License and the data sources are freely available - under Creative Commons licenses. + + Senreta Vortaro was created by Ian Mcxa. The source code is available on + Github under the Apache2 License. The dictionary + data is licenced under Creative Commons.\n\n + + Eo: Senreta Vortaro estas angla-Esperanta vortara aplikaĵo. La dinamika retpaĝo, Tuja Vortaro, + inspiris ĝin. Senreta Vortaro estas kreita por esti facile uzata de komencantoj.\n\n + + Senreta Vortaro estas verko de Ian Mcxa. La fontkodo estas havebla ĉe + Github per la Apache2 permesilo. La vortaraj + dataoj estas permesitaj per Creative Commons. diff --git a/dictionary-src/buildDB.py b/dictionary-src/buildDB.py index cba6999..7fe151c 100755 --- a/dictionary-src/buildDB.py +++ b/dictionary-src/buildDB.py @@ -47,16 +47,16 @@ def build_espdic(conn): print('parsing espdic...') # now let's parse the file into the database for line in espdic_in: - es, en = line.strip().split(' : ') + eo, en = line.strip().split(' : ') # insert the Esperanto word - c.execute('''insert into es values (?)''', (es,)) - esrow = c.lastrowid + c.execute('''insert into eo values (?)''', (eo,)) + eorow = c.lastrowid # some entries have es : (description in English) # this case needs to be handled specially if (en.startswith('(') and en.endswith(')')): - c.execute('''insert into en values (?,?,?,?)''', (esrow, '', en, 0)) + c.execute('''insert into en values (?,?,?,?)''', (eorow, '', en, 0)) else: # regex taken from https://stackoverflow.com/questions/26633452/how-to-split-by-commas-that-are-not-within-parentheses enlist = re.split(r',\s*(?![^()]*\))', en) @@ -74,7 +74,7 @@ def build_espdic(conn): elbefore = 0 el = None - c.execute('''insert into en values (?,?,?,?)''', (esrow, enword, el, elbefore)) + c.execute('''insert into en values (?,?,?,?)''', (eorow, enword, el, elbefore)) espdic_in.close() conn.commit() @@ -113,16 +113,16 @@ def create_tables(conn): c.execute('''create table trans (verb text primary key, trans integer) without rowid''') # Esperanto words - c.execute('''create table es - (esword text)''') + c.execute('''create table eo + (eoword text)''') # English words # Note that esindx refers to the rowid in the Esperanto table # el is the elaboration that may be before or after a word, denoted by elbefore c.execute('''create table en - (esrow integer, enword text, el text, elbefore integer)''') + (eorow integer, enword text, el text, elbefore integer)''') # we index the english words because we also want to search on them c.execute('''create index enword on en (enword)''') - c.execute('''create index esrow on en (esrow)''') + c.execute('''create index eorow on en (eorow)''') # commit and close our transaction conn.commit()