├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── README.md
├── app
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-playstore.png
│ ├── kotlin
│ └── com
│ │ └── sbgapps
│ │ └── scoreit
│ │ └── app
│ │ ├── ScoreItApp.kt
│ │ ├── di
│ │ └── UiModule.kt
│ │ ├── model
│ │ ├── Header.kt
│ │ ├── LapRow.kt
│ │ └── SavedGame.kt
│ │ └── ui
│ │ ├── AboutActivity.kt
│ │ ├── GameViewModel.kt
│ │ ├── NavDrawerFragment.kt
│ │ ├── chart
│ │ ├── ChartFragment.kt
│ │ └── ChartViewModel.kt
│ │ ├── color
│ │ ├── ColorAdapter.kt
│ │ └── ColorPickerFragment.kt
│ │ ├── edition
│ │ ├── EditionActivity.kt
│ │ ├── Step.kt
│ │ ├── belote
│ │ │ ├── BeloteEditionActivity.kt
│ │ │ ├── BeloteEditionBonusFragment.kt
│ │ │ └── BeloteEditionViewModel.kt
│ │ ├── coinche
│ │ │ ├── CoincheEditionActivity.kt
│ │ │ ├── CoincheEditionBonusFragment.kt
│ │ │ └── CoincheEditionViewModel.kt
│ │ ├── tarot
│ │ │ ├── TarotEditionActivity.kt
│ │ │ ├── TarotEditionBonusFragment.kt
│ │ │ └── TarotEditionViewModel.kt
│ │ └── universal
│ │ │ ├── UniversalEditionActivity.kt
│ │ │ ├── UniversalEditionAdapter.kt
│ │ │ ├── UniversalEditionViewModel.kt
│ │ │ └── UniversalInputScore.kt
│ │ ├── history
│ │ ├── HistoryActivity.kt
│ │ ├── HistorySwipeCallback.kt
│ │ └── adapter
│ │ │ ├── BaseLapAdapter.kt
│ │ │ ├── BeloteLapAdapter.kt
│ │ │ ├── CoincheLapAdapter.kt
│ │ │ ├── DonationAdapter.kt
│ │ │ ├── HeaderAdapter.kt
│ │ │ ├── LapResultAdapter.kt
│ │ │ ├── TarotLapAdapter.kt
│ │ │ └── UniversalLapAdapter.kt
│ │ ├── prefs
│ │ ├── PreferencesActivity.kt
│ │ └── PreferencesViewModel.kt
│ │ ├── saved
│ │ ├── SavedGameActivity.kt
│ │ ├── SavedGameAdapter.kt
│ │ ├── SavedGameSwipeCallback.kt
│ │ └── SavedGameViewModel.kt
│ │ ├── scoreboard
│ │ ├── ScoreBoardViewModel.kt
│ │ └── ScoreboardActivity.kt
│ │ └── widget
│ │ ├── AdaptableLinearLayout.kt
│ │ └── LineChart.kt
│ └── res
│ ├── anim
│ ├── fade_in.xml
│ └── fade_out.xml
│ ├── color
│ └── csl_secondary_enabled.xml
│ ├── drawable
│ ├── ic_arrow_back_24dp.xml
│ ├── ic_arrow_drop_down_24dp.xml
│ ├── ic_backspace_24dp.xml
│ ├── ic_baseline_rate_review_24dp.xml
│ ├── ic_beer_24dp.xml
│ ├── ic_cancel_24dp.xml
│ ├── ic_circle_color.xml
│ ├── ic_clear_all_24dp.xml
│ ├── ic_delete_24dp.xml
│ ├── ic_donate_coffee_24dp.xml
│ ├── ic_done_24dp.xml
│ ├── ic_edit_24dp.xml
│ ├── ic_email_24dp.xml
│ ├── ic_github_24dp.xml
│ ├── ic_heart_24dp.xml
│ ├── ic_launcher_foreground.xml
│ ├── ic_list_24dp.xml
│ ├── ic_menu_24dp.xml
│ ├── ic_messenger_24dp.xml
│ ├── ic_minus_24dp.xml
│ ├── ic_people_24dp.xml
│ ├── ic_plus_24dp.xml
│ ├── ic_refresh_24dp.xml
│ ├── ic_score_it.xml
│ ├── ic_show_chart_24dp.xml
│ ├── ic_swap_horiz_24dp.xml
│ └── ic_unarchive_24dp.xml
│ ├── layout
│ ├── activity_about.xml
│ ├── activity_edition_belote.xml
│ ├── activity_edition_coinche.xml
│ ├── activity_edition_tarot.xml
│ ├── activity_edition_universal.xml
│ ├── activity_history.xml
│ ├── activity_preferences.xml
│ ├── activity_saved_games.xml
│ ├── activity_scoreboard.xml
│ ├── dialog_edit_name.xml
│ ├── fragment_chart.xml
│ ├── fragment_color_picker.xml
│ ├── fragment_edition_belote_bonus.xml
│ ├── fragment_edition_coinche_bonus.xml
│ ├── fragment_edition_tarot_bonus.xml
│ ├── fragment_history.xml
│ ├── fragment_nav_drawer.xml
│ ├── fragment_universal_input_score.xml
│ ├── list_item_color.xml
│ ├── list_item_edition_bonus.xml
│ ├── list_item_edition_universal.xml
│ ├── list_item_header.xml
│ ├── list_item_lap_belote_coinche.xml
│ ├── list_item_lap_donation.xml
│ ├── list_item_lap_result.xml
│ ├── list_item_lap_tarot.xml
│ ├── list_item_lap_universal.xml
│ ├── list_item_saved_games.xml
│ └── tools_linearlistview_preview.xml
│ ├── menu
│ ├── menu_edition.xml
│ ├── menu_main.xml
│ └── nav_drawer.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-fr
│ └── strings.xml
│ ├── values-night
│ ├── colors.xml
│ └── themes.xml
│ ├── values-v23
│ └── colors.xml
│ ├── values-v27
│ └── colors.xml
│ └── values
│ ├── arrays.xml
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ic_launcher_background.xml
│ ├── ids.xml
│ ├── integers.xml
│ ├── shape.xml
│ ├── strings.xml
│ ├── styles.xml
│ ├── themes.xml
│ └── type.xml
├── art
├── feature_graphic.svg
├── ic_launcher.svg
└── promo_graphic.svg
├── build.gradle.kts
├── cache
├── build.gradle.kts
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── kotlin
│ └── com
│ │ └── sbgapps
│ │ └── scoreit
│ │ └── cache
│ │ ├── dao
│ │ ├── FileStorage.kt
│ │ └── ScoreItGameDao.kt
│ │ ├── di
│ │ └── CacheModule.kt
│ │ └── repository
│ │ ├── ScoreItBillingRepo.kt
│ │ ├── ScoreItCacheRepo.kt
│ │ └── ScoreItPreferencesRepo.kt
│ └── res
│ ├── values-fr
│ └── strings.xml
│ └── values
│ ├── arrays.xml
│ └── strings.xml
├── core
├── build.gradle.kts
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── kotlin
│ └── com
│ │ └── sbgapps
│ │ └── scoreit
│ │ └── core
│ │ ├── ext
│ │ ├── Collection.kt
│ │ ├── Context.kt
│ │ ├── DiffUtil.kt
│ │ ├── Fragment.kt
│ │ ├── FragmentActivity.kt
│ │ ├── LifecycleOwner.kt
│ │ ├── List.kt
│ │ ├── Menu.kt
│ │ ├── String.kt
│ │ └── View.kt
│ │ ├── ui
│ │ ├── BaseActivity.kt
│ │ ├── BaseFragment.kt
│ │ └── BaseViewModel.kt
│ │ ├── utils
│ │ ├── ApiHelper.kt
│ │ ├── RecyclerViewSwipeDecorator.kt
│ │ ├── ThemeHelper.kt
│ │ └── string
│ │ │ ├── StringFactory.kt
│ │ │ ├── StringFactoryDsl.kt
│ │ │ └── StringFactoryInterpreter.kt
│ │ └── widget
│ │ ├── AppBarNestedScrollViewOnScrollListener.kt
│ │ ├── AppBarRecyclerViewOnScrollListener.kt
│ │ ├── BaseViewHolder.kt
│ │ ├── DividerItemDecoration.kt
│ │ ├── EmptinessLayout.kt
│ │ ├── ErrorView.kt
│ │ ├── GenericRecyclerViewAdapter.kt
│ │ └── ItemAdapter.kt
│ └── res
│ ├── anim
│ ├── fade_in.xml
│ ├── fade_out.xml
│ ├── item_animation_fall_down.xml
│ └── layout_animation_fall_down.xml
│ ├── drawable
│ ├── ic_error_outline_black_24dp.xml
│ └── ic_signal_cellular_connected_no_internet_0_bar_black_24dp.xml
│ ├── layout
│ └── widget_error_view.xml
│ ├── values-fr
│ └── strings.xml
│ ├── values-v29
│ └── strings.xml
│ └── values
│ ├── dimens.xml
│ ├── ids.xml
│ ├── md_colors.xml
│ └── strings.xml
├── data
├── build.gradle.kts
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── kotlin
│ │ └── com
│ │ │ └── sbgapps
│ │ │ └── scoreit
│ │ │ └── data
│ │ │ ├── di
│ │ │ └── DataModule.kt
│ │ │ ├── interactor
│ │ │ ├── GameUseCase.kt
│ │ │ └── ScoreBoardUseCase.kt
│ │ │ ├── model
│ │ │ ├── BeloteBonus.kt
│ │ │ ├── BeloteBonusValue.kt
│ │ │ ├── CoincheValue.kt
│ │ │ ├── Game.kt
│ │ │ ├── GameType.kt
│ │ │ ├── Lap.kt
│ │ │ ├── Player.kt
│ │ │ ├── PlayerPosition.kt
│ │ │ ├── SavedGameInfo.kt
│ │ │ ├── ScoreBoard.kt
│ │ │ ├── TarotBidValue.kt
│ │ │ ├── TarotBonus.kt
│ │ │ ├── TarotBonusValue.kt
│ │ │ └── TarotOudlerValue.kt
│ │ │ ├── repository
│ │ │ ├── BillingRepo.kt
│ │ │ ├── CacheRepo.kt
│ │ │ └── PreferencesRepo.kt
│ │ │ ├── solver
│ │ │ ├── BeloteSolver.kt
│ │ │ ├── CoincheSolver.kt
│ │ │ ├── TarotSolver.kt
│ │ │ └── UniversalSolver.kt
│ │ │ └── source
│ │ │ └── DataStore.kt
│ └── res
│ │ ├── values-fr
│ │ └── strings.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── sbgapps
│ └── scoreit
│ └── data
│ └── solver
│ ├── BeloteSolverTest.kt
│ ├── CoincheSolverTest.kt
│ ├── TarotSolverTest.kt
│ └── UniversalSolverTest.kt
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshot.png
└── settings.gradle.kts
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 |
4 | # files for the dex VM
5 | *.dex
6 |
7 | # Java class files
8 | *.class
9 |
10 | # generated files
11 | bin/
12 | gen/
13 | *.aab
14 |
15 | # Local configuration file
16 | local.properties
17 |
18 | # Intellij project files
19 | *.iml
20 | *.ipr
21 | *.iws
22 | .idea/
23 | *.prefs
24 |
25 | # Gradle
26 | build/
27 | .gradle
28 |
29 | # Signing
30 | key
31 | signing.gradle
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ScoreIt
2 | =======================
3 |
4 | An application to count points for games:
5 | - Universal counter
6 | - Tarot
7 | - Belote
8 | - Coinche
9 |
10 | 
11 |
12 |
13 |
14 |
15 | Credits
16 | -------
17 |
18 | Author: [Stéphane Baiget](https://github.com/StephaneBg)
19 |
20 |
21 | License
22 | -------
23 |
24 | Copyright 2013 SBG Apps
25 |
26 | Licensed under the Apache License, Version 2.0 (the "License");
27 | you may not use this file except in compliance with the License.
28 | You may obtain a copy of the License at
29 |
30 | http://www.apache.org/licenses/LICENSE-2.0
31 |
32 | Unless required by applicable law or agreed to in writing, software
33 | distributed under the License is distributed on an "AS IS" BASIS,
34 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 | See the License for the specific language governing permissions and
36 | limitations under the License.
37 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ScoreItApp.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app
18 |
19 | import android.app.Application
20 | import com.sbgapps.scoreit.BuildConfig
21 | import com.sbgapps.scoreit.app.di.uiModule
22 | import com.sbgapps.scoreit.cache.di.cacheModule
23 | import com.sbgapps.scoreit.data.di.dataModule
24 | import org.koin.android.ext.koin.androidContext
25 | import org.koin.core.context.startKoin
26 | import timber.log.Timber
27 |
28 | class ScoreItApp : Application() {
29 |
30 | override fun onCreate() {
31 | super.onCreate()
32 |
33 | if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
34 |
35 | startKoin {
36 | androidContext(this@ScoreItApp)
37 | modules(
38 | listOf(
39 | uiModule,
40 | dataModule,
41 | cacheModule
42 | )
43 | )
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/di/UiModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.di
18 |
19 | import com.sbgapps.scoreit.app.ui.GameViewModel
20 | import com.sbgapps.scoreit.app.ui.chart.ChartViewModel
21 | import com.sbgapps.scoreit.app.ui.edition.belote.BeloteEditionViewModel
22 | import com.sbgapps.scoreit.app.ui.edition.coinche.CoincheEditionViewModel
23 | import com.sbgapps.scoreit.app.ui.edition.tarot.TarotEditionViewModel
24 | import com.sbgapps.scoreit.app.ui.edition.universal.UniversalEditionViewModel
25 | import com.sbgapps.scoreit.app.ui.prefs.PreferencesViewModel
26 | import com.sbgapps.scoreit.app.ui.saved.SavedGameViewModel
27 | import com.sbgapps.scoreit.app.ui.scoreboard.ScoreBoardViewModel
28 | import org.koin.androidx.viewmodel.dsl.viewModel
29 | import org.koin.dsl.module
30 |
31 | val uiModule = module {
32 |
33 | viewModel { GameViewModel(get(), get()) }
34 | viewModel { ChartViewModel(get()) }
35 | viewModel { PreferencesViewModel(get()) }
36 | viewModel { UniversalEditionViewModel(get()) }
37 | viewModel { TarotEditionViewModel(get(), get()) }
38 | viewModel { BeloteEditionViewModel(get(), get()) }
39 | viewModel { CoincheEditionViewModel(get(), get()) }
40 | viewModel { ScoreBoardViewModel(get()) }
41 | viewModel { (datePattern: String) -> SavedGameViewModel(get(), datePattern) }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/model/Header.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.model
18 |
19 | import com.sbgapps.scoreit.data.model.Player
20 |
21 | data class Header(
22 | val players: List,
23 | val scores: List,
24 | val markers: List
25 | )
26 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/model/LapRow.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.model
18 |
19 | import com.sbgapps.scoreit.core.utils.string.StringFactory
20 |
21 | sealed class LapRow(open val position: Int)
22 |
23 | data class UniversalLapRow(
24 | override val position: Int,
25 | val results: List
26 | ) : LapRow(position)
27 |
28 | data class BeloteLapRow(
29 | override val position: Int,
30 | val results: List,
31 | val isWon: Boolean = true
32 | ) : LapRow(position)
33 |
34 | data class CoincheLapRow(
35 | override val position: Int,
36 | val results: List,
37 | val isWon: Boolean
38 | ) : LapRow(position)
39 |
40 | data class TarotLapRow(
41 | override val position: Int,
42 | val results: List,
43 | val info: StringFactory,
44 | val isWon: Boolean
45 | ) : LapRow(position)
46 |
47 | data object DonationRow : LapRow(0)
48 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/model/SavedGame.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.model
18 |
19 | data class SavedGame(
20 | val fileName: String,
21 | val players: String,
22 | val date: String
23 | )
24 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/NavDrawerFragment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui
18 |
19 | import android.os.Bundle
20 | import android.view.LayoutInflater
21 | import android.view.View
22 | import android.view.ViewGroup
23 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment
24 | import com.google.android.material.navigation.NavigationView
25 | import com.sbgapps.scoreit.R
26 | import com.sbgapps.scoreit.app.ui.prefs.PreferencesActivity
27 | import com.sbgapps.scoreit.app.ui.scoreboard.ScoreboardActivity
28 | import com.sbgapps.scoreit.core.ext.start
29 | import com.sbgapps.scoreit.data.model.GameType
30 | import org.koin.androidx.viewmodel.ext.android.sharedViewModel
31 |
32 | class NavDrawerFragment : BottomSheetDialogFragment() {
33 |
34 | private val viewModel by sharedViewModel()
35 |
36 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
37 | inflater.inflate(R.layout.fragment_nav_drawer, container, false)
38 |
39 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
40 | (view as NavigationView).setNavigationItemSelectedListener { menuItem ->
41 | when (menuItem.itemId) {
42 | R.id.universal -> viewModel.selectGame(GameType.UNIVERSAL)
43 | R.id.scoreboard -> requireContext().start()
44 | R.id.tarot -> viewModel.selectGame(GameType.TAROT)
45 | R.id.belote -> viewModel.selectGame(GameType.BELOTE)
46 | R.id.coinche -> viewModel.selectGame(GameType.COINCHE)
47 |
48 | R.id.preferences -> requireContext().start()
49 | R.id.about -> requireContext().start()
50 | }
51 | this@NavDrawerFragment.dismiss()
52 | true
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/chart/ChartFragment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.chart
18 |
19 | import android.os.Bundle
20 | import android.view.LayoutInflater
21 | import android.view.View
22 | import android.view.ViewGroup
23 | import androidx.core.view.updateLayoutParams
24 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment
25 | import com.sbgapps.scoreit.R
26 | import com.sbgapps.scoreit.app.ui.widget.LineChart
27 | import com.sbgapps.scoreit.core.ext.dip
28 | import com.sbgapps.scoreit.core.ext.observe
29 | import com.sbgapps.scoreit.databinding.FragmentChartBinding
30 | import org.koin.androidx.viewmodel.ext.android.viewModel
31 |
32 | class ChartFragment : BottomSheetDialogFragment() {
33 |
34 | private val viewModel by viewModel()
35 | private lateinit var binding: FragmentChartBinding
36 |
37 | override fun onCreateView(
38 | inflater: LayoutInflater,
39 | container: ViewGroup?,
40 | savedInstanceState: Bundle?
41 | ): View {
42 | binding = FragmentChartBinding.inflate(inflater)
43 | return binding.root
44 | }
45 |
46 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
47 | observe(viewModel.getLines()) {
48 | it?.let {
49 | (view as LineChart).lines = it
50 | }
51 | }
52 | }
53 |
54 | override fun onStart() {
55 | super.onStart()
56 |
57 | dialog?.findViewById(R.id.design_bottom_sheet)?.updateLayoutParams {
58 | height = requireContext().dip(resources.configuration.screenHeightDp * 2 / 3)
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/chart/ChartViewModel.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.chart
18 |
19 | import androidx.lifecycle.LiveData
20 | import androidx.lifecycle.MutableLiveData
21 | import androidx.lifecycle.ViewModel
22 | import com.sbgapps.scoreit.app.ui.widget.LinePoint
23 | import com.sbgapps.scoreit.app.ui.widget.LineSet
24 | import com.sbgapps.scoreit.data.interactor.GameUseCase
25 |
26 | class ChartViewModel(private val useCase: GameUseCase) : ViewModel() {
27 |
28 | private val innerState = MutableLiveData>()
29 |
30 | fun getLines(): LiveData> {
31 | innerState.value ?: innerState.postValue(getPlayerResults())
32 | return innerState
33 | }
34 |
35 | private fun getPlayerResults(): List {
36 | val lines = mutableListOf()
37 | val lapResults = mutableListOf>()
38 | useCase.getGame().laps.forEachIndexed { index, lap ->
39 | val results = useCase.getResults(lap)
40 | lapResults += if (0 == index) {
41 | results
42 | } else {
43 | results.zip(lapResults[index - 1]) { current, previous ->
44 | previous + current
45 | }
46 | }
47 | }
48 |
49 | useCase.getPlayers().forEachIndexed { playerIndex, player ->
50 | val points = mutableListOf(LinePoint())
51 | lapResults.forEachIndexed { lapIndex, results ->
52 | points += LinePoint(lapIndex + 1, results[playerIndex])
53 | }
54 | lines += LineSet(points, player.color)
55 | }
56 |
57 | return lines
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/color/ColorAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.color
18 |
19 | import android.content.res.ColorStateList
20 | import com.sbgapps.scoreit.R
21 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
22 | import com.sbgapps.scoreit.core.widget.ItemAdapter
23 | import com.sbgapps.scoreit.databinding.ListItemColorBinding
24 |
25 | class ColorAdapter(
26 | private val color: Int,
27 | private val callback: (Int) -> Unit
28 | ) : ItemAdapter(R.layout.list_item_color) {
29 |
30 | private lateinit var binding: ListItemColorBinding
31 |
32 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
33 | binding = ListItemColorBinding.bind(viewHolder.itemView)
34 | binding.colorCircle.imageTintList = ColorStateList.valueOf(color)
35 | binding.root.setOnClickListener { callback(color) }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/color/ColorPickerFragment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.color
18 |
19 | import android.os.Bundle
20 | import android.view.LayoutInflater
21 | import android.view.View
22 | import android.view.ViewGroup
23 | import androidx.fragment.app.FragmentManager
24 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment
25 | import com.sbgapps.scoreit.core.widget.GenericRecyclerViewAdapter
26 | import com.sbgapps.scoreit.databinding.FragmentColorPickerBinding
27 |
28 | class ColorPickerFragment : BottomSheetDialogFragment() {
29 |
30 | private lateinit var binding: FragmentColorPickerBinding
31 | private lateinit var adapters: List
32 | private lateinit var listener: ((color: Int) -> Unit)
33 |
34 | override fun onCreateView(
35 | inflater: LayoutInflater,
36 | container: ViewGroup?,
37 | savedInstanceState: Bundle?
38 | ): View {
39 | binding = FragmentColorPickerBinding.inflate(inflater)
40 | return binding.root
41 | }
42 |
43 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
44 | super.onViewCreated(view, savedInstanceState)
45 | binding.recyclerView.adapter = GenericRecyclerViewAdapter(adapters)
46 | }
47 |
48 | fun show(colors: IntArray, fragmentManager: FragmentManager, listener: (color: Int) -> Unit) {
49 | this.listener = listener
50 | adapters = colors.map { ColorAdapter(it, ::onColorSelected) }
51 | show(fragmentManager, null)
52 | }
53 |
54 | private fun onColorSelected(color: Int) {
55 | dismiss()
56 | listener(color)
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/edition/Step.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.edition
18 |
19 | data class Step(
20 | val canAdd: Boolean,
21 | val canSubtract: Boolean
22 | )
23 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/BaseLapAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import androidx.annotation.LayoutRes
20 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
21 | import com.sbgapps.scoreit.core.widget.ItemAdapter
22 |
23 | open class BaseLapAdapter(
24 | val model: T,
25 | @LayoutRes layoutId: Int,
26 | private val clickCallback: () -> Unit
27 | ) : ItemAdapter(layoutId) {
28 |
29 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
30 | viewHolder.itemView.setOnClickListener { clickCallback() }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/BeloteLapAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import com.sbgapps.scoreit.R
20 | import com.sbgapps.scoreit.app.model.BeloteLapRow
21 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
22 | import com.sbgapps.scoreit.databinding.ListItemLapBeloteCoincheBinding
23 |
24 | class BeloteLapAdapter(
25 | model: BeloteLapRow,
26 | clickCallback: () -> Unit
27 | ) : BaseLapAdapter(model, R.layout.list_item_lap_belote_coinche, clickCallback) {
28 |
29 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
30 | super.onBindViewHolder(viewHolder)
31 | val binding = ListItemLapBeloteCoincheBinding.bind(viewHolder.itemView)
32 | binding.recyclerView.adapter = LapResultAdapter(model.results)
33 | binding.done.setBackgroundResource(if (model.isWon) R.color.game_won else R.color.game_lost)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/CoincheLapAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import com.sbgapps.scoreit.R
20 | import com.sbgapps.scoreit.app.model.CoincheLapRow
21 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
22 | import com.sbgapps.scoreit.databinding.ListItemLapBeloteCoincheBinding
23 |
24 | class CoincheLapAdapter(
25 | model: CoincheLapRow,
26 | clickCallback: () -> Unit
27 | ) : BaseLapAdapter(model, R.layout.list_item_lap_belote_coinche, clickCallback) {
28 |
29 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
30 | super.onBindViewHolder(viewHolder)
31 | val binding = ListItemLapBeloteCoincheBinding.bind(viewHolder.itemView)
32 | binding.recyclerView.adapter = LapResultAdapter(model.results)
33 | binding.done.setBackgroundResource(if (model.isWon) R.color.game_won else R.color.game_lost)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/DonationAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import android.annotation.SuppressLint
20 | import androidx.annotation.CallSuper
21 | import com.sbgapps.scoreit.R
22 | import com.sbgapps.scoreit.app.model.DonationRow
23 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
24 | import com.sbgapps.scoreit.data.repository.Donation
25 | import com.sbgapps.scoreit.databinding.ListItemLapDonationBinding
26 |
27 | class DonationAdapter(
28 | model: DonationRow,
29 | private val callback: (donation: Donation) -> Unit
30 | ) : BaseLapAdapter(model, R.layout.list_item_lap_donation, {}) {
31 |
32 | @SuppressLint("SetTextI18n")
33 | @CallSuper
34 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
35 | val binding = ListItemLapDonationBinding.bind(viewHolder.itemView)
36 | binding.coffee.text = Donation.COFFEE.name
37 | binding.coffee.setOnClickListener { callback(Donation.COFFEE) }
38 | binding.beer.text = Donation.BEER.name
39 | binding.beer.setOnClickListener { callback(Donation.BEER) }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/HeaderAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import android.view.View
20 | import android.view.ViewGroup
21 | import androidx.core.view.isInvisible
22 | import com.sbgapps.scoreit.app.model.Header
23 | import com.sbgapps.scoreit.app.ui.widget.AdaptableLinearLayoutAdapter
24 | import com.sbgapps.scoreit.core.ext.layoutInflater
25 | import com.sbgapps.scoreit.databinding.ListItemHeaderBinding
26 |
27 | class HeaderAdapter(
28 | private val model: Header,
29 | private val editCallback: (position: Int) -> Unit
30 | ) : AdaptableLinearLayoutAdapter {
31 |
32 | override fun getView(position: Int, parent: ViewGroup): View {
33 | val binding = ListItemHeaderBinding.inflate(parent.layoutInflater(), parent, false)
34 | val player = model.players[position]
35 | binding.player.apply {
36 | text = player.name
37 | setTextColor(player.color)
38 | setOnClickListener { editCallback(position) }
39 | }
40 | binding.score.text = model.scores[position].toString()
41 | binding.marker.isInvisible = !model.markers[position]
42 | return binding.root
43 | }
44 |
45 | override fun getCount(): Int = model.players.size
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/LapResultAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import android.view.View
20 | import android.view.ViewGroup
21 | import android.widget.TextView
22 | import com.sbgapps.scoreit.R
23 | import com.sbgapps.scoreit.app.ui.widget.AdaptableLinearLayoutAdapter
24 | import com.sbgapps.scoreit.core.ext.inflate
25 |
26 | class LapResultAdapter(private val model: List) : AdaptableLinearLayoutAdapter {
27 |
28 | override fun getView(position: Int, parent: ViewGroup): View {
29 | val view = parent.inflate(R.layout.list_item_lap_result) as TextView
30 | view.text = model[position]
31 | return view
32 | }
33 |
34 | override fun getCount(): Int = model.size
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/TarotLapAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import com.sbgapps.scoreit.R
20 | import com.sbgapps.scoreit.app.model.TarotLapRow
21 | import com.sbgapps.scoreit.core.utils.string.build
22 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
23 | import com.sbgapps.scoreit.databinding.ListItemLapTarotBinding
24 |
25 | class TarotLapAdapter(
26 | model: TarotLapRow,
27 | clickCallback: () -> Unit
28 | ) : BaseLapAdapter(model, R.layout.list_item_lap_tarot, clickCallback) {
29 |
30 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
31 | super.onBindViewHolder(viewHolder)
32 | val binding = ListItemLapTarotBinding.bind(viewHolder.itemView)
33 | binding.info.text = model.info.build(viewHolder.context)
34 | binding.recyclerView.adapter = LapResultAdapter(model.results)
35 | binding.done.setBackgroundResource(if (model.isWon) R.color.game_won else R.color.game_lost)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/history/adapter/UniversalLapAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.history.adapter
18 |
19 | import com.sbgapps.scoreit.R
20 | import com.sbgapps.scoreit.app.model.UniversalLapRow
21 | import com.sbgapps.scoreit.app.ui.widget.AdaptableLinearLayout
22 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
23 |
24 | class UniversalLapAdapter(
25 | model: UniversalLapRow,
26 | clickCallback: () -> Unit
27 | ) : BaseLapAdapter(model, R.layout.list_item_lap_universal, clickCallback) {
28 |
29 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
30 | super.onBindViewHolder(viewHolder)
31 | (viewHolder.itemView as AdaptableLinearLayout).adapter = LapResultAdapter(model.results.map { it.toString() })
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/prefs/PreferencesViewModel.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.prefs
18 |
19 | import androidx.lifecycle.ViewModel
20 | import com.sbgapps.scoreit.core.utils.convertThemeMode
21 | import com.sbgapps.scoreit.data.source.DataStore
22 |
23 | class PreferencesViewModel(private val dataStore: DataStore) : ViewModel() {
24 |
25 | fun isUniversalTotalDisplayed(): Boolean = dataStore.isUniversalTotalDisplayed()
26 |
27 | fun setUniversalTotalDisplayed(displayed: Boolean) {
28 | dataStore.setUniversalTotalDisplayed(displayed)
29 | }
30 |
31 | fun isBeloteScoreRounded(): Boolean = dataStore.isBeloteScoreRounded()
32 |
33 | fun setBeloteScoreRounded(rounded: Boolean) {
34 | dataStore.setBeloteScoreRounded(rounded)
35 | }
36 |
37 | fun isCoincheScoreRounded(): Boolean = dataStore.isCoincheScoreRounded()
38 |
39 | fun setCoincheScoreRounded(rounded: Boolean) {
40 | dataStore.setCoincheScoreRounded(rounded)
41 | }
42 |
43 | fun getPrefThemeMode(): String = dataStore.getPrefThemeMode()
44 |
45 | fun setPrefThemeMode(mode: String) {
46 | dataStore.setPrefThemeMode(mode)
47 | }
48 |
49 | fun getThemeMode(): Int = convertThemeMode(getPrefThemeMode())
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/saved/SavedGameAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.saved
18 |
19 | import com.sbgapps.scoreit.R
20 | import com.sbgapps.scoreit.core.widget.BaseViewHolder
21 | import com.sbgapps.scoreit.core.widget.ItemAdapter
22 | import com.sbgapps.scoreit.databinding.ListItemSavedGamesBinding
23 |
24 | class SavedGameAdapter(
25 | private val fileName: String,
26 | private val players: String,
27 | private val lastModified: String,
28 | private val callback: (fileName: String) -> Unit
29 | ) : ItemAdapter(R.layout.list_item_saved_games) {
30 |
31 | private lateinit var binding: ListItemSavedGamesBinding
32 |
33 | override fun onBindViewHolder(viewHolder: BaseViewHolder) {
34 | binding = ListItemSavedGamesBinding.bind(viewHolder.itemView)
35 | binding.fileName.text = fileName
36 | binding.players.text = players
37 | binding.lastModified.text = lastModified
38 | binding.root.setOnClickListener { callback(fileName) }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/sbgapps/scoreit/app/ui/widget/AdaptableLinearLayout.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.app.ui.widget
18 |
19 | import android.content.Context
20 | import android.util.AttributeSet
21 | import android.view.View
22 | import android.view.ViewGroup
23 | import android.widget.LinearLayout
24 | import com.sbgapps.scoreit.R
25 | import com.sbgapps.scoreit.core.ext.inflate
26 |
27 | class AdaptableLinearLayout @JvmOverloads constructor(
28 | context: Context,
29 | attrs: AttributeSet? = null,
30 | defStyleAttr: Int = 0
31 | ) : LinearLayout(context, attrs, defStyleAttr) {
32 |
33 | init {
34 | if (isInEditMode) repeat(4) {
35 | inflate(R.layout.tools_linearlistview_preview, true)
36 | }
37 | }
38 |
39 | var adapter: AdaptableLinearLayoutAdapter? = null
40 | set(adapter) {
41 | field = adapter
42 | setupChildren()
43 | }
44 |
45 | private fun setupChildren() {
46 | removeAllViews()
47 | adapter?.let {
48 | (0 until it.getCount()).forEach { i ->
49 | addView(it.getView(i, this))
50 | }
51 | }
52 | }
53 | }
54 |
55 | interface AdaptableLinearLayoutAdapter {
56 | fun getView(position: Int, parent: ViewGroup): View
57 | fun getCount(): Int
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
20 |
21 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
20 |
21 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/color/csl_secondary_enabled.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_back_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_drop_down_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_backspace_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_rate_review_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_beer_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_cancel_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_circle_color.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
21 |
22 |
23 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_clear_all_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_donate_coffee_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_done_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_edit_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_email_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_github_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_heart_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
23 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_list_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_messenger_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_minus_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
23 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_people_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_plus_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
23 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_refresh_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_show_chart_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_swap_horiz_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_unarchive_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edition_universal.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
25 |
26 |
31 |
32 |
37 |
38 |
39 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_saved_games.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
24 |
25 |
30 |
31 |
36 |
37 |
38 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_edit_name.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
24 |
28 |
29 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_chart.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_color_picker.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_nav_drawer.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_color.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
24 |
25 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_edition_bonus.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
27 |
36 |
37 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_lap_belote_coinche.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
30 |
31 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_lap_result.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_lap_universal.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tools_linearlistview_preview.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_edition.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/nav_drawer.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StephaneBg/ScoreIt/7684d40c56c3293b1e9b06158efcbefa51693f7a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | @color/md_green_400
19 | @color/md_orange_300
20 | #121212
21 | #1A1A1A
22 |
23 | @color/md_white_1000
24 | @color/md_white_1000
25 | @color/md_white_1000
26 | @color/md_grey_800
27 |
28 | #121212
29 | #121212
30 |
31 | @color/md_green_300
32 | @color/md_red_300
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v23/colors.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | @color/md_grey_50
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v27/colors.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | @color/md_grey_50
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 | @color/md_green_600
18 | @color/md_orange_500
19 | @color/md_grey_50
20 | @color/md_white_1000
21 |
22 | @color/md_white_1000
23 | @color/md_white_1000
24 | @color/md_grey_800
25 | @color/md_grey_200
26 |
27 | @color/md_black_1000
28 | @color/md_black_1000
29 |
30 | @color/md_green_400
31 | @color/md_red_400
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 92dp
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | #FAFAFA
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/integers.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 150
19 | 300
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/shape.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
23 |
24 |
28 |
29 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values/type.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | buildscript {
18 |
19 | repositories {
20 | mavenCentral()
21 | google()
22 | }
23 |
24 | dependencies {
25 | classpath(libs.kotlin.gradlePlugin)
26 | classpath(libs.android.gradlePlugin)
27 | }
28 |
29 | }
30 |
31 | plugins {
32 | id("com.google.devtools.ksp") version "1.9.10-1.0.13" apply false
33 | }
34 |
35 | allprojects {
36 | tasks.withType {
37 | kotlinOptions {
38 | jvmTarget = "1.8"
39 | }
40 | }
41 | }
42 |
43 | subprojects {
44 | afterEvaluate {
45 | extensions.configure {
46 | compileOptions {
47 | sourceCompatibility = JavaVersion.VERSION_1_8
48 | targetCompatibility = JavaVersion.VERSION_1_8
49 | }
50 | }
51 | }
52 | }
53 |
54 | tasks.create("clean") {
55 | delete(rootProject.buildDir)
56 | }
57 |
--------------------------------------------------------------------------------
/cache/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | plugins {
18 | id("com.android.library")
19 | id("kotlin-android")
20 | }
21 |
22 | android {
23 | namespace = "com.sbgapps.scoreit.cache"
24 | compileSdk = libs.versions.compileSdk.get().toInt()
25 |
26 | defaultConfig {
27 | minSdk = libs.versions.minSdk.get().toInt()
28 | }
29 |
30 | sourceSets {
31 | getByName("main").java.srcDirs("src/main/kotlin")
32 | }
33 |
34 | compileOptions {
35 | isCoreLibraryDesugaringEnabled = true
36 | }
37 | }
38 |
39 | dependencies {
40 | implementation(project(":data"))
41 | implementation(project(":core"))
42 |
43 | implementation(libs.androidx.coreKtx)
44 | implementation(libs.androidx.preference)
45 | implementation(libs.moshi.kotlin)
46 | implementation(libs.moshi.adapters)
47 | implementation(libs.billingKtx)
48 | implementation(libs.storage)
49 | implementation(libs.koinAndroidX)
50 | implementation(libs.timber)
51 |
52 | coreLibraryDesugaring(libs.desugaring)
53 | }
54 |
--------------------------------------------------------------------------------
/cache/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/cache/src/main/kotlin/com/sbgapps/scoreit/cache/repository/ScoreItBillingRepo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.cache.repository
18 |
19 | import android.app.Activity
20 | import com.android.billingclient.api.BillingClientStateListener
21 | import com.android.billingclient.api.BillingResult
22 | import com.android.billingclient.api.Purchase
23 | import com.android.billingclient.api.PurchasesUpdatedListener
24 | import com.sbgapps.scoreit.data.repository.BillingRepo
25 | import com.sbgapps.scoreit.data.repository.Donation
26 |
27 | class ScoreItBillingRepo : BillingRepo, PurchasesUpdatedListener, BillingClientStateListener {
28 |
29 | override fun getDonationSkus(): List? = null
30 |
31 | override fun startBillingFlow(activity: Activity, donation: Donation, callback: () -> Unit) =
32 | Unit
33 |
34 | override fun onPurchasesUpdated(result: BillingResult, purchases: MutableList?) = Unit
35 |
36 | override fun onBillingServiceDisconnected() = Unit
37 |
38 | override fun onBillingSetupFinished(result: BillingResult) = Unit
39 | }
40 |
--------------------------------------------------------------------------------
/cache/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 | Ma première partie
21 |
22 |
23 | Eux
24 | Nous
25 |
26 |
27 | Locaux
28 | Visiteurs
29 |
--------------------------------------------------------------------------------
/cache/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 | - @color/md_orange_700
21 | - @color/md_green_700
22 | - @color/md_blue_700
23 | - @color/md_red_700
24 | - @color/md_purple_700
25 | - @color/md_teal_700
26 | - @color/md_brown_700
27 | - @color/md_cyan_700
28 | - @color/md_lime_700
29 | - @color/md_blue_grey_700
30 | - @color/md_cyan_700
31 | - @color/md_indigo_700
32 | - @color/md_amber_700
33 | - @color/md_deep_purple_700
34 |
35 |
36 |
37 | - Riri
38 | - Fifi
39 | - Loulou
40 | - Toto
41 | - Titi
42 | - Lulu
43 | - Lili
44 | - Tutu
45 |
46 |
--------------------------------------------------------------------------------
/cache/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 | My first game
20 |
21 |
22 | Them
23 | Us
24 |
25 |
26 | Home
27 | Guest
28 |
--------------------------------------------------------------------------------
/core/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | plugins {
18 | id("com.android.library")
19 | id("kotlin-android")
20 | }
21 |
22 | android {
23 | namespace = "com.sbgapps.scoreit.core"
24 | compileSdk = libs.versions.compileSdk.get().toInt()
25 |
26 | defaultConfig {
27 | minSdk = libs.versions.minSdk.get().toInt()
28 | }
29 |
30 | sourceSets {
31 | getByName("main").java.srcDirs("src/main/kotlin")
32 | }
33 |
34 | compileOptions {
35 | isCoreLibraryDesugaringEnabled = true
36 | }
37 | }
38 |
39 | dependencies {
40 | implementation(libs.coroutines.android)
41 | implementation(libs.androidx.appCompat)
42 | implementation(libs.androidx.coreKtx)
43 | implementation(libs.androidx.fragmentKtx)
44 | implementation(libs.androidx.lifecyleViewmodel)
45 | implementation(libs.material)
46 | implementation(libs.koinAndroidX)
47 | implementation(libs.timber)
48 | implementation(libs.bundles.androidx.lifecycle)
49 |
50 | coreLibraryDesugaring(libs.desugaring)
51 | }
52 |
--------------------------------------------------------------------------------
/core/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/com/sbgapps/scoreit/core/ext/Collection.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.core.ext
18 |
19 | infix fun Collection.sameContentWith(collection: Collection) =
20 | collection.let { this.size == it.size && this.containsAll(it) }
--------------------------------------------------------------------------------
/core/src/main/kotlin/com/sbgapps/scoreit/core/ext/DiffUtil.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.core.ext
18 |
19 | import androidx.recyclerview.widget.DiffUtil
20 |
21 | fun DiffUtil.Callback.calculateDiff() = DiffUtil.calculateDiff(this)
--------------------------------------------------------------------------------
/core/src/main/kotlin/com/sbgapps/scoreit/core/ext/Fragment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.core.ext
18 |
19 | import android.view.View
20 | import androidx.fragment.app.Fragment
21 |
22 | inline fun Fragment.find(id: Int): T = view?.findViewById(id) as T
--------------------------------------------------------------------------------
/core/src/main/kotlin/com/sbgapps/scoreit/core/ext/FragmentActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.core.ext
18 |
19 | import android.os.Build
20 | import android.view.View
21 | import androidx.fragment.app.Fragment
22 | import androidx.fragment.app.FragmentActivity
23 | import androidx.fragment.app.commit
24 |
25 | fun FragmentActivity.addFragment(
26 | frameId: Int,
27 | fragment: Fragment,
28 | addToBackStack: Boolean = false
29 | ) = supportFragmentManager.commit {
30 | add(frameId, fragment)
31 | if (addToBackStack) addToBackStack(null)
32 | }
33 |
34 | fun FragmentActivity.addFragment(
35 | frameId: Int,
36 | fragment: Fragment,
37 | addToBackStack: Boolean = false,
38 | animIn: Int,
39 | animOut: Int
40 | ) = supportFragmentManager.commit {
41 | setCustomAnimations(animIn, animOut, animIn, animOut)
42 | add(frameId, fragment)
43 | if (addToBackStack) addToBackStack(null)
44 | }
45 |
46 | fun FragmentActivity.replaceFragment(
47 | frameId: Int,
48 | fragment: Fragment,
49 | addToBackStack: Boolean = false
50 | ) = supportFragmentManager.commit {
51 | replace(frameId, fragment)
52 | if (addToBackStack) addToBackStack(null)
53 | }
54 |
55 | fun FragmentActivity.replaceFragment(
56 | frameId: Int,
57 | fragment: Fragment,
58 | addToBackStack: Boolean = false,
59 | animIn: Int,
60 | animOut: Int
61 | ) = supportFragmentManager.commit {
62 | setCustomAnimations(animIn, animOut, animIn, animOut)
63 | replace(frameId, fragment)
64 | if (addToBackStack) addToBackStack(null)
65 | }
66 |
67 | fun FragmentActivity.setLightStatusBar() {
68 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
69 | var flags = window.decorView.systemUiVisibility
70 | flags = flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
71 | window.decorView.systemUiVisibility = flags
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/com/sbgapps/scoreit/core/ext/LifecycleOwner.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.core.ext
18 |
19 | import androidx.lifecycle.LifecycleOwner
20 | import androidx.lifecycle.LiveData
21 | import androidx.lifecycle.Observer
22 |
23 | fun > LifecycleOwner.observe(liveData: L, body: (T?) -> Unit) {
24 | liveData.observe(this, Observer(body))
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/com/sbgapps/scoreit/core/ext/List.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.core.ext
18 |
19 | @Suppress("UNCHECKED_CAST")
20 | inline fun List<*>.asListOfType(): List = this as List
21 |
22 | @Suppress("UNCHECKED_CAST")
23 | inline fun List<*>.asMutableListOfType(): MutableList = this.toMutableList() as MutableList
24 |
25 | inline fun List.replace(index: Int, element: E): List = this.mapIndexed { i, e ->
26 | if (index == i) element else e
27 | }
28 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/com/sbgapps/scoreit/core/ext/Menu.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Stéphane Baiget
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.sbgapps.scoreit.core.ext
18 |
19 | import android.view.Menu
20 | import android.view.MenuItem
21 |
22 | val Menu.items: List