add Undo
This commit is contained in:
parent
580d92a008
commit
238c88c91b
13 changed files with 61 additions and 10 deletions
|
@ -6,6 +6,7 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import kotlinx.android.synthetic.main.activity_customization.*
|
||||
import yuku.ambilwarna.AmbilWarnaDialog
|
||||
|
@ -19,13 +20,9 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_customization)
|
||||
|
||||
curTextColor = baseConfig.textColor
|
||||
curBackgroundColor = baseConfig.backgroundColor
|
||||
curPrimaryColor = baseConfig.primaryColor
|
||||
|
||||
initColorVariables()
|
||||
setupColorsPickers()
|
||||
updateTextColors(customization_holder)
|
||||
updateActionbarColor()
|
||||
|
||||
customization_text_color_holder.setOnClickListener { pickTextColor() }
|
||||
customization_background_color_holder.setOnClickListener { pickBackgroundColor() }
|
||||
|
@ -41,7 +38,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.undo -> {
|
||||
undoChanges()
|
||||
confirmUndoChanges()
|
||||
true
|
||||
}
|
||||
R.id.save -> {
|
||||
|
@ -53,14 +50,32 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
private fun saveChanges() {
|
||||
baseConfig.textColor = curTextColor
|
||||
baseConfig.backgroundColor = curBackgroundColor
|
||||
baseConfig.primaryColor = curPrimaryColor
|
||||
baseConfig.apply {
|
||||
textColor = curTextColor
|
||||
backgroundColor = curBackgroundColor
|
||||
primaryColor = curPrimaryColor
|
||||
}
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun undoChanges() {
|
||||
private fun confirmUndoChanges() {
|
||||
ConfirmationDialog(this, "", R.string.undo_changes_confirmation, R.string.yes, R.string.no) {
|
||||
resetColors()
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetColors() {
|
||||
initColorVariables()
|
||||
setupColorsPickers()
|
||||
updateTextColors(customization_holder)
|
||||
updateBackgroundColor()
|
||||
updateActionbarColor()
|
||||
}
|
||||
|
||||
private fun initColorVariables() {
|
||||
curTextColor = baseConfig.textColor
|
||||
curBackgroundColor = baseConfig.backgroundColor
|
||||
curPrimaryColor = baseConfig.primaryColor
|
||||
}
|
||||
|
||||
private fun setupColorsPickers() {
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dunkles Thema</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Speichern</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">Neue Funktionen</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Salva</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">保存</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Tema escuro</string>
|
||||
<string name="custom">Personalizado</string>
|
||||
<string name="save">Guardar</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">Novidades</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Сохранить</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">保存</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
|
@ -42,7 +42,10 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="undo_changes">Undo changes</string>
|
||||
<string name="undo_changes_confirmation">Are you sure you want to undo your changes?</string>
|
||||
<string name="save_before_closing">You have unsaved changes. Save before closing?</string>
|
||||
|
||||
<!-- What's new -->
|
||||
<string name="whats_new">What\'s new</string>
|
||||
|
|
Loading…
Reference in a new issue