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