|
| 1 | +package com.simplemobiletools.notes.activities |
| 2 | + |
| 3 | +import android.os.Bundle |
| 4 | +import android.support.v4.app.TaskStackBuilder |
| 5 | +import android.view.View |
| 6 | +import android.widget.AdapterView |
| 7 | +import com.simplemobiletools.notes.R |
| 8 | +import kotlinx.android.synthetic.main.activity_settings.* |
| 9 | + |
| 10 | +class SettingsActivity : SimpleActivity() { |
| 11 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 12 | + super.onCreate(savedInstanceState) |
| 13 | + setContentView(R.layout.activity_settings) |
| 14 | + |
| 15 | + setupDarkTheme() |
| 16 | + setupFontSize() |
| 17 | + } |
| 18 | + |
| 19 | + private fun setupDarkTheme() { |
| 20 | + settings_dark_theme.isChecked = config.isDarkTheme |
| 21 | + settings_dark_theme_holder.setOnClickListener { |
| 22 | + settings_dark_theme.toggle() |
| 23 | + config.isDarkTheme = settings_dark_theme.isChecked |
| 24 | + restartActivity() |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + private fun setupFontSize() { |
| 29 | + settings_font_size.setSelection(config.fontSize) |
| 30 | + settings_font_size.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { |
| 31 | + override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { |
| 32 | + config.fontSize = settings_font_size.selectedItemPosition |
| 33 | + } |
| 34 | + |
| 35 | + override fun onNothingSelected(parent: AdapterView<*>?) { |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + private fun restartActivity() { |
| 41 | + TaskStackBuilder.create(applicationContext).addNextIntentWithParentStack(intent).startActivities() |
| 42 | + } |
| 43 | +} |
0 commit comments