adding a toggle for using english
This commit is contained in:
parent
5e22077a0b
commit
4e82b6b706
|
@ -44,6 +44,8 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
||||||
private var isEraserOn = false
|
private var isEraserOn = false
|
||||||
private var isImageCaptureIntent = false
|
private var isImageCaptureIntent = false
|
||||||
|
|
||||||
|
private var storedUseEnglish = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
@ -64,10 +66,16 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
||||||
|
|
||||||
checkIntents()
|
checkIntents()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
|
storeStateVariables()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
if (storedUseEnglish != config.useEnglish) {
|
||||||
|
restartActivity()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val isStrokeWidthBarEnabled = config.showBrushSize
|
val isStrokeWidthBarEnabled = config.showBrushSize
|
||||||
stroke_width_bar.beVisibleIf(isStrokeWidthBarEnabled)
|
stroke_width_bar.beVisibleIf(isStrokeWidthBarEnabled)
|
||||||
my_canvas.setIsStrokeWidthBarEnabled(isStrokeWidthBarEnabled)
|
my_canvas.setIsStrokeWidthBarEnabled(isStrokeWidthBarEnabled)
|
||||||
|
@ -78,6 +86,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
config.brushColor = color
|
config.brushColor = color
|
||||||
config.brushSize = strokeWidth
|
config.brushSize = strokeWidth
|
||||||
|
storeStateVariables()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
@ -106,6 +115,10 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun storeStateVariables() {
|
||||||
|
storedUseEnglish = config.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.draw.activities
|
package com.simplemobiletools.draw.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.draw.R
|
import com.simplemobiletools.draw.R
|
||||||
import com.simplemobiletools.draw.extensions.config
|
import com.simplemobiletools.draw.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()
|
||||||
setupBrushSize()
|
setupBrushSize()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
}
|
}
|
||||||
|
@ -26,6 +30,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 setupBrushSize() {
|
private fun setupBrushSize() {
|
||||||
settings_show_brush_size.isChecked = config.showBrushSize
|
settings_show_brush_size.isChecked = config.showBrushSize
|
||||||
settings_show_brush_size_holder.setOnClickListener {
|
settings_show_brush_size_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_show_brush_size_holder"
|
android:id="@+id/settings_show_brush_size_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue