Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ZayJackPrvy committed Oct 12, 2024
2 parents 0ccd744 + de07bc8 commit 178ed8e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 19 deletions.
61 changes: 44 additions & 17 deletions app/src/main/java/be/scri/fragments/LanguageSettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package be.scri.fragments

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -98,11 +99,38 @@ class LanguageSettingsFragment : Fragment() {
}

private fun setupRecyclerView(language: String) {
binding.recyclerView.layoutManager = LinearLayoutManager(context)
binding.recyclerView.adapter = CustomAdapter(getRecyclerViewData(language), requireContext())
binding.functionalityRecyclerView.layoutManager = LinearLayoutManager(context)
binding.functionalityRecyclerView.adapter = CustomAdapter(getFunctionalityRecyclerViewData(language), requireContext())

binding.layoutRecyclerView.layoutManager = LinearLayoutManager(context)
binding.layoutRecyclerView.adapter = CustomAdapter(getLayoutRecyclerViewData(language), requireContext())
}

private fun getFunctionalityRecyclerViewData(language: String): List<SwitchItem> {
val sharedPref = requireActivity().getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
val list = mutableListOf<SwitchItem>()
list.add(
SwitchItem(
isChecked = sharedPref.getBoolean("period_on_double_tap_$language", false),
title = getString(R.string.app_settings_keyboard_functionality_double_space_period),
description = getString(R.string.app_settings_keyboard_functionality_double_space_period_description),
action = { enablePeriodOnSpaceBarDoubleTap(language) },
action2 = { disablePeriodOnSpaceBarDoubleTap(language) },
),
)
list.add(
SwitchItem(
isChecked = sharedPref.getBoolean("autosuggest_emojis_$language", true),
title = getString(R.string.app_settings_keyboard_functionality_auto_suggest_emoji),
description = getString(R.string.app_settings_keyboard_functionality_auto_suggest_emoji_description),
action = { enableEmojiAutosuggestions(language) },
action2 = { disableEmojiAutosuggestions(language) },
),
)
return list
}

private fun getRecyclerViewData(language: String): List<SwitchItem> {
private fun getLayoutRecyclerViewData(language: String): List<SwitchItem> {
val sharedPref = requireActivity().getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
val list = mutableListOf<SwitchItem>()
when (language) {
Expand Down Expand Up @@ -142,20 +170,11 @@ class LanguageSettingsFragment : Fragment() {
}
list.add(
SwitchItem(
isChecked = sharedPref.getBoolean("period_on_double_tap_$language", false),
title = getString(R.string.app_settings_keyboard_functionality_double_space_period),
description = getString(R.string.app_settings_keyboard_functionality_double_space_period_description),
action = { enablePeriodOnSpaceBarDoubleTap(language) },
action2 = { disablePeriodOnSpaceBarDoubleTap(language) },
),
)
list.add(
SwitchItem(
isChecked = sharedPref.getBoolean("autosuggest_emojis_$language", true),
title = getString(R.string.app_settings_keyboard_functionality_auto_suggest_emoji),
description = getString(R.string.app_settings_keyboard_functionality_auto_suggest_emoji_description),
action = { enableEmojiAutosuggestions(language) },
action2 = { disableEmojiAutosuggestions(language) },
isChecked = sharedPref.getBoolean("period_and_comma_$language", false),
title = getString(R.string.app_settings_keyboard_layout_period_and_comma),
description = getString(R.string.app_settings_keyboard_layout_period_and_comma_description),
action = { enableCommaAndPeriod() },
action2 = { disableCommaAndPeriod() },
),
)
return list
Expand Down Expand Up @@ -209,6 +228,14 @@ class LanguageSettingsFragment : Fragment() {
Toast.makeText(requireContext(), "$language Emoji Autosuggestions off", Toast.LENGTH_SHORT).show()
}

private fun enableCommaAndPeriod() {
Log.d("LanguageSettingsFragment", "This enableCommaAndPeriod-function is to be implemented later")
}

private fun disableCommaAndPeriod() {
Log.d("LanguageSettingsFragment", "This disableCommaAndPeriod-function is to be implemented later")
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
35 changes: 33 additions & 2 deletions app/src/main/res/layout/fragment_language_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:background="@color/you_background_color">

<TextView
android:id="@+id/languageSettingsTitle"
android:id="@+id/functionalitySettingsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app.settings.keyboard.functionality.title"
Expand All @@ -24,7 +24,7 @@
app:layout_constraintVertical_bias="0.022" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:id="@+id/functionalityRecyclerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
Expand All @@ -34,4 +34,35 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/layoutSettingsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app.settings.keyboard.layout.title"
android:layout_marginStart="3dp"
android:textColor="@color/app_text_color"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@id/functionalityRecyclerView"
app:layout_constraintBottom_toTopOf="@id/layoutRecyclerView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.054"
app:layout_constraintStart_toStartOf="parent"

app:layout_constraintVertical_bias="0.022" />




<androidx.recyclerview.widget.RecyclerView
android:id="@+id/layoutRecyclerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/functionalityRecyclerView" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 178ed8e

Please sign in to comment.