Fix issue with ???
.idea/gradle.xml
4 | 4 | <component name="GradleSettings"> | |
5 | 5 | <option name="linkedExternalProjectsSettings"> | |
6 | 6 | <GradleProjectSettings> | |
7 | - | <option name="testRunner" value="PLATFORM" /> | |
7 | + | <option name="testRunner" value="GRADLE" /> | |
8 | 8 | <option name="distributionType" value="DEFAULT_WRAPPED" /> | |
9 | 9 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | |
10 | 10 | <option name="modules"> | |
… | |||
14 | 14 | <option value="$PROJECT_DIR$/rubytextview" /> | |
15 | 15 | </set> | |
16 | 16 | </option> | |
17 | - | <option name="resolveModulePerSourceSet" value="false" /> | |
18 | 17 | </GradleProjectSettings> | |
19 | 18 | </option> | |
20 | 19 | </component> |
.idea/runConfigurations.xml unknown status 2
1 | - | <?xml version="1.0" encoding="UTF-8"?> | |
2 | - | <project version="4"> | |
3 | - | <component name="RunConfigurationProducerService"> | |
4 | - | <option name="ignoredProducers"> | |
5 | - | <set> | |
6 | - | <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | |
7 | - | <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | |
8 | - | <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | |
9 | - | </set> | |
10 | - | </option> | |
11 | - | </component> | |
12 | - | </project> | |
12 | > | ||
13 | 0 | > | \ No newline at end of file |
app/src/main/java/eu/lepiller/nani/result/Result.java
1 | 1 | package eu.lepiller.nani.result; | |
2 | 2 | ||
3 | + | import android.os.Build; | |
3 | 4 | import android.util.Log; | |
4 | 5 | ||
5 | 6 | import com.moji4j.MojiConverter; | |
… | |||
9 | 10 | import java.util.regex.Matcher; | |
10 | 11 | import java.util.regex.Pattern; | |
11 | 12 | ||
12 | - | import static java.lang.Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS; | |
13 | - | import static java.lang.Character.UnicodeBlock.KATAKANA; | |
13 | + | import static java.lang.Character.UnicodeBlock.*; | |
14 | 14 | ||
15 | 15 | public class Result { | |
16 | 16 | public static class Source { | |
… | |||
133 | 133 | return null; | |
134 | 134 | } | |
135 | 135 | ||
136 | + | private static boolean isKanji(char c) { | |
137 | + | Character.UnicodeBlock b = of(c); | |
138 | + | return b == CJK_UNIFIED_IDEOGRAPHS || | |
139 | + | b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || | |
140 | + | b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B || | |
141 | + | (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C) || | |
142 | + | (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D) || | |
143 | + | b == CJK_SYMBOLS_AND_PUNCTUATION; | |
144 | + | } | |
145 | + | ||
136 | 146 | public String getKanjiFurigana() { | |
137 | 147 | String txt = getKanji(); | |
138 | 148 | String reading = getReading(); | |
… | |||
142 | 152 | ArrayList<String> portions = new ArrayList<>(); | |
143 | 153 | ||
144 | 154 | StringBuilder current = new StringBuilder(); | |
145 | - | Character.UnicodeBlock b = CJK_UNIFIED_IDEOGRAPHS; | |
155 | + | boolean currentBlockIsKanji = true; | |
146 | 156 | ||
147 | 157 | MojiConverter converter = new MojiConverter(); | |
148 | 158 | for(int i=0; i<txt.length(); i++) { | |
149 | - | Character.UnicodeBlock b2 = Character.UnicodeBlock.of(txt.charAt(i)); | |
150 | - | if(b == b2) { | |
159 | + | boolean currentCharIsKanji = isKanji(txt.charAt(i)); | |
160 | + | if(currentBlockIsKanji == currentCharIsKanji) { | |
151 | 161 | // if the headwork contains katakana, convert it to hiragana to match pronunciation | |
152 | 162 | // better. | |
153 | 163 | current.append(txt.charAt(i)); | |
… | |||
158 | 168 | current = new StringBuilder(); | |
159 | 169 | current.append(txt.charAt(i)); | |
160 | 170 | } | |
161 | - | ||
162 | - | b = b2; | |
171 | + | currentBlockIsKanji = currentCharIsKanji; | |
163 | 172 | } | |
164 | 173 | String str = current.toString(); | |
165 | 174 | if(!str.isEmpty()) |