Merge pull request #227 from fatihergin/feature/viewbinding-and-sdk-34-migration
Feature/viewbinding and sdk 34 migration
This commit is contained in:
commit
60912ca721
|
@ -1,6 +1,5 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
|
@ -10,12 +9,13 @@ if (keystorePropertiesFile.exists()) {
|
|||
}
|
||||
|
||||
android {
|
||||
compileSdk 33
|
||||
namespace "com.simplemobiletools.keyboard"
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.simplemobiletools.keyboard"
|
||||
minSdk 23
|
||||
targetSdk 33
|
||||
targetSdk 34
|
||||
versionCode 22
|
||||
versionName "5.4.7"
|
||||
multiDexEnabled true
|
||||
|
@ -34,6 +34,11 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig true
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
|
@ -47,7 +52,16 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
flavorDimensions "variants"
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = '17'
|
||||
}
|
||||
|
||||
flavorDimensions = ["variants"]
|
||||
productFlavors {
|
||||
core {}
|
||||
fdroid {}
|
||||
|
@ -65,7 +79,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:2d4e07e5f4'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:0e173dc5ad'
|
||||
implementation 'androidx.emoji2:emoji2-bundled:1.2.0'
|
||||
implementation 'androidx.autofill:autofill:1.1.0'
|
||||
|
||||
|
|
|
@ -12,28 +12,32 @@ import com.simplemobiletools.commons.helpers.LICENSE_GSON
|
|||
import com.simplemobiletools.commons.models.FAQItem
|
||||
import com.simplemobiletools.keyboard.BuildConfig
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import com.simplemobiletools.keyboard.databinding.ActivityMainBinding
|
||||
|
||||
class MainActivity : SimpleActivity() {
|
||||
private val binding by viewBinding(ActivityMainBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
setContentView(binding.root)
|
||||
appLaunched(BuildConfig.APPLICATION_ID)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(main_nested_scrollview, main_toolbar)
|
||||
binding.apply {
|
||||
updateMaterialActivityViews(mainCoordinator, mainHolder, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(mainNestedScrollview, mainToolbar)
|
||||
|
||||
change_keyboard_holder.setOnClickListener {
|
||||
changeKeyboardHolder.setOnClickListener {
|
||||
(getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager).showInputMethodPicker()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(main_toolbar)
|
||||
setupToolbar(binding.mainToolbar)
|
||||
if (!isKeyboardEnabled()) {
|
||||
ConfirmationAdvancedDialog(this, messageId = R.string.redirection_note, positive = R.string.ok, negative = 0) { success ->
|
||||
if (success) {
|
||||
|
@ -47,12 +51,12 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
updateTextColors(main_nested_scrollview)
|
||||
updateTextColors(binding.mainNestedScrollview)
|
||||
updateChangeKeyboardColor()
|
||||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
main_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.mainToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||
R.id.settings -> launchSettings()
|
||||
|
@ -64,7 +68,7 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun refreshMenuItems() {
|
||||
main_toolbar.menu.apply {
|
||||
binding.mainToolbar.menu.apply {
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
||||
}
|
||||
}
|
||||
|
@ -89,8 +93,10 @@ class MainActivity : SimpleActivity() {
|
|||
private fun updateChangeKeyboardColor() {
|
||||
val applyBackground = resources.getDrawable(R.drawable.button_background_rounded, theme) as RippleDrawable
|
||||
(applyBackground as LayerDrawable).findDrawableByLayerId(R.id.button_background_holder).applyColorFilter(getProperPrimaryColor())
|
||||
change_keyboard.background = applyBackground
|
||||
change_keyboard.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
binding.changeKeyboard.apply {
|
||||
background = applyBackground
|
||||
setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
}
|
||||
}
|
||||
|
||||
private fun isKeyboardEnabled(): Boolean {
|
||||
|
|
|
@ -13,34 +13,39 @@ import com.simplemobiletools.commons.helpers.*
|
|||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.adapters.ClipsActivityAdapter
|
||||
import com.simplemobiletools.keyboard.databinding.ActivityManageClipboardItemsBinding
|
||||
import com.simplemobiletools.keyboard.dialogs.AddOrEditClipDialog
|
||||
import com.simplemobiletools.keyboard.dialogs.ExportClipsDialog
|
||||
import com.simplemobiletools.keyboard.extensions.clipsDB
|
||||
import com.simplemobiletools.keyboard.extensions.config
|
||||
import com.simplemobiletools.keyboard.helpers.ClipsHelper
|
||||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import kotlinx.android.synthetic.main.activity_manage_clipboard_items.*
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
private val PICK_EXPORT_CLIPS_INTENT = 21
|
||||
private val PICK_IMPORT_CLIPS_SOURCE_INTENT = 22
|
||||
companion object {
|
||||
private const val PICK_EXPORT_CLIPS_INTENT = 21
|
||||
private const val PICK_IMPORT_CLIPS_SOURCE_INTENT = 22
|
||||
}
|
||||
|
||||
private val binding by viewBinding(ActivityManageClipboardItemsBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_manage_clipboard_items)
|
||||
setContentView(binding.root)
|
||||
setupOptionsMenu()
|
||||
updateTextColors(suggestions_items_holder)
|
||||
updateTextColors(binding.suggestionsItemsHolder)
|
||||
updateClips()
|
||||
|
||||
updateMaterialActivityViews(clipboard_coordinator, clipboard_items_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(clipboard_nested_scrollview, clipboard_toolbar)
|
||||
binding.apply {
|
||||
updateMaterialActivityViews(clipboardCoordinator, clipboardItemsList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(clipboardNestedScrollview, clipboardToolbar)
|
||||
|
||||
clipboard_items_placeholder.text = "${getText(R.string.manage_clipboard_empty)}\n\n${getText(R.string.manage_clips)}"
|
||||
clipboard_items_placeholder_2.apply {
|
||||
clipboardItemsPlaceholder.text = "${getText(R.string.manage_clipboard_empty)}\n\n${getText(R.string.manage_clips)}"
|
||||
clipboardItemsPlaceholder2.apply {
|
||||
underlineText()
|
||||
setTextColor(getProperPrimaryColor())
|
||||
setOnClickListener {
|
||||
|
@ -48,10 +53,11 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(clipboard_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.clipboardToolbar, NavigationIcon.Arrow)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||
|
@ -67,7 +73,7 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
|
|||
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
clipboard_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.clipboardToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.add_clipboard_item -> {
|
||||
addOrEditClip()
|
||||
|
@ -97,15 +103,17 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
|
|||
ensureBackgroundThread {
|
||||
val clips = clipsDB.getClips().toMutableList() as ArrayList<Clip>
|
||||
runOnUiThread {
|
||||
ClipsActivityAdapter(this, clips, clipboard_items_list, this) {
|
||||
ClipsActivityAdapter(this, clips, binding.clipboardItemsList, this) {
|
||||
addOrEditClip(it as Clip)
|
||||
}.apply {
|
||||
clipboard_items_list.adapter = this
|
||||
binding.clipboardItemsList.adapter = this
|
||||
}
|
||||
|
||||
clipboard_items_list.beVisibleIf(clips.isNotEmpty())
|
||||
clipboard_items_placeholder.beVisibleIf(clips.isEmpty())
|
||||
clipboard_items_placeholder_2.beVisibleIf(clips.isEmpty())
|
||||
binding.apply {
|
||||
clipboardItemsList.beVisibleIf(clips.isNotEmpty())
|
||||
clipboardItemsPlaceholder.beVisibleIf(clips.isEmpty())
|
||||
clipboardItemsPlaceholder2.beVisibleIf(clips.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,29 +7,31 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.databinding.ActivitySettingsBinding
|
||||
import com.simplemobiletools.keyboard.extensions.config
|
||||
import com.simplemobiletools.keyboard.extensions.getKeyboardLanguageText
|
||||
import com.simplemobiletools.keyboard.extensions.getKeyboardLanguages
|
||||
import com.simplemobiletools.keyboard.helpers.*
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
private val binding by viewBinding(ActivitySettingsBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
setContentView(binding.root)
|
||||
|
||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
||||
binding.apply {
|
||||
updateMaterialActivityViews(settingsCoordinator, settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(settingsNestedScrollview, settingsToolbar)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||
|
||||
setupPurchaseThankYou()
|
||||
setupCustomizeColors()
|
||||
|
@ -45,47 +47,57 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupSentencesCapitalization()
|
||||
setupShowNumbersRow()
|
||||
|
||||
updateTextColors(settings_nested_scrollview)
|
||||
binding.apply {
|
||||
updateTextColors(settingsNestedScrollview)
|
||||
|
||||
arrayOf(settings_color_customization_section_label, settings_general_settings_label).forEach {
|
||||
arrayOf(settingsColorCustomizationSectionLabel, settingsGeneralSettingsLabel).forEach {
|
||||
it.setTextColor(getProperPrimaryColor())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPurchaseThankYou() {
|
||||
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
|
||||
settings_purchase_thank_you_holder.setOnClickListener {
|
||||
binding.apply {
|
||||
settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||
settingsPurchaseThankYouHolder.setOnClickListener {
|
||||
launchPurchaseThankYouIntent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCustomizeColors() {
|
||||
settings_color_customization_label.text = getCustomizeColorsString()
|
||||
settings_color_customization_holder.setOnClickListener {
|
||||
binding.apply {
|
||||
settingsColorCustomizationLabel.text = getCustomizeColorsString()
|
||||
settingsColorCustomizationHolder.setOnClickListener {
|
||||
handleCustomizeColorsClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
settings_use_english.isChecked = config.useEnglish
|
||||
settings_use_english_holder.setOnClickListener {
|
||||
settings_use_english.toggle()
|
||||
config.useEnglish = settings_use_english.isChecked
|
||||
binding.apply {
|
||||
settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
settingsUseEnglish.isChecked = config.useEnglish
|
||||
settingsUseEnglishHolder.setOnClickListener {
|
||||
settingsUseEnglish.toggle()
|
||||
config.useEnglish = settingsUseEnglish.isChecked
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLanguage() {
|
||||
settings_language.text = Locale.getDefault().displayLanguage
|
||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
||||
settings_language_holder.setOnClickListener {
|
||||
binding.apply {
|
||||
settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||
settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||
settingsLanguageHolder.setOnClickListener {
|
||||
launchChangeAppLanguageIntent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupManageClipboardItems() {
|
||||
settings_manage_clipboard_items_holder.setOnClickListener {
|
||||
binding.settingsManageClipboardItemsHolder.setOnClickListener {
|
||||
Intent(this, ManageClipboardItemsActivity::class.java).apply {
|
||||
startActivity(this)
|
||||
}
|
||||
|
@ -93,43 +105,52 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupVibrateOnKeypress() {
|
||||
settings_vibrate_on_keypress.isChecked = config.vibrateOnKeypress
|
||||
settings_vibrate_on_keypress_holder.setOnClickListener {
|
||||
settings_vibrate_on_keypress.toggle()
|
||||
config.vibrateOnKeypress = settings_vibrate_on_keypress.isChecked
|
||||
binding.apply {
|
||||
settingsVibrateOnKeypress.isChecked = config.vibrateOnKeypress
|
||||
settingsVibrateOnKeypressHolder.setOnClickListener {
|
||||
settingsVibrateOnKeypress.toggle()
|
||||
config.vibrateOnKeypress = settingsVibrateOnKeypress.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowPopupOnKeypress() {
|
||||
settings_show_popup_on_keypress.isChecked = config.showPopupOnKeypress
|
||||
settings_show_popup_on_keypress_holder.setOnClickListener {
|
||||
settings_show_popup_on_keypress.toggle()
|
||||
config.showPopupOnKeypress = settings_show_popup_on_keypress.isChecked
|
||||
binding.apply {
|
||||
settingsShowPopupOnKeypress.isChecked = config.showPopupOnKeypress
|
||||
settingsShowPopupOnKeypressHolder.setOnClickListener {
|
||||
settingsShowPopupOnKeypress.toggle()
|
||||
config.showPopupOnKeypress = settingsShowPopupOnKeypress.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowKeyBorders() {
|
||||
settings_show_key_borders.isChecked = config.showKeyBorders
|
||||
settings_show_key_borders_holder.setOnClickListener {
|
||||
settings_show_key_borders.toggle()
|
||||
config.showKeyBorders = settings_show_key_borders.isChecked
|
||||
binding.apply {
|
||||
settingsShowKeyBorders.isChecked = config.showKeyBorders
|
||||
settingsShowKeyBordersHolder.setOnClickListener {
|
||||
settingsShowKeyBorders.toggle()
|
||||
config.showKeyBorders = settingsShowKeyBorders.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupKeyboardLanguage() {
|
||||
settings_keyboard_language.text = getKeyboardLanguageText(config.keyboardLanguage)
|
||||
settings_keyboard_language_holder.setOnClickListener {
|
||||
binding.apply {
|
||||
settingsKeyboardLanguage.text = getKeyboardLanguageText(config.keyboardLanguage)
|
||||
settingsKeyboardLanguageHolder.setOnClickListener {
|
||||
val items = getKeyboardLanguages()
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.keyboardLanguage) {
|
||||
config.keyboardLanguage = it as Int
|
||||
settings_keyboard_language.text = getKeyboardLanguageText(config.keyboardLanguage)
|
||||
settingsKeyboardLanguage.text = getKeyboardLanguageText(config.keyboardLanguage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupKeyboardHeightMultiplier() {
|
||||
settings_keyboard_height_multiplier.text = getKeyboardHeightPercentageText(config.keyboardHeightPercentage)
|
||||
settings_keyboard_height_multiplier_holder.setOnClickListener {
|
||||
binding.apply {
|
||||
settingsKeyboardHeightMultiplier.text = getKeyboardHeightPercentageText(config.keyboardHeightPercentage)
|
||||
settingsKeyboardHeightMultiplierHolder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(KEYBOARD_HEIGHT_70_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_70_PERCENT)),
|
||||
RadioItem(KEYBOARD_HEIGHT_80_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_80_PERCENT)),
|
||||
|
@ -142,7 +163,8 @@ class SettingsActivity : SimpleActivity() {
|
|||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.keyboardHeightPercentage) {
|
||||
config.keyboardHeightPercentage = it as Int
|
||||
settings_keyboard_height_multiplier.text = getKeyboardHeightPercentageText(config.keyboardHeightPercentage)
|
||||
settingsKeyboardHeightMultiplier.text = getKeyboardHeightPercentageText(config.keyboardHeightPercentage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,26 +172,32 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun getKeyboardHeightPercentageText(keyboardHeightPercentage: Int): String = "$keyboardHeightPercentage%"
|
||||
|
||||
private fun setupShowClipboardContent() {
|
||||
settings_show_clipboard_content.isChecked = config.showClipboardContent
|
||||
settings_show_clipboard_content_holder.setOnClickListener {
|
||||
settings_show_clipboard_content.toggle()
|
||||
config.showClipboardContent = settings_show_clipboard_content.isChecked
|
||||
binding.apply {
|
||||
settingsShowClipboardContent.isChecked = config.showClipboardContent
|
||||
settingsShowClipboardContentHolder.setOnClickListener {
|
||||
settingsShowClipboardContent.toggle()
|
||||
config.showClipboardContent = settingsShowClipboardContent.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSentencesCapitalization() {
|
||||
settings_start_sentences_capitalized.isChecked = config.enableSentencesCapitalization
|
||||
settings_start_sentences_capitalized_holder.setOnClickListener {
|
||||
settings_start_sentences_capitalized.toggle()
|
||||
config.enableSentencesCapitalization = settings_start_sentences_capitalized.isChecked
|
||||
binding.apply {
|
||||
settingsStartSentencesCapitalized.isChecked = config.enableSentencesCapitalization
|
||||
settingsStartSentencesCapitalizedHolder.setOnClickListener {
|
||||
settingsStartSentencesCapitalized.toggle()
|
||||
config.enableSentencesCapitalization = settingsStartSentencesCapitalized.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowNumbersRow() {
|
||||
settings_show_numbers_row.isChecked = config.showNumbersRow
|
||||
settings_show_numbers_row_holder.setOnClickListener {
|
||||
settings_show_numbers_row.toggle()
|
||||
config.showNumbersRow = settings_show_numbers_row.isChecked
|
||||
binding.apply {
|
||||
settingsShowNumbersRow.isChecked = config.showNumbersRow
|
||||
settingsShowNumbersRowHolder.setOnClickListener {
|
||||
settingsShowNumbersRow.toggle()
|
||||
config.showNumbersRow = settingsShowNumbersRow.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
|||
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.databinding.ItemClipInActivityBinding
|
||||
import com.simplemobiletools.keyboard.dialogs.AddOrEditClipDialog
|
||||
import com.simplemobiletools.keyboard.extensions.clipsDB
|
||||
import com.simplemobiletools.keyboard.helpers.ClipsHelper
|
||||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import kotlinx.android.synthetic.main.item_clip_in_activity.view.*
|
||||
import java.util.*
|
||||
import java.util.Collections
|
||||
|
||||
class ClipsActivityAdapter(
|
||||
activity: BaseSimpleActivity, var items: ArrayList<Clip>, recyclerView: MyRecyclerView, val listener: RefreshRecyclerViewListener, itemClick: (Any) -> Unit
|
||||
|
@ -98,7 +98,7 @@ class ClipsActivityAdapter(
|
|||
wasClipMoved = false
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_clip_in_activity, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(ItemClipInActivityBinding.inflate(layoutInflater, parent, false).root)
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
|
@ -154,15 +154,15 @@ class ClipsActivityAdapter(
|
|||
}
|
||||
|
||||
val isSelected = selectedKeys.contains(clip.id!!.toInt())
|
||||
view.apply {
|
||||
setupViewBackground(activity)
|
||||
clip_value.text = clip.value
|
||||
clip_value.setTextColor(textColor)
|
||||
clip_drag_handle.applyColorFilter(textColor)
|
||||
ItemClipInActivityBinding.bind(view).apply {
|
||||
root.setupViewBackground(activity)
|
||||
clipValue.text = clip.value
|
||||
clipValue.setTextColor(textColor)
|
||||
clipDragHandle.applyColorFilter(textColor)
|
||||
|
||||
clip_drag_handle.beVisibleIf(selectedKeys.isNotEmpty())
|
||||
clip_holder.isSelected = isSelected
|
||||
clip_drag_handle.setOnTouchListener { v, event ->
|
||||
clipDragHandle.beVisibleIf(selectedKeys.isNotEmpty())
|
||||
clipHolder.isSelected = isSelected
|
||||
clipDragHandle.setOnTouchListener { v, event ->
|
||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||
startReorderDragListener.requestDrag(holder)
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.databinding.ItemClipOnKeyboardBinding
|
||||
import com.simplemobiletools.keyboard.databinding.ItemSectionLabelBinding
|
||||
import com.simplemobiletools.keyboard.extensions.config
|
||||
import com.simplemobiletools.keyboard.extensions.getCurrentClip
|
||||
import com.simplemobiletools.keyboard.extensions.getStrokeColor
|
||||
|
@ -22,8 +24,6 @@ import com.simplemobiletools.keyboard.interfaces.RefreshClipsListener
|
|||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import com.simplemobiletools.keyboard.models.ClipsSectionLabel
|
||||
import com.simplemobiletools.keyboard.models.ListItem
|
||||
import kotlinx.android.synthetic.main.item_clip_on_keyboard.view.*
|
||||
import kotlinx.android.synthetic.main.item_section_label.view.*
|
||||
|
||||
class ClipsKeyboardAdapter(
|
||||
val context: Context, var items: ArrayList<ListItem>, val refreshClipsListener: RefreshClipsListener,
|
||||
|
@ -36,13 +36,12 @@ class ClipsKeyboardAdapter(
|
|||
private var backgroundColor = context.getProperBackgroundColor()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val layoutId = when (viewType) {
|
||||
ITEM_SECTION_LABEL -> R.layout.item_section_label
|
||||
else -> R.layout.item_clip_on_keyboard
|
||||
val binding = when (viewType) {
|
||||
ITEM_SECTION_LABEL -> ItemSectionLabelBinding.inflate(layoutInflater, parent, false)
|
||||
else -> ItemClipOnKeyboardBinding.inflate(layoutInflater, parent, false)
|
||||
}
|
||||
|
||||
val view = layoutInflater.inflate(layoutId, parent, false)
|
||||
return ViewHolder(view)
|
||||
return ViewHolder(binding.root)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
|
@ -65,13 +64,13 @@ class ClipsKeyboardAdapter(
|
|||
}
|
||||
|
||||
private fun setupClip(view: View, clip: Clip) {
|
||||
view.apply {
|
||||
val rippleBg = clip_holder.background as RippleDrawable
|
||||
ItemClipOnKeyboardBinding.bind(view).apply {
|
||||
val rippleBg = clipHolder.background as RippleDrawable
|
||||
val layerDrawable = rippleBg.findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable
|
||||
layerDrawable.findDrawableByLayerId(R.id.clipboard_background_stroke).applyColorFilter(context.getStrokeColor())
|
||||
layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(backgroundColor)
|
||||
|
||||
clip_value.apply {
|
||||
clipValue.apply {
|
||||
text = clip.value
|
||||
removeUnderlines()
|
||||
setTextColor(textColor)
|
||||
|
@ -81,13 +80,13 @@ class ClipsKeyboardAdapter(
|
|||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
private fun setupSection(view: View, sectionLabel: ClipsSectionLabel) {
|
||||
view.apply {
|
||||
clips_section_label.apply {
|
||||
ItemSectionLabelBinding.bind(view).apply {
|
||||
clipsSectionLabel.apply {
|
||||
text = sectionLabel.value
|
||||
setTextColor(textColor)
|
||||
}
|
||||
|
||||
clips_section_icon.apply {
|
||||
clipsSectionIcon.apply {
|
||||
applyColorFilter(textColor)
|
||||
|
||||
if (sectionLabel.isCurrent) {
|
||||
|
|
|
@ -6,15 +6,13 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.emoji2.text.EmojiCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import kotlinx.android.synthetic.main.item_emoji.view.*
|
||||
import com.simplemobiletools.keyboard.databinding.ItemEmojiBinding
|
||||
|
||||
class EmojisAdapter(val context: Context, var items: List<String>, val itemClick: (emoji: String) -> Unit) : RecyclerView.Adapter<EmojisAdapter.ViewHolder>() {
|
||||
private val layoutInflater = LayoutInflater.from(context)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmojisAdapter.ViewHolder {
|
||||
val layoutId = R.layout.item_emoji
|
||||
val view = layoutInflater.inflate(layoutId, parent, false)
|
||||
val view = ItemEmojiBinding.inflate(layoutInflater, parent, false).root
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
|
@ -29,7 +27,7 @@ class EmojisAdapter(val context: Context, var items: List<String>, val itemClick
|
|||
|
||||
private fun setupEmoji(view: View, emoji: String) {
|
||||
val processed = EmojiCompat.get().process(emoji)
|
||||
view.emoji_value.text = processed
|
||||
ItemEmojiBinding.bind(view).emojiValue.text = processed
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
|
|
@ -5,15 +5,15 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.databinding.DialogAddOrEditClipBinding
|
||||
import com.simplemobiletools.keyboard.helpers.ClipsHelper
|
||||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import kotlinx.android.synthetic.main.dialog_add_or_edit_clip.view.*
|
||||
|
||||
class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Clip?, val callback: () -> Unit) {
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_add_or_edit_clip, null).apply {
|
||||
val binding = DialogAddOrEditClipBinding.inflate(activity.layoutInflater).apply {
|
||||
if (originalClip != null) {
|
||||
add_clip_value.setText(originalClip.value)
|
||||
addClipValue.setText(originalClip.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,10 @@ class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Cl
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.add_clip_value)
|
||||
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||
alertDialog.showKeyboard(binding.addClipValue)
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val clipValue = view.add_clip_value.value
|
||||
val clipValue = binding.addClipValue.value
|
||||
if (clipValue.isEmpty()) {
|
||||
activity.toast(R.string.value_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
|
|
|
@ -6,8 +6,8 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.databinding.DialogExportClipsBinding
|
||||
import com.simplemobiletools.keyboard.extensions.config
|
||||
import kotlinx.android.synthetic.main.dialog_export_clips.view.*
|
||||
|
||||
class ExportClipsDialog(
|
||||
val activity: BaseSimpleActivity, path: String, val hidePath: Boolean, callback: (path: String, filename: String) -> Unit
|
||||
|
@ -19,17 +19,17 @@ class ExportClipsDialog(
|
|||
activity.internalStoragePath
|
||||
}
|
||||
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_export_clips, null).apply {
|
||||
export_clips_filename.setText("${activity.getString(R.string.app_launcher_name)}_${activity.getCurrentFormattedDateTime()}")
|
||||
val binding = DialogExportClipsBinding.inflate(activity.layoutInflater).apply {
|
||||
exportClipsFilename.setText("${activity.getString(R.string.app_launcher_name)}_${activity.getCurrentFormattedDateTime()}")
|
||||
|
||||
if (hidePath) {
|
||||
export_clips_path_label.beGone()
|
||||
export_clips_path.beGone()
|
||||
exportClipsPathLabel.beGone()
|
||||
exportClipsPath.beGone()
|
||||
} else {
|
||||
export_clips_path.text = activity.humanizePath(folder)
|
||||
export_clips_path.setOnClickListener {
|
||||
exportClipsPath.text = activity.humanizePath(folder)
|
||||
exportClipsPath.setOnClickListener {
|
||||
FilePickerDialog(activity, folder, false, showFAB = true) {
|
||||
export_clips_path.text = activity.humanizePath(it)
|
||||
exportClipsPath.text = activity.humanizePath(it)
|
||||
folder = it
|
||||
}
|
||||
}
|
||||
|
@ -40,10 +40,10 @@ class ExportClipsDialog(
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_clipboard_items) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.export_clips_filename)
|
||||
activity.setupDialogStuff(binding.root, this, R.string.export_clipboard_items) { alertDialog ->
|
||||
alertDialog.showKeyboard(binding.exportClipsFilename)
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val filename = view.export_clips_filename.value
|
||||
val filename = binding.exportClipsFilename.value
|
||||
if (filename.isEmpty()) {
|
||||
activity.toast(R.string.filename_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
|
|
|
@ -4,10 +4,10 @@ import android.view.ContextThemeWrapper
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import android.widget.ScrollView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.databinding.DialogRadioGroupBinding
|
||||
import com.simplemobiletools.commons.databinding.RadioButtonBinding
|
||||
import com.simplemobiletools.commons.extensions.onGlobalLayout
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.keyboard.R
|
||||
|
@ -31,10 +31,10 @@ class KeyboardRadioGroupDialog(
|
|||
private val layoutInflater = LayoutInflater.from(context)
|
||||
|
||||
init {
|
||||
val view = layoutInflater.inflate(R.layout.dialog_radio_group, null)
|
||||
val radioGroup = view.findViewById<RadioGroup>(R.id.dialog_radio_group).apply {
|
||||
val binding = DialogRadioGroupBinding.inflate(layoutInflater)
|
||||
binding.dialogRadioGroup.apply {
|
||||
for (i in 0 until items.size) {
|
||||
val radioButton = (layoutInflater.inflate(R.layout.radio_button, null) as RadioButton).apply {
|
||||
val radioButton = RadioButtonBinding.inflate(layoutInflater).dialogRadioButton.apply {
|
||||
text = items[i].title
|
||||
isChecked = items[i].id == checkedItemId
|
||||
id = i
|
||||
|
@ -57,15 +57,15 @@ class KeyboardRadioGroupDialog(
|
|||
}
|
||||
|
||||
builder.apply {
|
||||
context.setupKeyboardDialogStuff(inputView.windowToken, view, this, titleId) { alertDialog ->
|
||||
context.setupKeyboardDialogStuff(inputView.windowToken, binding.root, this, titleId) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedItemId != -1) {
|
||||
view.findViewById<ScrollView>(R.id.dialog_radio_holder).apply {
|
||||
binding.dialogRadioHolder.apply {
|
||||
onGlobalLayout {
|
||||
scrollY = radioGroup.findViewById<View>(selectedItemId).bottom - height
|
||||
scrollY = binding.dialogRadioGroup.findViewById<View>(selectedItemId).bottom - height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.TextView
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.databinding.DialogTitleBinding
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
|
@ -120,8 +121,7 @@ fun Context.setupKeyboardDialogStuff(
|
|||
} else {
|
||||
var title: TextView? = null
|
||||
if (titleId != 0 || titleText.isNotEmpty()) {
|
||||
title = LayoutInflater.from(this).inflate(R.layout.dialog_title, null) as TextView
|
||||
title.apply {
|
||||
title = DialogTitleBinding.inflate(LayoutInflater.from(this)).dialogTitleTextview.apply {
|
||||
if (titleText.isNotEmpty()) {
|
||||
text = titleText
|
||||
} else {
|
||||
|
|
|
@ -31,14 +31,13 @@ import androidx.core.graphics.drawable.toBitmap
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.databinding.KeyboardViewKeyboardBinding
|
||||
import com.simplemobiletools.keyboard.extensions.config
|
||||
import com.simplemobiletools.keyboard.extensions.getStrokeColor
|
||||
import com.simplemobiletools.keyboard.extensions.safeStorageContext
|
||||
import com.simplemobiletools.keyboard.helpers.*
|
||||
import com.simplemobiletools.keyboard.interfaces.OnKeyboardActionListener
|
||||
import com.simplemobiletools.keyboard.views.MyKeyboardView
|
||||
import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.keyboard_holder
|
||||
import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.keyboard_view
|
||||
import java.util.Locale
|
||||
|
||||
// based on https://www.androidauthority.com/lets-build-custom-keyboard-android-832362/
|
||||
|
@ -60,19 +59,22 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
|
|||
private var switchToLetters = false
|
||||
private var breakIterator: BreakIterator? = null
|
||||
|
||||
private lateinit var binding: KeyboardViewKeyboardBinding
|
||||
|
||||
override fun onInitializeInterface() {
|
||||
super.onInitializeInterface()
|
||||
safeStorageContext.getSharedPrefs().registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onCreateInputView(): View {
|
||||
val keyboardHolder = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null)
|
||||
keyboardView = keyboardHolder.keyboard_view as MyKeyboardView
|
||||
keyboardView!!.setKeyboardHolder(keyboardHolder.keyboard_holder)
|
||||
keyboardView!!.setKeyboard(keyboard!!)
|
||||
keyboardView!!.setEditorInfo(currentInputEditorInfo)
|
||||
keyboardView!!.mOnKeyboardActionListener = this
|
||||
return keyboardHolder!!
|
||||
binding = KeyboardViewKeyboardBinding.inflate(layoutInflater)
|
||||
keyboardView = binding.keyboardView.apply {
|
||||
setKeyboardHolder(binding)
|
||||
setKeyboard(keyboard!!)
|
||||
setEditorInfo(currentInputEditorInfo)
|
||||
mOnKeyboardActionListener = this@SimpleKeyboardIME
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onPress(primaryCode: Int) {
|
||||
|
|
|
@ -37,6 +37,9 @@ import com.simplemobiletools.keyboard.activities.ManageClipboardItemsActivity
|
|||
import com.simplemobiletools.keyboard.activities.SettingsActivity
|
||||
import com.simplemobiletools.keyboard.adapters.ClipsKeyboardAdapter
|
||||
import com.simplemobiletools.keyboard.adapters.EmojisAdapter
|
||||
import com.simplemobiletools.keyboard.databinding.KeyboardKeyPreviewBinding
|
||||
import com.simplemobiletools.keyboard.databinding.KeyboardPopupKeyboardBinding
|
||||
import com.simplemobiletools.keyboard.databinding.KeyboardViewKeyboardBinding
|
||||
import com.simplemobiletools.keyboard.dialogs.ChangeLanguagePopup
|
||||
import com.simplemobiletools.keyboard.extensions.*
|
||||
import com.simplemobiletools.keyboard.helpers.*
|
||||
|
@ -51,8 +54,6 @@ import com.simplemobiletools.keyboard.interfaces.RefreshClipsListener
|
|||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import com.simplemobiletools.keyboard.models.ClipsSectionLabel
|
||||
import com.simplemobiletools.keyboard.models.ListItem
|
||||
import kotlinx.android.synthetic.main.keyboard_popup_keyboard.view.*
|
||||
import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.*
|
||||
import java.util.*
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables", "ClickableViewAccessibility")
|
||||
|
@ -66,6 +67,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
}
|
||||
|
||||
private var keyboardPopupBinding: KeyboardPopupKeyboardBinding? = null
|
||||
private var keyboardViewBinding: KeyboardViewKeyboardBinding? = null
|
||||
|
||||
private var accessHelper: AccessHelper? = null
|
||||
|
||||
private var mKeyboard: MyKeyboard? = null
|
||||
|
@ -203,7 +207,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
mPreviewPopup = PopupWindow(context)
|
||||
mPreviewText = inflater.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView
|
||||
mPreviewText = KeyboardKeyPreviewBinding.inflate(inflater).root
|
||||
mPreviewTextSizeLarge = context.resources.getDimension(R.dimen.preview_text_size).toInt()
|
||||
mPreviewPopup.contentView = mPreviewText
|
||||
mPreviewPopup.setBackgroundDrawable(null)
|
||||
|
@ -285,14 +289,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
/** Sets the top row above the keyboard containing a couple buttons and the clipboard **/
|
||||
fun setKeyboardHolder(keyboardHolder: View) {
|
||||
mToolbarHolder = keyboardHolder.toolbar_holder
|
||||
mClipboardManagerHolder = keyboardHolder.clipboard_manager_holder
|
||||
mEmojiPaletteHolder = keyboardHolder.emoji_palette_holder
|
||||
fun setKeyboardHolder(binding: KeyboardViewKeyboardBinding) {
|
||||
keyboardViewBinding = binding.apply {
|
||||
mToolbarHolder = toolbarHolder
|
||||
mClipboardManagerHolder = clipboardManagerHolder
|
||||
mEmojiPaletteHolder = emojiPaletteHolder
|
||||
|
||||
mToolbarHolder!!.apply {
|
||||
settings_cog.setOnLongClickListener { context.toast(R.string.settings); true; }
|
||||
settings_cog.setOnClickListener {
|
||||
settingsCog.setOnLongClickListener { context.toast(R.string.settings); true; }
|
||||
settingsCog.setOnClickListener {
|
||||
vibrateIfNeeded()
|
||||
Intent(context, SettingsActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
@ -300,23 +304,23 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
}
|
||||
|
||||
pinned_clipboard_items.setOnLongClickListener { context.toast(R.string.clipboard); true; }
|
||||
pinned_clipboard_items.setOnClickListener {
|
||||
pinnedClipboardItems.setOnLongClickListener { context.toast(R.string.clipboard); true; }
|
||||
pinnedClipboardItems.setOnClickListener {
|
||||
vibrateIfNeeded()
|
||||
openClipboardManager()
|
||||
}
|
||||
|
||||
clipboard_clear.setOnLongClickListener { context.toast(R.string.clear_clipboard_data); true; }
|
||||
clipboard_clear.setOnClickListener {
|
||||
clipboardClear.setOnLongClickListener { context.toast(R.string.clear_clipboard_data); true; }
|
||||
clipboardClear.setOnClickListener {
|
||||
vibrateIfNeeded()
|
||||
clearClipboardContent()
|
||||
toggleClipboardVisibility(false)
|
||||
}
|
||||
|
||||
suggestions_holder.addOnLayoutChangeListener(object : OnLayoutChangeListener {
|
||||
suggestionsHolder.addOnLayoutChangeListener(object : OnLayoutChangeListener {
|
||||
override fun onLayoutChange(v: View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) {
|
||||
updateSuggestionsToolbarLayout()
|
||||
suggestions_holder.removeOnLayoutChangeListener(this)
|
||||
binding.suggestionsHolder.removeOnLayoutChangeListener(this)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -330,23 +334,21 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
setupStoredClips()
|
||||
}
|
||||
|
||||
mClipboardManagerHolder!!.apply {
|
||||
clipboard_manager_close.setOnClickListener {
|
||||
binding.apply {
|
||||
clipboardManagerClose.setOnClickListener {
|
||||
vibrateIfNeeded()
|
||||
closeClipboardManager()
|
||||
}
|
||||
|
||||
clipboard_manager_manage.setOnLongClickListener { context.toast(R.string.manage_clipboard_items); true; }
|
||||
clipboard_manager_manage.setOnClickListener {
|
||||
clipboardManagerManage.setOnLongClickListener { context.toast(R.string.manage_clipboard_items); true; }
|
||||
clipboardManagerManage.setOnClickListener {
|
||||
Intent(context, ManageClipboardItemsActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mEmojiPaletteHolder!!.apply {
|
||||
emoji_palette_close.setOnClickListener {
|
||||
emojiPaletteClose.setOnClickListener {
|
||||
vibrateIfNeeded()
|
||||
closeEmojiPalette()
|
||||
}
|
||||
|
@ -367,7 +369,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
mUsingSystemTheme = config.isUsingSystemTheme
|
||||
}
|
||||
|
||||
val isMainKeyboard = changedView == null || changedView != mini_keyboard_view
|
||||
val isMainKeyboard = changedView == null || changedView != keyboardPopupBinding?.miniKeyboardView
|
||||
mKeyBackground = if (mShowKeyBorders && isMainKeyboard) {
|
||||
resources.getDrawable(R.drawable.keyboard_key_selector_outlined, context.theme)
|
||||
} else {
|
||||
|
@ -397,35 +399,33 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(mBackgroundColor)
|
||||
|
||||
val wasDarkened = mBackgroundColor != mBackgroundColor.darkenColor()
|
||||
mToolbarHolder?.apply {
|
||||
top_keyboard_divider.beGoneIf(wasDarkened)
|
||||
top_keyboard_divider.background = ColorDrawable(strokeColor)
|
||||
keyboardViewBinding?.apply {
|
||||
topKeyboardDivider.beGoneIf(wasDarkened)
|
||||
topKeyboardDivider.background = ColorDrawable(strokeColor)
|
||||
mToolbarHolder?.background = ColorDrawable(toolbarColor)
|
||||
|
||||
background = ColorDrawable(toolbarColor)
|
||||
clipboard_value.apply {
|
||||
clipboardValue.apply {
|
||||
background = rippleBg
|
||||
setTextColor(mTextColor)
|
||||
setLinkTextColor(mTextColor)
|
||||
}
|
||||
|
||||
settings_cog.applyColorFilter(mTextColor)
|
||||
pinned_clipboard_items.applyColorFilter(mTextColor)
|
||||
clipboard_clear.applyColorFilter(mTextColor)
|
||||
settingsCog.applyColorFilter(mTextColor)
|
||||
pinnedClipboardItems.applyColorFilter(mTextColor)
|
||||
clipboardClear.applyColorFilter(mTextColor)
|
||||
|
||||
beInvisibleIf(context.isDeviceLocked)
|
||||
}
|
||||
mToolbarHolder?.beInvisibleIf(context.isDeviceLocked)
|
||||
|
||||
mClipboardManagerHolder?.apply {
|
||||
top_clipboard_divider.beGoneIf(wasDarkened)
|
||||
top_clipboard_divider.background = ColorDrawable(strokeColor)
|
||||
clipboard_manager_holder.background = ColorDrawable(toolbarColor)
|
||||
topClipboardDivider.beGoneIf(wasDarkened)
|
||||
topClipboardDivider.background = ColorDrawable(strokeColor)
|
||||
clipboardManagerHolder.background = ColorDrawable(toolbarColor)
|
||||
|
||||
clipboard_manager_close.applyColorFilter(mTextColor)
|
||||
clipboard_manager_manage.applyColorFilter(mTextColor)
|
||||
clipboardManagerClose.applyColorFilter(mTextColor)
|
||||
clipboardManagerManage.applyColorFilter(mTextColor)
|
||||
|
||||
clipboard_manager_label.setTextColor(mTextColor)
|
||||
clipboard_content_placeholder_1.setTextColor(mTextColor)
|
||||
clipboard_content_placeholder_2.setTextColor(mTextColor)
|
||||
clipboardManagerLabel.setTextColor(mTextColor)
|
||||
clipboardContentPlaceholder1.setTextColor(mTextColor)
|
||||
clipboardContentPlaceholder2.setTextColor(mTextColor)
|
||||
}
|
||||
|
||||
setupEmojiPalette(toolbarColor = toolbarColor, backgroundColor = mBackgroundColor, textColor = mTextColor)
|
||||
|
@ -739,8 +739,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view && context.config.showClipboardContent) {
|
||||
val clipboardContent = context.getCurrentClip()
|
||||
if (clipboardContent?.isNotEmpty() == true) {
|
||||
mToolbarHolder?.apply {
|
||||
clipboard_value.apply {
|
||||
keyboardViewBinding?.apply {
|
||||
clipboardValue.apply {
|
||||
text = clipboardContent
|
||||
removeUnderlines()
|
||||
setOnClickListener {
|
||||
|
@ -760,11 +760,11 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
private fun hideClipboardViews() {
|
||||
mToolbarHolder?.apply {
|
||||
clipboard_value?.beGone()
|
||||
clipboard_value?.alpha = 0f
|
||||
clipboard_clear?.beGone()
|
||||
clipboard_clear?.alpha = 0f
|
||||
keyboardViewBinding?.apply {
|
||||
clipboardValue.beGone()
|
||||
clipboardValue.alpha = 0f
|
||||
clipboardClear.beGone()
|
||||
clipboardClear.alpha = 0f
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -779,13 +779,13 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
private fun toggleClipboardVisibility(show: Boolean) {
|
||||
if ((show && mToolbarHolder?.clipboard_value!!.alpha == 0f) || (!show && mToolbarHolder?.clipboard_value!!.alpha == 1f)) {
|
||||
if ((show && keyboardViewBinding?.clipboardValue!!.alpha == 0f) || (!show && keyboardViewBinding?.clipboardValue!!.alpha == 1f)) {
|
||||
val newAlpha = if (show) 1f else 0f
|
||||
val animations = ArrayList<ObjectAnimator>()
|
||||
val clipboardValueAnimation = ObjectAnimator.ofFloat(mToolbarHolder!!.clipboard_value!!, "alpha", newAlpha)
|
||||
val clipboardValueAnimation = ObjectAnimator.ofFloat(keyboardViewBinding!!.clipboardValue, "alpha", newAlpha)
|
||||
animations.add(clipboardValueAnimation)
|
||||
|
||||
val clipboardClearAnimation = ObjectAnimator.ofFloat(mToolbarHolder!!.clipboard_clear!!, "alpha", newAlpha)
|
||||
val clipboardClearAnimation = ObjectAnimator.ofFloat(keyboardViewBinding!!.clipboardClear, "alpha", newAlpha)
|
||||
animations.add(clipboardClearAnimation)
|
||||
|
||||
val animSet = AnimatorSet()
|
||||
|
@ -794,14 +794,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
animSet.interpolator = AccelerateInterpolator()
|
||||
animSet.doOnStart {
|
||||
if (show) {
|
||||
mToolbarHolder?.clipboard_value?.beVisible()
|
||||
mToolbarHolder?.clipboard_clear?.beVisible()
|
||||
keyboardViewBinding?.clipboardValue?.beVisible()
|
||||
keyboardViewBinding?.clipboardClear?.beVisible()
|
||||
}
|
||||
}
|
||||
animSet.doOnEnd {
|
||||
if (!show) {
|
||||
mToolbarHolder?.clipboard_value?.beGone()
|
||||
mToolbarHolder?.clipboard_clear?.beGone()
|
||||
keyboardViewBinding?.clipboardValue?.beGone()
|
||||
keyboardViewBinding?.clipboardClear?.beGone()
|
||||
}
|
||||
}
|
||||
animSet.start()
|
||||
|
@ -1001,8 +1001,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
mMiniKeyboardContainer = mMiniKeyboardCache[popupKey]
|
||||
if (mMiniKeyboardContainer == null) {
|
||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null)
|
||||
mMiniKeyboard = mMiniKeyboardContainer!!.findViewById<View>(R.id.mini_keyboard_view) as MyKeyboardView
|
||||
keyboardPopupBinding = KeyboardPopupKeyboardBinding.inflate(inflater).apply {
|
||||
mMiniKeyboardContainer = root
|
||||
mMiniKeyboard = miniKeyboardView
|
||||
}
|
||||
|
||||
mMiniKeyboard!!.mOnKeyboardActionListener = object : OnKeyboardActionListener {
|
||||
override fun onKey(code: Int) {
|
||||
|
@ -1048,7 +1050,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
)
|
||||
mMiniKeyboardCache[popupKey] = mMiniKeyboardContainer
|
||||
} else {
|
||||
mMiniKeyboard = mMiniKeyboardContainer!!.findViewById<View>(R.id.mini_keyboard_view) as MyKeyboardView
|
||||
mMiniKeyboard = keyboardPopupBinding!!.miniKeyboardView
|
||||
}
|
||||
|
||||
getLocationInWindow(mCoordinates)
|
||||
|
@ -1395,13 +1397,17 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
fun closeClipboardManager() {
|
||||
mClipboardManagerHolder?.clipboard_manager_holder?.beGone()
|
||||
mToolbarHolder?.suggestions_holder?.showAllInlineContentViews()
|
||||
keyboardViewBinding?.apply {
|
||||
clipboardManagerHolder.beGone()
|
||||
suggestionsHolder.showAllInlineContentViews()
|
||||
}
|
||||
}
|
||||
|
||||
private fun openClipboardManager() {
|
||||
mClipboardManagerHolder!!.clipboard_manager_holder.beVisible()
|
||||
mToolbarHolder?.suggestions_holder?.hideAllInlineContentViews()
|
||||
keyboardViewBinding?.apply {
|
||||
clipboardManagerHolder.beVisible()
|
||||
suggestionsHolder.hideAllInlineContentViews()
|
||||
}
|
||||
setupStoredClips()
|
||||
}
|
||||
|
||||
|
@ -1434,10 +1440,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
private fun setupClipsAdapter(clips: ArrayList<ListItem>) {
|
||||
mClipboardManagerHolder?.apply {
|
||||
clipboard_content_placeholder_1.beVisibleIf(clips.isEmpty())
|
||||
clipboard_content_placeholder_2.beVisibleIf(clips.isEmpty())
|
||||
clips_list.beVisibleIf(clips.isNotEmpty())
|
||||
keyboardViewBinding?.apply {
|
||||
clipboardContentPlaceholder1.beVisibleIf(clips.isEmpty())
|
||||
clipboardContentPlaceholder2.beVisibleIf(clips.isEmpty())
|
||||
clipsList.beVisibleIf(clips.isNotEmpty())
|
||||
}
|
||||
|
||||
val refreshClipsListener = object : RefreshClipsListener {
|
||||
|
@ -1451,26 +1457,27 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
vibrateIfNeeded()
|
||||
}
|
||||
|
||||
mClipboardManagerHolder?.clips_list?.adapter = adapter
|
||||
keyboardViewBinding?.clipsList?.adapter = adapter
|
||||
}
|
||||
|
||||
private fun setupEmojiPalette(toolbarColor: Int, backgroundColor: Int, textColor: Int) {
|
||||
mEmojiPaletteHolder?.apply {
|
||||
emoji_palette_top_bar.background = ColorDrawable(toolbarColor)
|
||||
emoji_palette_holder.background = ColorDrawable(backgroundColor)
|
||||
emoji_palette_close.applyColorFilter(textColor)
|
||||
emoji_palette_label.setTextColor(textColor)
|
||||
keyboardViewBinding?.apply {
|
||||
emojiPaletteTopBar.background = ColorDrawable(toolbarColor)
|
||||
emojiPaletteHolder.background = ColorDrawable(backgroundColor)
|
||||
emojiPaletteClose.applyColorFilter(textColor)
|
||||
emojiPaletteLabel.setTextColor(textColor)
|
||||
|
||||
emoji_palette_bottom_bar.background = ColorDrawable(backgroundColor)
|
||||
emojiPaletteBottomBar.background = ColorDrawable(backgroundColor)
|
||||
val bottomTextColor = textColor.darkenColor()
|
||||
emoji_palette_mode_change.apply {
|
||||
emojiPaletteModeChange.apply {
|
||||
setTextColor(bottomTextColor)
|
||||
setOnClickListener {
|
||||
vibrateIfNeeded()
|
||||
closeEmojiPalette()
|
||||
}
|
||||
}
|
||||
emoji_palette_backspace.apply {
|
||||
|
||||
emojiPaletteBackspace.apply {
|
||||
applyColorFilter(bottomTextColor)
|
||||
setOnTouchListener { _, event ->
|
||||
when (event.action) {
|
||||
|
@ -1498,18 +1505,19 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
setupEmojis()
|
||||
}
|
||||
|
||||
fun openEmojiPalette() {
|
||||
mEmojiPaletteHolder!!.emoji_palette_holder.beVisible()
|
||||
keyboardViewBinding!!.emojiPaletteHolder.beVisible()
|
||||
setupEmojis()
|
||||
}
|
||||
|
||||
private fun closeEmojiPalette() {
|
||||
mEmojiPaletteHolder?.apply {
|
||||
emoji_palette_holder?.beGone()
|
||||
mEmojiPaletteHolder?.emojis_list?.scrollToPosition(0)
|
||||
keyboardViewBinding?.apply {
|
||||
emojiPaletteHolder.beGone()
|
||||
emojisList?.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1539,7 +1547,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
private fun setupEmojiAdapter(emojis: List<String>) {
|
||||
mEmojiPaletteHolder?.emojis_list?.apply {
|
||||
keyboardViewBinding?.emojisList?.apply {
|
||||
val emojiItemWidth = context.resources.getDimensionPixelSize(R.dimen.emoji_item_size)
|
||||
val emojiTopBarElevation = context.resources.getDimensionPixelSize(R.dimen.emoji_top_bar_elevation).toFloat()
|
||||
|
||||
|
@ -1550,7 +1558,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
}
|
||||
|
||||
onScroll {
|
||||
mEmojiPaletteHolder!!.emoji_palette_top_bar.elevation = if (it > 4) emojiTopBarElevation else 0f
|
||||
keyboardViewBinding!!.emojiPaletteTopBar.elevation = if (it > 4) emojiTopBarElevation else 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1634,14 +1642,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
fun addToClipboardViews(it: InlineContentView, addToFront: Boolean = false) {
|
||||
if (mToolbarHolder?.autofill_suggestions_holder != null) {
|
||||
if (keyboardViewBinding?.autofillSuggestionsHolder != null) {
|
||||
val newLayoutParams = LinearLayout.LayoutParams(it.layoutParams)
|
||||
newLayoutParams.updateMarginsRelative(start = resources.getDimensionPixelSize(R.dimen.normal_margin))
|
||||
it.layoutParams = newLayoutParams
|
||||
if (addToFront) {
|
||||
mToolbarHolder?.autofill_suggestions_holder?.addView(it, 0)
|
||||
keyboardViewBinding?.autofillSuggestionsHolder?.addView(it, 0)
|
||||
} else {
|
||||
mToolbarHolder?.autofill_suggestions_holder?.addView(it)
|
||||
keyboardViewBinding?.autofillSuggestionsHolder?.addView(it)
|
||||
}
|
||||
updateSuggestionsToolbarLayout()
|
||||
}
|
||||
|
@ -1649,21 +1657,21 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
fun clearClipboardViews() {
|
||||
mToolbarHolder?.autofill_suggestions_holder?.removeAllViews()
|
||||
keyboardViewBinding?.autofillSuggestionsHolder?.removeAllViews()
|
||||
updateSuggestionsToolbarLayout()
|
||||
}
|
||||
|
||||
private fun updateSuggestionsToolbarLayout() {
|
||||
mToolbarHolder?.apply {
|
||||
keyboardViewBinding?.apply {
|
||||
if (hasInlineViews()) {
|
||||
// make room on suggestion toolbar for inline views
|
||||
suggestions_items_holder?.gravity = Gravity.NO_GRAVITY
|
||||
clipboard_value?.maxWidth = resources.getDimensionPixelSize(R.dimen.suggestion_max_width)
|
||||
suggestionsItemsHolder.gravity = Gravity.NO_GRAVITY
|
||||
clipboardValue.maxWidth = resources.getDimensionPixelSize(R.dimen.suggestion_max_width)
|
||||
} else {
|
||||
// restore original clipboard toolbar appearance
|
||||
suggestions_items_holder?.gravity = Gravity.CENTER_HORIZONTAL
|
||||
suggestions_holder?.measuredWidth?.also { maxWidth ->
|
||||
clipboard_value?.maxWidth = maxWidth
|
||||
suggestionsItemsHolder.gravity = Gravity.CENTER_HORIZONTAL
|
||||
suggestionsHolder.measuredWidth.also { maxWidth ->
|
||||
clipboardValue.maxWidth = maxWidth
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1672,5 +1680,5 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
/**
|
||||
* Returns true if there are [InlineContentView]s in [autofill_suggestions_holder]
|
||||
*/
|
||||
private fun hasInlineViews() = (mToolbarHolder?.autofill_suggestions_holder?.childCount ?: 0) > 0
|
||||
private fun hasInlineViews() = (keyboardViewBinding?.autofillSuggestionsHolder?.childCount ?: 0) > 0
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.7.10'
|
||||
ext.kotlin_version = '1.9.0'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
|
@ -9,7 +9,7 @@ buildscript {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||
classpath 'com.android.tools.build:gradle:8.1.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
android.nonTransitiveRClass=false
|
||||
org.gradle.jvmargs=-Xmx4g
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Tue Jan 04 09:48:27 CET 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
Loading…
Reference in New Issue