diff options
| author | Chasm Solacer | 2022-12-11 22:10:00 +0100 |
|---|---|---|
| committer | GitHub | 2022-12-11 22:10:00 +0100 |
| commit | 90cad963ec147313eee32bd4bb3a46922a3eea7d (patch) | |
| tree | 6b8b219bb50b1d28d28dcaddf473081f9e11df3e /srcs | |
| parent | bf318729555cc6e3362716e16d60b53d466e808f (diff) | |
| download | unexpected-keyboard-90cad963ec147313eee32bd4bb3a46922a3eea7d.tar.gz unexpected-keyboard-90cad963ec147313eee32bd4bb3a46922a3eea7d.zip | |
Make the keyboard transparent (#252)
* Add option for keyboard opacity (transparency). Keyboard background, keys and pressed keys can be adjusted separately.
* Make the borders transparent as well
* Moved setAlphas outside drawKeyFrame to top of onDraw method
Diffstat (limited to 'srcs')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 9 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 0ef5b67..c289436 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -1,6 +1,5 @@ package juloo.keyboard2; -import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; @@ -9,7 +8,6 @@ import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.KeyEvent; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; final class Config @@ -40,6 +38,9 @@ final class Config public float keyVerticalInterval; public float keyHorizontalInterval; public int labelBrightness; // 0 - 255 + public int keyboardOpacity; // 0 - 255 + public int keyOpacity; // 0 - 255 + public int keyActivatedOpacity; // 0 - 255 public boolean preciseRepeat; public boolean double_tap_lock_shift; public float characterSize; // Ratio @@ -141,6 +142,10 @@ final class Config * horizontalIntervalScale; // Label brightness is used as the alpha channel labelBrightness = _prefs.getInt("label_brightness", 100) * 255 / 100; + // Keyboard opacity + keyboardOpacity = _prefs.getInt("keyboard_opacity", 100) * 255 / 100; + keyOpacity = _prefs.getInt("key_opacity", 100) * 255 / 100; + keyActivatedOpacity = _prefs.getInt("key_activated_opacity", 100) * 255 / 100; // Do not substract keyVerticalInterval from keyHeight because this is done // during rendered. keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4; diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index ce6c9f4..c3271b9 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -3,7 +3,6 @@ package juloo.keyboard2; import android.content.Context; import android.content.ContextWrapper; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; @@ -12,7 +11,6 @@ import android.os.Build.VERSION; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.HapticFeedbackConstants; -import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.Window; @@ -258,6 +256,12 @@ public class Keyboard2View extends View protected void onDraw(Canvas canvas) { updateFlags(); + // Set keyboard background opacity + getBackground().setAlpha(_config.keyboardOpacity); + // Set keys opacity + _theme.keyBgPaint.setAlpha(_config.keyOpacity); + _theme.keyDownBgPaint.setAlpha(_config.keyActivatedOpacity); + _theme.keyBorderPaint.setAlpha(_config.keyOpacity); float y = _config.marginTop + _config.keyVerticalInterval / 2; for (KeyboardData.Row row : _keyboard.rows) { |
