Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/src/keyboards/java/be/scri/activities/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -76,6 +77,13 @@ class MainActivity : ComponentActivity() {

val navController = rememberNavController()

val navigateTo = intent.getStringExtra("navigate_to")
LaunchedEffect(navigateTo) {
if (navigateTo == "download_data") {
navController.navigate("download_data")
}
}

val isHintChangedMap = remember { mutableStateMapOf<Int, Boolean>() }

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ import be.scri.helpers.swedish.SVInterfaceVariables
* Object containing keyboard-specific constant mappings related to language-specific UI elements.
*/
object KeyboardLanguageMappingConstants {
val downloadDataPlaceholder =
mapOf(
"EN" to ENInterfaceVariables.DOWNLOAD_DATA_LBL,
"ES" to ESInterfaceVariables.DOWNLOAD_DATA_LBL,
"DE" to DEInterfaceVariables.DOWNLOAD_DATA_LBL,
"IT" to ITInterfaceVariables.DOWNLOAD_DATA_LBL,
"FR" to FRInterfaceVariables.DOWNLOAD_DATA_LBL,
"PT" to PTInterfaceVariables.DOWNLOAD_DATA_LBL,
"RU" to RUInterfaceVariables.DOWNLOAD_DATA_LBL,
"SV" to SVInterfaceVariables.DOWNLOAD_DATA_LBL,
)

val translatePlaceholder =
mapOf(
"EN" to ENInterfaceVariables.TRANSLATE_KEY_LBL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.english
* Interface variables for English language keyboards.
*/
object ENInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "$"
val CURRENCY_SYMBOL_ALTERNATES = listOf("$", "€", "£", "¥", "₩", "¢")

// MARK: Keyboard Labels

const val SPACE_BAR = "space"
const val LANGUAGE = "English"

const val DOWNLOAD_DATA_LBL = "Please download language data"

const val INVALID_COMMAND_MSG_WIKIDATA = "Not in Wikidata"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"Wikidata is a collaboratively edited knowledge graph that's maintained by the Wikimedia Foundation. It serves as a source of open data for projects like Wikipedia and countless others."
Expand All @@ -35,6 +32,11 @@ object ENInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("I", "I'm", "we")
val NUMERIC_AUTOSUGGESTIONS = listOf("is", "to", "and")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "$"
val CURRENCY_SYMBOL_ALTERNATES = listOf("$", "€", "£", "¥", "₩", "¢")

// MARK: Suggestion Pronouns

val VERBS_AFTER_PRONOUNS_ARRAY = listOf("have", "be", "can")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.french
* Interface variables for French language keyboards.
*/
object FRInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "€"
val CURRENCY_SYMBOL_ALTERNATES = listOf("€", "$", "£", "¥", "₩", "¢")

// MARK: Keyboard Labels

const val SPACE_BAR = "espace"
const val LANGUAGE = "Français"

const val DOWNLOAD_DATA_LBL = "Veuillez télécharger les données linguistiques"

const val INVALID_COMMAND_MSG_WIKIDATA = "Pas dans Wikidata"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"Wikidata est un réseau de connaissances collaboratif géré par la fondation Wikimedia. Il sert de source de données ouvertes pour des projets tels que Wikipédia et bien d'autres."
Expand All @@ -35,6 +32,11 @@ object FRInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("je", "il", "le")
val NUMERIC_AUTOSUGGESTIONS = listOf("je", "que", "c’est")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "€"
val CURRENCY_SYMBOL_ALTERNATES = listOf("€", "$", "£", "¥", "₩", "¢")

// MARK: Suggestion Pronouns

val VERBS_AFTER_PRONOUNS_ARRAY = listOf("être", "avoir", "ne")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.german
* Interface variables for German language keyboards.
*/
object DEInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "€"
val CURRENCY_SYMBOL_ALTERNATES = listOf("€", "$", "£", "¥", "₩", "¢")

// MARK: Keyboard Labels

const val SPACE_BAR = "Leerzeichen"
const val LANGUAGE = "Deutsch"

const val DOWNLOAD_DATA_LBL = "Bitte Sprachdaten herunterladen"

const val INVALID_COMMAND_MSG_WIKIDATA = "Nicht in Wikidata"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"Wikidata ist ein kollaborativ gestalteter, mehrsprachiger Wissensgraf, der von der Wikimedia Foundation gehostet wird. Sie dient als Quelle für offene Daten für unzählige Projekte, beispielsweise Wikipedia."
Expand All @@ -35,6 +32,11 @@ object DEInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("ich", "die", "das")
val NUMERIC_AUTOSUGGESTIONS = listOf("Prozent", "Milionen", "Meter")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "€"
val CURRENCY_SYMBOL_ALTERNATES = listOf("€", "$", "£", "¥", "₩", "¢")

// MARK: Suggestion Pronouns

val VERBS_AFTER_PRONOUNS_ARRAY = listOf("haben", "sein", "können")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.italian
* Interface variables for Italian language keyboards.
*/
object ITInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "€"
val CURRENCY_SYMBOL_ALTERNATES = listOf("€", "$", "£", "¥", "₩", "¢")

// MARK: Keyboard Labels

const val SPACE_BAR = "spazio"
const val LANGUAGE = "Italiano"

const val DOWNLOAD_DATA_LBL = "Scarica i dati della lingua"

const val INVALID_COMMAND_MSG_WIKIDATA = "Non in Wikidata"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"Wikidata è un grafo della conoscenza modificabile in modo collaborativo, gestito dalla Wikimedia Foundation. Serve come fonte di dati aperti per progetti come Wikipedia e innumerevoli altri."
Expand All @@ -35,6 +32,11 @@ object ITInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("ho", "non", "ma")
val NUMERIC_AUTOSUGGESTIONS = listOf("utenti", "anni", "e")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "€"
val CURRENCY_SYMBOL_ALTERNATES = listOf("€", "$", "£", "¥", "₩", "¢")

// MARK: Translate Command

const val TRANSLATE_KEY_LBL = "Tradurre"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.portuguese
* Interface variables for Portuguese language keyboards.
*/
object PTInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "$"
val CURRENCY_SYMBOL_ALTERNATES = listOf("$", "€", "£", "¥", "₩", "¢")

// MARK: Keyboard Labels

const val SPACE_BAR = "espaço"
const val LANGUAGE = "Português"

const val DOWNLOAD_DATA_LBL = "Por favor, baixe os dados do idioma"

const val INVALID_COMMAND_MSG_WIKIDATA = "Não está no Wikidata"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"A Wikidata é um grafo de conhecimento editado colaborativamente e mantivo pela Fundação Wikimedia. A Wikidata é uma fonte de dados públicos para projetos como a Wikipédia e muitos outros."
Expand All @@ -35,6 +32,11 @@ object PTInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("o", "a", "eu")
val NUMERIC_AUTOSUGGESTIONS = listOf("de", "que", "a")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "$"
val CURRENCY_SYMBOL_ALTERNATES = listOf("$", "€", "£", "¥", "₩", "¢")

// MARK: Translate Command

const val TRANSLATE_KEY_LBL = "Traduzir"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.russian
* Interface variables for Russian language keyboards.
*/
object RUInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "₽"
val CURRENCY_SYMBOL_ALTERNATES = listOf("₽", "$", "€", "£", "¥")

// MARK: Keyboard Labels

const val SPACE_BAR = "Пробел"
const val LANGUAGE = "Pусский"

const val DOWNLOAD_DATA_LBL = "Пожалуйста, скачайте языковые данные"

const val INVALID_COMMAND_MSG_WIKIDATA = "Нет в Викиданных"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"Викиданных — это совместно редактируемый граф знаний, поддерживаемый Фондом Викимедиа. Он служит источником открытых данных для таких проектов, как Википедия и бесчисленное множество других."
Expand All @@ -35,6 +32,11 @@ object RUInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("я", "а", "в")
val NUMERIC_AUTOSUGGESTIONS = listOf("в", "и", "я")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "₽"
val CURRENCY_SYMBOL_ALTERNATES = listOf("₽", "$", "€", "£", "¥")

// MARK: Translate Command

const val TRANSLATE_KEY_LBL = "Перевести"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.spanish
* Interface variables for Spanish language keyboards.
*/
object ESInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "$"
val CURRENCY_SYMBOL_ALTERNATES = listOf("₡", "S", "€", "£", "₲", "¢")

// MARK: Keyboard Labels

const val SPACE_BAR = "espacio"
const val LANGUAGE = "Español"

const val DOWNLOAD_DATA_LBL = "Por favor, descarga los datos del idioma"

const val INVALID_COMMAND_MSG_WIKIDATA = "No en Wikidata"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"Wikidata es un gráfico de conocimiento editado de forma colaborativa y mantenido por la Fundación Wikimedia. Sirve como fuente de datos abiertos para proyectos como Wikipedia y muchos otros."
Expand All @@ -35,6 +32,11 @@ object ESInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("el", "la", "no")
val NUMERIC_AUTOSUGGESTIONS = listOf("que", "de", "en")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "$"
val CURRENCY_SYMBOL_ALTERNATES = listOf("₡", "S", "€", "£", "₲", "¢")

// MARK: Suggestion Pronouns

val VERBS_AFTER_PRONOUNS_ARRAY = listOf("ser", "REFLEXIVE_PRONOUN", "no")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package be.scri.helpers.swedish
* Interface variables for Swedish language keyboards.
*/
object SVInterfaceVariables {
// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "kr"
val CURRENCY_SYMBOL_ALTERNATES = listOf("kr", "$", "€", "£", "¥")

// MARK: Keyboard Labels

const val SPACE_BAR = "mellanslag"
const val LANGUAGE = "Svenska"

const val DOWNLOAD_DATA_LBL = "Var god ladda ner språkdata"

const val INVALID_COMMAND_MSG_WIKIDATA = "Inte i Wikidata"
const val INVALID_COMMAND_TEXT_WIKIDATA_1 =
"Wikidata är en gemensamt redigerad kunskapsgraf som underhålls av Wikimedia Foundation. Det fungerar som en källa till öppen data för projekt som Wikipedia och flera andra."
Expand All @@ -35,6 +32,11 @@ object SVInterfaceVariables {
val BASE_AUTOSUGGESTIONS = listOf("jag", "det", "men")
val NUMERIC_AUTOSUGGESTIONS = listOf("jag", "det", "och")

// MARK: Currency Symbols

const val CURRENCY_SYMBOL = "kr"
val CURRENCY_SYMBOL_ALTERNATES = listOf("kr", "$", "€", "£", "¥")

// MARK: Translate Command

const val TRANSLATE_KEY_LBL = "Översätt"
Expand Down
41 changes: 27 additions & 14 deletions app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import DataContract
import android.R.color.white
import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
import android.database.sqlite.SQLiteException
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
Expand All @@ -28,6 +29,7 @@ import android.view.inputmethod.EditorInfo.IME_MASK_ACTION
import android.view.inputmethod.ExtractedTextRequest
import android.view.inputmethod.InputConnection
import android.widget.Button
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.graphics.ColorUtils
Expand All @@ -45,6 +47,7 @@ import be.scri.helpers.BackspaceHandler
import be.scri.helpers.DatabaseManagers
import be.scri.helpers.EmojiUtils.insertEmoji
import be.scri.helpers.KeyboardBase
import be.scri.helpers.KeyboardLanguageMappingConstants
import be.scri.helpers.LanguageMappingConstants.getLanguageAlias
import be.scri.helpers.NativeSuggestionEngine
import be.scri.helpers.PreferencesHelper
Expand Down Expand Up @@ -365,14 +368,21 @@ abstract class GeneralKeyboardIME(
val languageAlias = getLanguageAlias(language)
val dbFile = applicationContext.getDatabasePath("${languageAlias}LanguageData.sqlite")
val hasData = dbFile.exists()
val banner = binding.root.findViewById<Button>(R.id.empty_state_banner)
banner.visibility =
val bannerContainer = binding.root.findViewById<View>(R.id.empty_state_banner_container)
val banner = binding.root.findViewById<TextView>(R.id.empty_state_banner)
val downloadDataText =
KeyboardLanguageMappingConstants.downloadDataPlaceholder[languageAlias]
?: "Please download language data"
banner.text = downloadDataText
bannerContainer.visibility =
if (hasData) View.GONE else View.VISIBLE
binding.commandOptionsBar.visibility =
if (hasData && !isNumericKeyboardActive) View.VISIBLE else View.GONE
val isDarkMode = getIsDarkModeOrNot(applicationContext)
val bannerColor = if (isDarkMode) R.color.dark_tutorial_button_color else R.color.light_tutorial_button_color
val bannerTextColor = if (isDarkMode) R.color.dark_button_outline_color else R.color.light_text_color
val bannerColor =
if (isDarkMode) R.color.dark_tutorial_button_color else R.color.light_tutorial_button_color
val bannerTextColor =
if (isDarkMode) R.color.dark_button_outline_color else R.color.light_text_color
banner.setTextColor(ContextCompat.getColor(applicationContext, bannerTextColor))
banner.post {
val iconColor = ContextCompat.getColor(applicationContext, bannerTextColor)
Expand All @@ -385,29 +395,32 @@ abstract class GeneralKeyboardIME(
border.setColor(ContextCompat.getColor(applicationContext, bannerColor))

if (isDarkMode) {
border.setStroke((2f * resources.displayMetrics.density).toInt(), ContextCompat.getColor(applicationContext, bannerTextColor))
border.setStroke(
(1.5f * resources.displayMetrics.density).toInt(),
ContextCompat.getColor(applicationContext, bannerTextColor),
)
}

val rippleColor =
ColorUtils.setAlphaComponent(
ContextCompat.getColor(applicationContext, bannerTextColor),
51,
)
val rippleDrawable =
RippleDrawable(ColorStateList.valueOf(rippleColor), border, null)

val ripple =
RippleDrawable(
android.content.res.ColorStateList
.valueOf(rippleColor),
border,
null,
)
banner.background = ripple
bannerContainer.background = rippleDrawable
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
bannerContainer.outlineAmbientShadowColor = Color.TRANSPARENT
bannerContainer.outlineSpotShadowColor = Color.TRANSPARENT
}

banner.setOnClickListener {
bannerContainer.setOnClickListener {
val intent =
Intent(applicationContext, MainActivity::class.java)
.apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
putExtra("navigate_to", "download_data")
}

startActivity(intent)
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_arrow_circle_down_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,7h2v5.17l1.59,-1.59L16,12l-4,4 -4,-4 1.41,-1.41L11,12.17V7z"/>
</vector>
Loading
Loading