Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<item>@string/pref_theme_e_cobalt</item>
<item>@string/pref_theme_e_pine</item>
<item>@string/pref_theme_e_epaperblack</item>
<item>@string/pref_theme_e_gradientpurplepink</item>
</string-array>
<string-array name="pref_theme_values">
<item>system</item>
Expand All @@ -65,6 +66,7 @@
<item>cobalt</item>
<item>pine</item>
<item>epaperblack</item>
<item>gradientpurplepink</item>
</string-array>
<string-array name="pref_swipe_dist_entries">
<item>@string/pref_swipe_dist_e_very_short</item>
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<string name="pref_theme_e_cobalt">Cobalt</string>
<string name="pref_theme_e_pine">Pine</string>
<string name="pref_theme_e_epaperblack">ePaper Black</string>
<string name="pref_theme_e_gradientpurplepink">Purple Pink Gradient</string>
<string name="pref_swipe_dist_e_very_short">Very short</string>
<string name="pref_swipe_dist_e_short">Short</string>
<string name="pref_swipe_dist_e_default">Normal</string>
Expand Down
28 changes: 28 additions & 0 deletions res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<declare-styleable name="keyboard">
<!-- The background of the keyboard -->
<attr name="colorKeyboard" format="color"/>
<!-- Optional vertical gradient drawn behind the keys -->
<attr name="keyboardGradientStart" format="color"/>
<attr name="keyboardGradientEnd" format="color"/>
<!-- Background of the keys -->
<attr name="colorKey" format="color"/>
<!-- Background of the keys when pressed -->
Expand Down Expand Up @@ -332,4 +335,29 @@
<item name="clipboard_divider_color">?colorLabel</item>
<item name="clipboard_divider_height">2dp</item>
</style>
<style name="GradientPurplePink" parent="BaseTheme">
<item name="android:isLightTheme">false</item>
<item name="colorKeyboard">#251A3A</item>
<!-- Vertical Gradient -->
<item name="keyboardGradientStart">#8A2BE2</item>
<item name="keyboardGradientEnd">#AF6679</item>
<!-- Translucid keys : format #AARRGGBB -->
<item name="colorKey">#B3262033</item>
<item name="colorKeyActivated">#DD67527E</item>
<item name="colorKeyAction">#D13B2D50</item>
<item name="colorKeySpaceBar">#C72D253D</item>
<!-- Letters -->
<item name="colorLabel">#FFFFFFFF</item>
<item name="colorLabelPressed">#FFFFFFFF</item>
<item name="colorLabelActivated">#462563</item>
<item name="colorLabelLocked">#B9F6FF</item>
<item name="colorSubLabel">#B088D3</item>
<!-- Keys forms -->
<item name="keyBorderRadius">8dp</item>
<item name="keyBorderWidth">0dp</item>
<item name="keyBorderWidthActivated">0dp</item>
<!-- Emojis -->
<item name="emoji_button_bg">#3B2D50</item>
<item name="emoji_color">#FFFFFF</item>
</style>
</resources>
1 change: 1 addition & 0 deletions srcs/juloo.keyboard2/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ private int getThemeId(Resources res, String theme_name)
case "cobalt": return R.style.Cobalt;
case "pine": return R.style.Pine;
case "epaperblack": return R.style.ePaperBlack;
case "gradientpurplepink": return R.style.GradientPurplePink;
default:
case "system":
if ((night_mode & Configuration.UI_MODE_NIGHT_NO) != 0)
Expand Down
37 changes: 37 additions & 0 deletions srcs/juloo.keyboard2/Keyboard2View.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import android.view.WindowMetrics;
import java.util.Arrays;
import java.util.List;
import android.graphics.LinearGradient;
import android.graphics.Shader;

public class Keyboard2View extends View
implements View.OnTouchListener, Pointers.IPointerEventHandler
Expand Down Expand Up @@ -53,6 +55,8 @@ public class Keyboard2View extends View
private Theme _theme;
private Theme.Computed _tc;

private final Paint _keyboardBackgroundPaint = new Paint();

private static RectF _tmpRect = new RectF();

enum Vertical
Expand Down Expand Up @@ -337,9 +341,42 @@ public WindowInsets onApplyWindowInsets(WindowInsets wi)
Vertical.BOTTOM
};

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the right class to define and update _keyboardBackgroundPaint. Paints are computed in Theme.Computed (line 106 in Theme.java).

{
super.onSizeChanged(w, h, oldw, oldh);

if (_theme.hasKeyboardGradient && h > 0)
{
LinearGradient gradient = new LinearGradient(
0,
0,
0,
h,
_theme.keyboardGradientStart,
_theme.keyboardGradientEnd,
Shader.TileMode.CLAMP);

_keyboardBackgroundPaint.setShader(gradient);
}
else
{
_keyboardBackgroundPaint.setShader(null);
}
}

@Override
protected void onDraw(Canvas canvas)
{
if (_theme.hasKeyboardGradient)
{
canvas.drawRect(
0,
0,
getWidth(),
getHeight(),
_keyboardBackgroundPaint);
}
float y = _tc.margin_top;
for (KeyboardData.Row row : _keyboard.rows)
{
Expand Down
8 changes: 8 additions & 0 deletions srcs/juloo.keyboard2/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public class Theme
public final int colorKeyAction;
public final int colorKeySpaceBar;

// Optional keyboard background gradient
public final boolean hasKeyboardGradient;
public final int keyboardGradientStart;
public final int keyboardGradientEnd;

// Label colors
public final int lockedColor;
public final int activatedColor;
Expand Down Expand Up @@ -42,6 +47,9 @@ public Theme(Context context, AttributeSet attrs)
{
getKeyFont(context); // _key_font will be accessed
TypedArray s = context.getTheme().obtainStyledAttributes(attrs, R.styleable.keyboard, 0, 0);
hasKeyboardGradient = s.hasValue(R.styleable.keyboard_keyboardGradientStart) && s.hasValue(R.styleable.keyboard_keyboardGradientEnd);
keyboardGradientStart = s.getColor(R.styleable.keyboard_keyboardGradientStart, 0);
keyboardGradientEnd = s.getColor(R.styleable.keyboard_keyboardGradientEnd, 0);
colorKey = s.getColor(R.styleable.keyboard_colorKey, 0);
colorKeyActivated = s.getColor(R.styleable.keyboard_colorKeyActivated, 0);
colorKeyAction = s.getColor(R.styleable.keyboard_colorKeyAction, colorKey);
Expand Down
Loading