mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-06-05 21:49:13 +02:00
Merge pull request #259 from Naveen3Singh/locale_separator
Use device locale's decimal separator by default
This commit is contained in:
@ -80,6 +80,14 @@
|
|||||||
android:resource="@xml/widget_info" />
|
android:resource="@xml/widget_info" />
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".receivers.LocaleChangeReceiver"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".activities.SplashActivity.Red"
|
android:name=".activities.SplashActivity.Red"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
|
@ -9,6 +9,6 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var useCommaAsDecimalMark: Boolean
|
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()
|
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)
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user