adding a switch for forcing english language
This commit is contained in:
parent
3d319b7790
commit
1feff193dd
|
@ -37,7 +37,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.0.21'
|
||||
implementation 'com.simplemobiletools:commons:3.0.23'
|
||||
implementation 'com.squareup:otto:1.3.8'
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
android:required="true"/>
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_launcher_name"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.simplemobiletools.flashlight
|
||||
|
||||
import android.app.Application
|
||||
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
||||
|
||||
class App : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
checkUseEnglish()
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ class MainActivity : SimpleActivity() {
|
|||
private var mBus: Bus? = null
|
||||
private var mCameraImpl: MyCameraImpl? = null
|
||||
private var translucentWhite = 0
|
||||
private var mStoredUseEnglish = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -49,10 +50,16 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
setupStroboscope()
|
||||
storeStateVariables()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (mStoredUseEnglish != config.useEnglish) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
|
||||
mCameraImpl!!.handleCameraSetup()
|
||||
checkState(MyCameraImpl.isFlashlightOn)
|
||||
|
||||
|
@ -74,6 +81,11 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
storeStateVariables()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mBus!!.unregister(this)
|
||||
|
@ -98,6 +110,12 @@ class MainActivity : SimpleActivity() {
|
|||
return true
|
||||
}
|
||||
|
||||
private fun storeStateVariables() {
|
||||
config.apply {
|
||||
mStoredUseEnglish = useEnglish
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchSettings() {
|
||||
startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.simplemobiletools.flashlight.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.useEnglishToggled
|
||||
import com.simplemobiletools.flashlight.R
|
||||
import com.simplemobiletools.flashlight.extensions.config
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -16,6 +19,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
super.onResume()
|
||||
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupBrightDisplay()
|
||||
setupStroboscope()
|
||||
updateTextColors(settings_holder)
|
||||
|
@ -27,6 +31,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 setupBrightDisplay() {
|
||||
settings_bright_display.isChecked = config.brightDisplay
|
||||
settings_bright_display_holder.setOnClickListener {
|
||||
|
|
|
@ -30,6 +30,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_bright_display_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue