diff --git a/TaigiDict/app/build.gradle b/TaigiDict/app/build.gradle index e81cd82..1db15e9 100644 --- a/TaigiDict/app/build.gradle +++ b/TaigiDict/app/build.gradle @@ -24,8 +24,8 @@ android { applicationId "com.taccotap.taigidict" minSdkVersion 16 targetSdkVersion 25 - versionCode 2 - versionName "1.0.1" + versionCode 3 + versionName "1.0.2" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -74,11 +74,11 @@ dependencies { compile project(':taigi_dict_realm_model') // Support library - compile 'com.android.support:appcompat-v7:25.1.0' - compile 'com.android.support:design:25.1.0' - compile 'com.android.support:recyclerview-v7:25.1.0' - compile 'com.android.support:percent:25.1.0' - compile 'com.android.support:support-v4:25.1.0' + compile 'com.android.support:appcompat-v7:25.1.1' + compile 'com.android.support:design:25.1.1' + compile 'com.android.support:recyclerview-v7:25.1.1' + compile 'com.android.support:percent:25.1.1' + compile 'com.android.support:support-v4:25.1.1' // Realm compile 'com.github.eggheadgames:android-realm-asset-helper:2.0.0' diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/TaigiDictApp.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/TaigiDictApp.java index a6fc0a8..baabc65 100644 --- a/TaigiDict/app/src/main/java/com/taccotap/taigidict/TaigiDictApp.java +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/TaigiDictApp.java @@ -3,6 +3,7 @@ import android.app.Application; import com.crashlytics.android.Crashlytics; +import com.crashlytics.android.core.CrashlyticsCore; import com.eggheadgames.realmassethelper.IRealmAssetHelperStorageListener; import com.eggheadgames.realmassethelper.RealmAssetHelper; import com.eggheadgames.realmassethelper.RealmAssetHelperStatus; @@ -20,12 +21,26 @@ public class TaigiDictApp extends Application { @Override public void onCreate() { super.onCreate(); - Fabric.with(this, new Crashlytics()); + initFabric(); initRealm(); initCalligraphy(); } + private void initFabric() { + if (BuildConfig.DEBUG) { + // Set up Crashlytics, disabled for debug builds + Crashlytics crashlyticsKit = new Crashlytics.Builder() + .core(new CrashlyticsCore.Builder().disabled(true).build()) + .build(); + + // Initialize Fabric with the debug-disabled crashlytics. + Fabric.with(this, crashlyticsKit); + } else { + Fabric.with(this, new Crashlytics()); + } + } + private void initCalligraphy() { CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf") diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/TailoDictFragment.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/TailoDictFragment.java index 60183a0..984516e 100644 --- a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/TailoDictFragment.java +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/TailoDictFragment.java @@ -8,7 +8,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.ImageView; +import com.mikepenz.community_material_typeface_library.CommunityMaterial; +import com.mikepenz.iconics.IconicsDrawable; import com.taccotap.taigidict.R; import com.taccotap.taigidict.tailo.search.TailoSearchActivity; @@ -18,6 +21,12 @@ public class TailoDictFragment extends Fragment { + @BindView(R.id.descIcon1) + ImageView mDescIcon1ImageView; + + @BindView(R.id.descIcon2) + ImageView mDescIcon2ImageView; + @BindView(R.id.button_search_lmj) Button mSearchLmjButton; @@ -46,6 +55,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, final View view = inflater.inflate(R.layout.fragment_tailo_dict, container, false); ButterKnife.bind(this, view); + mDescIcon1ImageView.setImageDrawable( + new IconicsDrawable(getContext()).icon(CommunityMaterial.Icon.cmd_information_outline).color(getContext().getResources().getColor(R.color.colorPrimary)).sizeDp(18)); + mDescIcon2ImageView.setImageDrawable( + new IconicsDrawable(getContext()).icon(CommunityMaterial.Icon.cmd_information_outline).color(getContext().getResources().getColor(R.color.colorPrimary)).sizeDp(18)); + return view; } diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchActivity.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchActivity.java index 70f03a0..1068ad5 100644 --- a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchActivity.java +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchActivity.java @@ -17,6 +17,7 @@ import com.taccotap.taigidict.R; import com.taccotap.taigidict.tailo.utils.TailoConstants; import com.taccotap.taigidict.tailo.word.TailoWordActivity; +import com.taccotap.taigidict.utils.LomajiSearchUtils; import com.taccotap.taigidict.utils.LomajiUnicodeUtils; import com.taccotap.taigidict.utils.Poj2TailoUtils; import com.taccotap.taigidictmodel.tailo.TlTaigiWord; @@ -180,6 +181,10 @@ public boolean onQueryTextChange(String query) { handledQueryString = Poj2TailoUtils.poj2tailo(fixedLomaji); } + if (handledQueryString.contains(" ")) { + handledQueryString = LomajiSearchUtils.allowSpaceInsteadOfHyphen(handledQueryString); + } + doSearch(handledQueryString); return true; diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchAdapter.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchAdapter.java index 3c29c97..6d1b3ef 100644 --- a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchAdapter.java +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/search/TailoSearchAdapter.java @@ -4,10 +4,12 @@ import android.databinding.DataBindingUtil; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import com.taccotap.taigidict.R; import com.taccotap.taigidict.databinding.ListitemTailoSearchBinding; import com.taccotap.taigidict.tailo.utils.TailoConstants; +import com.taccotap.taigidict.tailo.utils.TailoDictHelper; import com.taccotap.taigidictmodel.tailo.TlTaigiWord; import io.reactivex.processors.PublishProcessor; @@ -27,6 +29,23 @@ public class TailoSearchAdapter extends RealmRecyclerViewAdapter mOnClickSubject = PublishProcessor.create(); + public class TailoSearchViewHolder extends RealmViewHolder { + public final ListitemTailoSearchBinding dataBinding; + public TextView titleTextView1; + public TextView titleContentTextView1; + public TextView titleTextView2; + public TextView titleContentTextView2; + + public TailoSearchViewHolder(ListitemTailoSearchBinding dataBinding) { + super(dataBinding.getRoot()); + this.dataBinding = dataBinding; + this.titleTextView1 = (TextView) dataBinding.getRoot().findViewById(R.id.titleTextView1); + this.titleContentTextView1 = (TextView) dataBinding.getRoot().findViewById(R.id.titleContentTextView1); + this.titleTextView2 = (TextView) dataBinding.getRoot().findViewById(R.id.titleTextView2); + this.titleContentTextView2 = (TextView) dataBinding.getRoot().findViewById(R.id.titleContentTextView2); + } + } + public TailoSearchAdapter(Context context, Realm realm) { super(context, realm.where(TlTaigiWord.class).contains("lomaji", TailoConstants.DEFAULT_QUERY_STRING).findAllAsync(), false); mRealm = realm; @@ -53,22 +72,26 @@ public void onClick(View view) { } }); - holder.dataBinding.setTaigiWord(tlTaigiWord); - holder.dataBinding.executePendingBindings(); + // [屬性] 附-外來詞表 + if (tlTaigiWord.getWordPropertyCode() == 12) { + holder.titleTextView1.setText(R.string.listitem_tailo_search_title_text_1_goalaigi); + holder.titleTextView2.setText(R.string.listitem_tailo_search_title_text_2_goalaigi); + + holder.titleContentTextView1.setText(tlTaigiWord.getHanji()); + holder.titleContentTextView2.setText(TailoDictHelper.getCombinatedHoagi(tlTaigiWord)); + } else { + holder.titleTextView1.setText(R.string.listitem_tailo_search_title_text_1_tailo); + holder.titleTextView2.setText(R.string.listitem_tailo_search_title_text_2_tailo); + + holder.dataBinding.setTaigiWord(tlTaigiWord); + holder.dataBinding.executePendingBindings(); + } } public TlTaigiWord getItem(int position) { return this.getData().get(position); } - public class TailoSearchViewHolder extends RealmViewHolder { - public final ListitemTailoSearchBinding dataBinding; - - public TailoSearchViewHolder(ListitemTailoSearchBinding dataBinding) { - super(dataBinding.getRoot()); - this.dataBinding = dataBinding; - } - } public void searchLomaji(String lomaji, boolean isSearchEquals) { final RealmResults realmResults; diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/utils/TailoDictHelper.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/utils/TailoDictHelper.java new file mode 100644 index 0000000..6b66ac0 --- /dev/null +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/utils/TailoDictHelper.java @@ -0,0 +1,95 @@ +package com.taccotap.taigidict.tailo.utils; + + +import android.text.TextUtils; + +import com.taccotap.taigidictmodel.tailo.TlDescription; +import com.taccotap.taigidictmodel.tailo.TlExampleSentence; +import com.taccotap.taigidictmodel.tailo.TlHoagiWord; +import com.taccotap.taigidictmodel.tailo.TlTaigiWord; + +import io.realm.RealmList; + +public class TailoDictHelper { + + public static String getCombinatedHoagi(TlTaigiWord taigiWord) { + final RealmList hoagiWords = taigiWord.getHoagiWords(); + final int count = hoagiWords.size(); + + if (count == 0) { + return ""; + } + + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < count; i++) { + final TlHoagiWord hoagiWord = hoagiWords.get(i); + + stringBuilder.append(hoagiWord.getHoagiWord()); + + if (i < count - 1) { + stringBuilder.append("、"); + } + } + + return stringBuilder.toString(); + } + + public static String getCombinatedDescription(TlTaigiWord taigiWord) { + final RealmList descriptions = taigiWord.getDescriptions(); + final int descriptionsCount = descriptions.size(); + + if (descriptionsCount == 0) { + return ""; + } + + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 1; i <= descriptionsCount; i++) { + final TlDescription description = descriptions.get(i - 1); + + if (descriptionsCount > 1) { + stringBuilder.append(i + "."); + } + + final String partOfSpeech = description.getPartOfSpeech(); + if (!TextUtils.isEmpty(partOfSpeech)) { + stringBuilder.append("【" + partOfSpeech + "】"); + } else { + if (descriptionsCount > 1) { + stringBuilder.append(" "); + } + } + + stringBuilder.append(description.getDescription()); + + final RealmList exampleSentences = description.getExampleSentences(); + final int exampleSentencesCount = exampleSentences.size(); + for (int j = 0; j < exampleSentencesCount; j++) { + final TlExampleSentence currentExampleSentence = exampleSentences.get(j); + + if (j == 0) { + stringBuilder.append("例:"); + } + + stringBuilder.append(currentExampleSentence.getExampleSentenceLomaji()); + stringBuilder.append(" "); + stringBuilder.append(currentExampleSentence.getExampleSentenceHanji()); + + if (!TextUtils.isEmpty(currentExampleSentence.getExampleSentenceHoagi())) { + stringBuilder.append(" ("); + stringBuilder.append(currentExampleSentence.getExampleSentenceHoagi()); + stringBuilder.append(")"); + } + + if (j < exampleSentencesCount - 1) { + stringBuilder.append(";"); + } + } + + if (i < descriptionsCount) { + stringBuilder.append(System.getProperty("line.separator")); + } + } + + return stringBuilder.toString(); + } +} diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/utils/TailoTaigiWordAudioUrlHelper.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/utils/TailoTaigiWordAudioUrlHelper.java index f1d111e..110eb02 100644 --- a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/utils/TailoTaigiWordAudioUrlHelper.java +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/utils/TailoTaigiWordAudioUrlHelper.java @@ -17,7 +17,7 @@ public static String getTaigiAudioUrl(int mainCode) { return stringBuilder.toString(); } - public static String getTaigiWailaiAudioUrl(int mainCode) { + public static String getTaigiGoaLaiAudioUrl(int mainCode) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(TailoConstants.URL_AUDIO_FILE_PREFIX + TailoConstants.URL_NODE_WAILAI); diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/word/TailoWordActivity.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/word/TailoWordActivity.java index ea7a34f..e654725 100644 --- a/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/word/TailoWordActivity.java +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/tailo/word/TailoWordActivity.java @@ -7,7 +7,6 @@ import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; -import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -16,10 +15,10 @@ import com.taccotap.taigidict.R; import com.taccotap.taigidict.databinding.ActivityTailoWordBinding; +import com.taccotap.taigidict.tailo.utils.TailoDictHelper; import com.taccotap.taigidict.tailo.utils.TailoTaigiWordAudioUrlHelper; import com.taccotap.taigidict.utils.NetworkUtils; import com.taccotap.taigidictmodel.tailo.TlDescription; -import com.taccotap.taigidictmodel.tailo.TlExampleSentence; import com.taccotap.taigidictmodel.tailo.TlTaigiWord; import butterknife.BindView; @@ -33,6 +32,18 @@ public class TailoWordActivity extends AppCompatActivity { private static final String TAG = TailoWordActivity.class.getSimpleName(); + @BindView(R.id.titleTextView1) + TextView mTitleTextView1; + + @BindView(R.id.titleContentTextView1) + TextView mTitleContentTextView1; + + @BindView(R.id.titleTextView2) + TextView mTitleTextView2; + + @BindView(R.id.titleContentTextView2) + TextView mTitleContentTextView2; + @BindView(R.id.descriptionLayout) ViewGroup mDescriptionLayout; @@ -42,6 +53,9 @@ public class TailoWordActivity extends AppCompatActivity { @BindView(R.id.wordPropertyLayout) ViewGroup mWordPropertyLayout; + @BindView(R.id.wordPropertyTextView) + TextView mWordPropertyTextView; + @BindView(R.id.fab) FloatingActionButton mFloatingActionButton; @@ -88,12 +102,22 @@ private void handleCurrentWord() { public void onChange(RealmModel element) { Log.i(TAG, "lomaji=" + mTaigiWord.getLomaji()); - // bind word - mBinding.setTaigiWord(mTaigiWord); - + // [屬性] 附-外來詞表 if (mTaigiWord.getWordPropertyCode() == 12) { - mVoiceUrl = TailoTaigiWordAudioUrlHelper.getTaigiWailaiAudioUrl(mMainCode); + // bind 外來語 + mTitleTextView1.setText(R.string.activity_tailo_word_title_text_1_goalaigi); + mTitleTextView2.setText(R.string.activity_tailo_word_title_text_2_goalaigi); + mTitleContentTextView1.setText(mTaigiWord.getHanji()); + mTitleContentTextView2.setText(TailoDictHelper.getCombinatedHoagi(mTaigiWord)); + mWordPropertyTextView.setText(mTaigiWord.getWordPropertyText()); + + // bind audio link + mVoiceUrl = TailoTaigiWordAudioUrlHelper.getTaigiGoaLaiAudioUrl(mMainCode); } else { + // bind word + mBinding.setTaigiWord(mTaigiWord); + + // bind audio link mVoiceUrl = TailoTaigiWordAudioUrlHelper.getTaigiAudioUrl(mMainCode); } @@ -106,55 +130,8 @@ public void onChange(RealmModel element) { final RealmList descriptions = mTaigiWord.getDescriptions(); final int descriptionsCount = descriptions.size(); if (descriptionsCount > 0) { - StringBuilder stringBuilder = new StringBuilder(); - for (int i = 1; i <= descriptionsCount; i++) { - final TlDescription description = descriptions.get(i - 1); - - if (descriptionsCount > 1) { - stringBuilder.append(i + "."); - } - - final String partOfSpeech = description.getPartOfSpeech(); - if (!TextUtils.isEmpty(partOfSpeech)) { - stringBuilder.append("【" + partOfSpeech + "】"); - } else { - if (descriptionsCount > 1) { - stringBuilder.append(" "); - } - } - - stringBuilder.append(description.getDescription()); - - final RealmList exampleSentences = description.getExampleSentences(); - final int exampleSentencesCount = exampleSentences.size(); - for (int j = 0; j < exampleSentencesCount; j++) { - final TlExampleSentence currentExampleSentence = exampleSentences.get(j); - - if (j == 0) { - stringBuilder.append("例:"); - } - - stringBuilder.append(currentExampleSentence.getExampleSentenceLomaji()); - stringBuilder.append(" "); - stringBuilder.append(currentExampleSentence.getExampleSentenceHanji()); - - if (!TextUtils.isEmpty(currentExampleSentence.getExampleSentenceHoagi())) { - stringBuilder.append(" ("); - stringBuilder.append(currentExampleSentence.getExampleSentenceHoagi()); - stringBuilder.append(")"); - } - - if (j < exampleSentencesCount - 1) { - stringBuilder.append(";"); - } - } - - if (i < descriptionsCount) { - stringBuilder.append(System.getProperty("line.separator")); - } - } - - mDescriptionTextView.setText(stringBuilder.toString()); + final String description = TailoDictHelper.getCombinatedDescription(mTaigiWord); + mDescriptionTextView.setText(description); } else { mDescriptionLayout.setVisibility(View.GONE); } diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/utils/LomajiSearchUtils.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/utils/LomajiSearchUtils.java new file mode 100644 index 0000000..5858ec2 --- /dev/null +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/utils/LomajiSearchUtils.java @@ -0,0 +1,9 @@ +package com.taccotap.taigidict.utils; + + +public class LomajiSearchUtils { + + public static final String allowSpaceInsteadOfHyphen(String queryString) { + return queryString.trim().replaceAll(" +", " ").replaceAll(" ", "-"); + } +} diff --git a/TaigiDict/app/src/main/java/com/taccotap/taigidict/utils/Poj2TailoUtils.java b/TaigiDict/app/src/main/java/com/taccotap/taigidict/utils/Poj2TailoUtils.java index 9541236..e341dcc 100644 --- a/TaigiDict/app/src/main/java/com/taccotap/taigidict/utils/Poj2TailoUtils.java +++ b/TaigiDict/app/src/main/java/com/taccotap/taigidict/utils/Poj2TailoUtils.java @@ -16,6 +16,14 @@ public static final String poj2tailo(String poj) { .replaceAll("E\u030dk", "I\u030dk") // E̍k -> I̍k .replaceAll("eng", "ing") // eng -> ing .replaceAll("Eng", "Ing") // Eng -> Ing + .replaceAll("\u00e9ng", "\u00edng") // éng -> íng + .replaceAll("\u00c9ng", "\u00cdng") // Éng -> Íng + .replaceAll("\u00e8ng", "\u00ecng") // èng -> ìng + .replaceAll("\u00c8ng", "\u00ccng") // Èng -> Ìng + .replaceAll("\u00eang", "\u00eeng") // êng -> îng + .replaceAll("\u00cang", "\u00ceng") // Êng -> Îng + .replaceAll("\u0113ng", "\u012bng") // ēng -> īng + .replaceAll("\u0102ng", "\u012ang") // Ēng -> Īng .replaceAll("e\u030dng", "i\u030dng") // e̍ng -> i̍ng .replaceAll("E\u030dng", "I\u030dng"); // E̍ng -> I̍ng return tailo; diff --git a/TaigiDict/app/src/main/res/layout/activity_tailo_word.xml b/TaigiDict/app/src/main/res/layout/activity_tailo_word.xml index f328c42..8d6ef2c 100644 --- a/TaigiDict/app/src/main/res/layout/activity_tailo_word.xml +++ b/TaigiDict/app/src/main/res/layout/activity_tailo_word.xml @@ -53,22 +53,26 @@ android:paddingTop="30dp"> diff --git a/TaigiDict/app/src/main/res/layout/fragment_tailo_dict.xml b/TaigiDict/app/src/main/res/layout/fragment_tailo_dict.xml index c731e42..bec290c 100644 --- a/TaigiDict/app/src/main/res/layout/fragment_tailo_dict.xml +++ b/TaigiDict/app/src/main/res/layout/fragment_tailo_dict.xml @@ -16,15 +16,55 @@ + android:layout_height="wrap_content" + android:orientation="vertical"> - + android:gravity="top" + android:orientation="horizontal"> + + + + + + + + + + + + + diff --git a/TaigiDict/app/src/main/res/layout/listitem_tailo_search.xml b/TaigiDict/app/src/main/res/layout/listitem_tailo_search.xml index 1109b13..ceadf9f 100644 --- a/TaigiDict/app/src/main/res/layout/listitem_tailo_search.xml +++ b/TaigiDict/app/src/main/res/layout/listitem_tailo_search.xml @@ -40,17 +40,19 @@ android:orientation="horizontal"> diff --git a/TaigiDict/app/src/main/res/values/strings.xml b/TaigiDict/app/src/main/res/values/strings.xml index 916bf6f..498aed8 100644 --- a/TaigiDict/app/src/main/res/values/strings.xml +++ b/TaigiDict/app/src/main/res/values/strings.xml @@ -9,6 +9,8 @@ 關於 授權資訊 + 若是欲用「羅馬字」來揣,會使輸入「臺羅」抑是「白話字」,請用羅馬字 ê 聲調符號。 + 若是欲聽看覓按怎唸,需要上網才會使聽。 請選一種揣 ê 方式: 臺語羅馬字 對應ê華語漢字 @@ -21,9 +23,16 @@ 揣差不多ê 揣攏相仝ê + 臺羅 + 漢字 + 外來語發音 + 對應 ê 華語 語音ê功能需要上網才會使聽。 真歹勢,這無法度聽。 + 發音 + 華語 + 多謝你 ê 使用,若是有啥物問題,請你對下跤 ê 方式來和我反應。\n\n若是你會使來幫贊,不管是建議 kap 指教,抑是提供其他 ê 辭典資料,想欲鬥出力出錢,攏誠歡迎,請和我連絡。 建議 kap 指教 需要你 ê 幫贊 diff --git a/TaigiDict/taigi_dict_parser_app/build.gradle b/TaigiDict/taigi_dict_parser_app/build.gradle index 02aa8cb..177464b 100644 --- a/TaigiDict/taigi_dict_parser_app/build.gradle +++ b/TaigiDict/taigi_dict_parser_app/build.gradle @@ -6,15 +6,21 @@ android { buildToolsVersion "25.0.2" defaultConfig { - minSdkVersion 16 + minSdkVersion 23 targetSdkVersion 25 - versionCode 1 - versionName "1.0.0" + versionCode 2 + versionName "1.0.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { + debug { + // Only use this flag on builds you don't proguard or upload to beta-by-crashlytics + ext.alwaysUpdateBuildId = false + // Disable fabric build ID generation for debug builds + ext.enableCrashlytics = false + } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' @@ -27,7 +33,7 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:appcompat-v7:25.1.1' testCompile 'junit:junit:4.12' compile project(':taigi_dict_realm_model') diff --git a/TaigiDict/taigi_dict_parser_app/src/main/java/com/taccotap/taigidictparser/tailo/parser/TlParseIntentService.java b/TaigiDict/taigi_dict_parser_app/src/main/java/com/taccotap/taigidictparser/tailo/parser/TlParseIntentService.java index 11f1009..506838e 100644 --- a/TaigiDict/taigi_dict_parser_app/src/main/java/com/taccotap/taigidictparser/tailo/parser/TlParseIntentService.java +++ b/TaigiDict/taigi_dict_parser_app/src/main/java/com/taccotap/taigidictparser/tailo/parser/TlParseIntentService.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.util.Log; +import android.util.SparseArray; import com.taccotap.taigidictmodel.tailo.TlAnotherPronounce; import com.taccotap.taigidictmodel.tailo.TlAntonym; @@ -22,7 +23,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import io.realm.Realm; @@ -68,10 +68,10 @@ private void parseDict() { parseDictDescription(); parseDictDescriptionPartOfSpeech(); - parseAnotherPronounce(); - parseExampleSentence(); + parseAnotherPronounce(); + parseThesaurus(); parseAnyonym(); @@ -196,18 +196,18 @@ public void execute(Realm realm) { }); // add to TaigiWord - final HashMap wordPropertyHashMap = new HashMap<>(); + final SparseArray wordPropertySparseArray = new SparseArray<>(); for (final TlTaigiWordProperty wordProperty : taigiWordProperties) { - wordPropertyHashMap.put(wordProperty.getPropertyCode(), wordProperty.getPropertyText()); + wordPropertySparseArray.put(wordProperty.getPropertyCode(), wordProperty.getPropertyText()); } mRealm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { final RealmResults taigiWords = mRealm.where(TlTaigiWord.class).findAll(); for (final TlTaigiWord taigiWord : taigiWords) { - final String wordPropertyText = wordPropertyHashMap.get(taigiWord.getWordPropertyCode()); + final String wordPropertyText = wordPropertySparseArray.get(taigiWord.getWordPropertyCode()); if (wordPropertyText == null) { - Log.e(TAG, "TlTaigiWord for TlTaigiWordProperty's wordPropertyText = " + wordPropertyText + " not found."); + Log.e(TAG, "TlTaigiWord for TlTaigiWordProperty's wordPropertyText with propertyCode = " + taigiWord.getWordPropertyCode() + " not found."); continue; } taigiWord.setWordPropertyText(wordPropertyText); @@ -276,16 +276,16 @@ public void execute(Realm realm) { // add to TaigiWord final RealmResults taigiWords = mRealm.where(TlTaigiWord.class).findAll(); - final HashMap taigiWordsHashMap = new HashMap<>(); + final SparseArray taigiWordSparseArray = new SparseArray<>(); for (final TlTaigiWord taigiWord : taigiWords) { - taigiWordsHashMap.put(taigiWord.getMainCode(), taigiWord); + taigiWordSparseArray.put(taigiWord.getMainCode(), taigiWord); } mRealm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { for (final TlHoagiWord hoagiWord : hoagiWords) { final int mainCode = hoagiWord.getMainCode(); - final TlTaigiWord foundTaigiWord = taigiWordsHashMap.get(mainCode); + final TlTaigiWord foundTaigiWord = taigiWordSparseArray.get(mainCode); if (foundTaigiWord == null) { Log.e(TAG, "TlTaigiWord for TlHoagiWord's maincode = " + mainCode + " not found."); continue; @@ -364,16 +364,16 @@ public void execute(Realm realm) { // add to TaigiWord final RealmResults taigiWords = mRealm.where(TlTaigiWord.class).findAll(); - final HashMap taigiWordsHashMap = new HashMap<>(); + final SparseArray taigiWordSparseArray = new SparseArray<>(); for (final TlTaigiWord taigiWord : taigiWords) { - taigiWordsHashMap.put(taigiWord.getMainCode(), taigiWord); + taigiWordSparseArray.put(taigiWord.getMainCode(), taigiWord); } mRealm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { for (final TlDescription description : descriptions) { final int mainCode = description.getMainCode(); - final TlTaigiWord foundTaigiWord = taigiWordsHashMap.get(mainCode); + final TlTaigiWord foundTaigiWord = taigiWordSparseArray.get(mainCode); if (foundTaigiWord == null) { Log.e(TAG, "TlTaigiWord for TlDescription's maincode = " + mainCode + " not found."); continue; @@ -387,6 +387,7 @@ public void execute(Realm realm) { Log.d(TAG, "finish: parseDictDescription()"); } + // 詞性 private void parseDictDescriptionPartOfSpeech() { Log.d(TAG, "start: parseDictDescriptionPartOfSpeech()"); @@ -439,18 +440,18 @@ public void execute(Realm realm) { }); // add to TlDescription - final HashMap partOfSpeechHashMap = new HashMap<>(); + final SparseArray partOfSpeechSparseArray = new SparseArray<>(); for (final TlDescriptionPartOfSpeech partOfSpeech : descriptionPartOfSpeeches) { - partOfSpeechHashMap.put(partOfSpeech.getPartOfSpeechCode(), partOfSpeech.getPartOfSpeechText()); + partOfSpeechSparseArray.put(partOfSpeech.getPartOfSpeechCode(), partOfSpeech.getPartOfSpeechText()); } mRealm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { final RealmResults descriptions = mRealm.where(TlDescription.class).findAll(); for (final TlDescription description : descriptions) { - final String partOfSpeechText = partOfSpeechHashMap.get(description.getPartOfSpeechCode()); + final String partOfSpeechText = partOfSpeechSparseArray.get(description.getPartOfSpeechCode()); if (partOfSpeechText == null) { - Log.e(TAG, "TlDescription for TlDescriptionPartOfSpeech's partOfSpeechText = " + partOfSpeechText + " not found."); + Log.e(TAG, "TlDescription for TlDescriptionPartOfSpeech's partOfSpeechText with PartOfSpeechCode = " + description.getPartOfSpeechCode() + " not found."); continue; } description.setPartOfSpeech(partOfSpeechText); @@ -592,21 +593,21 @@ public void execute(Realm realm) { // add to TlDescription final RealmResults taigiWords = mRealm.where(TlTaigiWord.class).findAll(); - final HashMap taigiWordsHashMap = new HashMap<>(); + final SparseArray taigiWordSparseArray = new SparseArray<>(); for (final TlTaigiWord taigiWord : taigiWords) { - taigiWordsHashMap.put(taigiWord.getMainCode(), taigiWord); + taigiWordSparseArray.put(taigiWord.getMainCode(), taigiWord); } final RealmResults descriptions = mRealm.where(TlDescription.class).findAll(); - final HashMap descriptionHashMap = new HashMap<>(); + final SparseArray descriptionSparseArray = new SparseArray<>(); for (final TlDescription description : descriptions) { - descriptionHashMap.put(description.getMainCode(), description); + descriptionSparseArray.put(description.getMainCode(), description); } mRealm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { for (final TlExampleSentence currentExampleSentence : exampleSentences) { final int mainCode = currentExampleSentence.getMainCode(); - final TlTaigiWord foundTaigiWord = taigiWordsHashMap.get(mainCode); + final TlTaigiWord foundTaigiWord = taigiWordSparseArray.get(mainCode); if (foundTaigiWord == null) { Log.e(TAG, "TlTaigiWord for TlExampleSentence's maincode = " + mainCode + " not found."); continue; diff --git a/TaigiDict/taigi_dict_realm_model/build.gradle b/TaigiDict/taigi_dict_realm_model/build.gradle index 4464687..eb49692 100644 --- a/TaigiDict/taigi_dict_realm_model/build.gradle +++ b/TaigiDict/taigi_dict_realm_model/build.gradle @@ -32,6 +32,6 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:appcompat-v7:25.1.1' testCompile 'junit:junit:4.12' }