Add support for light theme for autofill suggestions

This commit is contained in:
Ensar Sarajčić 2023-07-10 09:32:56 +02:00
parent a143e100db
commit a87683ad3d
1 changed files with 16 additions and 4 deletions

View File

@ -3,6 +3,8 @@ package com.simplemobiletools.keyboard.services
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.RippleDrawable
import android.inputmethodservice.InputMethodService import android.inputmethodservice.InputMethodService
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@ -23,9 +25,11 @@ import androidx.autofill.inline.common.ImageViewStyle
import androidx.autofill.inline.common.TextViewStyle import androidx.autofill.inline.common.TextViewStyle
import androidx.autofill.inline.common.ViewStyle import androidx.autofill.inline.common.ViewStyle
import androidx.autofill.inline.v1.InlineSuggestionUi import androidx.autofill.inline.v1.InlineSuggestionUi
import com.simplemobiletools.commons.extensions.getSharedPrefs import androidx.core.graphics.drawable.toBitmap
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.keyboard.R import com.simplemobiletools.keyboard.R
import com.simplemobiletools.keyboard.extensions.config import com.simplemobiletools.keyboard.extensions.config
import com.simplemobiletools.keyboard.extensions.getStrokeColor
import com.simplemobiletools.keyboard.extensions.safeStorageContext import com.simplemobiletools.keyboard.extensions.safeStorageContext
import com.simplemobiletools.keyboard.helpers.* import com.simplemobiletools.keyboard.helpers.*
import com.simplemobiletools.keyboard.interfaces.OnKeyboardActionListener import com.simplemobiletools.keyboard.interfaces.OnKeyboardActionListener
@ -388,9 +392,17 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
val textSize = resources.getDimension(R.dimen.label_text_size) / resources.displayMetrics.scaledDensity val textSize = resources.getDimension(R.dimen.label_text_size) / resources.displayMetrics.scaledDensity
val rippleBg = resources.getDrawable(R.drawable.clipboard_background, theme) as RippleDrawable
val layerDrawable = rippleBg.findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable
layerDrawable.findDrawableByLayerId(R.id.clipboard_background_stroke).applyColorFilter(getStrokeColor())
layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(getProperBackgroundColor())
val maxWidth = resources.getDimensionPixelSize(R.dimen.suggestion_max_width)
val height = resources.getDimensionPixelSize(R.dimen.label_text_size) + verticalPadding * 2
val chipStyle = val chipStyle =
ViewStyle.Builder() ViewStyle.Builder()
.setBackground(Icon.createWithResource(this, R.drawable.clipboard_background)) .setBackground(Icon.createWithBitmap(rippleBg.toBitmap(width = maxWidth, height = height)))
.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding) .setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding)
.build() .build()
@ -405,13 +417,13 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
.setTitleStyle( .setTitleStyle(
TextViewStyle.Builder() TextViewStyle.Builder()
.setLayoutMargin(0, 0, horizontalPadding, 0) .setLayoutMargin(0, 0, horizontalPadding, 0)
.setTextColor(resources.getColor(R.color.default_text_color, theme)) .setTextColor(getProperTextColor())
.setTextSize(textSize) .setTextSize(textSize)
.build() .build()
) )
.setSubtitleStyle( .setSubtitleStyle(
TextViewStyle.Builder() TextViewStyle.Builder()
.setTextColor(resources.getColor(R.color.default_text_color, theme)) .setTextColor(getProperTextColor())
.setTextSize(textSize) .setTextSize(textSize)
.build() .build()
) )