Merge branch 'SimpleMobileTools:main' into add_languages

This commit is contained in:
Naveen Singh
2022-08-19 15:55:13 +05:30
committed by GitHub
50 changed files with 184 additions and 77 deletions

View File

@@ -31,6 +31,7 @@ class SettingsActivity : SimpleActivity() {
setupVibrateOnKeypress()
setupShowPopupOnKeypress()
setupKeyboardLanguage()
setupKeyboardHeightMultiplier()
updateTextColors(settings_nested_scrollview)
@@ -145,4 +146,29 @@ class SettingsActivity : SimpleActivity() {
else -> "${getString(R.string.translation_english)} (QWERTY)"
}
}
private fun setupKeyboardHeightMultiplier() {
settings_keyboard_height_multiplier.text = getKeyboardHeightMultiplierText(config.keyboardHeightMultiplier)
settings_keyboard_height_multiplier_holder.setOnClickListener {
val items = arrayListOf(
RadioItem(KEYBOARD_HEIGHT_MULTIPLIER_SMALL, getKeyboardHeightMultiplierText(KEYBOARD_HEIGHT_MULTIPLIER_SMALL)),
RadioItem(KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM, getKeyboardHeightMultiplierText(KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM)),
RadioItem(KEYBOARD_HEIGHT_MULTIPLIER_LARGE, getKeyboardHeightMultiplierText(KEYBOARD_HEIGHT_MULTIPLIER_LARGE)),
)
RadioGroupDialog(this@SettingsActivity, items, config.keyboardHeightMultiplier) {
config.keyboardHeightMultiplier = it as Int
settings_keyboard_height_multiplier.text = getKeyboardHeightMultiplierText(config.keyboardHeightMultiplier)
}
}
}
private fun getKeyboardHeightMultiplierText(multiplier: Int): String {
return when (multiplier) {
KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> getString(R.string.small)
KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> getString(R.string.medium)
KEYBOARD_HEIGHT_MULTIPLIER_LARGE -> getString(R.string.large)
else -> getString(R.string.small)
}
}
}

View File

@@ -25,6 +25,11 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(KEYBOARD_LANGUAGE, getDefaultLanguage())
set(keyboardLanguage) = prefs.edit().putInt(KEYBOARD_LANGUAGE, keyboardLanguage).apply()
var keyboardHeightMultiplier: Int
get() = prefs.getInt(HEIGHT_MULTIPLIER, 1)
set(keyboardHeightMultiplier) = prefs.edit().putInt(HEIGHT_MULTIPLIER, keyboardHeightMultiplier).apply()
private fun getDefaultLanguage(): Int {
val conf = context.resources.configuration
return if (conf.locale.toString().toLowerCase(Locale.getDefault()).startsWith("ru_")) {

View File

@@ -12,6 +12,7 @@ const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress"
const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress"
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
const val KEYBOARD_LANGUAGE = "keyboard_language"
const val HEIGHT_MULTIPLIER = "height_multiplier"
// differentiate current and pinned clips at the keyboards' Clipboard section
const val ITEM_SECTION_LABEL = 0
@@ -31,5 +32,9 @@ const val LANGUAGE_TURKISH_Q = 10
const val LANGUAGE_LITHUANIAN = 11
const val LANGUAGE_BENGALI = 12
// keyboard height multiplier options
const val KEYBOARD_HEIGHT_MULTIPLIER_SMALL = 1
const val KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM = 2
const val KEYBOARD_HEIGHT_MULTIPLIER_LARGE = 3
const val EMOJI_SPEC_FILE_PATH = "media/emoji_spec.txt"

View File

@@ -12,6 +12,8 @@ import android.view.inputmethod.EditorInfo
import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
import androidx.annotation.XmlRes
import com.simplemobiletools.keyboard.R
import com.simplemobiletools.keyboard.extensions.config
import kotlin.math.roundToInt
/**
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard consists of rows of keys.
@@ -28,6 +30,9 @@ class MyKeyboard {
/** Default key height */
private var mDefaultHeight = 0
/** Multiplier for the keyboard height */
var mKeyboardHeightMultiplier: Float = 1F
/** Is the keyboard in the shifted state */
var mShiftState = SHIFT_OFF
@@ -100,7 +105,7 @@ class MyKeyboard {
this.parent = parent
val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard)
defaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth)
defaultHeight = res.getDimension(R.dimen.key_height).toInt()
defaultHeight = (res.getDimension(R.dimen.key_height) * this.parent.mKeyboardHeightMultiplier).roundToInt()
defaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap)
a.recycle()
}
@@ -244,6 +249,7 @@ class MyKeyboard {
mDefaultHorizontalGap = 0
mDefaultWidth = mDisplayWidth / 10
mDefaultHeight = mDefaultWidth
mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier);
mKeys = ArrayList()
mEnterKeyType = enterKeyType
loadKeyboard(context, context.resources.getXml(xmlLayoutResId))
@@ -267,6 +273,7 @@ class MyKeyboard {
row.defaultHeight = mDefaultHeight
row.defaultWidth = keyWidth
row.defaultHorizontalGap = mDefaultHorizontalGap
mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier);
characters.forEachIndexed { index, character ->
val key = Key(row)
@@ -377,4 +384,13 @@ class MyKeyboard {
mDefaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, mDisplayWidth, 0)
a.recycle()
}
private fun getKeyboardHeightMultiplier(multiplierType: Int): Float {
return when(multiplierType) {
KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> 1.0F
KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> 1.2F
KEYBOARD_HEIGHT_MULTIPLIER_LARGE -> 1.4F
else -> 1.0F
}
}
}

View File

@@ -167,7 +167,7 @@
style="@style/SettingsHolderTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_keyboard_language_label"
@@ -185,6 +185,30 @@
tools:text="@string/translation_english" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_keyboard_height_multiplier_holder"
style="@style/SettingsHolderTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_keyboard_height_multiplier_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/keyboard_height" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_keyboard_height_multiplier"
style="@style/SettingsTextValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_keyboard_height_multiplier_label"
tools:text="@string/small" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@@ -38,4 +38,4 @@
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>
</resources>

View File

@@ -14,7 +14,7 @@
<string name="clipboard_recent">Недавнее</string>
<string name="clipboard_current">Текущее</string>
<string name="clipboard_pinned">Закреплено</string>
<string name="add_new_item">Добавить новый элемент</string>
<string name="add_new_item">Добавить</string>
<string name="manage_clips">Здесь вы можете изменять или добавлять данные для быстрого доступа.</string>
<string name="clip_text">Выбрать текст</string>
<string name="pin_text">Закрепить текст</string>
@@ -25,10 +25,10 @@
<string name="keycode_delete">Удалить</string>
<string name="keycode_mode_change">Изменить тип клавиатуры</string>
<string name="keycode_shift">Shift</string>
<string name="keycode_enter">Войти</string>
<string name="keycode_enter">Enter</string>
<!-- Settings -->
<string name="show_clipboard_content">Показывать содержимое буфера обмена при наличии</string>
<string name="show_popup">Показывать всплывающее окно при нажатии клавиши</string>
<string name="show_popup">Показ ввода по нажатию</string>
<string name="vibrate_on_keypress">Вибрация по нажатию</string>
<string name="keyboard_language">Язык клавиатуры</string>
<string name="keyboard_height">Высота клавиатуры</string>