Skip to content

Commit

Permalink
Merge pull request #25 from Entreco/develop
Browse files Browse the repository at this point in the history
0.2.1-Barney
  • Loading branch information
Entreco committed Jan 6, 2018
2 parents 00b8d2a + 1557399 commit 34960ac
Show file tree
Hide file tree
Showing 93 changed files with 1,536 additions and 504 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ freeline/
freeline_project_description.json

android/DartsScorecard/\.idea/

android/DartsScorecard/scripts/dsc_keystore

android/DartsScorecard/app/lint-report\.html

release/

*.exec

android/DartsScorecard/dig/web/
**/dig/web/
**/lint-report\.html
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ cache:
- $HOME/.gradle/native #Cache library downloaded from the gradle dependency
env:
global:
- ANDROID_API=26
- ANDROID_API=27
- EMULATOR_API=26
- ANDROID_BUILD_TOOLS=26.0.2
- ANDROID_BUILD_TOOLS=27.0.3
- ADB_INSTALL_TIMEOUT=5
- secure: UH6Td9+MFk1nsYYMKN9t6/XcMmSZtB+L4sWMUmYBMaK1Q6YnGCnyHmU5RWkP+9a3AiZQ+n9XK+9TV+azMxJzyOoPMEzvBYtienvI1ZwTg+gqVOsMGG8TKubdgBfYQKm+mtdc3ctgucqjRg0yb4aUDp4CeNwwCuX1zuzIaAYp8IgRElkJzhJMeTcrCUWTBNk2F9ix0eRyOKOCIwgiAa6wNn1zMRvpbPh3esJ7CcnC0xesBtWriFtJDKFhPPWowPrWhGerLe3y5oNySqPpjxfBDIU9HPThNLNwBgp25Ww2c4Ib4Im0p59dPyKBU8mv3eoHvWtrSYW0bZQfKuJD6JsI0wg7Afx2hOxhPWw2evwjmhYWEfspSTUDUZIV/BhLhR2WbeZgAgd1gBh1ulxe79kne1FLsojVr+wZXA5Cn1TF2R4pnTj8EYLctbz/J1/sbcKwut6+I4z7FgbLDOEvaHTJZiscotR0ofML6OoYkKba8LznCES8RqYc3oyCKJvRD5oiVyHhMScAptMeignnPCGmhzm2evpclZfjoZ6vGyI/MgZML4as7WWz1FuiaNV+vJx6PyuNzBjYyNpKJ7O/G4yUT6EITrw3UPVCaSJr6eM3o8eAjy8XTkFsuRJ4iEhMAGiDRlvIlAMrUQyp8PxxvKB9YS6skFfAXXAUp59m/PLbRc0=
- secure: b9RwM5JGKpo0axCpeqDx9WZfZppiJWKF6d1zxTpO6cIiUmsgpL2GQy1fK/jHzKA1mlFIgq87pu11M696PqPJq7RadkeqlhKAq0zw8lBphg5Tn50wZUglusvIbMPC4VnsFLNeBd3elZIepglbh994sQxxpCpc8IF29x8cj//xrR6Z+EvyWYjnLgtbQjjdql6K0JRhGyTn+FXe5qLxmgu2lc4QL/RBcpnF+gpLrFfzBf/M/ruSyLjjpLZLCtzz90dAD/Ewb+sLvlfM0SUbXvFg+P2YoSo7rbDum+l45S6meIs6ygqcpb/3ByL9pSK3XEzrqLFQFggST8Puy8pHkwL8IVLuOtTPiO2HUtyzbTJLbEmupwEr6nXF2xtQE4vqgCNCLd63JxldRf3D2nrLG9OXJMlQRzkAfYtXj15tqyDfiLlCzIocfASsj/MF8XKzeR45+6GC9KLULpR0s1MdxYYhhb+Ss4sV8VElC3C4mlQiCA6G5AOJtPcnUshGNXbw3oWotJgY76IEJG2gSnb2SSI94VuXCI/39DLxXoTF1knixdaFJOO2QvBU2b8eZKrU4w1+rUrSfIMnBdn27hdqs+uKYNuJIwtMMCcrFtZmZnKjXcBwjgQdm51gWuMiJN5S8xM8turo23jL2Cak7rXn8RUmLHbhu3Jpl8iQzQOPFm1zmkg=
Expand All @@ -35,6 +35,7 @@ android:
- android-sdk-license-.+
- google-gdk-license-.+
before_install:
- yes | sdkmanager "platforms;android-27"
- openssl aes-256-cbc -K $encrypted_c5c67234e863_key -iv $encrypted_c5c67234e863_iv
-in android/DartsScorecard/scripts/dsc_keystore.enc -out android/DartsScorecard/scripts/dsc_keystore
-d
Expand Down
34 changes: 4 additions & 30 deletions android/DartsScorecard/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,25 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.getkeepsafe.dexcount'
apply from: '../scripts/versioning.gradle'
apply from: '../scripts/coverage.gradle'
apply from: '../scripts/android_common.gradle'

