0002-Revert-Fix-issue-with.patch
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 | |
124 |