Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions app/src/main/java/org/kaqui/testactivities/TestActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -532,26 +532,44 @@ class TestActivity : BaseActivity(), TestFragmentHolder, CoroutineScope {
}

private fun showItemInDict(kanji: Kanji) {
val intent = Intent("sk.baka.aedict3.action.ACTION_SEARCH_JMDICT")
intent.putExtra("kanjis", kanji.kanji)
intent.putExtra("search_in_kanjidic", true)
intent.putExtra("showEntryDetailOnSingleResult", true)
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
val dict = applicationContext.defaultSharedPreferences.getString("external_dictionary", "aedict3")
if (dict == "aedict3") {
val intent = Intent("sk.baka.aedict3.action.ACTION_SEARCH_JMDICT")
intent.putExtra("kanjis", kanji.kanji)
intent.putExtra("search_in_kanjidic", true)
intent.putExtra("showEntryDetailOnSingleResult", true)
try {
startActivity(intent)
return
} catch (e: ActivityNotFoundException) {
// not available
}
}
if (dict == "jiten") {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://jiten.obfusk.dev/kanji?query=${kanji.kanji}")))
} else {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://jisho.org/search/${kanji.kanji}%20%23kanji")))
}
}

private fun showItemInDict(word: Word) {
val intent = Intent("sk.baka.aedict3.action.ACTION_SEARCH_JMDICT")
intent.putExtra("kanjis", word.word)
intent.putExtra("showEntryDetailOnSingleResult", true)
intent.putExtra("match_jp", "Exact")
intent.putExtra("deinflect", false)
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
val dict = applicationContext.defaultSharedPreferences.getString("external_dictionary", "aedict3")
if (dict == "aedict3") {
val intent = Intent("sk.baka.aedict3.action.ACTION_SEARCH_JMDICT")
intent.putExtra("kanjis", word.word)
intent.putExtra("showEntryDetailOnSingleResult", true)
intent.putExtra("match_jp", "Exact")
intent.putExtra("deinflect", false)
try {
startActivity(intent)
return
} catch (e: ActivityNotFoundException) {
// not available
}
}
if (dict == "jiten") {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://jiten.obfusk.dev/jmdict?query=${word.word}&exact=yes")))
} else {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://jisho.org/search/${word.word}")))
}
}
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/res/values/preferences_lists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@
<item>rtk</item>
<item>rtk6</item>
</string-array>
</resources>

<string-array name="external_dictionary_strings">
<item>@string/ext_dict_aedict3</item>
<item>@string/ext_dict_jisho</item>
<item>@string/ext_dict_jiten</item>
</string-array>
<string-array name="external_dictionary_ids">
<item>aedict3</item>
<item>jisho</item>
<item>jiten</item>
</string-array>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
<string name="failed_to_load_resource">Failed to load resource: %s</string>
<string name="keep_screen_on_summary">Keep screen lit during tests</string>
<string name="keep_screen_on">Keep screen on</string>
<string name="external_dictionary">External dictionary</string>
<string name="ext_dict_aedict3">aedict3 (non-free, requires app)</string>
<string name="ext_dict_jisho">jisho.org (opens in browser)</string>
<string name="ext_dict_jiten">jiten.obfusk.dev (open source, opens in app or browser)</string>

<string name="title_about">About Kakugo</string>
<string name="about_text"><![CDATA[
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
app:summaryOn="@string/hide_answers_on_summary"
app:title="@string/hide_answers"
app:defaultValue="true" />

<ListPreference
app:defaultValue="aedict3"
app:entries="@array/external_dictionary_strings"
app:entryValues="@array/external_dictionary_ids"
app:key="external_dictionary"
app:summary="%s"
app:title="@string/external_dictionary" />
</PreferenceCategory>

<PreferenceCategory app:title="@string/pref_cat_about">
Expand Down