From 6c20ab55b5b33543aedf5a56ffdea0b85f9e9cb6 Mon Sep 17 00:00:00 2001
From: satok <satok@google.com>
Date: Tue, 29 Jun 2010 05:32:48 +0900
Subject: [PATCH] Add a typeFace element and a symbol's color element

- add default bold theme
- add

Change-Id: Ie3f31a6973c12e7f8b885d0036f50e8647c9fe82
---
 .../res/layout/{input.xml => input_basic.xml} |  2 +-
 ...nput2.xml => input_basic_highcontrast.xml} |  2 +-
 java/res/layout/input_stone_bold.xml          | 38 +++++++++++++++++++
 .../{input7.xml => input_stone_normal.xml}    |  3 +-
 ...input7_popup.xml => input_stone_popup.xml} |  9 ++---
 java/res/values/attrs.xml                     | 12 ++++++
 java/res/values/strings.xml                   |  7 +++-
 java/res/values/styles.xml                    |  1 +
 java/res/xml/prefs.xml                        |  2 +-
 .../inputmethod/latin/KeyboardSwitcher.java   | 11 ++++--
 .../inputmethod/latin/LatinImeLogger.java     |  4 +-
 .../latin/LatinKeyboardBaseView.java          | 28 +++++++++++++-
 12 files changed, 101 insertions(+), 18 deletions(-)
 rename java/res/layout/{input.xml => input_basic.xml} (95%)
 rename java/res/layout/{input2.xml => input_basic_highcontrast.xml} (95%)
 create mode 100755 java/res/layout/input_stone_bold.xml
 rename java/res/layout/{input7.xml => input_stone_normal.xml} (93%)
 rename java/res/layout/{input7_popup.xml => input_stone_popup.xml} (86%)

diff --git a/java/res/layout/input.xml b/java/res/layout/input_basic.xml
similarity index 95%
rename from java/res/layout/input.xml
rename to java/res/layout/input_basic.xml
index 039fdd8df6..ffa59543b9 100755
--- a/java/res/layout/input.xml
+++ b/java/res/layout/input_basic.xml
@@ -21,7 +21,7 @@
 <com.android.inputmethod.latin.LatinKeyboardView
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
-        android:id="@android:id/keyboardView"
+        android:id="@+id/LatinkeyboardBaseView"
         android:layout_alignParentBottom="true"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
diff --git a/java/res/layout/input2.xml b/java/res/layout/input_basic_highcontrast.xml
similarity index 95%
rename from java/res/layout/input2.xml
rename to java/res/layout/input_basic_highcontrast.xml
index 3c9ec2fdf2..dc4d097360 100755
--- a/java/res/layout/input2.xml
+++ b/java/res/layout/input_basic_highcontrast.xml
@@ -22,7 +22,7 @@
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
 
-        android:id="@android:id/keyboardView"
+        android:id="@+id/LatinkeyboardBaseView"
         android:layout_alignParentBottom="true"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
diff --git a/java/res/layout/input_stone_bold.xml b/java/res/layout/input_stone_bold.xml
new file mode 100755
index 0000000000..8cc082b5d1
--- /dev/null
+++ b/java/res/layout/input_stone_bold.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2010, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<com.android.inputmethod.latin.LatinKeyboardView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
+        android:id="@+id/LatinkeyboardBaseView"
+        android:layout_alignParentBottom="true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@drawable/keyboard_background"
+        android:textStyle="bold"
+
+        latin:keyBackground="@drawable/btn_keyboard_key_ginger"
+        latin:keyTextSize="22dip"
+        latin:keyTextColor="@color/latinkeyboard_key_color_black"
+        latin:shadowColor="@color/latinkeyboard_key_color_white"
+        latin:keyTextStyle="bold"
+        latin:symbolColorScheme="black"
+        latin:popupLayout="@layout/input_stone_popup"
+        />
diff --git a/java/res/layout/input7.xml b/java/res/layout/input_stone_normal.xml
similarity index 93%
rename from java/res/layout/input7.xml
rename to java/res/layout/input_stone_normal.xml
index 1290eb8ca1..51693502e4 100755
--- a/java/res/layout/input7.xml
+++ b/java/res/layout/input_stone_normal.xml
@@ -31,5 +31,6 @@
         latin:keyTextSize="22dip"
         latin:keyTextColor="@color/latinkeyboard_key_color_black"
         latin:shadowColor="@color/latinkeyboard_key_color_white"
