Skip to content

Commit

Permalink
Merge branch 'release/v1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
shiami committed Feb 16, 2017
2 parents 812cbfa + 07bc7af commit 83e812f
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 113 deletions.
14 changes: 7 additions & 7 deletions TaigiDict/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -180,6 +181,10 @@ public boolean onQueryTextChange(String query) {
handledQueryString = Poj2TailoUtils.poj2tailo(fixedLomaji);
}

if (handledQueryString.contains(" ")) {
handledQueryString = LomajiSearchUtils.allowSpaceInsteadOfHyphen(handledQueryString);
}

doSearch(handledQueryString);

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +29,23 @@ public class TailoSearchAdapter extends RealmRecyclerViewAdapter<TlTaigiWord, Ta

private final PublishProcessor<Integer> 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;
Expand All @@ -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<TlTaigiWord> realmResults;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<TlHoagiWord> 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<TlDescription> 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<TlExampleSentence> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 83e812f

Please sign in to comment.