Split in more fragments. Trigger gui update trough db change
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-12-28 12:30:31 +01:00
parent 70da57df9c
commit f6b3f70e18
19 changed files with 413 additions and 229 deletions

View File

@@ -80,6 +80,7 @@ dependencies {
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.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.fragment:fragment:1.4.1'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.4' androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'

View File

@@ -18,7 +18,6 @@ import me.zobrist.tichucounter.data.Round
import me.zobrist.tichucounter.databinding.ActivityMainBinding import me.zobrist.tichucounter.databinding.ActivityMainBinding
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.HistoryListViewModel
import me.zobrist.tichucounter.fragments.KeyboardViewModel import me.zobrist.tichucounter.fragments.KeyboardViewModel
import me.zobrist.tichucounter.repository.GameRepository import me.zobrist.tichucounter.repository.GameRepository
import javax.inject.Inject import javax.inject.Inject
@@ -29,10 +28,10 @@ class MainActivity : AppCompatActivity() {
private var currentRound: Round = Round(0, 0, null, null) private var currentRound: Round = Round(0, 0, null, null)
private val keyboardViewModel: KeyboardViewModel by viewModels() private val keyboardViewModel: KeyboardViewModel by viewModels()
private val historyListViewModel: HistoryListViewModel by viewModels()
@Inject @Inject
lateinit var tichu: Tichu lateinit var tichu: Tichu
@Inject @Inject
lateinit var gameRepository: GameRepository lateinit var gameRepository: GameRepository
@@ -53,25 +52,15 @@ class MainActivity : AppCompatActivity() {
val game = gameRepository.getActiveGame() val game = gameRepository.getActiveGame()
if (game == null) { if (game == null) {
val game = gameRepository.newGame() gameRepository.newGame()
} }
} }
historyListViewModel.updateAll()
updateTheme(this.getSharedPreferences("Settings", MODE_PRIVATE).getInt("Theme", 2)) updateTheme(this.getSharedPreferences("Settings", MODE_PRIVATE).getInt("Theme", 2))
keepScreenOn( keepScreenOn(
this.getSharedPreferences("Settings", MODE_PRIVATE).getBoolean("Screen_On", false) this.getSharedPreferences("Settings", MODE_PRIVATE).getBoolean("Screen_On", false)
) )
binding.contentMain.nameTeamA.setText(
this.getSharedPreferences("Settings", MODE_PRIVATE).getString("nameTeamA", "TeamA")
)
binding.contentMain.nameTeamB.setText(
this.getSharedPreferences("Settings", MODE_PRIVATE).getString("nameTeamB", "TeamB")
)
keyboardViewModel.scoreA.observe(this) { value -> keyboardViewModel.scoreA.observe(this) { value ->
val oldValue = currentRound.scoreA val oldValue = currentRound.scoreA
currentRound.scoreA = value currentRound.scoreA = value
@@ -107,26 +96,12 @@ class MainActivity : AppCompatActivity() {
keyboardViewModel.setSubmitButtonEnable(tichu.isValidRound(currentRound)) keyboardViewModel.setSubmitButtonEnable(tichu.isValidRound(currentRound))
} }
} }
keyboardViewModel.submitButtonClicked.observe(this) {
historyListViewModel.updateAll()
}
historyListViewModel.totalScoreA.observe(this) { value ->
binding.contentMain.scoreA.text = value.toString()
}
historyListViewModel.totalScoreB.observe(this) { value ->
binding.contentMain.scoreB.text = value.toString()
}
} }
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
val prefs = this.getSharedPreferences("Settings", MODE_PRIVATE).edit() val prefs = this.getSharedPreferences("Settings", MODE_PRIVATE).edit()
prefs.putString("nameTeamA", binding.contentMain.nameTeamA.text.toString())
prefs.putString("nameTeamB", binding.contentMain.nameTeamB.text.toString())
prefs.apply() prefs.apply()
} }
@@ -150,7 +125,6 @@ class MainActivity : AppCompatActivity() {
dialog.dismiss() dialog.dismiss()
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
gameRepository.newGame() gameRepository.newGame()
historyListViewModel.updateAll()
} }
}.setNegativeButton(getString(R.string.no)) { dialog, _ -> }.setNegativeButton(getString(R.string.no)) { dialog, _ ->
dialog.cancel() dialog.cancel()
@@ -164,7 +138,6 @@ class MainActivity : AppCompatActivity() {
val history = gameRepository.getActiveRoundHistory() val history = gameRepository.getActiveRoundHistory()
if (history.isNotEmpty()) { if (history.isNotEmpty()) {
gameRepository.removeRoundFromHistory(history.last()) gameRepository.removeRoundFromHistory(history.last())
historyListViewModel.updateAll()
} }
} }
true true

