Really fix issue with ???
0001-Fix-issue-with.patch unknown status 1
1 | + | From 52a2885e28309631edab2fe653c956600107394b Mon Sep 17 00:00:00 2001 | |
2 | + | From: Julien Lepiller <julien@lepiller.eu> | |
3 | + | Date: Sat, 25 Jun 2022 15:57:04 +0200 | |
4 | + | Subject: [PATCH 1/2] =?UTF-8?q?Fix=20issue=20with=20=E3=80=85?= | |
5 | + | MIME-Version: 1.0 | |
6 | + | Content-Type: text/plain; charset=UTF-8 | |
7 | + | Content-Transfer-Encoding: 8bit | |
8 | + | ||
9 | + | --- | |
10 | + | .idea/gradle.xml | 3 +-- | |
11 | + | .idea/runConfigurations.xml | 12 ---------- | |
12 | + | .../java/eu/lepiller/nani/result/Result.java | 23 +++++++++++++------ | |
13 | + | 3 files changed, 17 insertions(+), 21 deletions(-) | |
14 | + | delete mode 100644 .idea/runConfigurations.xml | |
15 | + | ||
16 | + | diff --git a/.idea/gradle.xml b/.idea/gradle.xml | |
17 | + | index 91df564..dffceeb 100644 | |
18 | + | --- a/.idea/gradle.xml | |
19 | + | +++ b/.idea/gradle.xml | |
20 | + | @@ -4,7 +4,7 @@ | |
21 | + | <component name="GradleSettings"> | |
22 | + | <option name="linkedExternalProjectsSettings"> | |
23 | + | <GradleProjectSettings> | |
24 | + | - <option name="testRunner" value="PLATFORM" /> | |
25 | + | + <option name="testRunner" value="GRADLE" /> | |
26 | + | <option name="distributionType" value="DEFAULT_WRAPPED" /> | |
27 | + | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | |
28 | + | <option name="modules"> | |
29 | + | @@ -14,7 +14,6 @@ | |
30 | + | <option value="$PROJECT_DIR$/rubytextview" /> | |
31 | + | </set> | |
32 | + | </option> | |
33 | + | - <option name="resolveModulePerSourceSet" value="false" /> | |
34 | + | </GradleProjectSettings> | |
35 | + | </option> | |
36 | + | </component> | |
37 | + | diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml | |
38 | + | deleted file mode 100644 | |
39 | + | index 7f68460..0000000 | |
40 | + | --- a/.idea/runConfigurations.xml | |
41 | + | +++ /dev/null | |
42 | + | @@ -1,12 +0,0 @@ | |
43 | + | -<?xml version="1.0" encoding="UTF-8"?> | |
44 | + | -<project version="4"> | |
45 | + | - <component name="RunConfigurationProducerService"> | |
46 | + | - <option name="ignoredProducers"> | |
47 | + | - <set> | |
48 | + | - <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | |
49 | + | - <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | |
50 | + | - <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | |
51 | + | - </set> | |
52 | + | - </option> | |
53 | + | - </component> | |
54 | + | -</project> | |
55 | + | \ No newline at end of file | |
56 | + | diff --git a/app/src/main/java/eu/lepiller/nani/result/Result.java b/app/src/main/java/eu/lepiller/nani/result/Result.java | |
57 | + | index ed1cfb5..ff7e87c 100644 | |
58 | + | --- a/app/src/main/java/eu/lepiller/nani/result/Result.java | |
59 | + | +++ b/app/src/main/java/eu/lepiller/nani/result/Result.java | |
60 | + | @@ -1,5 +1,6 @@ | |
61 | + | package eu.lepiller.nani.result; | |
62 | + | ||
63 | + | +import android.os.Build; | |
64 | + | import android.util.Log; | |
65 | + | ||
66 | + | import com.moji4j.MojiConverter; | |
67 | + | @@ -9,8 +10,7 @@ import java.util.List; | |
68 | + | import java.util.regex.Matcher; | |
69 | + | import java.util.regex.Pattern; | |
70 | + | ||
71 | + | -import static java.lang.Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS; | |
72 | + | -import static java.lang.Character.UnicodeBlock.KATAKANA; | |
73 | + | +import static java.lang.Character.UnicodeBlock.*; | |
74 | + | ||
75 | + | public class Result { | |
76 | + | public static class Source { | |
77 | + | @@ -133,6 +133,16 @@ public class Result { | |
78 | + | return null; | |
79 | + | } | |
80 | + | ||
81 | + | + private static boolean isKanji(char c) { | |
82 | + | + Character.UnicodeBlock b = of(c); | |
83 | + | + return b == CJK_UNIFIED_IDEOGRAPHS || | |
84 | + | + b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || | |
85 | + | + b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B || | |
86 | + | + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C) || | |
87 | + | + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D) || | |
88 | + | + b == CJK_SYMBOLS_AND_PUNCTUATION; | |
89 | + | + } | |
90 | + | + | |
91 | + | public String getKanjiFurigana() { | |
92 | + | String txt = getKanji(); | |
93 | + | String reading = getReading(); | |
94 | + | @@ -142,12 +152,12 @@ public class Result { | |
95 | + | ArrayList<String> portions = new ArrayList<>(); | |
96 | + | ||
97 | + | StringBuilder current = new StringBuilder(); | |
98 | + | - Character.UnicodeBlock b = CJK_UNIFIED_IDEOGRAPHS; | |
99 | + | + boolean currentBlockIsKanji = true; | |
100 | + | ||
101 | + | MojiConverter converter = new MojiConverter(); | |
102 | + | for(int i=0; i<txt.length(); i++) { | |
103 | + | - Character.UnicodeBlock b2 = Character.UnicodeBlock.of(txt.charAt(i)); | |
104 | + | - if(b == b2) { | |
105 | + | + boolean currentCharIsKanji = isKanji(txt.charAt(i)); | |
106 | + | + if(currentBlockIsKanji == currentCharIsKanji) { | |
107 | + | // if the headwork contains katakana, convert it to hiragana to match pronunciation | |
108 | + | // better. | |
109 | + | current.append(txt.charAt(i)); | |
110 | + | @@ -158,8 +168,7 @@ public class Result { | |
111 | + | current = new StringBuilder(); | |
112 | + | current.append(txt.charAt(i)); | |
113 | + | } | |
114 | + | - | |
115 | + | - b = b2; | |
116 | + | + currentBlockIsKanji = currentCharIsKanji; | |
117 | + | } | |
118 | + | String str = current.toString(); | |
119 | + | if(!str.isEmpty()) | |
120 | + | -- | |
121 | + | 2.36.1 | |
122 | + |
0002-Revert-Fix-issue-with.patch unknown status 1
1 | + | From 578597e322002ae1d9fb2cd649c1d57950c8d5e2 Mon Sep 17 00:00:00 2001 | |
2 | + | From: Julien Lepiller <julien@lepiller.eu> | |
3 | + | Date: Sat, 25 Jun 2022 16:06:16 +0200 | |
4 | + | Subject: [PATCH 2/2] =?UTF-8?q?Revert=20"Fix=20issue=20with=20=E3=80=85"?= | |
5 | + | MIME-Version: 1.0 | |
6 | + | Content-Type: text/plain; charset=UTF-8 | |
7 | + | Content-Transfer-Encoding: 8bit | |
8 | + | ||
9 | + | This reverts commit 52a2885e28309631edab2fe653c956600107394b. | |
10 | + | --- | |
11 | + | .idea/gradle.xml | 3 ++- | |
12 | + | .idea/runConfigurations.xml | 12 ++++++++++ | |
13 | + | .../java/eu/lepiller/nani/result/Result.java | 23 ++++++------------- | |
14 | + | 3 files changed, 21 insertions(+), 17 deletions(-) | |
15 | + | create mode 100644 .idea/runConfigurations.xml | |
16 | + | ||
17 | + | diff --git a/.idea/gradle.xml b/.idea/gradle.xml | |
18 | + | index dffceeb..91df564 100644 | |
19 | + | --- a/.idea/gradle.xml | |
20 | + | +++ b/.idea/gradle.xml | |
21 | + | @@ -4,7 +4,7 @@ | |
22 | + | <component name="GradleSettings"> | |
23 | + | <option name="linkedExternalProjectsSettings"> | |
24 | + | <GradleProjectSettings> | |
25 | + | - <option name="testRunner" value="GRADLE" /> | |
26 | + | + <option name="testRunner" value="PLATFORM" /> | |
27 | + | <option name="distributionType" value="DEFAULT_WRAPPED" /> | |
28 | + | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | |
29 | + | <option name="modules"> | |
30 | + | @@ -14,6 +14,7 @@ | |
31 | + | <option value="$PROJECT_DIR$/rubytextview" /> | |
32 | + | </set> | |
33 | + | </option> | |
34 | + | + <option name="resolveModulePerSourceSet" value="false" /> | |
35 | + | </GradleProjectSettings> | |
36 | + | </option> | |
37 | + | </component> | |
38 | + | diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml | |
39 | + | new file mode 100644 | |
40 | + | index 0000000..7f68460 | |
41 | + | --- /dev/null | |
42 | + | +++ b/.idea/runConfigurations.xml | |
43 | + | @@ -0,0 +1,12 @@ | |
44 | + | +<?xml version="1.0" encoding="UTF-8"?> | |
45 | + | +<project version="4"> | |
46 | + | + <component name="RunConfigurationProducerService"> | |
47 | + | + <option name="ignoredProducers"> | |
48 | + | + <set> | |
49 | + | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | |
50 | + | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | |
51 | + | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | |
52 | + | + </set> | |
53 | + | + </option> | |
54 | + | + </component> | |
55 | + | +</project> | |
56 | + | \ No newline at end of file | |
57 | + | diff --git a/app/src/main/java/eu/lepiller/nani/result/Result.java b/app/src/main/java/eu/lepiller/nani/result/Result.java | |
58 | + | index ff7e87c..ed1cfb5 100644 | |
59 | + | --- a/app/src/main/java/eu/lepiller/nani/result/Result.java | |
60 | + | +++ b/app/src/main/java/eu/lepiller/nani/result/Result.java | |
61 | + | @@ -1,6 +1,5 @@ | |
62 | + | package eu.lepiller.nani.result; | |
63 | + | ||
64 | + | -import android.os.Build; | |
65 | + | import android.util.Log; | |
66 | + | ||
67 | + | import com.moji4j.MojiConverter; | |
68 | + | @@ -10,7 +9,8 @@ import java.util.List; | |
69 | + | import java.util.regex.Matcher; | |
70 | + | import java.util.regex.Pattern; | |
71 | + | ||
72 | + | -import static java.lang.Character.UnicodeBlock.*; | |
73 | + | +import static java.lang.Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS; | |
74 | + | +import static java.lang.Character.UnicodeBlock.KATAKANA; | |
75 | + | ||
76 | + | public class Result { | |
77 | + | public static class Source { | |
78 | + | @@ -133,16 +133,6 @@ public class Result { | |
79 | + | return null; | |
80 | + | } | |
81 | + | ||
82 | + | - private static boolean isKanji(char c) { | |
83 | + | - Character.UnicodeBlock b = of(c); | |
84 | + | - return b == CJK_UNIFIED_IDEOGRAPHS || | |
85 | + | - b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || | |
86 | + | - b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B || | |
87 | + | - (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C) || | |
88 | + | - (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && b == CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D) || | |
89 | + | - b == CJK_SYMBOLS_AND_PUNCTUATION; | |
90 | + | - } | |
91 | + | - | |
92 | + | public String getKanjiFurigana() { | |
93 | + | String txt = getKanji(); | |
94 | + | String reading = getReading(); | |
95 | + | @@ -152,12 +142,12 @@ public class Result { | |
96 | + | ArrayList<String> portions = new ArrayList<>(); | |
97 | + | ||
98 | + | StringBuilder current = new StringBuilder(); | |
99 | + | - boolean currentBlockIsKanji = true; | |
100 | + | + Character.UnicodeBlock b = CJK_UNIFIED_IDEOGRAPHS; | |
101 | + | ||
102 | + | MojiConverter converter = new MojiConverter(); | |
103 | + | for(int i=0; i<txt.length(); i++) { | |
104 | + | - boolean currentCharIsKanji = isKanji(txt.charAt(i)); | |
105 | + | - if(currentBlockIsKanji == currentCharIsKanji) { | |
106 | + | + Character.UnicodeBlock b2 = Character.UnicodeBlock.of(txt.charAt(i)); | |
107 | + | + if(b == b2) { | |
108 | + | // if the headwork contains katakana, convert it to hiragana to match pronunciation | |
109 | + | // better. | |
110 | + | current.append(txt.charAt(i)); | |
111 | + | @@ -168,7 +158,8 @@ public class Result { | |
112 | + | current = new StringBuilder(); | |
113 | + | current.append(txt.charAt(i)); | |
114 | + | } | |
115 | + | - currentBlockIsKanji = currentCharIsKanji; | |
116 | + | + | |
117 | + | + b = b2; | |
118 | + | } | |
119 | + | String str = current.toString(); | |
120 | + | if(!str.isEmpty()) | |
121 | + | -- | |
122 | + | 2.36.1 | |
123 | + |
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 = Character.UnicodeBlock.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 | + | ||
146 | + | ||
136 | 147 | public String getKanjiFurigana() { | |
137 | 148 | String txt = getKanji(); | |
138 | 149 | String reading = getReading(); | |
… | |||
168 | 179 | // Create a regexp to match kanji places | |
169 | 180 | current = new StringBuilder(); | |
170 | 181 | current.append("^"); | |
182 | + | boolean wasKanji = false; | |
171 | 183 | for(String s: portions) { | |
172 | - | if(Character.UnicodeBlock.of(s.charAt(0)) == CJK_UNIFIED_IDEOGRAPHS) { | |
173 | - | current.append("(.*)"); | |
184 | + | if(isKanji(s.charAt(0))) { | |
185 | + | if(!wasKanji) | |
186 | + | current.append("(.*)"); | |
187 | + | wasKanji = true; | |
174 | 188 | } else { | |
175 | 189 | for(Character c: s.toCharArray()) { | |
176 | 190 | if(Character.UnicodeBlock.of(c) == KATAKANA) { | |
… | |||
182 | 196 | current.append(c); | |
183 | 197 | } | |
184 | 198 | } | |
199 | + | wasKanji = false; | |
185 | 200 | } | |
186 | 201 | } | |
187 | 202 | current.append("$"); | |
… | |||
202 | 217 | ||
203 | 218 | current = new StringBuilder(); | |
204 | 219 | int group = 1; | |
220 | + | wasKanji = false; | |
205 | 221 | for(String s: portions) { | |
206 | - | if(Character.UnicodeBlock.of(s.charAt(0)) == CJK_UNIFIED_IDEOGRAPHS) { | |
222 | + | if(isKanji(s.charAt(0))) { | |
207 | 223 | current.append(s); | |
208 | - | current.append("|"); | |
209 | - | current.append(m.group(group)); | |
210 | - | current.append(" "); | |
211 | - | group++; | |
224 | + | wasKanji = true; | |
212 | 225 | } else { | |
226 | + | if(wasKanji) { | |
227 | + | current.append("|"); | |
228 | + | current.append(m.group(group)); | |
229 | + | current.append(" "); | |
230 | + | group++; | |
231 | + | } | |
213 | 232 | current.append(s); | |
214 | 233 | current.append(" "); | |
234 | + | wasKanji = false; | |
215 | 235 | } | |
216 | 236 | } | |
237 | + | if(wasKanji) { | |
238 | + | current.append("|"); | |
239 | + | current.append(m.group(group)); | |
240 | + | current.append(" "); | |
241 | + | } | |
217 | 242 | Log.v("RESULT", "Finaly: " + current); | |
218 | 243 | return current.toString(); | |
219 | 244 | } |