Use custom theme for Keyboard theme switch
This change reduces the number of layout files and make these
theme-generic. This might be very helpful to re-design suggestion
strip.
Bug: 4175031
Change-Id: Idca10a4aa0bf7ac496eedd1879311e59780a423b
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index f03da4f..0e5b38b 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -15,11 +15,20 @@
-->
<resources>
+ <declare-styleable name="KeyboardTheme">
+ <!-- KeyboardView style -->
+ <attr name="keyboardViewStyle" format="reference" />
+ <attr name="keyPreviewStyle" format="reference" />
+ <!-- PopupMiniKeyboardView style -->
+ <attr name="popupMiniKeyboardViewStyle" format="reference" />
+ <attr name="popupMiniKeyboardPanelStyle" format="reference" />
+ <!-- Suggestions strip style -->
+ <attr name="suggestionsStripBackgroundStyle" format="reference" />
+ <attr name="suggestionBackgroundStyle" format="reference" />
+ <attr name="suggestionPreviewBackgroundStyle" format="reference" />
+ </declare-styleable>
<declare-styleable name="KeyboardView">
- <!-- Default KeyboardView style. -->
- <attr name="keyboardViewStyle" format="reference" />
-
<!-- Image for the key. This image needs to be a StateListDrawable, with the following
possible states: normal, pressed, checkable, checkable+pressed, checkable+checked,
checkable+checked+pressed. -->
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index 3a389e5..7cb4593 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -15,9 +15,9 @@
-->
<resources>
+ <!-- Theme "Basic" -->
<style name="KeyboardView">
<item name="android:background">@drawable/keyboard_background</item>
-
<item name="keyBackground">@drawable/btn_keyboard_key</item>
<item name="keyLetterRatio">@fraction/key_letter_ratio</item>
<item name="keyLetterStyle">normal</item>
@@ -35,6 +35,91 @@
<item name="backgroundDimAmount">0.5</item>
<item name="colorScheme">white</item>
</style>
+ <style name="KeyPreviewStyle">
+ <item name="android:background">@drawable/keyboard_key_feedback</item>
+ </style>
+ <style name="PopupMiniKeyboardView" parent="KeyboardView">
+ <item name="keyBackground">@drawable/btn_keyboard_key_popup</item>
+ <item name="keyHysteresisDistance">0dip</item>
+ <item name="verticalCorrection">@dimen/mini_keyboard_vertical_correction</item>
+ </style>
+ <style name="PopupMiniKeyboardPanelStyle">
+ <item name="android:background">@drawable/keyboard_popup_panel_background</item>
+ <item name="android:paddingLeft">@dimen/mini_keyboard_horizontal_padding</item>
+ <item name="android:paddingRight">@dimen/mini_keyboard_horizontal_padding</item>
+ </style>
+ <style name="SuggestionsStripBackgroundStyle">
+ <item name="android:background">@drawable/keyboard_suggest_strip</item>
+ </style>
+ <style name="SuggestionBackgroundStyle">
+ <item name="android:background">@drawable/btn_candidate</item>
+ </style>
+ <style name="SuggestionPreviewBackgroundStyle">
+ <item name="android:background">@drawable/candidate_feedback_background</item>
+ </style>
+ <!-- Theme "Basic high contrast" -->
+ <style name="KeyboardView.HighContrast" parent="KeyboardView">
+ <item name="android:background">@android:color/black</item>
+ <item name="keyBackground">@drawable/btn_keyboard_key3</item>
+ </style>
+ <!-- Theme "Stone" -->
+ <style name="KeyboardView.Stone" parent="KeyboardView">
+ <item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
+ <item name="keyTextColor">@color/latinkeyboard_key_color_black</item>
+ <item name="keyTextColorDisabled">#FF808080</item>
+ <item name="shadowColor">@color/latinkeyboard_key_color_white</item>
+ <item name="colorScheme">black</item>
+ </style>
+ <style name="PopupMiniKeyboardView.Stone" parent="PopupMiniKeyboardView">
+ <item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
+ <item name="keyTextColor">@color/latinkeyboard_key_color_black</item>
+ <item name="shadowColor">@color/latinkeyboard_key_color_white</item>
+ </style>
+ <!-- Theme "Stone bold" -->
+ <style name="KeyboardView.Stone.Bold" parent="KeyboardView.Stone">
+ <item name="keyLetterStyle">bold</item>
+ </style>
+ <!-- Theme "Gingerbread" -->
+ <style name="KeyboardView.Gingerbread" parent="KeyboardView">
+ <item name="android:background">@drawable/keyboard_dark_background</item>
+ <item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item>
+ <item name="keyLetterStyle">bold</item>
+ </style>
+ <style name="PopupMiniKeyboardView.Gingerbread" parent="PopupMiniKeyboardView">
+ <item name="android:background">@null</item>
+ </style>
+ <!-- Theme "Honeycomb" -->
+ <style name="KeyboardView.Honeycomb" parent="KeyboardView">
+ <item name="android:background">@drawable/keyboard_background_holo</item>
+ <item name="keyBackground">@drawable/btn_keyboard_key_honeycomb</item>
+ <item name="keyPreviewHeight">@dimen/key_preview_height_holo</item>
+ <item name="keyPreviewOffset">@dimen/key_preview_offset_holo</item>
+ <item name="keyTextColorDisabled">#FF63666D</item>
+ <item name="keyLetterStyle">bold</item>
+ <item name="shadowColor">#00000000</item>
+ <item name="shadowRadius">0.0</item>
+ </style>
+ <style name="KeyPreviewStyle.Honeycomb">
+ <item name="android:background">@drawable/keyboard_key_feedback_honeycomb</item>
+ </style>
+ <style name="PopupMiniKeyboardView.Honeycomb" parent="PopupMiniKeyboardView">
+ <item name="android:background">@null</item>
+ <item name="keyBackground">@drawable/btn_keyboard_key_popup_honeycomb</item>
+ </style>
+ <style name="PopupMiniKeyboardPanelStyle.Honeycomb">
+ <item name="android:background">@drawable/keyboard_popup_panel_background_holo</item>
+ <item name="android:paddingLeft">@dimen/mini_keyboard_horizontal_padding_holo</item>
+ <item name="android:paddingRight">@dimen/mini_keyboard_horizontal_padding_holo</item>
+ </style>
+ <style name="SuggestionsStripBackgroundStyle.Holo">
+ <item name="android:background">@drawable/keyboard_suggest_strip_holo</item>
+ </style>
+ <style name="SuggestionBackgroundStyle.Holo">
+ <item name="android:background">@drawable/btn_candidate_holo</item>
+ </style>
+ <style name="SuggestionPreviewBackgroundStyle.Holo">
+ <item name="android:background">@drawable/keyboard_popup_panel_background_holo</item>
+ </style>
<style name="PopupMiniKeyboardAnimation">
<item name="android:windowEnterAnimation">@anim/mini_keyboard_fadein</item>
<item name="android:windowExitAnimation">@anim/mini_keyboard_fadeout</item>
diff --git a/java/res/values/themes.xml b/java/res/values/themes.xml
new file mode 100644
index 0000000..5315a9a
--- /dev/null
+++ b/java/res/values/themes.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<resources>
+ <style name="KeyboardTheme" parent="android:Theme">
+ <item name="keyboardViewStyle">@style/KeyboardView</item>
+ <item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
+ <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item>
+ <item name="popupMiniKeyboardPanelStyle">@style/PopupMiniKeyboardPanelStyle</item>
+ <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
+ <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
+ <item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
+ </style>
+ <style name="KeyboardTheme.HighContrast" parent="android:Theme">
+ <item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item>
+ <item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
+ <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item>
+ <item name="popupMiniKeyboardPanelStyle">@style/PopupMiniKeyboardPanelStyle</item>
+ <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
+ <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
+ </style>
+ <style name="KeyboardTheme.Stone" parent="android:Theme.Light">
+ <item name="keyboardViewStyle">@style/KeyboardView.Stone</item>
+ <item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
+ <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item>
+ <item name="popupMiniKeyboardPanelStyle">@style/PopupMiniKeyboardPanelStyle</item>
+ <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
+ <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
+ </style>
+ <style name="KeyboardTheme.Stone.Bold" parent="android:Theme.Light">
+ <item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item>
+ <item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
+ <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item>
+ <item name="popupMiniKeyboardPanelStyle">@style/PopupMiniKeyboardPanelStyle</item>
+ <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
+ <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
+ </style>
+ <style name="KeyboardTheme.Gingerbread" parent="android:Theme.Black">
+ <item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
+ <item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
+ <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Gingerbread</item>
+ <item name="popupMiniKeyboardPanelStyle">@style/PopupMiniKeyboardPanelStyle</item>
+ <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
+ <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
+ </style>
+ <style name="KeyboardTheme.Honeycomb" parent="android:Theme.Holo">
+ <item name="keyboardViewStyle">@style/KeyboardView.Honeycomb</item>
+ <item name="keyPreviewStyle">@style/KeyPreviewStyle.Honeycomb</item>
+ <item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Honeycomb</item>
+ <item name="popupMiniKeyboardPanelStyle">@style/PopupMiniKeyboardPanelStyle.Honeycomb</item>
+ <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle.Holo</item>
+ <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.Holo</item>
+ </style>
+</resources>