mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-02-17 03:50:39 +01:00
Merge pull request #259 from Naveen3Singh/locale_separator
Use device locale's decimal separator by default
This commit is contained in:
commit
6a754cfc26
@ -80,6 +80,14 @@
|
||||
android:resource="@xml/widget_info" />
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".receivers.LocaleChangeReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<activity-alias
|
||||
android:name=".activities.SplashActivity.Red"
|
||||
android:enabled="false"
|
||||
|
@ -9,6 +9,6 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
}
|
||||
|
||||
var useCommaAsDecimalMark: Boolean
|
||||
get() = prefs.getBoolean(USE_COMMA_AS_DECIMAL_MARK, false)
|
||||
get() = prefs.getBoolean(USE_COMMA_AS_DECIMAL_MARK, getDecimalSeparator() == COMMA)
|
||||
set(useCommaAsDecimalMark) = prefs.edit().putBoolean(USE_COMMA_AS_DECIMAL_MARK, useCommaAsDecimalMark).apply()
|
||||
}
|
||||
|
@ -29,3 +29,7 @@ class NumberFormatHelper(
|
||||
return str.replace(groupingSeparator, "").replace(decimalSeparator, DOT)
|
||||
}
|
||||
}
|
||||
|
||||
fun getDecimalSeparator(): String {
|
||||
return DecimalFormatSymbols.getInstance().decimalSeparator.toString()
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.simplemobiletools.calculator.receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.calculator.extensions.updateWidgets
|
||||
|
||||
class LocaleChangeReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (Intent.ACTION_LOCALE_CHANGED == intent.action) {
|
||||
context.updateWidgets()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user