-        latin:popupLayout="@layout/input7_popup"
+        latin:symbolColorScheme="black"
+        latin:popupLayout="@layout/input_stone_popup"
         />
diff --git a/java/res/layout/input7_popup.xml b/java/res/layout/input_stone_popup.xml
similarity index 86%
rename from java/res/layout/input7_popup.xml
rename to java/res/layout/input_stone_popup.xml
index 2056757fa9..e6eae5dad7 100755
--- a/java/res/layout/input7_popup.xml
+++ b/java/res/layout/input_stone_popup.xml
@@ -25,10 +25,9 @@
         android:orientation="horizontal"
         android:background="@drawable/keyboard_popup_panel_background"
         >
-    <com.android.inputmethod.latin.LatinKeyboardView
-            xmlns:android="http://schemas.android.com/apk/res/android"
+    <com.android.inputmethod.latin.LatinKeyboardBaseView
             xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
-            android:id="@android:id/keyboardView"
+            android:id="@+id/LatinKeyboardBaseView"
             android:layout_alignParentBottom="true"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
@@ -38,9 +37,9 @@
             latin:keyTextColor="@color/latinkeyboard_key_color_black"
             latin:shadowColor="@color/latinkeyboard_key_color_white"
             latin:keyTextSize="22dip"
-            latin:popupLayout="@layout/input7_popup"
+            latin:popupLayout="@layout/input_stone_popup"
         />
-    <ImageButton android:id="@android:id/closeButton"
+    <ImageButton android:id="@+id/closeButton"
         android:background="@android:color/transparent"
         android:src="@drawable/btn_close"
         android:layout_width="wrap_content"
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 2468e9df0a..e3171eb337 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -52,6 +52,18 @@
         <attr name="shadowColor" format="color" />
         <attr name="shadowRadius" format="float" />
         <attr name="backgroundDimAmount" format="float" />
+
+        <attr name="keyTextStyle">
+            <flag name="normal" value="0" />
+            <flag name="bold" value="1" />
+            <flag name="italic" value="2" />
+        </attr>
+
+        <attr name="symbolColorScheme">
+            <flag name="white" value="0" />
+            <flag name="black" value="1" />
+        </attr>
+
     </declare-styleable>
 
 </resources>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index 64b8dbe59e..f2d823f0b9 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -332,18 +332,21 @@
     <string name="keyboard_layout">Keyboard Theme</string>
     <string name="layout_basic" translatable="false">Basic</string>
     <string name="layout_high_contrast" translatable="false">Basic (High Contrast)</string>
-    <string name="layout_stone"  translatable="false">Default</string>
+    <string name="layout_stone_bold"  translatable="false">Default (bold)</string>
+    <string name="layout_stone_normal"  translatable="false">Default (normal)</string>
 
     <string-array name="keyboard_layout_modes" translatable="false">
         <item>@string/layout_basic</item>
         <item>@string/layout_high_contrast</item>
-        <item>@string/layout_stone</item>
+        <item>@string/layout_stone_normal</item>
+        <item>@string/layout_stone_bold</item>
     </string-array>
 
     <string-array name="keyboard_layout_modes_values" translatable="false">
         <item>0</item>
         <item>1</item>
         <item>2</item>
+        <item>3</item>
     </string-array>
 
     <string name="prefs_debug_mode">Debug (Temporary)</string>
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index a59a15083e..1433550338 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -30,5 +30,6 @@
         <item name="shadowColor">#BB000000</item>
         <item name="shadowRadius">2.75</item>
         <item name="backgroundDimAmount">0.5</item>
+        <item name="symbolColorScheme">white</item>
     </style>
 </resources>
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index b50588a9e8..10e3998f96 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -60,7 +60,7 @@
             android:persistent="true"
             android:entryValues="@array/keyboard_layout_modes_values"
             android:entries="@array/keyboard_layout_modes"
