diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 4a7ebae6d..e46b1fc8d 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -93,6 +93,7 @@ dependencies {
implementation(projects.feature.notification)
implementation(projects.feature.location)
implementation(projects.feature.about)
+ implementation(projects.feature.settings)
implementation("androidx.legacy:legacy-support-v4:1.0.0")
diff --git a/app/src/main/java/org/mifos/mobile/MifosSelfServiceApp.kt b/app/src/main/java/org/mifos/mobile/MifosSelfServiceApp.kt
index bebd02177..9dc985bb0 100644
--- a/app/src/main/java/org/mifos/mobile/MifosSelfServiceApp.kt
+++ b/app/src/main/java/org/mifos/mobile/MifosSelfServiceApp.kt
@@ -11,8 +11,8 @@ import com.raizlabs.android.dbflow.config.FlowConfig
import com.raizlabs.android.dbflow.config.FlowManager
import dagger.hilt.android.HiltAndroidApp
import org.mifos.mobile.core.datastore.PreferencesHelper
-import org.mifos.mobile.ui.settings.applySavedTheme
import org.mifos.mobile.core.common.utils.LanguageHelper.onAttach
+import org.mifos.mobile.feature.settings.applySavedTheme
/**
* @author ishan
diff --git a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsComposeFragment.kt b/app/src/main/java/org/mifos/mobile/ui/settings/SettingsComposeFragment.kt
index 95651306f..cf5a041b4 100644
--- a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsComposeFragment.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/settings/SettingsComposeFragment.kt
@@ -9,6 +9,7 @@ import dagger.hilt.android.AndroidEntryPoint
import org.mifos.mobile.R
import org.mifos.mobile.core.ui.component.mifosComposeView
import org.mifos.mobile.core.ui.theme.MifosMobileTheme
+import org.mifos.mobile.feature.settings.SettingsScreen
import org.mifos.mobile.ui.activities.HomeActivity
import org.mifos.mobile.ui.activities.PassCodeActivity
import org.mifos.mobile.ui.activities.base.BaseActivity
diff --git a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsFragment.kt b/app/src/main/java/org/mifos/mobile/ui/settings/SettingsFragment.kt
deleted file mode 100644
index 1d86d4ffc..000000000
--- a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsFragment.kt
+++ /dev/null
@@ -1,196 +0,0 @@
-package org.mifos.mobile.ui.settings
-
-import android.content.Intent
-import android.content.SharedPreferences
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener
-import android.os.Build
-import android.os.Bundle
-import androidx.appcompat.app.AppCompatDelegate
-import androidx.fragment.app.DialogFragment
-import androidx.preference.ListPreference
-import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
-import com.google.android.material.dialog.MaterialAlertDialogBuilder
-import com.mifos.mobile.passcode.utils.PasscodePreferencesHelper
-import dagger.hilt.android.AndroidEntryPoint
-import org.mifos.mobile.R
-import org.mifos.mobile.ui.activities.PassCodeActivity
-import org.mifos.mobile.ui.activities.base.BaseActivity
-import org.mifos.mobile.ui.update_password.UpdatePasswordFragment
-import org.mifos.mobile.utils.ConfigurationDialogFragmentCompat
-import org.mifos.mobile.utils.ConfigurationPreference
-import org.mifos.mobile.core.datastore.PreferencesHelper
-import org.mifos.mobile.core.common.utils.LanguageHelper
-import java.util.Locale
-
-/**
- * Created by dilpreet on 02/10/17.
- */
-@AndroidEntryPoint
-class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener {
-
- private val prefsHelper by lazy { PreferencesHelper(requireContext().applicationContext) }
- var preference: android.preference.Preference? = null
-
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.settings_preference)
- findPreference(getString(R.string.theme_type)).setOnPreferenceClickListener {
- val previouslySelectedTheme = prefsHelper.appTheme
-
- MaterialAlertDialogBuilder(requireContext())
- .setTitle(getString(R.string.change_app_theme))
- .setSingleChoiceItems(
- resources.getStringArray(R.array.themes),
- previouslySelectedTheme,
- ) { dialog, selectedTheme ->
- prefsHelper.applyTheme(AppTheme.fromIndex(selectedTheme))
- dialog.dismiss()
- }
- .show()
- return@setOnPreferenceClickListener true
- }
- findPreference(getString(R.string.passcode)).setOnPreferenceClickListener {
- val passCodePreferencesHelper = PasscodePreferencesHelper(activity)
- val currPassCode = passCodePreferencesHelper.passCode
- passCodePreferencesHelper.savePassCode("")
- val intent = Intent(activity, PassCodeActivity::class.java).apply {
- putExtra(org.mifos.mobile.core.common.Constants.CURR_PASSWORD, currPassCode)
- putExtra(org.mifos.mobile.core.common.Constants.IS_TO_UPDATE_PASS_CODE, true)
- }
- preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
- startActivity(intent)
- true
- }
- when (preference?.key) {
- getString(R.string.password) -> {
- // TODO("create changePasswordActivity and implement the logic for password change")
- }
-
- getString(R.string.passcode) -> {
- activity?.let {
- val passCodePreferencesHelper = PasscodePreferencesHelper(activity)
- val currPassCode = passCodePreferencesHelper.passCode
- passCodePreferencesHelper.savePassCode("")
- val intent = Intent(it, PassCodeActivity::class.java).apply {
- putExtra(org.mifos.mobile.core.common.Constants.CURR_PASSWORD, currPassCode)
- putExtra(org.mifos.mobile.core.common.Constants.IS_TO_UPDATE_PASS_CODE, true)
- }
- preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
- startActivity(intent)
- }
- }
- }
- }
-
- override fun onResume() {
- super.onResume()
- (activity as? BaseActivity)?.showToolbar()
- activity?.title = getString(R.string.settings)
- preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
- }
-
- override fun onPause() {
- super.onPause()
- preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
- }
-
- override fun onDisplayPreferenceDialog(preference: Preference) {
- var dialogFragment: DialogFragment? = null
- if (preference is ConfigurationPreference) {
- dialogFragment = ConfigurationDialogFragmentCompat()
- val bundle = Bundle(1)
- bundle.putString("key", preference.getKey())
- dialogFragment.setArguments(bundle)
- }
- if (dialogFragment != null) {
- dialogFragment.setTargetFragment(this, 0)
- dialogFragment.show(
- parentFragmentManager,
- "android.support.v7.preference.PreferenceFragment.DIALOG",
- )
- } else {
- super.onDisplayPreferenceDialog(preference)
- }
- }
-
- override fun onPreferenceTreeClick(preference: Preference): Boolean {
- when (preference.key) {
- org.mifos.mobile.core.common.Constants.PASSWORD -> (activity as BaseActivity?)?.replaceFragment(
- UpdatePasswordFragment.newInstance(),
- true,
- R.id.container,
- )
- }
- return super.onPreferenceTreeClick(preference)
- }
-
- companion object {
- @JvmStatic
- fun newInstance(): SettingsFragment {
- return SettingsFragment()
- }
- }
-
- override fun onSharedPreferenceChanged(p0: SharedPreferences?, p1: String?) {
- val preference = findPreference(p1)
- if (preference is ListPreference) {
- val isSystemLanguage =
- (preference.value == resources.getStringArray(R.array.languages_value)[0])
- prefsHelper.putBoolean(
- context?.getString(R.string.default_system_language),
- isSystemLanguage
- )
- if (!isSystemLanguage) {
- LanguageHelper.setLocale(context, preference.value)
- } else {
- if (!resources.getStringArray(R.array.languages_value)
- .contains(Locale.getDefault().language)
- ) {
- LanguageHelper.setLocale(context, "en")
- } else {
- LanguageHelper.setLocale(context, Locale.getDefault().language)
- }
- }
- val intent = Intent(activity, activity?.javaClass)
- intent.putExtra(org.mifos.mobile.core.common.Constants.HAS_SETTINGS_CHANGED, true)
- startActivity(intent)
- activity?.finish()
- }
- }
-}
-
-enum class AppTheme {
- SYSTEM, LIGHT, DARK;
-
- companion object {
- fun fromIndex(index: Int): AppTheme = when (index) {
- 1 -> LIGHT
- 2 -> DARK
- else -> SYSTEM
- }
- }
-}
-
-fun PreferencesHelper.applySavedTheme() {
- val applicationTheme = AppTheme.fromIndex(this.appTheme)
- AppCompatDelegate.setDefaultNightMode(
- when {
- applicationTheme == AppTheme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
- applicationTheme == AppTheme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
- Build.VERSION.SDK_INT > Build.VERSION_CODES.P -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
- else -> AppCompatDelegate.MODE_NIGHT_NO
- },
- )
-}
-
-fun PreferencesHelper.applyTheme(applicationTheme: AppTheme) {
- this.appTheme = applicationTheme.ordinal
- AppCompatDelegate.setDefaultNightMode(
- when {
- applicationTheme == AppTheme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
- applicationTheme == AppTheme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
- Build.VERSION.SDK_INT > Build.VERSION_CODES.P -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
- else -> AppCompatDelegate.MODE_NIGHT_NO
- },
- )
-}
\ No newline at end of file
diff --git a/feature/settings/.gitignore b/feature/settings/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/feature/settings/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/feature/settings/build.gradle.kts b/feature/settings/build.gradle.kts
new file mode 100644
index 000000000..954e6e86f
--- /dev/null
+++ b/feature/settings/build.gradle.kts
@@ -0,0 +1,20 @@
+plugins {
+ alias(libs.plugins.mifos.android.feature)
+ alias(libs.plugins.mifos.android.library.compose)
+}
+
+android {
+ namespace = "org.mifos.mobile.feature.settings"
+}
+
+dependencies {
+ implementation(projects.ui)
+ implementation(projects.core.common)
+ implementation(projects.core.model)
+ implementation(projects.core.data)
+ implementation(libs.androidx.appcompat)
+
+ testImplementation(libs.junit)
+ androidTestImplementation(libs.androidx.test.ext.junit)
+ androidTestImplementation(libs.espresso.core)
+}
\ No newline at end of file
diff --git a/feature/settings/consumer-rules.pro b/feature/settings/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/feature/settings/proguard-rules.pro b/feature/settings/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/feature/settings/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/feature/settings/src/androidTest/java/org/mifos/mobile/feature/settings/ExampleInstrumentedTest.kt b/feature/settings/src/androidTest/java/org/mifos/mobile/feature/settings/ExampleInstrumentedTest.kt
new file mode 100644
index 000000000..dfe1d4a46
--- /dev/null
+++ b/feature/settings/src/androidTest/java/org/mifos/mobile/feature/settings/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package org.mifos.mobile.feature.settings
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("org.mifos.mobile.feature.settings.test", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/feature/settings/src/main/AndroidManifest.xml b/feature/settings/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..a5918e68a
--- /dev/null
+++ b/feature/settings/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsScreen.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsScreen.kt
similarity index 99%
rename from app/src/main/java/org/mifos/mobile/ui/settings/SettingsScreen.kt
rename to feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsScreen.kt
index cc92ed3ba..c82dc22cd 100644
--- a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsScreen.kt
+++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsScreen.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.settings
+package org.mifos.mobile.feature.settings
import android.content.Context
import androidx.compose.foundation.layout.Column
@@ -33,7 +33,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
-import org.mifos.mobile.R
import org.mifos.mobile.core.ui.component.MFScaffold
import org.mifos.mobile.core.ui.component.MifosRadioButtonDialog
import org.mifos.mobile.core.ui.component.MifosTopBarTitle
diff --git a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsViewModel.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsViewModel.kt
similarity index 79%
rename from app/src/main/java/org/mifos/mobile/ui/settings/SettingsViewModel.kt
rename to feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsViewModel.kt
index fe03424ec..1aeab7574 100644
--- a/app/src/main/java/org/mifos/mobile/ui/settings/SettingsViewModel.kt
+++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/SettingsViewModel.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.settings
+package org.mifos.mobile.feature.settings
import android.os.Build
@@ -11,7 +11,6 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.stateIn
-import org.mifos.mobile.R
import org.mifos.mobile.core.datastore.PreferencesHelper
import org.mifos.mobile.core.model.enums.AppTheme
import org.mifos.mobile.core.model.enums.MifosAppLanguage
@@ -72,7 +71,7 @@ class SettingsViewModel @Inject constructor(
}
)
preferencesHelper.appTheme = theme.ordinal
- preferencesHelper.applySavedTheme()
+ preferencesHelper.applyTheme(theme)
}
}
@@ -119,4 +118,28 @@ enum class SettingsCardItem(
)
}
+fun PreferencesHelper.applySavedTheme() {
+ val applicationTheme = AppTheme.entries.find { it.ordinal == this.appTheme }
+ AppCompatDelegate.setDefaultNightMode(
+ when {
+ applicationTheme == AppTheme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
+ applicationTheme == AppTheme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
+ Build.VERSION.SDK_INT > Build.VERSION_CODES.P -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
+ else -> AppCompatDelegate.MODE_NIGHT_NO
+ },
+ )
+}
+
+
+fun PreferencesHelper.applyTheme(applicationTheme: AppTheme) {
+ this.appTheme = applicationTheme.ordinal
+ AppCompatDelegate.setDefaultNightMode(
+ when {
+ applicationTheme == AppTheme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
+ applicationTheme == AppTheme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
+ Build.VERSION.SDK_INT > Build.VERSION_CODES.P -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
+ else -> AppCompatDelegate.MODE_NIGHT_NO
+ },
+ )
+}
diff --git a/app/src/main/java/org/mifos/mobile/ui/settings/UpdateEndpointDialog.kt b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/UpdateEndpointDialog.kt
similarity index 98%
rename from app/src/main/java/org/mifos/mobile/ui/settings/UpdateEndpointDialog.kt
rename to feature/settings/src/main/java/org/mifos/mobile/feature/settings/UpdateEndpointDialog.kt
index 82f82591d..ca01b712c 100644
--- a/app/src/main/java/org/mifos/mobile/ui/settings/UpdateEndpointDialog.kt
+++ b/feature/settings/src/main/java/org/mifos/mobile/feature/settings/UpdateEndpointDialog.kt
@@ -1,4 +1,4 @@
-package org.mifos.mobile.ui.settings
+package org.mifos.mobile.feature.settings
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -21,7 +21,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
-import org.mifos.mobile.R
import org.mifos.mobile.core.ui.theme.MifosMobileTheme
@Composable
diff --git a/feature/settings/src/main/res/drawable/ic_baseline_dark_mode_24.xml b/feature/settings/src/main/res/drawable/ic_baseline_dark_mode_24.xml
new file mode 100644
index 000000000..e52c5baff
--- /dev/null
+++ b/feature/settings/src/main/res/drawable/ic_baseline_dark_mode_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_lock_black_24dp.xml b/feature/settings/src/main/res/drawable/ic_lock_black_24dp.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_lock_black_24dp.xml
rename to feature/settings/src/main/res/drawable/ic_lock_black_24dp.xml
diff --git a/app/src/main/res/drawable/ic_passcode.xml b/feature/settings/src/main/res/drawable/ic_passcode.xml
similarity index 98%
rename from app/src/main/res/drawable/ic_passcode.xml
rename to feature/settings/src/main/res/drawable/ic_passcode.xml
index d00509740..bc2ba28ef 100644
--- a/app/src/main/res/drawable/ic_passcode.xml
+++ b/feature/settings/src/main/res/drawable/ic_passcode.xml
@@ -1,11 +1,11 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_translate.xml b/feature/settings/src/main/res/drawable/ic_translate.xml
similarity index 98%
rename from app/src/main/res/drawable/ic_translate.xml
rename to feature/settings/src/main/res/drawable/ic_translate.xml
index ec8633e20..fbabff144 100644
--- a/app/src/main/res/drawable/ic_translate.xml
+++ b/feature/settings/src/main/res/drawable/ic_translate.xml
@@ -1,11 +1,11 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_update.xml b/feature/settings/src/main/res/drawable/ic_update.xml
similarity index 98%
rename from app/src/main/res/drawable/ic_update.xml
rename to feature/settings/src/main/res/drawable/ic_update.xml
index ab86a8ce5..bb668bb31 100644
--- a/app/src/main/res/drawable/ic_update.xml
+++ b/feature/settings/src/main/res/drawable/ic_update.xml
@@ -1,11 +1,11 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/feature/settings/src/main/res/values/strings.xml b/feature/settings/src/main/res/values/strings.xml
new file mode 100644
index 000000000..aba0d20dd
--- /dev/null
+++ b/feature/settings/src/main/res/values/strings.xml
@@ -0,0 +1,44 @@
+
+
+ Change theme
+ Settings
+ Password
+ Change Passcode
+ Change App Passcode
+ Change Password
+ Change your Account Password
+ Language
+ Choose your language
+ Other
+ Accounts
+ Theme
+ Update Endpoint
+ Click here to change your Endpoint Configurations
+ Enter the Base URL
+ Enter the Tenant
+ Cancel
+ OK
+
+ default_system_language
+ language_type
+
+ - System Language
+ - English
+ - हिंदी
+ - عربى
+ - اُردُو
+ - বাঙালি
+ - Español
+ - français
+ - bahasa Indonesia
+ - ភាសាខ្មែរ
+ - ಕನ್ನಡ
+ - తెలుగు
+ - မြန်မာ
+ - Polski
+ - Português
+ - русский
+ - Kiswahili
+ - فارسی
+
+
\ No newline at end of file
diff --git a/feature/settings/src/test/java/org/mifos/mobile/feature/settings/ExampleUnitTest.kt b/feature/settings/src/test/java/org/mifos/mobile/feature/settings/ExampleUnitTest.kt
new file mode 100644
index 000000000..f4b977b8a
--- /dev/null
+++ b/feature/settings/src/test/java/org/mifos/mobile/feature/settings/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package org.mifos.mobile.feature.settings
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 765dfa102..59ea5538b 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -44,3 +44,4 @@ include(":feature:help")
include(":feature:notification")
include(":feature:location")
include(":feature:about")
+include(":feature:settings")