OSDN Git Service

Add HTML Entities test fix for unicode notes on Android.
authorRandy Baumgarte <randy@fbn.cx>
Sun, 3 Apr 2011 15:24:52 +0000 (11:24 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 3 Apr 2011 18:03:21 +0000 (14:03 -0400)
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/dialog/ConfigDebugPage.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java

index fabcac1..eac6dc1 100644 (file)
@@ -110,6 +110,7 @@ public class Global {
     public static int minimumWordCount = 2;\r
     private static String wordRegex;\r
     public static boolean enableCarriageReturnFix = false;\r
+    public static boolean enableHTMLEntitiesFix = false;\r
     \r
     public static String name = null;\r
     public static QSettings    settings;\r
@@ -170,6 +171,7 @@ public class Global {
                        keepRunning = true;\r
                        disableUploads = disableUploads();\r
                        enableCarriageReturnFix = enableCarriageReturnFix();\r
+                       enableHTMLEntitiesFix = enableHtmlEntitiesFix();\r
                        logger = new ApplicationLogger("global.log");\r
                        shortcutKeys = new ShortcutKeys();\r
                        mimicEvernoteInterface = getMimicEvernoteInterface();\r
@@ -894,6 +896,30 @@ public class Global {
                        settings.setValue("enableCarriageReturnFix", "false");\r
                settings.endGroup();\r
     }\r
+    public static boolean enableHtmlEntitiesFix() {\r
+       try {\r
+               settings.beginGroup("Debug");\r
+               String text = (String)settings.value("enableHtmlEntitiesFix", "false");\r
+               settings.endGroup();\r
+               if (text.equalsIgnoreCase("true"))\r
+                       return true;\r
+               else\r
+                       return false;\r
+               } catch (java.lang.ClassCastException e) {\r
+                       Boolean value = (Boolean) settings.value("enableHtmlEntitiesFix", false);\r
+                       settings.endGroup();\r
+                       return value;\r
+               }\r
+    }\r
+    public static void saveHtmlEntitiesFix(boolean val) {\r
+               settings.beginGroup("Debug");\r
+               if (val)\r
+                       settings.setValue("enableHtmlEntitiesFix", "true");\r
+               else\r
+                       settings.setValue("enableHtmlEntitiesFix", "false");\r
+               settings.endGroup();\r
+    }\r
+\r
     public static void setIndexThreads(int val) {\r
                settings.beginGroup("General");\r
                settings.setValue("indexThreads", val);\r
index 3719d26..8d31a67 100644 (file)
@@ -37,6 +37,7 @@ public class ConfigDebugPage extends QWidget {
        QComboBox serverCombo;\r
        QCheckBox disableUploads;\r
        QCheckBox carriageReturnFix;\r
+       QCheckBox htmlEntitiesFix;\r
        QCheckBox enableThumbnails;\r
        QSpinBox  databaseCache;\r
        \r
@@ -106,10 +107,24 @@ public class ConfigDebugPage extends QWidget {
                crlfLayout.addWidget(carriageReturnFix);\r
                crlfGroup.setLayout(crlfLayout);\r
 \r
+               QGroupBox htmlGroup = new QGroupBox(tr("Android Note Fix"));\r
+               String entitiesMessage = new String(tr("Note: This is an experimental fix to correct Unicode" +\r
+                               " notes created on Android Evernote clients."));\r
+               htmlEntitiesFix = new QCheckBox(this);\r
+               QVBoxLayout htmlLayout = new QVBoxLayout();\r
+               htmlEntitiesFix.setText(tr("Enable Android Fix"));\r
+               htmlLayout.addWidget(htmlEntitiesFix);\r
+               htmlGroup.setLayout(htmlLayout);\r
+\r
+               \r
                QTextBrowser msg = new QTextBrowser(this);\r
+               QTextBrowser htmlMsg = new QTextBrowser(this);\r
                msg.setText(crlfMessage);\r
+               htmlMsg.setText(entitiesMessage);\r
                crlfLayout.addWidget(msg);\r
                mainLayout.addWidget(crlfGroup);\r
+               htmlLayout.addWidget(htmlMsg);\r
+               mainLayout.addWidget(htmlGroup);\r
 \r
                mainLayout.addStretch(1);\r
                setLayout(mainLayout);\r
@@ -129,6 +144,17 @@ public class ConfigDebugPage extends QWidget {
                int i = messageCombo.currentIndex();\r
                return messageCombo.itemData(i).toString();\r
        }\r
+\r
+\r
+       //******************************************\r
+       //* Experimental fixes\r
+       //******************************************\r
+       public void setHtmlEntitiesFix(boolean val) {\r
+               htmlEntitiesFix.setChecked(val);\r
+       }\r
+       public boolean getHtmlEntitiesFix() {\r
+               return htmlEntitiesFix.isChecked();\r
+       }\r
        public void setCarriageReturnFix(boolean val) {\r
                carriageReturnFix.setChecked(val);\r
        }\r
index 43e85a1..efd2b71 100644 (file)
@@ -177,6 +177,8 @@ public class ConfigDialog extends QDialog {
                Global.setMessageLevel( debugPage.getDebugLevel());\r
                Global.saveCarriageReturnFix(debugPage.getCarriageReturnFix());\r
                Global.enableCarriageReturnFix = debugPage.getCarriageReturnFix();\r
+               Global.saveHtmlEntitiesFix(debugPage.getHtmlEntitiesFix());\r
+               Global.enableHTMLEntitiesFix = debugPage.getHtmlEntitiesFix();\r
                \r
                Global.setSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS, spellPage.getIgnoreDigitWords());\r
                Global.setSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES, spellPage.getIgnoreInternetAddresses());\r
@@ -328,6 +330,7 @@ public class ConfigDialog extends QDialog {
                                                \r
                debugPage.setDebugLevel(Global.getMessageLevel());\r
                debugPage.setCarriageReturnFix(Global.enableCarriageReturnFix());\r
+               debugPage.setHtmlEntitiesFix(Global.enableHTMLEntitiesFix);\r
                \r
        }\r
        \r