Move all fragments to ui package. Store created and modified date to game.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -78,13 +78,13 @@ dependencies {
|
|||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
|
||||||
implementation 'androidx.fragment:fragment:1.4.1'
|
implementation 'androidx.fragment:fragment-ktx:1.5.5'
|
||||||
implementation 'androidx.preference:preference:1.1.1'
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
implementation "com.google.dagger:hilt-android:2.44"
|
implementation "com.google.dagger:hilt-android:2.44"
|
||||||
kapt "com.google.dagger:hilt-compiler:2.44"
|
kapt "com.google.dagger:hilt-compiler:2.44"
|
||||||
implementation("androidx.room:room-runtime:2.4.3")
|
implementation("androidx.room:room-runtime:2.4.3")
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
android:localeConfig="@xml/locales_config"
|
android:localeConfig="@xml/locales_config"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules">
|
||||||
<activity
|
<activity
|
||||||
android:name=".DrawerActivity"
|
android:name=".DrawerActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ abstract class BaseActivity : AppCompatActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||||
when(key) {
|
when (key) {
|
||||||
"language" -> setLanguage(sharedPreferences.getString(key, null))
|
"language" -> setLanguage(sharedPreferences.getString(key, null))
|
||||||
"screen_on" -> keepScreenOn(sharedPreferences.getBoolean(key, false))
|
"screen_on" -> keepScreenOn(sharedPreferences.getBoolean(key, false))
|
||||||
"theme" -> updateTheme(sharedPreferences.getString(key, null))
|
"theme" -> updateTheme(sharedPreferences.getString(key, null))
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package me.zobrist.tichucounter.data
|
|||||||
|
|
||||||
import androidx.room.Database
|
import androidx.room.Database
|
||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
|
import androidx.room.TypeConverters
|
||||||
|
|
||||||
@Database(entities = [Round::class, Game::class], version = 1)
|
@Database(entities = [Round::class, Game::class], version = 1)
|
||||||
|
@TypeConverters(DateConverter::class)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
abstract fun roundDao(): RoundDao
|
abstract fun roundDao(): RoundDao
|
||||||
abstract fun gameDao(): GameDao
|
abstract fun gameDao(): GameDao
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package me.zobrist.tichucounter.data
|
package me.zobrist.tichucounter.data
|
||||||
|
|
||||||
|
import androidx.room.ProvidedTypeConverter
|
||||||
import androidx.room.TypeConverter
|
import androidx.room.TypeConverter
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ProvidedTypeConverter
|
||||||
object DateConverter {
|
object DateConverter {
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun toDate(dateLong: Long?): Date? {
|
fun toDate(dateLong: Long?): Date? {
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package me.zobrist.tichucounter.data
|
|||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
data class Game(
|
data class Game(
|
||||||
val active: Boolean,
|
val active: Boolean,
|
||||||
var nameA: String,
|
var nameA: String,
|
||||||
var nameB: String,
|
var nameB: String,
|
||||||
|
val created: Date,
|
||||||
|
var modified: Date,
|
||||||
@PrimaryKey(autoGenerate = true) val uid: Long? = null
|
@PrimaryKey(autoGenerate = true) val uid: Long? = null
|
||||||
)
|
)
|
||||||
@@ -7,14 +7,11 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
@Dao
|
@Dao
|
||||||
interface GameDao : DaoBase<Game> {
|
interface GameDao : DaoBase<Game> {
|
||||||
|
|
||||||
@Query("SELECT * FROM game")
|
|
||||||
fun getAll(): Flow<List<Game>>
|
|
||||||
|
|
||||||
@Query("SELECT * FROM game WHERE uid is :gameId")
|
@Query("SELECT * FROM game WHERE uid is :gameId")
|
||||||
fun getGameById(gameId: Long): Flow<Game>
|
fun getGameById(gameId: Long): Flow<Game>
|
||||||
|
|
||||||
@Query("SELECT * FROM game WHERE active is 1")
|
@Query("SELECT * FROM game WHERE active is 1")
|
||||||
fun getActive(): Game
|
fun getActive(): Flow<Game?>
|
||||||
|
|
||||||
@Query("UPDATE game SET active = 1 WHERE uid is :gameId;")
|
@Query("UPDATE game SET active = 1 WHERE uid is :gameId;")
|
||||||
fun setActive(gameId: Long)
|
fun setActive(gameId: Long)
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
@Dao
|
@Dao
|
||||||
interface RoundDao : DaoBase<Round> {
|
interface RoundDao : DaoBase<Round> {
|
||||||
|
|
||||||
@Query("SELECT * FROM round")
|
|
||||||
fun getAll(): Flow<List<Round>>
|
|
||||||
|
|
||||||
@Query("SELECT * FROM round WHERE gameId is :gameId")
|
@Query("SELECT * FROM round WHERE gameId is :gameId")
|
||||||
fun getAllForGame(gameId: Long?): List<Round>
|
fun getAllForGame(gameId: Long?): List<Round>
|
||||||
|
|
||||||
@@ -19,8 +16,4 @@ interface RoundDao : DaoBase<Round> {
|
|||||||
"WHERE game.active == 1"
|
"WHERE game.active == 1"
|
||||||
)
|
)
|
||||||
fun getForActiveGame(): Flow<List<Round>>
|
fun getForActiveGame(): Flow<List<Round>>
|
||||||
|
|
||||||
@Insert
|
|
||||||
fun insertAll(vararg rounds: Round)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
package me.zobrist.tichucounter.repository
|
package me.zobrist.tichucounter.repository
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import me.zobrist.tichucounter.data.Game
|
import me.zobrist.tichucounter.data.Game
|
||||||
import me.zobrist.tichucounter.data.GameDao
|
import me.zobrist.tichucounter.data.GameDao
|
||||||
import me.zobrist.tichucounter.data.Round
|
import me.zobrist.tichucounter.data.Round
|
||||||
import me.zobrist.tichucounter.data.RoundDao
|
import me.zobrist.tichucounter.data.RoundDao
|
||||||
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GameRepository @Inject constructor(
|
class GameRepository @Inject constructor(
|
||||||
@@ -13,32 +16,40 @@ class GameRepository @Inject constructor(
|
|||||||
private val roundDao: RoundDao
|
private val roundDao: RoundDao
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun newGame(): Game {
|
private var _activeGame: Game? = null
|
||||||
return withContext(Dispatchers.IO) {
|
|
||||||
val currentGame = gameDao.getActive()
|
val activeGame: Game
|
||||||
val game = if (currentGame == null) {
|
get() {
|
||||||
Game(true, "TeamA", "TeamB")
|
return _activeGame!!
|
||||||
} else {
|
}
|
||||||
Game(true, currentGame.nameA, currentGame.nameB)
|
|
||||||
|
init {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
gameDao.getActive().collect {
|
||||||
|
if (it == null) {
|
||||||
|
gameDao.insert(Game(true, "TeamA", "TeamB", Date(), Date()))
|
||||||
|
} else {
|
||||||
|
_activeGame = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val id = gameDao.insert(game)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun newGame() {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
val id =
|
||||||
|
gameDao.insert(Game(true, activeGame.nameA, activeGame.nameB, Date(), Date()))
|
||||||
setActive(id)
|
setActive(id)
|
||||||
return@withContext gameDao.getActive()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun updateGame(game: Game) {
|
suspend fun updateGame(game: Game) {
|
||||||
|
game.modified = Date()
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
gameDao.update(game)
|
gameDao.update(game)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getActiveGame(): Game {
|
|
||||||
return withContext(Dispatchers.IO) {
|
|
||||||
return@withContext gameDao.getActive()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun setActive(id: Long) {
|
private suspend fun setActive(id: Long) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
gameDao.setActive(id)
|
gameDao.setActive(id)
|
||||||
@@ -46,28 +57,23 @@ class GameRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getActiveRoundHistory(): List<Round> {
|
suspend fun revertLastRound() {
|
||||||
return withContext(Dispatchers.IO) {
|
|
||||||
val active = getActiveGame()
|
|
||||||
if (active?.uid != null) {
|
|
||||||
return@withContext roundDao.getAllForGame(active.uid)
|
|
||||||
} else {
|
|
||||||
return@withContext listOf<Round>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun removeRoundFromHistory(round: Round) {
|
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
roundDao.delete(round)
|
try {
|
||||||
|
val lastRound = roundDao.getAllForGame(activeGame.uid).last()
|
||||||
|
roundDao.delete(lastRound)
|
||||||
|
} catch (_: NoSuchElementException) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun addRoundToActiveGame(scoreA: Int, scoreB: Int) {
|
suspend fun addRoundToActiveGame(scoreA: Int, scoreB: Int) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
val active = getActiveGame()
|
val active = activeGame
|
||||||
|
active.modified = Date()
|
||||||
val round = Round(active.uid!!, scoreA, scoreB)
|
val round = Round(active.uid!!, scoreA, scoreB)
|
||||||
roundDao.insertAll(round)
|
roundDao.insert(round)
|
||||||
|
gameDao.update(active)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -15,9 +15,8 @@ import me.zobrist.tichucounter.data.Round
|
|||||||
import me.zobrist.tichucounter.databinding.FragmentCounterBinding
|
import me.zobrist.tichucounter.databinding.FragmentCounterBinding
|
||||||
import me.zobrist.tichucounter.domain.Tichu
|
import me.zobrist.tichucounter.domain.Tichu
|
||||||
import me.zobrist.tichucounter.domain.getAbsoluteDifference
|
import me.zobrist.tichucounter.domain.getAbsoluteDifference
|
||||||
import me.zobrist.tichucounter.fragments.FragmentBase
|
|
||||||
import me.zobrist.tichucounter.fragments.KeyboardViewModel
|
|
||||||
import me.zobrist.tichucounter.repository.GameRepository
|
import me.zobrist.tichucounter.repository.GameRepository
|
||||||
|
import me.zobrist.tichucounter.ui.FragmentBase
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@@ -107,10 +106,7 @@ class CounterFragment : FragmentBase<FragmentCounterBinding>(), MenuProvider {
|
|||||||
}
|
}
|
||||||
R.id.action_undo -> {
|
R.id.action_undo -> {
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
val history = gameRepository.getActiveRoundHistory()
|
gameRepository.revertLastRound()
|
||||||
if (history.isNotEmpty()) {
|
|
||||||
gameRepository.removeRoundFromHistory(history.last())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -7,6 +7,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import me.zobrist.tichucounter.databinding.FragmentHistoryListBinding
|
import me.zobrist.tichucounter.databinding.FragmentHistoryListBinding
|
||||||
|
import me.zobrist.tichucounter.ui.FragmentBase
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HistoryList : FragmentBase<FragmentHistoryListBinding>() {
|
class HistoryList : FragmentBase<FragmentHistoryListBinding>() {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
@@ -20,7 +20,7 @@ class HistoryListViewModel @Inject constructor(private val roundDao: RoundDao) :
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
roundDao.getForActiveGame().collect() { scores ->
|
roundDao.getForActiveGame().collect { scores ->
|
||||||
update(scores)
|
update(scores)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -11,6 +11,7 @@ import android.widget.EditText
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import me.zobrist.tichucounter.databinding.FragmentKeyboardBinding
|
import me.zobrist.tichucounter.databinding.FragmentKeyboardBinding
|
||||||
|
import me.zobrist.tichucounter.ui.FragmentBase
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class Keyboard : FragmentBase<FragmentKeyboardBinding>() {
|
class Keyboard : FragmentBase<FragmentKeyboardBinding>() {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -8,6 +8,7 @@ import androidx.core.widget.doAfterTextChanged
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import me.zobrist.tichucounter.databinding.FragmentTeamNamesBinding
|
import me.zobrist.tichucounter.databinding.FragmentTeamNamesBinding
|
||||||
|
import me.zobrist.tichucounter.ui.FragmentBase
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class TeamNames : FragmentBase<FragmentTeamNamesBinding>() {
|
class TeamNames : FragmentBase<FragmentTeamNamesBinding>() {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
@@ -32,17 +32,16 @@ class TeamNamesViewModel @Inject constructor(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
gameDao.getAll().collect() {
|
gameDao.getActive().collect {
|
||||||
val game = gameRepository.getActiveGame()
|
_nameA.value = it?.nameA
|
||||||
_nameA.value = game.nameA
|
_nameB.value = it?.nameB
|
||||||
_nameB.value = game.nameB
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setNameA(name: String) {
|
fun setNameA(name: String) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val game = gameRepository.getActiveGame()
|
val game = gameRepository.activeGame
|
||||||
game.nameA = name
|
game.nameA = name
|
||||||
gameRepository.updateGame(game)
|
gameRepository.updateGame(game)
|
||||||
}
|
}
|
||||||
@@ -50,7 +49,7 @@ class TeamNamesViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun setNameB(name: String) {
|
fun setNameB(name: String) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val game = gameRepository.getActiveGame()
|
val game = gameRepository.activeGame
|
||||||
game.nameB = name
|
game.nameB = name
|
||||||
gameRepository.updateGame(game)
|
gameRepository.updateGame(game)
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -7,6 +7,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import me.zobrist.tichucounter.databinding.FragmentTeamScoresBinding
|
import me.zobrist.tichucounter.databinding.FragmentTeamScoresBinding
|
||||||
|
import me.zobrist.tichucounter.ui.FragmentBase
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class TeamScores : FragmentBase<FragmentTeamScoresBinding>() {
|
class TeamScores : FragmentBase<FragmentTeamScoresBinding>() {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter.fragments
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
@@ -18,7 +18,7 @@ class TeamScoresViewModel @Inject constructor(private val roundDao: RoundDao) :
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
roundDao.getForActiveGame().collect() { scores ->
|
roundDao.getForActiveGame().collect { scores ->
|
||||||
update(scores)
|
update(scores)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,12 +22,11 @@ class SlideshowFragment : Fragment() {
|
|||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
val slideshowViewModel =
|
val slideshowViewModel =
|
||||||
ViewModelProvider(this).get(SlideshowViewModel::class.java)
|
ViewModelProvider(this)[SlideshowViewModel::class.java]
|
||||||
|
|
||||||
_binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
_binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
||||||
val root: View = binding.root
|
|
||||||
|
|
||||||
return root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/teamNames"
|
android:id="@+id/teamNames"
|
||||||
android:name="me.zobrist.tichucounter.fragments.TeamNames"
|
android:name="me.zobrist.tichucounter.ui.counter.TeamNames"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/teamScores"
|
android:id="@+id/teamScores"
|
||||||
android:name="me.zobrist.tichucounter.fragments.TeamScores"
|
android:name="me.zobrist.tichucounter.ui.counter.TeamScores"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/scrollHistory"
|
android:id="@+id/scrollHistory"
|
||||||
android:name="me.zobrist.tichucounter.fragments.HistoryList"
|
android:name="me.zobrist.tichucounter.ui.counter.HistoryList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/keyboard"
|
android:id="@+id/keyboard"
|
||||||
android:name="me.zobrist.tichucounter.fragments.Keyboard"
|
android:name="me.zobrist.tichucounter.ui.counter.Keyboard"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/teamNames"
|
android:id="@+id/teamNames"
|
||||||
android:name="me.zobrist.tichucounter.fragments.TeamNames"
|
android:name="me.zobrist.tichucounter.ui.counter.TeamNames"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/teamScores"
|
android:id="@+id/teamScores"
|
||||||
android:name="me.zobrist.tichucounter.fragments.TeamScores"
|
android:name="me.zobrist.tichucounter.ui.counter.TeamScores"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/scrollHistory"
|
android:id="@+id/scrollHistory"
|
||||||
android:name="me.zobrist.tichucounter.fragments.HistoryList"
|
android:name="me.zobrist.tichucounter.ui.counter.HistoryList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/keyboard"
|
android:id="@+id/keyboard"
|
||||||
android:name="me.zobrist.tichucounter.fragments.Keyboard"
|
android:name="me.zobrist.tichucounter.ui.counter.Keyboard"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragments.HistoryList">
|
tools:context=".ui.counter.HistoryList">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/scrollViewHistory"
|
android:id="@+id/scrollViewHistory"
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:context=".fragments.Keyboard">
|
tools:context=".ui.counter.Keyboard">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragments.TeamNames">
|
tools:context=".ui.counter.TeamNames">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/viewNames"
|
android:id="@+id/viewNames"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragments.TeamScores">
|
tools:context=".ui.counter.TeamScores">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/viewScore"
|
android:id="@+id/viewScore"
|
||||||
|
|||||||
6
app/src/main/res/xml/data_extraction_rules.xml
Normal file
6
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
|
||||||
|
</cloud-backup>
|
||||||
|
</data-extraction-rules>
|
||||||
@@ -17,7 +17,7 @@ class TichuUnitTest {
|
|||||||
var inputScoreA = 125
|
var inputScoreA = 125
|
||||||
var inputScoreB = -25
|
var inputScoreB = -25
|
||||||
|
|
||||||
val tichu: Tichu = Tichu()
|
val tichu = Tichu()
|
||||||
|
|
||||||
// Normal round range -25 to 125 as input
|
// Normal round range -25 to 125 as input
|
||||||
while (inputScoreB <= 125) {
|
while (inputScoreB <= 125) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.7.0"
|
ext.kotlin_version = "1.7.20"
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
Reference in New Issue
Block a user