From 953dab9e354c7cb5dd8ea640624691da654b04d0 Mon Sep 17 00:00:00 2001 From: alexxk2 Date: Mon, 29 May 2023 09:47:05 +0300 Subject: [PATCH] 22.05.2023 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -добавлен экран настроек и переход на него (язык и темная тема, только экран и фрагмент, логики пока нет) -настроены цвета в таймере -файлы частично распределены по пакетам в соответсвии с clean architecture Tasks: -добавить скролабл поведение на appBar, чтобы он уезжал когда ты крутишь ресайкл вниз -удалить лишние вью с главного (титул старый и кнопку настроек старую) - изменить поведение крестиков на editText в опциях с цифрами, надо чтобы они уходили, когда фокус не на окне - сдвинуть ближе кнопки в опциях, но чтобы сохранился эффек смены -настроить обработку ошибок ввода более точечно в опциях -сделать по кнопке назад(добавить) из таймера отключение таймера -почистить код от мусора(старого кода, лишних картинок, стрингов и тд) -сделать выбор при нажатии назад(отменить тренировку или нет) поменять кнопку старт на главной с старт на котинью --- app/src/main/AndroidManifest.xml | 30 +--- .../getup/activities/ActivityUtils.kt | 30 ---- .../practice/getup/adapters/ListAdapter.kt | 112 --------------- .../com/practice/getup/data/DataSource.kt | 107 -------------- .../com/practice/getup/database/Workout.kt | 19 --- .../getup/database/WorkoutDatabase.kt | 2 +- .../getup/fragments/DetailFragment.kt | 67 --------- .../practice/getup/fragments/ListFragment.kt | 95 ------------ .../getup/interfaces/AdvancedTimer.kt | 11 -- .../java/com/practice/getup/model/Exercise.kt | 9 -- .../java/com/practice/getup/model/Options.kt | 19 --- .../getup/{model => models}/SoundStages.kt | 2 +- .../practice/getup/{model => models}/Stage.kt | 4 +- .../getup/{model => models}/TimerStages.kt | 2 +- .../WorkoutDatabaseViewModel.kt | 2 +- .../edit}/OptionsViewModel.kt | 4 +- .../presentation/main/MainMenuViewModel.kt | 11 ++ .../settings/SettingsViewModel.kt | 8 ++ .../timer}/WorkoutViewModel.kt | 30 ++-- .../getup/{activities => ui}/MainActivity.kt | 2 +- .../{fragments => ui/edit}/OptionsFragment.kt | 136 +----------------- .../{fragments => ui/main}/MainFragment.kt | 69 ++++----- .../main}/WorkoutListAdapter.kt | 2 +- .../getup/ui/settings/SettingsFragment.kt | 48 +++++++ .../{adapters => ui/timer}/WorkoutAdapter.kt | 2 +- .../timer}/WorkoutFragment.kt | 20 +-- .../getup/{activities => utils}/UiText.kt | 2 +- .../getup/viewModels/MainMenuViewModel.kt | 18 --- .../main/res/drawable/ic_arrow_back_night.xml | 5 + app/src/main/res/drawable/ic_delete.xml | 2 +- .../main/res/layout-land/fragment_workout.xml | 2 +- app/src/main/res/layout/activity_main.xml | 2 +- app/src/main/res/layout/fragment_detail.xml | 21 --- app/src/main/res/layout/fragment_list.xml | 64 --------- app/src/main/res/layout/fragment_main.xml | 18 +-- app/src/main/res/layout/fragment_options.xml | 2 +- app/src/main/res/layout/fragment_settings.xml | 83 +++++++++++ app/src/main/res/layout/fragment_workout.xml | 2 +- app/src/main/res/layout/list_item.xml | 112 --------------- app/src/main/res/navigation/nav_graph.xml | 31 ++-- app/src/main/res/values-night/styles.xml | 50 +++++++ app/src/main/res/values/dimens.xml | 11 ++ app/src/main/res/values/strings.xml | 12 +- app/src/main/res/values/styles.xml | 47 ++++++ app/src/main/res/values/themes.xml | 17 ++- 45 files changed, 375 insertions(+), 969 deletions(-) delete mode 100644 app/src/main/java/com/practice/getup/activities/ActivityUtils.kt delete mode 100644 app/src/main/java/com/practice/getup/adapters/ListAdapter.kt delete mode 100644 app/src/main/java/com/practice/getup/data/DataSource.kt delete mode 100644 app/src/main/java/com/practice/getup/database/Workout.kt delete mode 100644 app/src/main/java/com/practice/getup/fragments/DetailFragment.kt delete mode 100644 app/src/main/java/com/practice/getup/fragments/ListFragment.kt delete mode 100644 app/src/main/java/com/practice/getup/interfaces/AdvancedTimer.kt delete mode 100644 app/src/main/java/com/practice/getup/model/Exercise.kt delete mode 100644 app/src/main/java/com/practice/getup/model/Options.kt rename app/src/main/java/com/practice/getup/{model => models}/SoundStages.kt (68%) rename app/src/main/java/com/practice/getup/{model => models}/Stage.kt (61%) rename app/src/main/java/com/practice/getup/{model => models}/TimerStages.kt (69%) rename app/src/main/java/com/practice/getup/{viewModels => presentation}/WorkoutDatabaseViewModel.kt (98%) rename app/src/main/java/com/practice/getup/{viewModels => presentation/edit}/OptionsViewModel.kt (93%) create mode 100644 app/src/main/java/com/practice/getup/presentation/main/MainMenuViewModel.kt create mode 100644 app/src/main/java/com/practice/getup/presentation/settings/SettingsViewModel.kt rename app/src/main/java/com/practice/getup/{viewModels => presentation/timer}/WorkoutViewModel.kt (91%) rename app/src/main/java/com/practice/getup/{activities => ui}/MainActivity.kt (96%) rename app/src/main/java/com/practice/getup/{fragments => ui/edit}/OptionsFragment.kt (66%) rename app/src/main/java/com/practice/getup/{fragments => ui/main}/MainFragment.kt (64%) rename app/src/main/java/com/practice/getup/{adapters => ui/main}/WorkoutListAdapter.kt (98%) create mode 100644 app/src/main/java/com/practice/getup/ui/settings/SettingsFragment.kt rename app/src/main/java/com/practice/getup/{adapters => ui/timer}/WorkoutAdapter.kt (98%) rename app/src/main/java/com/practice/getup/{fragments => ui/timer}/WorkoutFragment.kt (93%) rename app/src/main/java/com/practice/getup/{activities => utils}/UiText.kt (90%) delete mode 100644 app/src/main/java/com/practice/getup/viewModels/MainMenuViewModel.kt create mode 100644 app/src/main/res/drawable/ic_arrow_back_night.xml delete mode 100644 app/src/main/res/layout/fragment_detail.xml delete mode 100644 app/src/main/res/layout/fragment_list.xml create mode 100644 app/src/main/res/layout/fragment_settings.xml delete mode 100644 app/src/main/res/layout/list_item.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ef1c335..bd23cac 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,35 +14,7 @@ android:theme="@style/Theme.GetUp" tools:targetApi="31"> - - - - - - - - - - - - diff --git a/app/src/main/java/com/practice/getup/activities/ActivityUtils.kt b/app/src/main/java/com/practice/getup/activities/ActivityUtils.kt deleted file mode 100644 index 0cddfff..0000000 --- a/app/src/main/java/com/practice/getup/activities/ActivityUtils.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.practice.getup.activities - - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.practice.getup.database.Workout -import com.practice.getup.database.WorkoutDao -import com.practice.getup.model.Options -import com.practice.getup.viewModels.OptionsViewModel -import com.practice.getup.viewModels.WorkoutDatabaseViewModel -import com.practice.getup.viewModels.WorkoutViewModel -import java.lang.IllegalArgumentException - - -class ViewModelFactoryFragments(private val workout: Workout) : ViewModelProvider.Factory { - - override fun create(modelClass: Class): T { - - if (modelClass.isAssignableFrom(WorkoutViewModel::class.java)) { - @Suppress("UNCHECKED_CAST") - return WorkoutViewModel(workout) as T - } else throw IllegalArgumentException("Unknown ViewModel class") - } - - -} - - - - diff --git a/app/src/main/java/com/practice/getup/adapters/ListAdapter.kt b/app/src/main/java/com/practice/getup/adapters/ListAdapter.kt deleted file mode 100644 index 6669ab7..0000000 --- a/app/src/main/java/com/practice/getup/adapters/ListAdapter.kt +++ /dev/null @@ -1,112 +0,0 @@ -package com.practice.getup.adapters - -import android.content.Context -import android.graphics.Color -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide -import com.practice.getup.R -import com.practice.getup.databinding.ListItemBinding -import com.practice.getup.model.Exercise - - -class ListAdapter( - - private val context: Context, - private val dataSet: List, - private val actionListener: ExerciseActionListener - -): RecyclerView.Adapter(), View.OnClickListener{ - - - //create viewholder for adapter via binding - class ListViewHolder(val binding: ListItemBinding): RecyclerView.ViewHolder(binding.root) - - - //create onClick method (necessary) - override fun onClick(v: View?) { - val exercise = v?.tag as Exercise - when (v.id) { - R.id.button_delete -> actionListener.onDeleteExercise(exercise) - R.id.button_add -> actionListener.onAddExercise(exercise) - else -> actionListener.onClickExercise(exercise) - } - } - - //standard 3 functions for recyclerview adapter are below - //don`t forget do add clickListeners for action buttons and body of ItemView - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListViewHolder { - val inflater = LayoutInflater.from(parent.context) - val binding = ListItemBinding.inflate(inflater, parent, false) - - binding.root.setOnClickListener(this) - binding.buttonDelete.setOnClickListener(this) - binding.buttonAdd.setOnClickListener(this) - - - return ListViewHolder(binding) - } - - //don`t forget do add tags for action buttons in item_layout - override fun onBindViewHolder(holder: ListViewHolder, position: Int) { - val item = dataSet[position] - - with(holder.binding) { - itemName.text = context.resources.getString(item.stringNameId) - itemDifficulty.text = context.resources.getString(item.stringDifficulty) - - root.tag = item - buttonDelete.tag = item - buttonAdd.tag = item - } - - - //TODO add normal pictures not gif - //load gif images via Glide - Glide.with(context).load(item.gifImageResourceId).into(holder.binding.itemGifImage) - - //change a color of background in textViewDifficulty and imageViews difficultyBricks - when (item.stringDifficulty) { - R.string.difficulty_easy -> { - holder.binding.easyBrick.setBackgroundColor(Color.parseColor("#64dd17")) - //change other bricks color to default - holder.binding.mediumBrick.setBackgroundColor(Color.parseColor("#bdbdbd")) - holder.binding.hardBrick.setBackgroundColor(Color.parseColor("#bdbdbd")) - } - - R.string.difficulty_medium -> { - holder.binding.mediumBrick.setBackgroundColor(Color.parseColor("#f4dd47")) - //change other bricks color to default - holder.binding.easyBrick.setBackgroundColor(Color.parseColor("#bdbdbd")) - holder.binding.hardBrick.setBackgroundColor(Color.parseColor("#bdbdbd")) - - } - - else -> { - holder.binding.hardBrick.setBackgroundColor(Color.parseColor("#ff5b56")) - //change other bricks color to default - holder.binding.easyBrick.setBackgroundColor(Color.parseColor("#bdbdbd")) - holder.binding.mediumBrick.setBackgroundColor(Color.parseColor("#bdbdbd")) - } - } - - - } - - - - override fun getItemCount() = dataSet.size - - //interface to move our functions to ListActivity. Don`t forget to put private val listener in class - interface ExerciseActionListener{ - fun onDeleteExercise(exercise: Exercise) - fun onClickExercise(exercise: Exercise) - fun onAddExercise(exercise: Exercise) - } - - - -} - diff --git a/app/src/main/java/com/practice/getup/data/DataSource.kt b/app/src/main/java/com/practice/getup/data/DataSource.kt deleted file mode 100644 index 9336567..0000000 --- a/app/src/main/java/com/practice/getup/data/DataSource.kt +++ /dev/null @@ -1,107 +0,0 @@ -package com.practice.getup.data - -import com.practice.getup.R -import com.practice.getup.model.Exercise - -class DataSource { - - fun loadExercise(): List { - - return listOf( - Exercise( - R.string.exercise1, - R.string.exercise1_description, - R.string.difficulty_easy, - R.raw.prone_position, - R.raw.prone_position_video - ), - Exercise( - R.string.exercise2, - R.string.exercise2_description, - R.string.difficulty_easy, - R.raw.pushups, - R.raw.pushups_video - ), - Exercise( - R.string.exercise3, - R.string.exercise3_description, - R.string.difficulty_easy, - R.raw.squats, - R.raw.squats_video - ), - Exercise( - R.string.exercise4, - R.string.exercise4_description, - R.string.difficulty_easy, - R.raw.crunches, - R.raw.crunches_video - ), - Exercise( - R.string.exercise5, - R.string.exercise5_description, - R.string.difficulty_medium, - R.raw.lunges, - R.raw.lunges_video - ), - Exercise( - R.string.exercise6, - R.string.exercise6_description, - R.string.difficulty_medium, - R.raw.crunches_hard, - R.raw.crunches_hard_video - ), - Exercise( - R.string.exercise7, - R.string.exercise7_description, - R.string.difficulty_medium, - R.raw.plank, - R.raw.plank_video - ), - Exercise( - R.string.exercise8, - R.string.exercise8_description, - R.string.difficulty_medium, - R.raw.slow_pushups, - R.raw.slow_pushups_video - ), - Exercise( - R.string.exercise9, - R.string.exercise9_description, - R.string.difficulty_hard, - R.raw.hard_squats, - R.raw.hard_squats_video - ), - Exercise( - R.string.exercise10, - R.string.exercise10_description, - R.string.difficulty_hard, - R.raw.hard_plank, - R.raw.hard_plank_video - ), - Exercise( - R.string.exercise11, - R.string.exercise11_description, - R.string.difficulty_hard, - R.raw.diamond_pushup, - R.raw.diamond_pushups_video - ), - Exercise( - R.string.exercise12, - R.string.exercise12_description, - R.string.difficulty_hard, - R.raw.climber, - R.raw.climber_video - ) - ) - } - - fun loadEasyList(): List { - return loadExercise().filter { it.stringDifficulty == R.string.difficulty_easy } - } - fun loadMediumList(): List { - return loadExercise().filter { it.stringDifficulty == R.string.difficulty_medium } - } - fun loadHardList(): List { - return loadExercise().filter { it.stringDifficulty == R.string.difficulty_hard } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/database/Workout.kt b/app/src/main/java/com/practice/getup/database/Workout.kt deleted file mode 100644 index db35d76..0000000 --- a/app/src/main/java/com/practice/getup/database/Workout.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.practice.getup.database - -import android.os.Parcelable -import androidx.annotation.NonNull -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.PrimaryKey -import kotlinx.parcelize.Parcelize - -@Parcelize -@Entity(tableName = "workout") -data class Workout( - @PrimaryKey(autoGenerate = true) val id: Int = 0, - @NonNull @ColumnInfo val name: String, - @NonNull @ColumnInfo("preparing_time") val preparingTime: Int, - @NonNull @ColumnInfo("work_time") val workTime: Int, - @NonNull @ColumnInfo("rest_time") val restTime: Int, - @NonNull @ColumnInfo("number_of_sets") val numberOfSets: Int -): Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/database/WorkoutDatabase.kt b/app/src/main/java/com/practice/getup/database/WorkoutDatabase.kt index 6905d4f..9464314 100644 --- a/app/src/main/java/com/practice/getup/database/WorkoutDatabase.kt +++ b/app/src/main/java/com/practice/getup/database/WorkoutDatabase.kt @@ -13,7 +13,7 @@ abstract class WorkoutDatabase() : RoomDatabase() { companion object{ private var INSTANCE: WorkoutDatabase? = null - fun getDataBase(context: Context): WorkoutDatabase{ + fun getDataBase(context: Context): WorkoutDatabase { return INSTANCE ?: synchronized(this){ val instance = Room.databaseBuilder( context, diff --git a/app/src/main/java/com/practice/getup/fragments/DetailFragment.kt b/app/src/main/java/com/practice/getup/fragments/DetailFragment.kt deleted file mode 100644 index b9e13e1..0000000 --- a/app/src/main/java/com/practice/getup/fragments/DetailFragment.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.practice.getup.fragments - -import android.net.Uri -import android.os.Bundle -import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup - -import com.practice.getup.databinding.FragmentDetailBinding - - -class DetailFragment : Fragment() { - - private var _binding: FragmentDetailBinding? = null - private val binding get() = _binding!! - private var intRes = 0 - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - arguments?.let { - intRes = it.getInt(INT_RES) - } - - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - _binding = FragmentDetailBinding.inflate(layoutInflater,container,false) - return binding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - loadVideo() - } - - private fun loadVideo(){ - - val mediaController = android.widget.MediaController(context) - mediaController.setAnchorView(binding.videoView1) - - val offlineVideoUri: Uri = - Uri.parse("android.resource://${context?.packageName}/${intRes}") - - with(binding.videoView1) { - setMediaController(mediaController) - setVideoURI(offlineVideoUri) - requestFocus() - start() - } - } - - companion object{ - const val INT_RES = "intres" - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } -} \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/fragments/ListFragment.kt b/app/src/main/java/com/practice/getup/fragments/ListFragment.kt deleted file mode 100644 index da89159..0000000 --- a/app/src/main/java/com/practice/getup/fragments/ListFragment.kt +++ /dev/null @@ -1,95 +0,0 @@ -package com.practice.getup.fragments - - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.animation.AnimationUtils -import androidx.core.view.get -import androidx.fragment.app.Fragment -import androidx.navigation.findNavController -import androidx.recyclerview.widget.LinearLayoutManager -import com.google.android.material.snackbar.Snackbar -import com.practice.getup.R -import com.practice.getup.adapters.ListAdapter -import com.practice.getup.data.DataSource -import com.practice.getup.databinding.FragmentListBinding -import com.practice.getup.model.Exercise - - -class ListFragment : Fragment() { - - private var _binding: FragmentListBinding? = null - private val binding get() = _binding!! - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - - _binding = FragmentListBinding.inflate(layoutInflater, container,false) - return binding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - loadRecycleView(DataSource().loadExercise()) - - //TODO когда отжимаешь все чипы то надо, чтобы все пропадало или сделать, чтобы all levels - //было не отжимаемым - with(binding) - { - chipEasy.setOnClickListener { - loadRecycleView(DataSource().loadEasyList()) - } - chipMedium.setOnClickListener { - loadRecycleView(DataSource().loadMediumList()) - } - chipHard.setOnClickListener { - loadRecycleView(DataSource().loadHardList()) - } - chipAll.setOnClickListener { - loadRecycleView(DataSource().loadExercise()) - } - } - } - - private fun loadRecycleView(data: List) { - - binding.recyclerView.layoutManager = LinearLayoutManager(context) - binding.recyclerView.adapter = ListAdapter(requireContext(),data, object: ListAdapter.ExerciseActionListener{ - override fun onDeleteExercise(exercise: Exercise) { - Snackbar.make(binding.recyclerView, R.string.snackbar_delete, Snackbar.LENGTH_SHORT) - .setAction(R.string.snackbar_got_it) {} - .show() - - //TODO работает, но надо фиксить чтобы анимация не пропадала - binding.recyclerView.smoothScrollToPosition(4) - binding.recyclerView[4].animation = AnimationUtils.loadAnimation(context, R.anim.has_focus_animation) - binding.recyclerView[4].scaleX =1.2f - binding.recyclerView[4].scaleY =1.2f - } - - override fun onClickExercise(exercise: Exercise) { - val action = ListFragmentDirections.actionListFragmentToDetailFragment(exercise.videoResource) - binding.root.findNavController().navigate(action) - } - override fun onAddExercise(exercise: Exercise) { - Snackbar.make(binding.recyclerView, R.string.snackbar_delete, Snackbar.LENGTH_SHORT) - .setAction(R.string.snackbar_got_it) {} - .show() - } - }) - - binding.recyclerView.startLayoutAnimation() - binding.recyclerView.setHasFixedSize(true) - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } -} \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/interfaces/AdvancedTimer.kt b/app/src/main/java/com/practice/getup/interfaces/AdvancedTimer.kt deleted file mode 100644 index 4b27269..0000000 --- a/app/src/main/java/com/practice/getup/interfaces/AdvancedTimer.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.practice.getup.interfaces - -interface AdvancedTimer { - - fun start() - - fun pauseTimer() - - fun restartTimer() - -} \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/model/Exercise.kt b/app/src/main/java/com/practice/getup/model/Exercise.kt deleted file mode 100644 index f7f7e40..0000000 --- a/app/src/main/java/com/practice/getup/model/Exercise.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.practice.getup.model - -data class Exercise( - val stringNameId: Int, - val stringDescriptionId: Int, - val stringDifficulty: Int, - val gifImageResourceId: Int, - val videoResource: Int -) \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/model/Options.kt b/app/src/main/java/com/practice/getup/model/Options.kt deleted file mode 100644 index 1a17e7e..0000000 --- a/app/src/main/java/com/practice/getup/model/Options.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.practice.getup.model - -import android.os.Parcelable -import kotlinx.parcelize.Parcelize - -@Parcelize -data class Options( - val preparingTime: Int, - val workTime: Int, - val restTime: Int, - val numberOfSets: Int - -) : Parcelable { - companion object { - @JvmStatic val DEFAULT = Options(10,10, 10,2) - } -} - - diff --git a/app/src/main/java/com/practice/getup/model/SoundStages.kt b/app/src/main/java/com/practice/getup/models/SoundStages.kt similarity index 68% rename from app/src/main/java/com/practice/getup/model/SoundStages.kt rename to app/src/main/java/com/practice/getup/models/SoundStages.kt index a654b63..1639596 100644 --- a/app/src/main/java/com/practice/getup/model/SoundStages.kt +++ b/app/src/main/java/com/practice/getup/models/SoundStages.kt @@ -1,4 +1,4 @@ -package com.practice.getup.model +package com.practice.getup.models enum class SoundStages { COUNTDOWN, diff --git a/app/src/main/java/com/practice/getup/model/Stage.kt b/app/src/main/java/com/practice/getup/models/Stage.kt similarity index 61% rename from app/src/main/java/com/practice/getup/model/Stage.kt rename to app/src/main/java/com/practice/getup/models/Stage.kt index 921f28e..b96d0be 100644 --- a/app/src/main/java/com/practice/getup/model/Stage.kt +++ b/app/src/main/java/com/practice/getup/models/Stage.kt @@ -1,6 +1,6 @@ -package com.practice.getup.model +package com.practice.getup.models -import com.practice.getup.activities.UiText +import com.practice.getup.utils.UiText data class Stage( val id: String, diff --git a/app/src/main/java/com/practice/getup/model/TimerStages.kt b/app/src/main/java/com/practice/getup/models/TimerStages.kt similarity index 69% rename from app/src/main/java/com/practice/getup/model/TimerStages.kt rename to app/src/main/java/com/practice/getup/models/TimerStages.kt index 248710e..c8191ac 100644 --- a/app/src/main/java/com/practice/getup/model/TimerStages.kt +++ b/app/src/main/java/com/practice/getup/models/TimerStages.kt @@ -1,4 +1,4 @@ -package com.practice.getup.model +package com.practice.getup.models enum class TimerStages { PREPARATION, diff --git a/app/src/main/java/com/practice/getup/viewModels/WorkoutDatabaseViewModel.kt b/app/src/main/java/com/practice/getup/presentation/WorkoutDatabaseViewModel.kt similarity index 98% rename from app/src/main/java/com/practice/getup/viewModels/WorkoutDatabaseViewModel.kt rename to app/src/main/java/com/practice/getup/presentation/WorkoutDatabaseViewModel.kt index 3fbaa9c..1af6505 100644 --- a/app/src/main/java/com/practice/getup/viewModels/WorkoutDatabaseViewModel.kt +++ b/app/src/main/java/com/practice/getup/presentation/WorkoutDatabaseViewModel.kt @@ -1,4 +1,4 @@ -package com.practice.getup.viewModels +package com.practice.getup.presentation import androidx.lifecycle.LiveData import androidx.lifecycle.ViewModel diff --git a/app/src/main/java/com/practice/getup/viewModels/OptionsViewModel.kt b/app/src/main/java/com/practice/getup/presentation/edit/OptionsViewModel.kt similarity index 93% rename from app/src/main/java/com/practice/getup/viewModels/OptionsViewModel.kt rename to app/src/main/java/com/practice/getup/presentation/edit/OptionsViewModel.kt index afcf682..4b29e8d 100644 --- a/app/src/main/java/com/practice/getup/viewModels/OptionsViewModel.kt +++ b/app/src/main/java/com/practice/getup/presentation/edit/OptionsViewModel.kt @@ -1,11 +1,9 @@ -package com.practice.getup.viewModels +package com.practice.getup.presentation.edit import android.text.Editable import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import com.bumptech.glide.Glide.init -import com.practice.getup.model.Options class OptionsViewModel : ViewModel() { diff --git a/app/src/main/java/com/practice/getup/presentation/main/MainMenuViewModel.kt b/app/src/main/java/com/practice/getup/presentation/main/MainMenuViewModel.kt new file mode 100644 index 0000000..0d6bcb5 --- /dev/null +++ b/app/src/main/java/com/practice/getup/presentation/main/MainMenuViewModel.kt @@ -0,0 +1,11 @@ +package com.practice.getup.presentation.main + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class MainMenuViewModel: ViewModel() { + + + +} \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/presentation/settings/SettingsViewModel.kt b/app/src/main/java/com/practice/getup/presentation/settings/SettingsViewModel.kt new file mode 100644 index 0000000..aec5ae8 --- /dev/null +++ b/app/src/main/java/com/practice/getup/presentation/settings/SettingsViewModel.kt @@ -0,0 +1,8 @@ +package com.practice.getup.presentation.settings + +import androidx.lifecycle.ViewModel + +class SettingsViewModel: ViewModel() { + + +} \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/viewModels/WorkoutViewModel.kt b/app/src/main/java/com/practice/getup/presentation/timer/WorkoutViewModel.kt similarity index 91% rename from app/src/main/java/com/practice/getup/viewModels/WorkoutViewModel.kt rename to app/src/main/java/com/practice/getup/presentation/timer/WorkoutViewModel.kt index 09e0a59..26f6a64 100644 --- a/app/src/main/java/com/practice/getup/viewModels/WorkoutViewModel.kt +++ b/app/src/main/java/com/practice/getup/presentation/timer/WorkoutViewModel.kt @@ -4,14 +4,14 @@ import android.os.CountDownTimer import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import androidx.lifecycle.asLiveData +import androidx.lifecycle.ViewModelProvider import com.practice.getup.R -import com.practice.getup.model.Stage -import com.practice.getup.model.TimerStages -import com.practice.getup.activities.UiText +import com.practice.getup.models.Stage +import com.practice.getup.models.TimerStages +import com.practice.getup.utils.UiText import com.practice.getup.database.Workout -import com.practice.getup.database.WorkoutDao -import com.practice.getup.model.SoundStages +import com.practice.getup.models.SoundStages +import java.lang.IllegalArgumentException class WorkoutViewModel(private val workout: Workout) : ViewModel() { @@ -40,7 +40,7 @@ class WorkoutViewModel(private val workout: Workout) : ViewModel() { private val _globalTimeToShow = MutableLiveData("") val globalTimeToShow: LiveData = _globalTimeToShow - private val _indicatorProgressValue = MutableLiveData(0) + private val _indicatorProgressValue = MutableLiveData(0) val indicatorProgressValue: LiveData = _indicatorProgressValue private val _stageList = MutableLiveData>() @@ -55,7 +55,6 @@ class WorkoutViewModel(private val workout: Workout) : ViewModel() { init { updateLocalTime(preparationTime) updateGlobalTime(preparationTime) - //_indicatorProgressValue.value = 0 createListOfStages(_currentStagePosition.value ?: (numberOfSets * 2 + 3)) } @@ -229,4 +228,17 @@ class WorkoutViewModel(private val workout: Workout) : ViewModel() { _stageList.value = tempList } -} \ No newline at end of file +} + +class ViewModelFactoryFragments(private val workout: Workout) : ViewModelProvider.Factory { + + override fun create(modelClass: Class): T { + + if (modelClass.isAssignableFrom(WorkoutViewModel::class.java)) { + @Suppress("UNCHECKED_CAST") + return WorkoutViewModel(workout) as T + } else throw IllegalArgumentException("Unknown ViewModel class") + } + + +} diff --git a/app/src/main/java/com/practice/getup/activities/MainActivity.kt b/app/src/main/java/com/practice/getup/ui/MainActivity.kt similarity index 96% rename from app/src/main/java/com/practice/getup/activities/MainActivity.kt rename to app/src/main/java/com/practice/getup/ui/MainActivity.kt index 71931a3..1ef9839 100644 --- a/app/src/main/java/com/practice/getup/activities/MainActivity.kt +++ b/app/src/main/java/com/practice/getup/ui/MainActivity.kt @@ -1,4 +1,4 @@ -package com.practice.getup.activities +package com.practice.getup.ui import androidx.appcompat.app.AppCompatActivity diff --git a/app/src/main/java/com/practice/getup/fragments/OptionsFragment.kt b/app/src/main/java/com/practice/getup/ui/edit/OptionsFragment.kt similarity index 66% rename from app/src/main/java/com/practice/getup/fragments/OptionsFragment.kt rename to app/src/main/java/com/practice/getup/ui/edit/OptionsFragment.kt index 3206802..3ba5f12 100644 --- a/app/src/main/java/com/practice/getup/fragments/OptionsFragment.kt +++ b/app/src/main/java/com/practice/getup/ui/edit/OptionsFragment.kt @@ -1,4 +1,4 @@ -package com.practice.getup.fragments +package com.practice.getup.ui.edit import android.content.Context import android.os.Bundle @@ -12,28 +12,24 @@ import androidx.core.widget.addTextChangedListener import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels -import androidx.navigation.findNavController import androidx.navigation.fragment.findNavController import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.google.android.material.internal.ViewUtils.hideKeyboard import com.google.android.material.snackbar.Snackbar -import com.google.gson.Gson import com.practice.getup.App import com.practice.getup.R -import com.practice.getup.activities.ViewModelFactoryFragments import com.practice.getup.database.Workout import com.practice.getup.databinding.FragmentOptionsBinding -import com.practice.getup.model.Options -import com.practice.getup.viewModels.OptionsViewModel -import com.practice.getup.viewModels.WorkoutDatabaseViewModel -import com.practice.getup.viewModels.WorkoutDatabaseViewModelFactory + +import com.practice.getup.presentation.edit.OptionsViewModel +import com.practice.getup.presentation.WorkoutDatabaseViewModel +import com.practice.getup.presentation.WorkoutDatabaseViewModelFactory class OptionsFragment : Fragment() { private var _binding: FragmentOptionsBinding? = null private val binding get() = _binding!! - private lateinit var options: Options + private val viewModel: OptionsViewModel by viewModels() private var id = 0 private lateinit var workout: Workout @@ -49,7 +45,6 @@ class OptionsFragment : Fragment() { super.onCreate(savedInstanceState) arguments?.let { - options = it.getParcelable(OPTIONS)?: Options.DEFAULT id = it.getInt(ID) } } @@ -69,8 +64,6 @@ class OptionsFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - //NEW CODE - changeAppearance() viewModel.totalTime.observe(viewLifecycleOwner) { newTotalTime -> @@ -119,64 +112,8 @@ class OptionsFragment : Fragment() { else binding.inputRestTime.error = null } - //OLD CODE - - /*viewModel.totalTime.observe(viewLifecycleOwner) { newTotalTime -> - binding.totalWorkoutTime.text = newTotalTime - } - - with(binding) { - optionsSaveButton.setOnClickListener { - setOptions() - } - - - editPreparationTime.addTextChangedListener { - with(viewModel) { - getPreparationTimeInput(it) - calculateTotalTime() - } - - inputPreparationTime.error = showZeroInputErrorTime(it) - } - - editWorkTime.addTextChangedListener { - with(viewModel) { - getWorkTimeInput(it) - calculateTotalTime() - } - - inputWorkTime.error = showZeroInputErrorTime(it) - } - - editRestTime.addTextChangedListener { - with(viewModel) { - getRestTimeInput(it) - calculateTotalTime() - } - - inputRestTime.error = showZeroInputErrorTime(it) - - } - - editSetsNumber.addTextChangedListener { - with(viewModel) { - getSetsNumberInput(it) - calculateTotalTime() - } - - inputSetsNumber.error = showZeroInputErrorSets(it) - } - - optionsBackButton.setOnClickListener { - - binding.root.findNavController().navigateUp() - } - }*/ - } - //NEW CODE private fun isNumberInputValid(): Boolean{ return databaseViewModel.isNumberInputValid( binding.editPreparationTime.text.toString(), @@ -286,73 +223,12 @@ class OptionsFragment : Fragment() { inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) } - //OLD CODE - - - /*private fun showZeroInputErrorSets(input: Editable?): String? { - val convertedInput = input.toString().toIntOrNull() - return if (convertedInput == 0) getString(R.string.number_format_exception_sets_short) else null - }*/ - - /*private fun setOptions() { - - viewModel.updateOptions() - - with(viewModel.options) { - val preparationTimeInput = value?.preparingTime ?: Options.DEFAULT.preparingTime - val workTimeInput = value?.workTime ?: Options.DEFAULT.workTime - val restTimeInput = value?.restTime ?: Options.DEFAULT.restTime - val numberOfSets = value?.numberOfSets ?: Options.DEFAULT.numberOfSets - - if (preparationTimeInput == 0) { - showZeroException(R.string.number_format_exception_preparation) - return - } - if (workTimeInput == 0) { - showZeroException(R.string.number_format_exception_work) - return - } - if (restTimeInput == 0) { - showZeroException(R.string.number_format_exception_rest) - return - } - if (numberOfSets == 0) { - showZeroException(R.string.number_format_exception_sets) - return - } - - hideKeyboard(binding.optionsActivity) - saveOptions() - val action = OptionsFragmentDirections.actionOptionsFragmentToMainFragment() - binding.root.findNavController().navigate(action) - - } - }*/ - - /*private fun showZeroException(exceptionString: Int) { - Snackbar.make(binding.optionsActivity, exceptionString, 20000) - .setAction(R.string.snackbar_ok_button) {} - .show() - hideKeyboard(binding.optionsActivity) - } - - - - private fun saveOptions(){ - val sharedPref = activity?.getSharedPreferences(SHARED_PREF,0) - val jSonOptions = Gson().toJson(viewModel.options.value) - sharedPref?.edit()?.putString(SAVED_OPTIONS,jSonOptions)?.apply() - }*/ - - override fun onDestroyView() { super.onDestroyView() _binding = null } companion object { - const val OPTIONS = "options" - const val SAVED_OPTIONS = "saved_options" const val SHARED_PREF = "shared_preferences" const val ID = "id" } diff --git a/app/src/main/java/com/practice/getup/fragments/MainFragment.kt b/app/src/main/java/com/practice/getup/ui/main/MainFragment.kt similarity index 64% rename from app/src/main/java/com/practice/getup/fragments/MainFragment.kt rename to app/src/main/java/com/practice/getup/ui/main/MainFragment.kt index 47b8599..afc36e5 100644 --- a/app/src/main/java/com/practice/getup/fragments/MainFragment.kt +++ b/app/src/main/java/com/practice/getup/ui/main/MainFragment.kt @@ -1,28 +1,24 @@ -package com.practice.getup.fragments +package com.practice.getup.ui.main -import android.app.AlertDialog import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.Toast import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels +import androidx.navigation.NavDirections import androidx.navigation.fragment.findNavController import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar -import com.google.gson.Gson import com.practice.getup.App import com.practice.getup.R -import com.practice.getup.adapters.WorkoutListAdapter import com.practice.getup.database.Workout import com.practice.getup.databinding.FragmentMainBinding -import com.practice.getup.model.Options -import com.practice.getup.viewModels.MainMenuViewModel -import com.practice.getup.viewModels.WorkoutDatabaseViewModel -import com.practice.getup.viewModels.WorkoutDatabaseViewModelFactory +import com.practice.getup.presentation.main.MainMenuViewModel +import com.practice.getup.presentation.WorkoutDatabaseViewModel +import com.practice.getup.presentation.WorkoutDatabaseViewModelFactory class MainFragment : Fragment() { @@ -30,7 +26,7 @@ class MainFragment : Fragment() { private var _binding: FragmentMainBinding? = null private val binding get() = _binding!! private val viewModel: MainMenuViewModel by viewModels() - private var options: Options = Options.DEFAULT + private val databaseViewModel: WorkoutDatabaseViewModel by activityViewModels { WorkoutDatabaseViewModelFactory( @@ -41,10 +37,6 @@ class MainFragment : Fragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - arguments?.let { - options = it.getParcelable(OPTIONS) ?: Options.DEFAULT - } - } override fun onCreateView( @@ -70,13 +62,15 @@ class MainFragment : Fragment() { } override fun onStartItem(workout: Workout) { - val action = MainFragmentDirections.actionMainFragmentToWorkoutFragment(workout = workout) - findNavController().navigate(action) + val action = + MainFragmentDirections.actionMainFragmentToWorkoutFragment(workout = workout) + navigate(action) } override fun onEditItem(workout: Workout) { - val action = MainFragmentDirections.actionMainFragmentToOptionsFragment(id = workout.id) - findNavController().navigate(action) + val action = + MainFragmentDirections.actionMainFragmentToOptionsFragment(id = workout.id) + navigate(action) } }) @@ -95,34 +89,21 @@ class MainFragment : Fragment() { binding.floatingButtonDelete.setOnClickListener { showDeleteAllConfirmationDialog()} - /*checkForSavedOptions() - viewModel.setOptions(options)*/ - - /* binding.buttonSettings.setOnClickListener { - val action = MainFragmentDirections.actionMainFragmentToOptionsFragment(viewModel.options.value?: Options.DEFAULT) - navigate(action) - } + binding.topAppBar.setOnMenuItemClickListener {menuItem -> + when(menuItem.itemId){ + R.id.settings -> { + val action = MainFragmentDirections.actionMainFragmentToSettingsFragment() + navigate(action) + true + } + else ->false + } - binding.buttonStartWorkout.setOnClickListener { - val action = MainFragmentDirections.actionMainFragmentToWorkoutFragment(viewModel.options.value?: Options.DEFAULT) - navigate(action) - } + } - binding.buttonWatchList.setOnClickListener { - val action = MainFragmentDirections.actionMainFragmentToListFragment() - navigate(action) - }*/ } - - private fun checkForSavedOptions() { - val sharedPref = activity?.getSharedPreferences(SHARED_PREF, 0) - val jSonDefaultOptions = Gson().toJson(Options.DEFAULT) - val savedOptions = sharedPref?.getString(SAVED_OPTIONS, jSonDefaultOptions) - options = Gson().fromJson(savedOptions, Options::class.java) - } - private fun manageEmptyListUi(list: List){ if (list.isEmpty()){ binding.recyclerView.visibility = View.GONE @@ -151,6 +132,9 @@ class MainFragment : Fragment() { .show() } + private fun navigate(action: NavDirections){ + findNavController().navigate(action) + } override fun onDestroyView() { super.onDestroyView() @@ -158,9 +142,6 @@ class MainFragment : Fragment() { } companion object { - const val OPTIONS = "options" const val SHARED_PREF = "shared_preferences" - const val SAVED_OPTIONS = "saved_options" - const val ID = "id" } } \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/adapters/WorkoutListAdapter.kt b/app/src/main/java/com/practice/getup/ui/main/WorkoutListAdapter.kt similarity index 98% rename from app/src/main/java/com/practice/getup/adapters/WorkoutListAdapter.kt rename to app/src/main/java/com/practice/getup/ui/main/WorkoutListAdapter.kt index f2b422f..ea78290 100644 --- a/app/src/main/java/com/practice/getup/adapters/WorkoutListAdapter.kt +++ b/app/src/main/java/com/practice/getup/ui/main/WorkoutListAdapter.kt @@ -1,4 +1,4 @@ -package com.practice.getup.adapters +package com.practice.getup.ui.main import android.content.Context import android.view.LayoutInflater diff --git a/app/src/main/java/com/practice/getup/ui/settings/SettingsFragment.kt b/app/src/main/java/com/practice/getup/ui/settings/SettingsFragment.kt new file mode 100644 index 0000000..0b00fca --- /dev/null +++ b/app/src/main/java/com/practice/getup/ui/settings/SettingsFragment.kt @@ -0,0 +1,48 @@ +package com.practice.getup.ui.settings + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.viewModels +import androidx.navigation.fragment.findNavController +import com.practice.getup.databinding.FragmentSettingsBinding +import com.practice.getup.presentation.settings.SettingsViewModel + + +class SettingsFragment : Fragment() { + + private var _binding: FragmentSettingsBinding? = null + private val binding get() = _binding!! + private val viewModel: SettingsViewModel by viewModels() + + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + arguments?.let { + + } + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + _binding = FragmentSettingsBinding.inflate(layoutInflater,container,false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.backButton.setOnClickListener { findNavController().navigateUp() } + + } + + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/practice/getup/adapters/WorkoutAdapter.kt b/app/src/main/java/com/practice/getup/ui/timer/WorkoutAdapter.kt similarity index 98% rename from app/src/main/java/com/practice/getup/adapters/WorkoutAdapter.kt rename to app/src/main/java/com/practice/getup/ui/timer/WorkoutAdapter.kt index fb1df31..9b4a9a7 100644 --- a/app/src/main/java/com/practice/getup/adapters/WorkoutAdapter.kt +++ b/app/src/main/java/com/practice/getup/ui/timer/WorkoutAdapter.kt @@ -7,7 +7,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.practice.getup.databinding.WorkoutItemBinding -import com.practice.getup.model.Stage +import com.practice.getup.models.Stage class WorkoutDiffCallback( diff --git a/app/src/main/java/com/practice/getup/fragments/WorkoutFragment.kt b/app/src/main/java/com/practice/getup/ui/timer/WorkoutFragment.kt similarity index 93% rename from app/src/main/java/com/practice/getup/fragments/WorkoutFragment.kt rename to app/src/main/java/com/practice/getup/ui/timer/WorkoutFragment.kt index de48e2e..5ac84b5 100644 --- a/app/src/main/java/com/practice/getup/fragments/WorkoutFragment.kt +++ b/app/src/main/java/com/practice/getup/ui/timer/WorkoutFragment.kt @@ -1,31 +1,26 @@ -package com.practice.getup.fragments +package com.practice.getup.ui.timer -import android.icu.lang.UCharacter.GraphemeClusterBreak.T import android.media.MediaPlayer import android.os.Build import android.os.Bundle -import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.activity.addCallback import androidx.fragment.app.Fragment -import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager -import com.bumptech.glide.Priority import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.practice.getup.App import com.practice.getup.R -import com.practice.getup.activities.ViewModelFactoryFragments import com.practice.getup.adapters.WorkoutAdapter import com.practice.getup.database.Workout import com.practice.getup.databinding.FragmentWorkoutBinding -import com.practice.getup.model.Options -import com.practice.getup.model.SoundStages -import com.practice.getup.model.TimerStages + +import com.practice.getup.models.SoundStages +import com.practice.getup.models.TimerStages +import com.practice.getup.viewModels.ViewModelFactoryFragments import com.practice.getup.viewModels.WorkoutViewModel import kotlinx.coroutines.Runnable @@ -34,7 +29,6 @@ class WorkoutFragment : Fragment() { private var _binding: FragmentWorkoutBinding? = null private val binding get() = _binding!! - private lateinit var options: Options private val viewModel: WorkoutViewModel by viewModels { ViewModelFactoryFragments(workout) } @@ -46,8 +40,6 @@ class WorkoutFragment : Fragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) arguments?.let { - options = it.getParcelable(OPTIONS) ?: Options.DEFAULT - workout = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { it.getParcelable(WORKOUT, Workout::class.java)!! } else it.getParcelable(WORKOUT)!! @@ -214,8 +206,6 @@ class WorkoutFragment : Fragment() { } } - - override fun onDestroy() { super.onDestroy() mediaPlayer?.release() diff --git a/app/src/main/java/com/practice/getup/activities/UiText.kt b/app/src/main/java/com/practice/getup/utils/UiText.kt similarity index 90% rename from app/src/main/java/com/practice/getup/activities/UiText.kt rename to app/src/main/java/com/practice/getup/utils/UiText.kt index f1a2753..5bd72f1 100644 --- a/app/src/main/java/com/practice/getup/activities/UiText.kt +++ b/app/src/main/java/com/practice/getup/utils/UiText.kt @@ -1,4 +1,4 @@ -package com.practice.getup.activities +package com.practice.getup.utils import android.content.Context import androidx.annotation.StringRes diff --git a/app/src/main/java/com/practice/getup/viewModels/MainMenuViewModel.kt b/app/src/main/java/com/practice/getup/viewModels/MainMenuViewModel.kt deleted file mode 100644 index b22f0fd..0000000 --- a/app/src/main/java/com/practice/getup/viewModels/MainMenuViewModel.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.practice.getup.viewModels - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import com.practice.getup.model.Options - -class MainMenuViewModel: ViewModel() { - - private val _options = MutableLiveData(Options.DEFAULT) - val options: LiveData = _options - - fun setOptions(optionsImport: Options){ - _options.value = optionsImport - - } - -} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_arrow_back_night.xml b/app/src/main/res/drawable/ic_arrow_back_night.xml new file mode 100644 index 0000000..2e266c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_back_night.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_delete.xml b/app/src/main/res/drawable/ic_delete.xml index d286523..3a3d289 100644 --- a/app/src/main/res/drawable/ic_delete.xml +++ b/app/src/main/res/drawable/ic_delete.xml @@ -1,4 +1,4 @@ - diff --git a/app/src/main/res/layout-land/fragment_workout.xml b/app/src/main/res/layout-land/fragment_workout.xml index cdb0b1c..82080ac 100644 --- a/app/src/main/res/layout-land/fragment_workout.xml +++ b/app/src/main/res/layout-land/fragment_workout.xml @@ -5,7 +5,7 @@ android:id="@+id/constraint_layout" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".fragments.WorkoutFragment"> + tools:context=".ui.timer.WorkoutFragment"> + tools:context=".ui.MainActivity"> - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_list.xml b/app/src/main/res/layout/fragment_list.xml deleted file mode 100644 index fc5e996..0000000 --- a/app/src/main/res/layout/fragment_list.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml index cf35e39..7d47a5b 100644 --- a/app/src/main/res/layout/fragment_main.xml +++ b/app/src/main/res/layout/fragment_main.xml @@ -4,12 +4,10 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - - tools:context=".fragments.MainFragment"> - + tools:context=".ui.main.MainFragment"> @@ -51,7 +50,6 @@ app:layout_constraintTop_toTopOf="parent" /> - + app:layout_constraintTop_toBottomOf="@id/top_app_bar_layout" + app:layout_constraintVertical_bias="0.0" /> + tools:context=".ui.edit.OptionsFragment"> + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_workout.xml b/app/src/main/res/layout/fragment_workout.xml index e093037..33796c9 100644 --- a/app/src/main/res/layout/fragment_workout.xml +++ b/app/src/main/res/layout/fragment_workout.xml @@ -5,7 +5,7 @@ android:id="@+id/constraint_layout" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".fragments.WorkoutFragment"> + tools:context=".ui.timer.WorkoutFragment"> - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 9962114..fdf3242 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -7,31 +7,22 @@ - - - + android:id="@+id/action_mainFragment_to_settingsFragment" + app:destination="@id/settingsFragment" /> - - + android:id="@+id/settingsFragment" + android:name="com.practice.getup.ui.settings.SettingsFragment" + android:label="fragment_settings" + tools:layout="@layout/fragment_settings" /> \ No newline at end of file diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 740fb25..bb2f96b 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -2,6 +2,14 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 82d1d4c..1522510 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -11,5 +11,16 @@ 28dp 14dp 16dp + 180dp + 16dp + 16dp + + + 22sp + 48dp + 16sp + 12sp + 10dp + 24dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 43be663..c10e163 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -69,7 +69,6 @@ PAUSE RESUME SAVE - BACK RESTART 10 sec by default* 30 sec by default* @@ -137,5 +136,16 @@ Are you sure you want to finish this workout? + ScrollingActivity + Settings + + + back button + Settings + Dark theme + Language + English + Russian + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c878ca3..3aefc23 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -7,6 +7,13 @@ 18sp + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 54f9b9f..703537d 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,6 +1,7 @@ + + + +