aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-12-07 22:27:26 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-12-07 22:30:04 +0900
commitdac257ac3f5541d968e735968670eb46a813cf72 (patch)
tree9b6bc91f3f2daf50eac0b5326138d42e424b58e4
parente39d0560209380fa2aaf7ac7cc3aa9bc0a5ea0e6 (diff)
downloadSmileEssence-dac257ac3f5541d968e735968670eb46a813cf72.tar.gz
bye-byte morse
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/util/Morse.java108
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java10
-rw-r--r--app/src/main/res/values/keys.xml1
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/setting.xml4
5 files changed, 1 insertions, 123 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/util/Morse.java b/app/src/main/java/net/lacolaco/smileessence/util/Morse.java
deleted file mode 100644
index 3c4f63a2..00000000
--- a/app/src/main/java/net/lacolaco/smileessence/util/Morse.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2012-2014 lacolaco.net
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package net.lacolaco.smileessence.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class Morse {
-
- // ------------------------------ FIELDS ------------------------------
-
- private static final HashMap<String, String> mcJa;
- private static final Pattern morsePattern = Pattern.compile("[-・]+");
-
- // -------------------------- STATIC METHODS --------------------------
-
- /**
- * 与えられた文字列がモールス文を含むかどうかを返す
- *
- * @param mc 判定する文字列
- * @return モールスを含むならtrue, そうでなければfalse
- */
- public static boolean isMorse(String mc) {
- Matcher matcher = morsePattern.matcher(mc);
- ArrayList<String> list = new ArrayList<>();
- while (matcher.find()) {
- list.add(matcher.group());
- }
- if (list.size() <= 2) {
- return false;
- } else {
- for (String s : list) {
- if (!"・・・".equals(s) && !"・・".equals(s) && !"・".equals(s)) {
- return true;
- }
- }
- return false;
- }
- }
-
- /**
- * 和文モールスをカタカナ・数字に復元する *
- *
- * @param str 復元したい文字列
- * @return 復元部分が置換された文字列
- */
- public static String morseToJa(String str) {
- String[] strArr = toRightMorse(str).split(" ");
- StringBuilder sb = new StringBuilder();
- for (String tok : strArr) {
- sb.append(mcJa.containsKey(tok) ? mcJa.get(tok) : tok);
- }
- return sb.toString();
- }
-
- private static String toRightMorse(String str) {
- str = str.replace("‐", "-").replace(" ", " ").trim();
- Pattern pattern = Pattern.compile("[^・- ][・-]");
- StringBuilder sb = new StringBuilder(str);
- Matcher matcher = pattern.matcher(str);
- while (matcher.find()) {
- int i = matcher.start();
- sb.insert(i + 1, " ");
- matcher.reset(sb);
- }
- pattern = Pattern.compile("[・-][^・- ]");
- matcher = pattern.matcher(sb);
- while (matcher.find()) {
- int i = matcher.start();
- sb.insert(i + 1, " ");
- matcher.reset(sb);
- }
- return sb.toString();
- }
-
- static {
- mcJa = new HashMap<>();
-
- String[][] ja2 = {{"・-", "イ"}, {"・-・-", "ロ"}, {"-・・・", "ハ"}, {"-・-・", "ニ"}, {"-・・", "ホ"}, {"・", "ヘ"}, {"・・-・・", "ト"}, {"・・-・", "チ"}, {"--・", "リ"}, {"・・・・", "ヌ"}, {"-・--・", "ル"}, {"・---", "ヲ"}, {"-・-", "ワ"}, {"・-・・", "カ"}, {"--", "ヨ"}, {"-・", "タ"}, {"---", "レ"}, {"---・", "ソ"}, {"・--・", "ツ"}, {"--・-", "ネ"}, {"・-・", "ナ"}, {"・・・", "ラ"}, {"-", "ム"}, {"・・-", "ウ"}, {"・-・・-", "ヰ"}, {"・・--", "ノ"}, {"・-・・・", "オ"}, {"・・・-", "ク"}, {"・--", "ヤ"}, {"-・・-", "マ"}, {"-・--", "ケ"}, {"--・・", "フ"}, {"----", "コ"}, {"-・---", "エ"}, {"・-・--", "テ"}, {"--・--", "ア"}, {"-・-・-", "サ"}, {"-・-・・", "キ"}, {"-・・--", "ユ"}, {"-・・・-", "メ"}, {"・・-・-", "ミ"}, {"--・-・", "シ"}, {"・--・・", "ヱ"}, {"--・・-", "ヒ"}, {"-・・-・", "モ"}, {"・---・", "セ"}, {"---・-", "ス"}, {"・-・-・", "ン"}, {"・・", "゛"}, {"・・--・", "゜"}, {"・--・-", "ー"}, {"・-・-・-", "、"}, {"-・--・-", "("}, {"・-・・-・", ")"}, {"・----", "1"}, {"・・---", "2"}, {"・・・--", "3"}, {"・・・・-", "4"}, {"・・・・・", "5"}, {"-・・・・", "6"}, {"--・・・", "7"}, {"---・・", "8"}, {"----・", "9"}, {"-----", "0"}, {"", ""}};
- for (String[] pr : ja2) {
- mcJa.put(pr[0], pr[1]);
- }
- }
-}
diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java
index 64f20567..608c0186 100644
--- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java
+++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java
@@ -156,11 +156,7 @@ public class StatusViewModel implements IViewModel, IdObject {
int colorNormal = Themes.getStyledColor(activity, R.attr.color_status_text_normal);
content.setTextColor(colorNormal);
String rawText = tweet.getOriginalTweet().getText();
- if (isReadMorseEnabled() && Morse.isMorse(rawText)) {
- content.setText(String.format("%s\n(%s)", rawText, Morse.morseToJa(rawText)));
- } else {
- content.setText(rawText);
- }
+ content.setText(rawText);
TextView footer = (TextView) convertedView.findViewById(R.id.textview_status_footer);
footer.setTextSize(textSize - 2);
int colorFooter = Themes.getStyledColor(activity, R.attr.color_status_text_footer);
@@ -213,10 +209,6 @@ public class StatusViewModel implements IViewModel, IdObject {
}
}
- private boolean isReadMorseEnabled() {
- return UserPreferenceHelper.getInstance().get(R.string.key_setting_read_morse, true);
- }
-
private void onClick(Activity activity) {
StatusDetailDialogFragment fragment = new StatusDetailDialogFragment();
fragment.setStatusID(tweet.getId());
diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml
index f0b94fcc..3daa9609 100644
--- a/app/src/main/res/values/keys.xml
+++ b/app/src/main/res/values/keys.xml
@@ -29,7 +29,6 @@
<string name="key_setting_accounts">manageAccounts</string>
<string name="key_setting_notify_on_unfavorited">unfavNotify</string>
<string name="key_setting_show_confirm_dialog">confirm</string>
- <string name="key_setting_read_morse">morse</string>
<string name="key_setting_theme">theme</string>
<string name="key_setting_application_information">appInfo</string>
<string name="key_setting_licenses">licenseNotice</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 35649e41..a99468b4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -62,7 +62,6 @@
<string name="setting_text_size_dialog_message">Set a value between 8\-24</string>
<string name="setting_theme_title">Theme</string>
<string name="setting_theme_dialog_title">Choose theme</string>
- <string name="setting_read_morse">Enable morse</string>
<string name="setting_category_system_title">System Setting</string>
<string name="setting_safe_mode_title">Safe mode</string>
<string name="setting_safe_mode_summary_on">Show confirm dialog</string>
diff --git a/app/src/main/res/xml/setting.xml b/app/src/main/res/xml/setting.xml
index f3d000a0..fd8843dd 100644
--- a/app/src/main/res/xml/setting.xml
+++ b/app/src/main/res/xml/setting.xml
@@ -50,10 +50,6 @@
android:entryValues="@array/setting_theme_ids"
android:key="@string/key_setting_theme"
android:title="@string/setting_theme_title" />
- <SwitchPreference
- android:defaultValue="true"
- android:key="@string/key_setting_read_morse"
- android:title="@string/setting_read_morse" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/setting_category_system_title">
<SwitchPreference