adding a toggle for using English language
This commit is contained in:
parent
8c19b94d09
commit
d751ec72ab
|
@ -3,7 +3,9 @@ package com.simplemobiletools.calendar
|
|||
import android.support.multidex.MultiDexApplication
|
||||
import com.facebook.stetho.Stetho
|
||||
import com.simplemobiletools.calendar.BuildConfig.USE_LEAK_CANARY
|
||||
import com.simplemobiletools.calendar.extensions.config
|
||||
import com.squareup.leakcanary.LeakCanary
|
||||
import java.util.*
|
||||
|
||||
class App : MultiDexApplication() {
|
||||
override fun onCreate() {
|
||||
|
@ -15,6 +17,12 @@ class App : MultiDexApplication() {
|
|||
LeakCanary.install(this)
|
||||
}
|
||||
|
||||
if (config.useEnglish) {
|
||||
val conf = resources.configuration
|
||||
conf.locale = Locale.ENGLISH
|
||||
resources.updateConfiguration(conf, resources.displayMetrics)
|
||||
}
|
||||
|
||||
Stetho.initializeWithDefaults(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class DayActivity : SimpleActivity(), NavigationListener, ViewPager.OnPageChange
|
|||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_day, menu)
|
||||
updateMenuTextSize(resources, menu)
|
||||
menu.findItem(R.id.filter).isVisible = eventTypeColors.size() > 1 || config.displayEventTypes.isEmpty()
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -465,6 +465,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_event, menu)
|
||||
updateMenuTextSize(resources, menu)
|
||||
if (wasActivityInitialized) {
|
||||
menu.findItem(R.id.delete).isVisible = mDialogTheme != 0 && mEvent.id != 0
|
||||
menu.findItem(R.id.share).isVisible = mDialogTheme != 0 && mEvent.id != 0
|
||||
|
|
|
@ -53,6 +53,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
private val PREFILLED_WEEKS = 61
|
||||
|
||||
private var mIsMonthSelected = false
|
||||
private var mStoredUseEnglish = false
|
||||
private var mStoredTextColor = 0
|
||||
private var mStoredBackgroundColor = 0
|
||||
private var mStoredPrimaryColor = 0
|
||||
|
@ -117,6 +118,11 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (mStoredUseEnglish != config.useEnglish) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
|
||||
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor
|
||||
|| mStoredDayCode != Formatter.getTodayCode()) {
|
||||
updateViewPager()
|
||||
|
@ -143,11 +149,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mStoredTextColor = config.textColor
|
||||
mStoredIsSundayFirst = config.isSundayFirst
|
||||
mStoredBackgroundColor = config.backgroundColor
|
||||
mStoredPrimaryColor = config.primaryColor
|
||||
mStoredUse24HourFormat = config.use24hourFormat
|
||||
storeStateVariables()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@ -158,9 +160,12 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
menu.findItem(R.id.filter).isVisible = mShouldFilterBeVisible
|
||||
menu.findItem(R.id.go_to_today).isVisible = shouldGoToTodayBeVisible()
|
||||
menu.findItem(R.id.refresh_caldav_calendars).isVisible = config.caldavSync
|
||||
updateMenuTextSize(resources, menu)
|
||||
menu.apply {
|
||||
findItem(R.id.filter).isVisible = mShouldFilterBeVisible
|
||||
findItem(R.id.go_to_today).isVisible = shouldGoToTodayBeVisible()
|
||||
findItem(R.id.refresh_caldav_calendars).isVisible = config.caldavSync
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -191,9 +196,13 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
}
|
||||
|
||||
private fun storeStateVariables() {
|
||||
mStoredTextColor = config.textColor
|
||||
mStoredPrimaryColor = config.primaryColor
|
||||
mStoredBackgroundColor = config.backgroundColor
|
||||
config.apply {
|
||||
mStoredUseEnglish = useEnglish
|
||||
mStoredIsSundayFirst = isSundayFirst
|
||||
mStoredTextColor = textColor
|
||||
mStoredPrimaryColor = primaryColor
|
||||
mStoredBackgroundColor = backgroundColor
|
||||
}
|
||||
mStoredDayCode = Formatter.getTodayCode()
|
||||
}
|
||||
|
||||
|
|
|
@ -18,13 +18,11 @@ import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
|
|||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
|
||||
import com.simplemobiletools.calendar.models.EventType
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CALENDAR
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
private val GET_RINGTONE_URI = 1
|
||||
|
@ -44,6 +42,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
super.onResume()
|
||||
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupManageEventTypes()
|
||||
setupHourFormat()
|
||||
setupSundayFirst()
|
||||
|
@ -84,6 +83,16 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
settings_use_english_holder.beVisibleIf(config.wasUseEnglishToggled || Locale.getDefault().language != "en")
|
||||
settings_use_english.isChecked = config.useEnglish
|
||||
settings_use_english_holder.setOnClickListener {
|
||||
settings_use_english.toggle()
|
||||
config.useEnglish = settings_use_english.isChecked
|
||||
useEnglishToggled()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupManageEventTypes() {
|
||||
settings_manage_event_types_holder.setOnClickListener {
|
||||
startActivity(Intent(this, ManageEventTypesActivity::class.java))
|
||||
|
|
|
@ -49,6 +49,26 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_use_english_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_use_english"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/use_english_language"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_hour_format_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue