mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-04 13:50:42 +00:00
add holo no border theme (wip)
issues: small pressed drawable for emoji key and action key black line in clipboard history
This commit is contained in:
parent
6b44f24a76
commit
10753d780b
11 changed files with 110 additions and 31 deletions
|
@ -59,14 +59,17 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
// These should be aligned with Keyboard.themeId and Keyboard.Case.keyboardTheme
|
||||
// attributes' values in attrs.xml.
|
||||
public static final int THEME_ID_HOLO_BASE = 0;
|
||||
public static final int THEME_ID_LXX_BASE = 1;
|
||||
public static final int THEME_ID_LXX_BASE_BORDER = 2;
|
||||
public static final int THEME_ID_HOLO_BASE_NO_BORDER = 1;
|
||||
public static final int THEME_ID_LXX_BASE = 2;
|
||||
public static final int THEME_ID_LXX_BASE_BORDER = 3;
|
||||
public static final int DEFAULT_THEME_ID = THEME_ID_LXX_BASE;
|
||||
|
||||
/* package private for testing */
|
||||
static final KeyboardTheme[] KEYBOARD_THEMES = {
|
||||
new KeyboardTheme(THEME_ID_HOLO_BASE, "HoloBase", R.style.KeyboardTheme_HoloBase,
|
||||
VERSION_CODES.BASE),
|
||||
new KeyboardTheme(THEME_ID_HOLO_BASE, "HoloBase", R.style.KeyboardTheme_HoloBase,
|
||||
VERSION_CODES.BASE),
|
||||
new KeyboardTheme(THEME_ID_HOLO_BASE_NO_BORDER, "HoloBaseNoBorder", R.style.KeyboardTheme_HoloBaseNoBorder,
|
||||
VERSION_CODES.BASE),
|
||||
new KeyboardTheme(THEME_ID_LXX_BASE, "LXXBase", R.style.KeyboardTheme_LXX_Base,
|
||||
VERSION_CODES.LOLLIPOP),
|
||||
new KeyboardTheme(THEME_ID_LXX_BASE_BORDER, "LXXBaseBorder", R.style.KeyboardTheme_LXX_Base_Border,
|
||||
|
@ -160,17 +163,21 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
}
|
||||
|
||||
// todo: this actually should be called style now, as the colors are independent
|
||||
// and selection should be simplified, becuase really...
|
||||
// and selection should be simplified, because really...
|
||||
public static KeyboardTheme getKeyboardTheme(final Context context) {
|
||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(context);
|
||||
final String style = prefs.getString(Settings.PREF_THEME_STYLE, THEME_STYLE_MATERIAL);
|
||||
final boolean borders = prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false);
|
||||
final int matchingId = style.equals(THEME_STYLE_HOLO) ? THEME_ID_HOLO_BASE : (borders ? THEME_ID_LXX_BASE_BORDER : THEME_ID_LXX_BASE);
|
||||
final int matchingId;
|
||||
if (style.equals(THEME_STYLE_HOLO))
|
||||
matchingId = borders ? THEME_ID_HOLO_BASE : THEME_ID_HOLO_BASE_NO_BORDER;
|
||||
else
|
||||
matchingId = borders ? THEME_ID_LXX_BASE_BORDER : THEME_ID_LXX_BASE;
|
||||
for (KeyboardTheme keyboardTheme : KEYBOARD_THEMES) {
|
||||
if (keyboardTheme.mThemeId == matchingId)
|
||||
return keyboardTheme;
|
||||
}
|
||||
return KEYBOARD_THEMES[2]; // base no border as default
|
||||
return KEYBOARD_THEMES[3]; // base no border as default
|
||||
}
|
||||
|
||||
/* package private for testing */
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.view.View
|
|||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardActionListener
|
||||
import org.dslul.openboard.inputmethod.latin.common.Colors
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings
|
||||
|
||||
|
@ -56,6 +57,8 @@ class KeyboardWrapperView @JvmOverloads constructor(
|
|||
val colors = Settings.getInstance().current.mColors
|
||||
stopOneHandedModeBtn.colorFilter = colors.keyTextFilter
|
||||
switchOneHandedModeBtn.colorFilter = colors.keyTextFilter
|
||||
colors.setBackgroundColor(stopOneHandedModeBtn.background, Colors.TYPE_BACKGROUND)
|
||||
colors.setBackgroundColor(switchOneHandedModeBtn.background, Colors.TYPE_BACKGROUND)
|
||||
}
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
|
@ -117,6 +120,7 @@ class KeyboardWrapperView @JvmOverloads constructor(
|
|||
buttonsLeft + (spareWidth + switchOneHandedModeBtn.measuredWidth) / 2,
|
||||
2 * stopOneHandedModeBtn.measuredHeight + switchOneHandedModeBtn.measuredHeight
|
||||
)
|
||||
Settings.getInstance().current.mColors.keyboardBackground?.let { background = it }
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -130,12 +134,8 @@ class KeyboardWrapperView @JvmOverloads constructor(
|
|||
R.styleable.KeyboardTheme, defStyle, 0)
|
||||
val keyboardViewStyleId = themeAttr.getResourceId(R.styleable.KeyboardTheme_mainKeyboardViewStyle, 0)
|
||||
themeAttr.recycle()
|
||||
val backgroundDrawable = Settings.getInstance().current.mColors.keyboardBackground
|
||||
if (backgroundDrawable == null) {
|
||||
val styleAttr = context.obtainStyledAttributes(keyboardViewStyleId, intArrayOf(android.R.attr.background))
|
||||
setBackgroundResource(styleAttr.getResourceId(0, 0))
|
||||
styleAttr.recycle()
|
||||
} else
|
||||
background = backgroundDrawable
|
||||
val styleAttr = context.obtainStyledAttributes(keyboardViewStyleId, intArrayOf(android.R.attr.background))
|
||||
setBackgroundResource(styleAttr.getResourceId(0, 0))
|
||||
styleAttr.recycle()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_pressed_klp_light" />
|
||||
</selector>
|
|
@ -234,10 +234,11 @@
|
|||
<declare-styleable name="Keyboard">
|
||||
<attr name="themeId" format="enum">
|
||||
<!-- This should be aligned with
|
||||
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardTheme#THEME_ID_HOLO_BLUE} etc. -->
|
||||
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardTheme#THEME_ID_HOLO_BASE} etc. -->
|
||||
<enum name="HoloBase" value="0" />
|
||||
<enum name="LXXBase" value="1" />
|
||||
<enum name="LXXBaseBorder" value="2" />
|
||||
<enum name="HoloBaseNoBorder" value="1" />
|
||||
<enum name="LXXBase" value="2" />
|
||||
<enum name="LXXBaseBorder" value="3" />
|
||||
</attr>
|
||||
<!-- Touch position correction -->
|
||||
<attr name="touchPositionCorrectionData" format="reference" />
|
||||
|
@ -490,11 +491,12 @@
|
|||
<enum name="numpad" value="28" />
|
||||
</attr>
|
||||
<!-- This should be aligned with Keyboard.themeId and
|
||||
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardTheme#THEME_ID_HOLO_BLUE} etc. -->
|
||||
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardTheme#THEME_ID_HOLO_BASE} etc. -->
|
||||
<attr name="keyboardTheme" format="enum|string">
|
||||
<enum name="HoloBase" value="0" />
|
||||
<enum name="LXXBase" value="1" />
|
||||
<enum name="LXXBaseBorder" value="2" />
|
||||
<enum name="HoloBaseNoBorder" value="1" />
|
||||
<enum name="LXXBase" value="2" />
|
||||
<enum name="LXXBaseBorder" value="3" />
|
||||
</attr>
|
||||
<!-- This should be aligned with
|
||||
{@link org.dslul.openboard.inputmethod.keyboard.KeyboardId#MODE_TEXT} etc. -->
|
||||
|
|
65
app/src/main/res/values/themes-holo_base_no_border.xml
Normal file
65
app/src/main/res/values/themes-holo_base_no_border.xml
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2015, 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.HoloBaseNoBorder" parent="KeyboardTheme.HoloBase">
|
||||
<item name="inputViewStyle">@style/InputView.Holo</item>
|
||||
<item name="keyboardStyle">@style/Keyboard.HoloBaseNoBorder</item>
|
||||
<item name="keyboardViewStyle">@style/KeyboardView.HoloBase</item>
|
||||
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.HoloBaseNoBorder</item>
|
||||
<item name="emojiPalettesViewStyle">@style/EmojiPalettesView.HoloBaseNoBorder</item>
|
||||
<item name="clipboardHistoryViewStyle">@style/ClipboardHistoryView.HoloBaseNoBorder</item>
|
||||
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.HoloBase</item>
|
||||
<!-- Note: HoloBase theme uses the same style for both general more keys and action more keys. -->
|
||||
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.HoloBase</item>
|
||||
<item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.HoloBase</item>
|
||||
<item name="suggestionStripViewStyle">@style/SuggestionStripView.HoloBase</item>
|
||||
<item name="suggestionWordStyle">@style/SuggestionWord.HoloBase</item>
|
||||
</style>
|
||||
<style
|
||||
name="Keyboard.HoloBaseNoBorder"
|
||||
parent="Keyboard"
|
||||
>
|
||||
<!-- This should be aligned with KeyboardTheme.THEME_ID_* -->
|
||||
<item name="themeId">HoloBaseNoBorder</item>
|
||||
</style>
|
||||
<style
|
||||
name="MainKeyboardView.HoloBaseNoBorder"
|
||||
parent="MainKeyboardView.HoloBase"
|
||||
>
|
||||
<item name="keyBackground">@drawable/btn_keyboard_key_holo_white_no_border</item>
|
||||
<item name="functionalKeyBackground">@drawable/btn_keyboard_key_holo_white_no_border</item>
|
||||
<item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lxx_base</item>
|
||||
</style>
|
||||
<style
|
||||
name="EmojiPalettesView.HoloBaseNoBorder"
|
||||
parent="EmojiPalettesView.HoloBase"
|
||||
>
|
||||
<item name="functionalKeyBackground">@drawable/btn_keyboard_key_holo_white_no_border</item>
|
||||
<item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lxx_base</item>
|
||||
</style>
|
||||
<style
|
||||
name="ClipboardHistoryView.HoloBaseNoBorder"
|
||||
parent="ClipboardHistoryView.HoloBase"
|
||||
>
|
||||
<item name="keyBackground">@drawable/btn_keyboard_key_holo_white_no_border</item>
|
||||
<item name="functionalKeyBackground">@drawable/btn_keyboard_key_holo_white_no_border</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -73,7 +73,7 @@
|
|||
</switch>
|
||||
<!-- numpadKeyStyle -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder|LXXBase">
|
||||
<key-style
|
||||
latin:styleName="numpadKeyStyle"
|
||||
latin:keySpec="!icon/numpad_key|!code/key_numpad"
|
||||
|
@ -91,7 +91,7 @@
|
|||
</switch>
|
||||
<!-- alphaNumpadKeyStyle -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder|LXXBase">
|
||||
<key-style
|
||||
latin:styleName="alphaNumpadKeyStyle"
|
||||
latin:keySpec="!text/keylabel_to_alpha|!code/key_alphaNumpad"
|
||||
|
@ -109,7 +109,7 @@
|
|||
</switch>
|
||||
<!-- symbolNumpadKeyStyle -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder|LXXBase">
|
||||
<key-style
|
||||
latin:styleName="symbolNumpadKeyStyle"
|
||||
latin:keySpec="!text/keylabel_to_symbol|!code/key_symbolNumpad"
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
</switch>
|
||||
<!-- Enter key style -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder">
|
||||
<key-style
|
||||
latin:styleName="defaultEnterKeyStyle"
|
||||
latin:keySpec="!icon/enter_key|!code/key_enter"
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
latin:backgroundType="functional" />
|
||||
<!-- emojiKeyStyle must be defined before including @xml/key_syles_enter. -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder">
|
||||
<key-style
|
||||
latin:styleName="emojiKeyStyle"
|
||||
latin:keySpec="!icon/emoji_normal_key|!code/key_emoji"
|
||||
|
@ -97,7 +97,7 @@
|
|||
</switch>
|
||||
<!-- numpadKeyStyle -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder|LXXBase">
|
||||
<key-style
|
||||
latin:styleName="numpadKeyStyle"
|
||||
latin:keySpec="!icon/numpad_key|!code/key_numpad"
|
||||
|
@ -115,7 +115,7 @@
|
|||
</switch>
|
||||
<!-- alphaNumpadKeyStyle -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder|LXXBase">
|
||||
<key-style
|
||||
latin:styleName="alphaNumpadKeyStyle"
|
||||
latin:keySpec="!text/keylabel_to_alpha|!code/key_alphaNumpad"
|
||||
|
@ -133,7 +133,7 @@
|
|||
</switch>
|
||||
<!-- symbolNumpadKeyStyle -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder|LXXBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder|LXXBase">
|
||||
<key-style
|
||||
latin:styleName="symbolNumpadKeyStyle"
|
||||
latin:keySpec="!text/keylabel_to_symbol|!code/key_symbolNumpad"
|
||||
|
|
|
@ -213,7 +213,7 @@
|
|||
</switch>
|
||||
<!-- Enter key style -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase|LXXBaseBorder">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder|LXXBaseBorder">
|
||||
<key-style
|
||||
latin:styleName="defaultEnterKeyStyle"
|
||||
latin:keySpec="!icon/enter_key|!code/key_enter"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
xmlns:latin="http://schemas.android.com/apk/res-auto"
|
||||
>
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder">
|
||||
<key-style
|
||||
latin:styleName="navigateNextMoreKeysStyle"
|
||||
latin:keyLabelFlags="hasPopupHint|preserveCase"
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
<!-- TODO: Consolidate these space key styles with numSpaceKeyStyle above by introducing <case>
|
||||
predicator that checks device form-factor. -->
|
||||
<switch>
|
||||
<case latin:keyboardTheme="HoloBase">
|
||||
<case latin:keyboardTheme="HoloBase|HoloBaseNoBorder">
|
||||
<key-style
|
||||
latin:styleName="tabletNumSpaceKeyStyle"
|
||||
latin:keySpec="!icon/space_key|!code/key_space"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue