переключение кнопки уведомления и сохранение после закрытия приложения
This commit is contained in:
1 parent
0762bfffbf
commit
f034cdf357
2 files changed
+20
-2
No files matched your search
@@ -8,6 +8,8 @@ import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import androidx.core.content.edit
|
||||
|
||||
class Settings : AppCompatActivity() {
|
||||
private var player: MediaPlayer? = null
|
||||
@@ -42,6 +44,22 @@ class Settings : AppCompatActivity() {
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
val prefs = getSharedPreferences("helponizer_prefs", MODE_PRIVATE)
|
||||
var shet = prefs.getInt("shet", 0)
|
||||
|
||||
findViewById<MaterialButton>(R.id.buttonNotification).text =
|
||||
if (shet == 1) "Выключить уведомление" else "Включить уведомление"
|
||||
|
||||
findViewById<View>(R.id.buttonNotification).setOnClickListener {
|
||||
if (shet == 1) {
|
||||
findViewById<MaterialButton>(R.id.buttonNotification).text = "Включить уведомление"
|
||||
shet = 0
|
||||
} else {
|
||||
findViewById<MaterialButton>(R.id.buttonNotification).text = "Выключить уведомление"
|
||||
shet = 1
|
||||
}
|
||||
prefs.edit { putInt("shet", shet) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
<string name="settings_title">Настройки</string>
|
||||
<string name="settings_change_palette">Сменить палитру</string>
|
||||
<string name="settings_play_sound">Воспроизвести звук</string>
|
||||
<string name="settings_text_up">A+ Увеличить текст</string>
|
||||
<string name="settings_text_down">A− Уменьшить текст</string>
|
||||
<string name="settings_text_up">Увеличить текст</string>
|
||||
<string name="settings_text_down">Уменьшить текст</string>
|
||||
<string name="settings_notification">Включить уведомление</string>
|
||||
|
||||
<!-- Common -->
|
||||
|
||||
Reference in new issue
Block a user