Skip to content

Commit

Permalink
Add Autosuggest emojis menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
Linfye committed Sep 6, 2024
1 parent db3334a commit 2617372
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion app/src/main/java/be/scri/fragments/LanguageSettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import be.scri.activities.MainActivity
import be.scri.databinding.FragmentLanguageSettingsBinding
import be.scri.helpers.CustomAdapter
import be.scri.models.SwitchItem
import android.widget.Toast

class LanguageSettingsFragment : Fragment() {
private var _binding: FragmentLanguageSettingsBinding? = null
Expand Down Expand Up @@ -107,10 +108,17 @@ class LanguageSettingsFragment : Fragment() {
return listOf(
SwitchItem(
isChecked = sharedPref.getBoolean("period_on_double_tap_$language", false),
title = "Double space Periods",
title = "Double space periods",
action = { enablePeriodOnSpaceBarDoubleTap(language) },
action2 = { disablePeriodOnSpaceBarDoubleTap(language) },
),
SwitchItem(
isChecked = sharedPref.getBoolean("autosuggest_emojis_$language", true),
title = "Autosuggest emojis",
action = { enableEmojiAutosuggestions(language) },
action2 = { disableEmojiAutosuggestions(language) },
)

)
}

Expand All @@ -128,6 +136,22 @@ class LanguageSettingsFragment : Fragment() {
editor.apply()
}

private fun enableEmojiAutosuggestions(language: String) {
val sharedPref = requireActivity().getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
val editor = sharedPref.edit()
editor.putBoolean("emoji_suggestions_$language", true)
editor.apply()
Toast.makeText(requireContext() , "$language Emoji Autosuggestions on", Toast.LENGTH_SHORT).show();
}

private fun disableEmojiAutosuggestions(language: String) {
val sharedPref = requireActivity().getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
val editor = sharedPref.edit()
editor.putBoolean("emoji_suggestions_$language", false)
editor.apply()
Toast.makeText(requireContext(), "$language Emoji Autosuggestions off", Toast.LENGTH_SHORT).show();
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down

0 comments on commit 2617372

Please sign in to comment.