Добавлены формы 1 и 6
This commit is contained in:
@@ -3,6 +3,7 @@ package com.example.timert
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.Toast
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
@@ -18,18 +19,30 @@ class MainActivity : AppCompatActivity() {
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||
insets
|
||||
}
|
||||
var button: Button = findViewById(R.id.button1)
|
||||
|
||||
button.setOnClickListener{
|
||||
val intent = Intent(this,timer::class.java)
|
||||
// Кнопки главной формы:
|
||||
val settingsButton: Button = findViewById(R.id.settingsButton)
|
||||
settingsButton.setOnClickListener {
|
||||
val intent = Intent(this, SettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
var button2: Button = findViewById(R.id.button2)
|
||||
|
||||
button2.setOnClickListener{
|
||||
val intent = Intent(this,CreatingTraining::class.java)
|
||||
startActivity(intent)
|
||||
val startTrainingButton: Button = findViewById(R.id.startTrainingButton)
|
||||
startTrainingButton.setOnClickListener {
|
||||
Toast.makeText(this, "Запуск тренировки!", Toast.LENGTH_SHORT).show() // Заглушка
|
||||
//TODO: Intent для запуска Activity тренировки (форма 5)
|
||||
}
|
||||
|
||||
val templatesButton: Button = findViewById(R.id.templatesButton)
|
||||
templatesButton.setOnClickListener {
|
||||
Toast.makeText(this, "Открытие шаблонов!", Toast.LENGTH_SHORT).show() // Заглушка
|
||||
//TODO: Intent для открытия Activity шаблонов (форма 3)
|
||||
}
|
||||
|
||||
val newTemplateButton: Button = findViewById(R.id.newTemplateButton)
|
||||
newTemplateButton.setOnClickListener {
|
||||
Toast.makeText(this, "Создание нового шаблона!", Toast.LENGTH_SHORT).show() // Заглушка
|
||||
//TODO: Intent для открытия Activity создания шаблона (форма 3)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.example.timert
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.widget.Switch
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.text.HtmlCompat
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings2)
|
||||
|
||||
val versionTextView: TextView = findViewById(R.id.versionTextView)
|
||||
val darkModeSwitch: Switch = findViewById(R.id.darkModeSwitch)
|
||||
val aboutButton: Button = findViewById(R.id.aboutButton)
|
||||
val developersButton: Button = findViewById(R.id.developersButton)
|
||||
|
||||
// Получаем сохраненное состояние темы из SharedPreferences
|
||||
val sharedPreferences = getSharedPreferences("AppSettings", Context.MODE_PRIVATE)
|
||||
val isDarkMode = sharedPreferences.getBoolean("DarkMode", false) // По умолчанию - светлая тема
|
||||
darkModeSwitch.isChecked = isDarkMode
|
||||
|
||||
// Применяем тему
|
||||
if (isDarkMode) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
}
|
||||
|
||||
try {
|
||||
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
val versionName = packageInfo.versionName
|
||||
versionTextView.text = "Версия: $versionName"
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
versionTextView.text = "Версия: Неизвестно"
|
||||
}
|
||||
|
||||
// Устанавливаем слушатель для Switch
|
||||
darkModeSwitch.setOnCheckedChangeListener { _, isChecked ->
|
||||
// Сохраняем состояние темы в SharedPreferences
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putBoolean("DarkMode", isChecked)
|
||||
editor.apply()
|
||||
|
||||
// Применяем тему
|
||||
if (isChecked) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
}
|
||||
}
|
||||
|
||||
// Обработчик нажатия на кнопку "О программе"
|
||||
aboutButton.setOnClickListener {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("О программе")
|
||||
.setMessage("Краткое описание пользования приложением.\n\nНапример: Это приложение позволяет тренироваться, чтобы быть как арнольдшварцнигер 😄")
|
||||
.setPositiveButton("ОК", null)
|
||||
.show()
|
||||
}
|
||||
|
||||
// Обработчик нажатия на кнопку "Разработчики"
|
||||
developersButton.setOnClickListener {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("Разработчики")
|
||||
.setMessage(HtmlCompat.fromHtml(
|
||||
"<p style='margin-left: 2em;'><b>Вятский государственный университет</b></p><br>" +
|
||||
"<p style='margin-left: 2em;'>Емцова Надежда Александровна</p>" +
|
||||
"<p style='margin-left: 2em;'>Новиков Николай Алексеевич</p>" +
|
||||
"<p style='margin-left: 2em;'>Пискун Алёна Викторовна</p>",
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
))
|
||||
.setPositiveButton("ОК", null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,20 +40,20 @@ class timer : AppCompatActivity() {
|
||||
|
||||
|
||||
|
||||
val pauseButton: ImageButton = findViewById(R.id.play)
|
||||
val pauseButton: ImageButton = findViewById(R.id.play)
|
||||
|
||||
pauseButton.setOnClickListener {
|
||||
if (isPlay) {
|
||||
pauseButton.setOnClickListener {
|
||||
if (isPlay) {
|
||||
|
||||
pauseButton.setImageResource(R.drawable.icon_play)
|
||||
// здесь ещё можно возобновить таймер
|
||||
} else {
|
||||
pauseButton.setImageResource(R.drawable.icon_play)
|
||||
// здесь ещё можно возобновить таймер
|
||||
} else {
|
||||
|
||||
pauseButton.setImageResource(R.drawable.icon_pause)
|
||||
// здесь можно остановить таймер
|
||||
}
|
||||
isPlay = !isPlay
|
||||
pauseButton.setImageResource(R.drawable.icon_pause)
|
||||
// здесь можно остановить таймер
|
||||
}
|
||||
isPlay = !isPlay
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user