View File

@@ -1,3 +1,5 @@
package me.zobrist.tichucounter.data
import androidx.room.TypeConverter import androidx.room.TypeConverter
import java.util.* import java.util.*

View File

@@ -1,20 +1,19 @@
package me.zobrist.tichucounter.data package me.zobrist.tichucounter.data
import androidx.room.Dao import androidx.room.*
import androidx.room.Delete import kotlinx.coroutines.flow.Flow
import androidx.room.Insert
import androidx.room.Query
@Dao @Dao
interface GameDao { interface GameDao {
@Query("SELECT * FROM game") @Query("SELECT * FROM game")
fun getAll(): List<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): Game fun getGameById(gameId: Long): Game
@Query("SELECT * FROM game WHERE active is 1") @Query("SELECT * FROM game WHERE active is 1")
fun getActive(): Game fun getActive(): Game
@Query("UPDATE game SET active = 1 WHERE uid is :gameId;") @Query("UPDATE game SET active = 1 WHERE uid is :gameId;")
@@ -26,6 +25,9 @@ interface GameDao {
@Insert @Insert
fun insert(game: Game): Long fun insert(game: Game): Long
@Update
fun update(game: Game)
@Delete @Delete
fun delete(round: Game) fun delete(round: Game)
} }

View File

@@ -4,12 +4,13 @@ import androidx.room.Dao
import androidx.room.Delete import androidx.room.Delete
import androidx.room.Insert import androidx.room.Insert
import androidx.room.Query import androidx.room.Query
import kotlinx.coroutines.flow.Flow
@Dao @Dao
interface RoundDao { interface RoundDao {
@Query("SELECT * FROM round") @Query("SELECT * FROM round")
fun getAll(): List<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>

View File

@@ -26,7 +26,7 @@ class HistoryList : Fragment() {
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View {
_binding = FragmentHistoryListBinding.inflate(inflater, container, false) _binding = FragmentHistoryListBinding.inflate(inflater, container, false)
return binding.root return binding.root
} }

View File

@@ -1,34 +1,42 @@
package me.zobrist.tichucounter.fragments package me.zobrist.tichucounter.fragments
import SingleLiveEvent
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
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.framework.SingleLiveEvent
import me.zobrist.tichucounter.repository.GameRepository import me.zobrist.tichucounter.repository.GameRepository
import javax.inject.Inject import javax.inject.Inject
@HiltViewModel @HiltViewModel
class HistoryListViewModel @Inject constructor(val gameRepository: GameRepository) : ViewModel() { class HistoryListViewModel @Inject constructor(
private val _totalScoreA: MutableLiveData<Int> = MutableLiveData<Int>() private val roundDao: RoundDao,
private val _totalScoreB: MutableLiveData<Int> = MutableLiveData<Int>() private val gameDao: GameDao,
private val gameRepository: GameRepository
) : ViewModel() {
private val _historyA: MutableLiveData<String> = MutableLiveData<String>() private val _historyA: MutableLiveData<String> = MutableLiveData<String>()
private val _historyB: MutableLiveData<String> = MutableLiveData<String>() private val _historyB: MutableLiveData<String> = MutableLiveData<String>()
private val _scrollDown: SingleLiveEvent<Boolean> = SingleLiveEvent() private val _scrollDown: SingleLiveEvent<Boolean> = SingleLiveEvent()
val totalScoreA: LiveData<Int> init {
get() { viewModelScope.launch {
return _totalScoreA roundDao.getAll().collect {
update()
}
} }
val totalScoreB: LiveData<Int> viewModelScope.launch {
get() { gameDao.getAll().collect {
return _totalScoreB update()
}
} }
}
val historyA: LiveData<String> val historyA: LiveData<String>
get() { get() {
@@ -45,20 +53,13 @@ class HistoryListViewModel @Inject constructor(val gameRepository: GameRepositor
return _scrollDown return _scrollDown
} }
private fun getScoreA(scores: List<Round>) { private suspend fun update() {
var tempScore = 0 val scores = gameRepository.getActiveRoundHistory()
scores.forEach { if (scores != null) {
it.scoreA?.let { it -> tempScore += it } getHistoryA(scores)
getHistoryB(scores)
} }
_totalScoreA.value = tempScore scrollDown()
}
private fun getScoreB(scores: List<Round>) {
var tempScore = 0
scores.forEach {
it.scoreB?.let { it -> tempScore += it }
}
_totalScoreB.value = tempScore
} }
private fun getHistoryA(scores: List<Round>) { private fun getHistoryA(scores: List<Round>) {
@@ -77,21 +78,6 @@ class HistoryListViewModel @Inject constructor(val gameRepository: GameRepositor
_historyB.value = tempHistory _historyB.value = tempHistory
} }
fun updateAll() {
viewModelScope.launch {
val scores = gameRepository.getActiveRoundHistory()
if (scores != null) {
getHistoryA(scores)
getHistoryB(scores)
getScoreA(scores)
getScoreB(scores)
}
scrollDown()
}
}
private fun scrollDown() { private fun scrollDown() {
_scrollDown.value = true _scrollDown.value = true
} }

View File

@@ -10,7 +10,6 @@ import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import me.zobrist.tichucounter.databinding.FragmentKeyboardBinding import me.zobrist.tichucounter.databinding.FragmentKeyboardBinding
class Keyboard : Fragment() { class Keyboard : Fragment() {
@@ -51,9 +50,9 @@ class Keyboard : Fragment() {
disableSubmitButton() disableSubmitButton()
viewModel.enableSubmitButton.observe(viewLifecycleOwner, Observer { enabled -> viewModel.enableSubmitButton.observe(viewLifecycleOwner) { enabled ->
if (enabled) enableSubmitButton() else disableSubmitButton() if (enabled) enableSubmitButton() else disableSubmitButton()
}) }
viewModel.scoreA.observe(viewLifecycleOwner) { value -> viewModel.scoreA.observe(viewLifecycleOwner) { value ->
updateScore(binding.inputTeamA, value) updateScore(binding.inputTeamA, value)
@@ -146,12 +145,12 @@ class Keyboard : Fragment() {
var value = getActiveValue() var value = getActiveValue()
if (value == null) { if (value == null) {
if (getActiveText() == "-") { unhandledNegation = if (getActiveText() == "-") {
setActiveText("") setActiveText("")
unhandledNegation = false false
} else { } else {
setActiveText("-") setActiveText("-")
unhandledNegation = true true
} }
} else { } else {
value = value?.times(-1) value = value?.times(-1)
@@ -194,7 +193,7 @@ class Keyboard : Fragment() {
return return
} }
var text = try { val text = try {
score.toString() score.toString()
} catch (e: Exception) { } catch (e: Exception) {
"" ""

View File

@@ -1,6 +1,5 @@
package me.zobrist.tichucounter.fragments package me.zobrist.tichucounter.fragments
import SingleLiveEvent
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
@@ -15,8 +14,6 @@ class KeyboardViewModel @Inject constructor(val gameRepository: GameRepository)
private val _scoreA: MutableLiveData<Int?> = MutableLiveData() private val _scoreA: MutableLiveData<Int?> = MutableLiveData()
private val _scoreB: MutableLiveData<Int?> = MutableLiveData() private val _scoreB: MutableLiveData<Int?> = MutableLiveData()
private val _enableSubmitButton: MutableLiveData<Boolean> = MutableLiveData() private val _enableSubmitButton: MutableLiveData<Boolean> = MutableLiveData()
private val _submitButtonClicked: SingleLiveEvent<Boolean> = SingleLiveEvent()
val scoreA: LiveData<Int?> val scoreA: LiveData<Int?>
get() { get() {
@@ -33,11 +30,6 @@ class KeyboardViewModel @Inject constructor(val gameRepository: GameRepository)
return _enableSubmitButton return _enableSubmitButton
} }
val submitButtonClicked: LiveData<Boolean>
get() {
return _submitButtonClicked
}
fun setScoreA(score: Int?) { fun setScoreA(score: Int?) {
_scoreA.value = score _scoreA.value = score
} }
@@ -56,7 +48,6 @@ class KeyboardViewModel @Inject constructor(val gameRepository: GameRepository)
_scoreA.value = null _scoreA.value = null
_scoreB.value = null _scoreB.value = null
setSubmitButtonEnable(false) setSubmitButtonEnable(false)
_submitButtonClicked.value = true
} }
} }
} }

View File

@@ -0,0 +1,63 @@
package me.zobrist.tichucounter.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import me.zobrist.tichucounter.databinding.FragmentTeamNamesBinding
class TeamNames : Fragment() {
private var _binding: FragmentTeamNamesBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
companion object {
fun newInstance() = TeamNames()
}
private val viewModel: TeamNamesViewModel by activityViewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentTeamNamesBinding.inflate(inflater, container, false)
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
binding.nameTeamA.setOnFocusChangeListener { _, focus ->
if (!focus) {
viewModel.setNameA(binding.nameTeamA.text.toString())
}
}
binding.nameTeamB.setOnFocusChangeListener { _, focus ->
if (!focus) {
viewModel.setNameB(binding.nameTeamB.text.toString())
}
}
viewModel.nameA.observe(viewLifecycleOwner) { value ->
binding.nameTeamA.setText(value)
}
viewModel.nameB.observe(viewLifecycleOwner) { value ->
binding.nameTeamB.setText(value)
}
}
}

View File

@@ -0,0 +1,58 @@
package me.zobrist.tichucounter.fragments
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import me.zobrist.tichucounter.data.GameDao
import me.zobrist.tichucounter.repository.GameRepository
import javax.inject.Inject
@HiltViewModel
class TeamNamesViewModel @Inject constructor(
private val gameDao: GameDao,
private val gameRepository: GameRepository
) :
ViewModel() {
private val _nameA: MutableLiveData<String> = MutableLiveData()
private val _nameB: MutableLiveData<String> = MutableLiveData()
val nameA: LiveData<String>
get() {
return _nameA
}
val nameB: LiveData<String>
get() {
return _nameB
}
init {
viewModelScope.launch {
gameDao.getAll().collect() {
val game = gameRepository.getActiveGame()
_nameA.value = game.nameA
_nameB.value = game.nameB
}
}
}
fun setNameA(name: String) {
viewModelScope.launch {
val game = gameRepository.getActiveGame()
game.nameA = name
gameRepository.updateGame(game)
}
}
fun setNameB(name: String) {
viewModelScope.launch {
val game = gameRepository.getActiveGame()
game.nameB = name
gameRepository.updateGame(game)
}
}
}

View File

@@ -0,0 +1,50 @@
package me.zobrist.tichucounter.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import me.zobrist.tichucounter.databinding.FragmentTeamScoresBinding
class TeamScores : Fragment() {
private var _binding: FragmentTeamScoresBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
companion object {
fun newInstance() = TeamScores()
}
private val viewModel: TeamScoresViewModel by activityViewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentTeamScoresBinding.inflate(inflater, container, false)
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel.scoreA.observe(viewLifecycleOwner) {
binding.scoreA.text = it?.toString() ?: ""
}
viewModel.scoreB.observe(viewLifecycleOwner) {
binding.scoreB.text = it?.toString() ?: ""
}
}
}

View File

@@ -0,0 +1,61 @@
package me.zobrist.tichucounter.fragments
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import me.zobrist.tichucounter.data.GameDao
import me.zobrist.tichucounter.data.RoundDao
import me.zobrist.tichucounter.repository.GameRepository
import javax.inject.Inject
@HiltViewModel
class TeamScoresViewModel @Inject constructor(
private val roundDao: RoundDao,
private val gameDao: GameDao,
private val gameRepository: GameRepository
) : ViewModel() {
private var _scoreA: MutableLiveData<Int> = MutableLiveData()
private var _scoreB: MutableLiveData<Int> = MutableLiveData()
init {
viewModelScope.launch {
roundDao.getAll().collect {
update()
}
}
viewModelScope.launch {
gameDao.getAll().collect {
update()
}
}
}
private suspend fun update() {
val scores = gameRepository.getActiveRoundHistory()
var scoreA = 0
var scoreB = 0
scores.forEach {
it.scoreA?.let { a -> scoreA += a }
it.scoreB?.let { b -> scoreB += b }
}
_scoreA.value = scoreA
_scoreB.value = scoreB
}
val scoreA: LiveData<Int>
get() {
return _scoreA
}
val scoreB: LiveData<Int>
get() {
return _scoreB
}
}

View File

@@ -1,3 +1,5 @@
package me.zobrist.tichucounter.framework
import android.util.Log import android.util.Log
import androidx.annotation.MainThread import androidx.annotation.MainThread
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
@@ -26,11 +28,11 @@ class SingleLiveEvent<T> : MutableLiveData<T>() {
Log.w(TAG, "Multiple observers registered but only one will be notified of changes.") Log.w(TAG, "Multiple observers registered but only one will be notified of changes.")
} }
// Observe the internal MutableLiveData // Observe the internal MutableLiveData
super.observe(owner, Observer { t -> super.observe(owner) { t ->
if (pending.compareAndSet(true, false)) { if (pending.compareAndSet(true, false)) {
observer.onChanged(t) observer.onChanged(t)
} }
}) }
} }
@MainThread @MainThread
@@ -48,6 +50,6 @@ class SingleLiveEvent<T> : MutableLiveData<T>() {
} }
companion object { companion object {
private val TAG = "SingleLiveEvent" private const val TAG = "me.zobrist.tichucounter.framework.SingleLiveEvent"
} }
} }

View File

@@ -15,20 +15,31 @@ class GameRepository @Inject constructor(
suspend fun newGame(): Game { suspend fun newGame(): Game {
return withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) {
val game = Game(true, "TeamA", "TeamB") val currentGame = gameDao.getActive()
val game = if (currentGame == null) {
Game(true, "TeamA", "TeamB")
} else {
Game(true, currentGame.nameA, currentGame.nameB)
}
val id = gameDao.insert(game) val id = gameDao.insert(game)
setActive(id) setActive(id)
return@withContext gameDao.getActive() return@withContext gameDao.getActive()
} }
} }
suspend fun updateGame(game: Game) {
withContext(Dispatchers.IO) {
gameDao.update(game)
}
}
suspend fun getActiveGame(): Game { suspend fun getActiveGame(): Game {
return withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) {
return@withContext gameDao.getActive() return@withContext gameDao.getActive()
} }
} }
suspend fun setActive(id: Long) { private suspend fun setActive(id: Long) {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
gameDao.setActive(id) gameDao.setActive(id)
gameDao.setOthersInactive(id) gameDao.setOthersInactive(id)

View File

@@ -17,73 +17,27 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<LinearLayout <androidx.fragment.app.FragmentContainerView
android:id="@+id/viewNames" android:id="@+id/teamNames"
android:name="me.zobrist.tichucounter.fragments.TeamNames"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout="@layout/fragment_team_names" />
<EditText <androidx.fragment.app.FragmentContainerView
android:id="@+id/nameTeamA" android:id="@+id/teamScores"
android:layout_width="match_parent" android:name="me.zobrist.tichucounter.fragments.TeamScores"
android:layout_height="wrap_content"
android:layout_weight="1"
android:autofillHints=""
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="text"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="@string/team_a"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<EditText
android:id="@+id/nameTeamB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:autofillHints=""
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="text"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="@string/team_b"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
</LinearLayout>
<LinearLayout
android:id="@+id/viewScore"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/teamNames"
tools:layout="@layout/fragment_team_scores" />
<TextView <androidx.fragment.app.FragmentContainerView
android:id="@+id/scoreA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/scoreB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<fragment
android:id="@+id/scrollHistory" android:id="@+id/scrollHistory"
android:name="me.zobrist.tichucounter.fragments.HistoryList" android:name="me.zobrist.tichucounter.fragments.HistoryList"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -103,7 +57,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/left"> app:layout_constraintStart_toEndOf="@+id/left">
<fragment <androidx.fragment.app.FragmentContainerView
android:id="@+id/keyboard" android:id="@+id/keyboard"
android:name="me.zobrist.tichucounter.fragments.Keyboard" android:name="me.zobrist.tichucounter.fragments.Keyboard"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@@ -6,79 +6,25 @@
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout <androidx.fragment.app.FragmentContainerView
android:id="@+id/viewNames" android:id="@+id/teamNames"
android:layout_width="match_parent" android:name="me.zobrist.tichucounter.fragments.TeamNames"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/nameTeamA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:autofillHints=""
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="text"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="@string/team_a"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<EditText
android:id="@+id/nameTeamB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:autofillHints=""
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="text"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="@string/team_b"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
</LinearLayout>
<LinearLayout
android:id="@+id/viewScore"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/viewNames"> app:layout_constraintTop_toTopOf="parent"
tools:layout="@layout/fragment_team_names" />
<TextView <androidx.fragment.app.FragmentContainerView
android:id="@+id/scoreA" android:id="@+id/teamScores"
android:layout_width="wrap_content" android:name="me.zobrist.tichucounter.fragments.TeamScores"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_weight="1" android:layout_height="wrap_content"
android:gravity="center" app:layout_constraintEnd_toEndOf="parent"
android:text="0" app:layout_constraintStart_toStartOf="parent"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" app:layout_constraintTop_toBottomOf="@id/teamNames"
android:textSize="18sp" tools:layout="@layout/fragment_team_scores" />
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/scoreB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="18sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
</LinearLayout>
<View <View
@@ -89,11 +35,11 @@
android:background="?android:attr/listDivider" android:background="?android:attr/listDivider"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/viewScore" app:layout_constraintTop_toBottomOf="@id/teamScores"
tools:layout_editor_absoluteY="50dp" /> tools:layout_editor_absoluteY="50dp" />
<fragment <androidx.fragment.app.FragmentContainerView
android:id="@+id/scrollHistory" android:id="@+id/scrollHistory"
android:name="me.zobrist.tichucounter.fragments.HistoryList" android:name="me.zobrist.tichucounter.fragments.HistoryList"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -114,7 +60,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<fragment <androidx.fragment.app.FragmentContainerView
android:id="@+id/keyboard" android:id="@+id/keyboard"
android:name="me.zobrist.tichucounter.fragments.Keyboard" android:name="me.zobrist.tichucounter.fragments.Keyboard"
android:layout_width="0dp" android:layout_width="0dp"

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.TeamNames">
<LinearLayout
android:id="@+id/viewNames"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/nameTeamA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:autofillHints=""
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="text"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="@string/team_a"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<EditText
android:id="@+id/nameTeamB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:autofillHints=""
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="text"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="@string/team_b"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
</LinearLayout>
</FrameLayout>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.TeamScores">
<LinearLayout
android:id="@+id/viewScore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/scoreA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="18sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/scoreB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="18sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
</LinearLayout>
</FrameLayout>