android {
def config = rootProject.extensions.getByName("ext")
compileSdkVersion config.androidCompileSdkVersion
buildToolsVersion config.androidBuildToolsVersion

def config = rootProject.extensions.getByName("ext")
defaultConfig {
applicationId "nl.entreco.dartsscorecard"
minSdkVersion config.androidMinSdkVersion
targetSdkVersion config.androidTargetSdkVersion
versionCode config.versionCode
versionName config.versionName

resConfigs "en", "nl"

resValue "string", "version", "${config.versionName}"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
debug {
testCoverageEnabled true
}
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions {
htmlReport true
htmlOutput file("lint-report.html")
abortOnError false
}

dataBinding {
enabled = true
}

testOptions {
unitTests.returnDefaultValues = true
}
}

dependencies {
Expand Down Expand Up @@ -82,6 +58,4 @@ dependencies {
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoCore"
}

apply plugin: 'com.google.gms.google-services'


apply plugin: 'com.google.gms.google-services'
13 changes: 10 additions & 3 deletions android/DartsScorecard/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@
</intent-filter>
</activity>
<activity android:name=".launch.LaunchActivity" />
<activity android:name=".setup.Setup01Activity" />
<activity android:name=".setup.edit.EditPlayerActivity" />
<activity android:name=".play.Play01Activity" />
<activity
android:name=".setup.Setup01Activity"
android:parentActivityName=".launch.LaunchActivity" />
<activity
android:name=".setup.edit.EditPlayerActivity"
android:parentActivityName=".setup.Setup01Activity"
android:windowSoftInputMode="adjustResize"/>
<activity
android:name=".play.Play01Activity"
android:parentActivityName=".launch.LaunchActivity" />

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ abstract class TestableAdapter<T : RecyclerView.ViewHolder?> : RecyclerView.Adap
}
}

protected fun tryNotifyItemRangeInserted(position: Int, count: Int) {
try {
notifyItemRangeInserted(position, count)
} catch (ignore: NullPointerException) {
}
}