-            android:defaultValue="6"
+            android:defaultValue="3"
             />
 
     <PreferenceScreen
diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index 665e16aeca..bbde23221c 100644
--- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -48,10 +48,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
     public static final int KEYBOARDMODE_IM = R.id.mode_im;
     public static final int KEYBOARDMODE_WEB = R.id.mode_webentry;
 
-    public static final String DEFAULT_LAYOUT_ID = "2";
+    public static final String DEFAULT_LAYOUT_ID = "3";
     public static final String PREF_KEYBOARD_LAYOUT = "keyboard_layout";
     private static final int[] LAYOUTS = new int [] {
-        R.layout.input, R.layout.input2, R.layout.input7};
+        R.layout.input_basic, R.layout.input_basic_highcontrast, R.layout.input_stone_normal,
+        R.layout.input_stone_bold};
 
     private static final int SYMBOLS_MODE_STATE_NONE = 0;
     private static final int SYMBOLS_MODE_STATE_BEGIN = 1;
@@ -424,8 +425,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
         }
     }
 
-    // TODO: Generalize for any theme
     public boolean isBlackSym () {
-        return (mLayoutId == 6);
+        if (mInputView != null && mInputView.getSymbolColorSheme() == 1) {
+            return true;
+        }
+        return false;
     }
 }
diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
index 42d5689d23..e8899504e5 100644
--- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java
+++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
@@ -264,8 +264,10 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
             Log.d(TAG, "Log theme Id. (1)");
         }
         // TODO: Not to convert theme ID here. Currently "2" is treated as "6" in a log server.
-        if (mThemeId == "2") {
+        if (mThemeId.equals("2")) {
             mThemeId = "6";
+        } else if (mThemeId.equals("3")) {
+            mThemeId = "7";
         }
         mLogBuffer.add(new LogEntry (time, ID_THEME_ID,
                 new String[] {mThemeId}));
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 64299b626b..6b8d4f890b 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -165,6 +165,8 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
     private Map<Key,View> mMiniKeyboardCache;
     private int[] mWindowOffset;
     private Key[] mKeys;
+    private Typeface mKeyTextStyle = Typeface.DEFAULT;
+    private int mSymbolColorScheme = 0;
 
     /** Listener for {@link OnKeyboardActionListener}. */
     private OnKeyboardActionListener mKeyboardActionListener;
@@ -334,6 +336,24 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
             case R.styleable.LatinKeyboardBaseView_backgroundDimAmount:
                 mBackgroundDimAmount = a.getFloat(attr, 0.5f);
                 break;
+            //case android.R.styleable.
+            case R.styleable.LatinKeyboardBaseView_keyTextStyle:
+                int textStyle = a.getInt(attr, 0);
+                switch (textStyle) {
+                    case 0:
+                        mKeyTextStyle = Typeface.DEFAULT;
+                        break;
+                    case 1:
+                        mKeyTextStyle = Typeface.DEFAULT_BOLD;
+                        break;
+                    default:
+                        mKeyTextStyle = Typeface.defaultFromStyle(textStyle);
+                        break;
+                }
+                break;
+            case R.styleable.LatinKeyboardBaseView_symbolColorScheme:
+                mSymbolColorScheme = a.getInt(attr, 0);
+                break;
             }
         }
 
@@ -526,6 +546,10 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
         return mShowPreview;
     }
 
+    public int getSymbolColorSheme() {
+        return mSymbolColorScheme;
+    }
+
     public void setVerticalCorrection(int verticalOffset) {
     }
 
@@ -693,7 +717,7 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
                     paint.setTypeface(Typeface.DEFAULT_BOLD);
                 } else {
                     paint.setTextSize(mKeyTextSize);
-                    paint.setTypeface(Typeface.DEFAULT);
+                    paint.setTypeface(mKeyTextStyle);
                 }
                 // Draw a drop shadow for the text
                 paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
@@ -894,7 +918,7 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
                 mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
             } else {
                 mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
-                mPreviewText.setTypeface(Typeface.DEFAULT);
+                mPreviewText.setTypeface(mKeyTextStyle);
             }
         }
         mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
-- 
GitLab