Compare commits

...

6 Commits

Author SHA1 Message Date
Patrick Goldinger
1307f401cc Release v0.2.6 2020-12-01 20:46:24 +01:00
Patrick Goldinger
ca6006767b Improve key font sizing (#48)
- Key font size is now generated with a better algorithm.
- Key font size in general is now bigger and the letter/white space
  ratio has been improved.
2020-12-01 19:57:58 +01:00
Patrick Goldinger
2202db53ba Add reference to permission list to README.md 2020-12-01 16:46:08 +01:00
Patrick Goldinger
321f19272e Fix Smartbar number row disappearing incorrectly (#52) 2020-11-30 22:24:06 +01:00
Patrick Goldinger
06a8a04020 Improve keyboard height calculation (#50) 2020-11-30 22:03:33 +01:00
Patrick Goldinger
2a1f7c3217 Add Horizontal Ellipsis (Three-dots) character to symbols (#51) 2020-11-30 18:18:02 +01:00
14 changed files with 106 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
<img align="left" width="80" height="80"
src="fastlane/metadata/android/en-US/images/icon.png" alt="App icon">
# FlorisBoard [![Crowdin](https://badges.crowdin.net/florisboard/localized.svg)](https://crowdin.florisboard.patrickgold.dev)
# FlorisBoard ![Release](https://img.shields.io/github/v/release/florisboard/florisboard) [![Crowdin](https://badges.crowdin.net/florisboard/localized.svg)](https://crowdin.florisboard.patrickgold.dev)
**FlorisBoard** is a free and open-source keyboard for Android 6.0+
devices. It aims at being modern, user-friendly and customizable while
@@ -121,6 +121,10 @@ translating FlorisBoard to make it more accessible, etc. For more
information see the ![contributing guidelines](CONTRIBUTING.md). Thank
you for your help!
## List of permissions FlorisBoard requests
Please refer to this [page](https://github.com/florisboard/florisboard/wiki/List-of-permissions-FlorisBoard-requests)
to get more information on this topic.
## Used libraries, components and icons
* [Google Flexbox Layout for Android](https://github.com/google/flexbox-layout)
by [google](https://github.com/google)

View File

@@ -10,8 +10,8 @@ android {
applicationId "dev.patrickgold.florisboard"
minSdkVersion 23
targetSdkVersion 29
versionCode 17
versionName "0.2.5"
versionCode 18
versionName "0.2.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@@ -12,7 +12,9 @@
{ "code": 44, "label": ",", "popup": [] },
{ "code": -205, "label": "view_numeric_advanced", "type": "system_gui" },
{ "code": 32, "label": " ", "popup": [] },
{ "code": 46, "label": ".", "popup": [] },
{ "code": 46, "label": ".", "popup": [
{ "code": 8230, "label": "…" }
] },
{ "code": 10, "label": "enter", "type": "enter_editing" }
]
]

View File

@@ -19,6 +19,7 @@ package dev.patrickgold.florisboard.ime.core
import android.content.Context
import android.content.res.Configuration
import android.util.AttributeSet
import android.util.DisplayMetrics
import android.util.Log
import android.widget.LinearLayout
import android.widget.ViewFlipper
@@ -27,6 +28,7 @@ import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.util.ViewLayoutUtils
import kotlin.math.roundToInt
/**
* Root view of the keyboard. Notifies [FlorisBoard] when it has been attached to a window.
*/
@@ -52,7 +54,11 @@ class InputView : LinearLayout {
constructor(context: Context) : this(context, null)
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
override fun onAttachedToWindow() {
if (BuildConfig.DEBUG) Log.i(this::class.simpleName, "onAttachedToWindow()")
@@ -68,7 +74,7 @@ class InputView : LinearLayout {
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val heightFactor = when (resources.configuration.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> 0.85f
Configuration.ORIENTATION_LANDSCAPE -> 1.0f
else -> if (prefs.keyboard.oneHandedMode != "off") {
0.9f
} else {
@@ -84,15 +90,47 @@ class InputView : LinearLayout {
"extra_tall" -> 1.15f
else -> 1.00f
}
var height = (resources.getDimension(R.dimen.inputView_baseHeight) * heightFactor).roundToInt()
var height = (calcInputViewHeight() * heightFactor).roundToInt()
desiredInputViewHeight = height
desiredSmartbarHeight = (0.16129 * height).roundToInt()
desiredTextKeyboardViewHeight = height - desiredSmartbarHeight
desiredMediaKeyboardViewHeight = height
// Add bottom offset for curved screens here. As the desired heights have already been set,
// adding a value to the height now will result in a bottom padding (aka offset).
height += ViewLayoutUtils.convertDpToPixel(florisboard.prefs.keyboard.bottomOffset.toFloat(), context).toInt()
height += ViewLayoutUtils.convertDpToPixel(
florisboard.prefs.keyboard.bottomOffset.toFloat(),
context
).toInt()
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))
}
/**
* Calculates the input view height based on the current screen dimensions and the auto
* selected dimension values.
*
* This method and the fraction values have been inspired by [OpenBoard](https://github.com/dslul/openboard)
* but are not 1:1 the same. This implementation differs from the
* [original](https://github.com/dslul/openboard/blob/90ae4c8aec034a8935e1fd02b441be25c7dba6ce/app/src/main/java/org/dslul/openboard/inputmethod/latin/utils/ResourceUtils.java)
* by calculating the average of the min and max height values, then taking at least the input
* view base height and return this resulting value.
*/
private fun calcInputViewHeight(): Float {
val dm: DisplayMetrics = resources.displayMetrics
val minBaseSize: Float = when (resources.configuration.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> resources.getFraction(
R.fraction.inputView_minHeightFraction, dm.heightPixels, dm.heightPixels
)
else -> resources.getFraction(
R.fraction.inputView_minHeightFraction, dm.widthPixels, dm.widthPixels
)
}
val maxBaseSize: Float = resources.getFraction(
R.fraction.inputView_maxHeightFraction, dm.heightPixels, dm.heightPixels
)
return ((minBaseSize + maxBaseSize) / 2.0f).coerceAtLeast(
resources.getDimension(R.dimen.inputView_baseHeight)
)
}
}

View File

@@ -639,5 +639,6 @@ class TextInputManager private constructor() : CoroutineScope by MainScope(),
if (keyData.code != KeyCode.SHIFT && !capsLock) {
updateCapsState()
}
smartbarManager.updateActiveContainerVisibility()
}
}

View File

@@ -39,7 +39,6 @@ import dev.patrickgold.florisboard.ime.text.keyboard.KeyboardMode
import dev.patrickgold.florisboard.ime.text.keyboard.KeyboardView
import dev.patrickgold.florisboard.util.setBackgroundTintColor2
import java.util.*
import kotlin.math.abs
/**
* View class for managing the rendering and the events of a single keyboard key.
@@ -75,7 +74,7 @@ class KeyView(
alpha = 255
color = 0
isAntiAlias = true
isFakeBoldText = true
isFakeBoldText = false
textAlign = Paint.Align.CENTER
textSize = resources.getDimension(R.dimen.key_textSize)
typeface = Typeface.DEFAULT
@@ -85,7 +84,7 @@ class KeyView(
alpha = 120
color = 0
isAntiAlias = true
isFakeBoldText = true
isFakeBoldText = false
textAlign = Paint.Align.CENTER
textSize = resources.getDimension(R.dimen.key_textHintSize)
typeface = Typeface.DEFAULT
@@ -581,8 +580,8 @@ class KeyView(
* Automatically sets the text size of [boxPaint] for given [text] so it fits within the given
* bounds.
*
* Implementation based on this SO answer by Michael Scheper, but has been modified to
* incorporate the height as well: https://stackoverflow.com/a/21895626/6801193
* Implementation based on this blog post by Lucas (SketchingDev), written on Aug 20, 2015
* https://sketchingdev.co.uk/blog/resizing-text-to-fit-into-a-container-on-android.html
*
* @param boxPaint The [Paint] object which the text size should be applied to.
* @param boxWidth The max width for the surrounding box of [text].
@@ -590,28 +589,20 @@ class KeyView(
* @param text The text for which the size should be calculated.
*/
private fun setTextSizeFor(boxPaint: Paint, boxWidth: Float, boxHeight: Float, text: String) {
var textSize = 64.0f
// Must loop twice as there can be bot with and height which are too big, which requires
// 2 iterations to adjust
for (n in 0..1) {
var stage = 1
var textSize = 0.0f
while (stage < 3) {
if (stage == 1) {
textSize += 10.0f
} else if (stage == 2) {
textSize -= 1.0f
}
boxPaint.textSize = textSize
boxPaint.getTextBounds(text, 0, text.length, tempRect)
val diffWidth = tempRect.width() - boxWidth
val diffHeight = tempRect.height() - boxHeight
val factor = if (diffWidth < 0 && diffHeight < 0) {
// Text box is smaller as given box, text size must be increased
if (abs(diffWidth) < abs(diffHeight)) {
boxWidth / tempRect.width()
} else {
boxHeight / tempRect.height()
}
} else if (diffWidth > diffHeight) {
// Text box is larger on minimum one side than given box, text size must be decreased
boxWidth / tempRect.width()
} else {
boxHeight / tempRect.height()
val fits = tempRect.width() < boxWidth && tempRect.height() < boxHeight
if (stage == 1 && !fits || stage == 2 && fits) {
stage++
}
textSize *= factor
}
boxPaint.textSize = textSize
}
@@ -792,8 +783,8 @@ class KeyView(
data.type == KeyType.CHARACTER && data.code != KeyCode.SPACE -> {
setTextSizeFor(
labelPaint,
desiredWidth - (2.6f * drawablePadding),
desiredHeight - (3.6f * drawablePadding),
desiredWidth - (2.2f * drawablePadding),
desiredHeight - (3.0f * drawablePadding),
// Note: taking a "X" here because it is one of the biggest letters and
// the keys must have the same base character for calculation, else
// they will all look different and weird...

View File

@@ -205,7 +205,7 @@ class SmartbarManager private constructor() : CoroutineScope by MainScope(),
ccRow?.updateVisibility()
}
private fun updateActiveContainerVisibility() {
fun updateActiveContainerVisibility() {
val smartbarView = smartbarView ?: return
if (isQuickActionsVisible) {

View File

@@ -1,4 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="inputView_baseHeight">214dp</dimen>
<dimen name="smartbar_baseHeight">34dp</dimen>
<dimen name="textKeyboardView_baseHeight">184dp</dimen>
<dimen name="mediaKeyboardView_baseHeight">@dimen/inputView_baseHeight</dimen>
<fraction name="inputView_minHeightFraction">45%p</fraction>
<fraction name="inputView_maxHeightFraction">46%p</fraction>
<dimen name="media_tab_paddingH">10dp</dimen>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<fraction name="inputView_minHeightFraction">40%p</fraction>
<fraction name="inputView_maxHeightFraction">46%p</fraction>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<fraction name="inputView_minHeightFraction">35%p</fraction>
<fraction name="inputView_maxHeightFraction">46%p</fraction>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<fraction name="inputView_minHeightFraction">35%p</fraction>
<fraction name="inputView_maxHeightFraction">46%p</fraction>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<fraction name="inputView_minHeightFraction">35%p</fraction>
<fraction name="inputView_maxHeightFraction">46%p</fraction>
</resources>

View File

@@ -5,6 +5,9 @@
<dimen name="textKeyboardView_baseHeight">208dp</dimen>
<dimen name="mediaKeyboardView_baseHeight">@dimen/inputView_baseHeight</dimen>
<fraction name="inputView_minHeightFraction">38.2%p</fraction>
<fraction name="inputView_maxHeightFraction">46%p</fraction>
<dimen name="key_width">33dp</dimen>
<dimen name="key_height">42dp</dimen>
<dimen name="emoji_key_width">@dimen/key_height</dimen>

View File

@@ -0,0 +1,4 @@
- Add Horizontal Ellipsis (Three-dots) character to symbols (#51)
- Improve keyboard height calculation (#50)
- Improve key font sizing (#48)
- Fix Smartbar number row disappearing incorrectly (#52)