protected fun tryNotifyItemRangeChanged(position: Int, count: Int) {
try {
notifyItemRangeChanged(position, count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import android.arch.lifecycle.ViewModelProvider
import android.arch.lifecycle.ViewModelProviders
import android.os.Bundle
import android.preference.PreferenceManager
import android.support.annotation.StringRes
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import nl.entreco.dartsscorecard.App
import nl.entreco.dartsscorecard.R
import nl.entreco.dartsscorecard.di.viewmodel.ViewModelComponent
import nl.entreco.dartsscorecard.di.viewmodel.ViewModelModule

Expand Down Expand Up @@ -52,4 +55,10 @@ abstract class ViewModelActivity : AppCompatActivity() {
protected fun swapStyle() {
styler.switch()
}

protected fun initToolbar(toolbar: Toolbar, @StringRes title: Int = R.string.app_name, showHomeEnabled: Boolean = true) {
setSupportActionBar(toolbar)
setTitle(title)
supportActionBar?.setDisplayHomeAsUpEnabled(showHomeEnabled)
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
package nl.entreco.dartsscorecard.di.setup

import android.content.Context
import dagger.Module
import dagger.Provides
import nl.entreco.dartsscorecard.setup.Setup01Activity
import nl.entreco.dartsscorecard.setup.Setup01Navigator
import nl.entreco.dartsscorecard.setup.players.PlayerEditor
import nl.entreco.data.setup.repository.SharedPreferenceRepo
import nl.entreco.domain.repository.PreferenceRepository

/**
* Created by Entreco on 20/12/2017.
*/
@Module
class Setup01Module(private val activity: Setup01Activity) {
class Setup01Module(activity: Setup01Activity) {

private val navigator = Setup01Navigator(activity)
private val prefs = activity.getSharedPreferences("setup", Context.MODE_PRIVATE)

@Provides
@Setup01Scope
fun provideNavigator(): Setup01Navigator {
return Setup01Navigator(activity)
return navigator
}

@Provides
@Setup01Scope
fun providePlayerEditor(): PlayerEditor {
return navigator
}

@Provides
@Setup01Scope
fun providePreferenceRepo(): PreferenceRepository {
return SharedPreferenceRepo(prefs)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v7.widget.Toolbar
import android.view.Menu
import android.view.MenuItem
import nl.entreco.dartsscorecard.R
Expand Down Expand Up @@ -39,11 +40,16 @@ class Play01Activity : ViewModelActivity() {
initGame()
}

initToolbar(toolbar(binding))
resumeGame()
}

private fun initGame() {
viewModel.load(retrieveSetup(), scoreViewModel)
viewModel.load(retrieveSetup(intent), scoreViewModel)
}

private fun toolbar(binding: ActivityPlay01Binding): Toolbar {
return binding.includeToolbar?.toolbar!!
}

private fun resumeGame() {
Expand All @@ -65,13 +71,14 @@ class Play01Activity : ViewModelActivity() {
return super.onOptionsItemSelected(item)
}

private fun retrieveSetup(): RetrieveGameRequest {
return RetrieveGameRequest(intent.getLongExtra("gameId", -1),
TeamIdsString(intent.getStringExtra("teamIds")),
intent.getParcelableExtra("exec"))
}

companion object {
@JvmStatic
fun retrieveSetup(intent: Intent): RetrieveGameRequest {
return RetrieveGameRequest(intent.getLongExtra("gameId", -1),
TeamIdsString(intent.getStringExtra("teamIds")),
intent.getParcelableExtra("exec"))
}

@JvmStatic
fun startGame(context: Context, retrieve: RetrieveGameRequest) {
val intent = Intent(context, Play01Activity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import android.support.v4.graphics.ColorUtils
import android.util.Log
import android.util.TypedValue
import android.view.animation.AccelerateDecelerateInterpolator
import android.view.animation.OvershootInterpolator
import android.view.animation.AccelerateInterpolator
import android.view.animation.DecelerateInterpolator
import android.widget.ImageView
import android.widget.TextView
import nl.entreco.dartsscorecard.R
Expand All @@ -35,33 +36,44 @@ abstract class TeamScoreBindings {
val diff = oldScore - score
when (diff) {
180 -> handle180(view)
0 -> {}
else -> { clear(view, 0)}
0 -> { }
else -> {
clear(view)
}
}
}

private fun clear(view: TextView, delay: Long) {
view.animate().cancel()
view.animate().translationX(200F).setStartDelay(delay).withEndAction({
view.setText( R.string.empty )
}).setDuration(DEFAULT_ANIMATION_TIME).start()
private fun clear(view: TextView, delay: Long = 0) {
view.animate().scaleY(0F).setStartDelay(delay)
.setInterpolator(DecelerateInterpolator())
.withStartAction {
view.pivotY = view.height.toFloat()
}
.withEndAction({
view.scaleY = 0F
view.translationY = 0F
view.setText(R.string.empty)
}).setDuration(if (delay == 0L) 0 else DEFAULT_ANIMATION_TIME).start()
}

private fun handle180(view: TextView) {
view.animate().cancel()
view.setText( R.string.score_180 )
view.animate().translationX(0F).setInterpolator(OvershootInterpolator()).setDuration(DEFAULT_ANIMATION_TIME)
view.setText(R.string.score_180)
view.animate().scaleY(1F).setDuration(DEFAULT_ANIMATION_TIME)
.setInterpolator(AccelerateInterpolator())
.withStartAction {
view.scaleY = 0F
view.pivotY = 0F
}
.withEndAction({
val howLong = 1200L
animateColor(view, R.attr.colorOneEighty, R.attr.scoreText, howLong)
clear(view, howLong)
animateColor(view, R.attr.colorOneEighty, R.attr.scoreText, 1200L)
clear(view, 1200L)
}).start()
}

private fun animateColor(view: TextView, attr: Int, attr2: Int, duration: Long) {
view.animate().setDuration(duration / 3)
.setStartDelay(duration / 3)
.withStartAction{ view.setTextColor(fromAttr(view.context, attr)) }
.withStartAction { view.setTextColor(fromAttr(view.context, attr)) }
.withEndAction { view.setTextColor(fromAttr(view.context, attr2)) }
.start()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package nl.entreco.dartsscorecard.setup

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v7.widget.Toolbar
import nl.entreco.dartsscorecard.R
import nl.entreco.dartsscorecard.base.ViewModelActivity
import nl.entreco.dartsscorecard.databinding.ActivitySetup01Binding
import nl.entreco.dartsscorecard.di.setup.Setup01Component
import nl.entreco.dartsscorecard.di.setup.Setup01Module
import nl.entreco.dartsscorecard.setup.ad.AdViewModel
import nl.entreco.dartsscorecard.setup.edit.EditPlayerActivity
import nl.entreco.dartsscorecard.setup.players.PlayersViewModel
import nl.entreco.dartsscorecard.setup.settings.SettingsViewModel

Expand All @@ -25,6 +24,7 @@ class Setup01Activity : ViewModelActivity() {
private val playersViewModel: PlayersViewModel by viewModelProvider { component.players() }
private val adsViewModel: AdViewModel by viewModelProvider { component.ads() }
private val settingsViewModel: SettingsViewModel by viewModelProvider { component.settings() }
private val navigator: Setup01Navigator by lazy { Setup01Navigator(this) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -33,17 +33,19 @@ class Setup01Activity : ViewModelActivity() {
binding.playersViewModel = playersViewModel
binding.adsViewModel = adsViewModel
binding.settingsViewModel = settingsViewModel
binding.navigator = Setup01Navigator(this).apply { onAddNewPlayer(playersViewModel.adapter) }
binding.navigator = navigator

navigator.onAddNewPlayer(0)
initToolbar(toolbar(binding), R.string.title_setup)
}

private fun toolbar(binding: ActivitySetup01Binding): Toolbar {
return binding.includeToolbar?.toolbar!!
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && requestCode == EditPlayerActivity.REQUEST_CODE) {
val oldName = data?.getStringExtra("oldName")!!
val playerName = data.getStringExtra("playerName")!!
val teamIndex = data.getIntExtra("teamIndex", -1)
playersViewModel.handlePlayerUpdated(oldName, playerName, teamIndex)
}
navigator.handleResult(requestCode, resultCode, data, playersViewModel.adapter)
}

companion object {
Expand Down
Loading

0 comments on commit 34960ac

Please sign in to comment.