Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Entreco committed Mar 30, 2018
2 parents 302a484 + 8211926 commit 5fb4c98
Show file tree
Hide file tree
Showing 602 changed files with 9,635 additions and 7,363 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ release/

**/dig/web/
**/lint-report\.html

store/recordings/

\.DS_Store

store/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ before_install:
- 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
- openssl aes-256-cbc -K $encrypted_5b6e56c7f62f_key -iv $encrypted_5b6e56c7f62f_iv -in android/DartsScorecard/app/google-services.json.enc -out android/DartsScorecard/app/google-services.json -d
- openssl aes-256-cbc -K $encrypted_60401f83f63b_key -iv $encrypted_60401f83f63b_iv -in android/DartsScorecard/app/google-services.json.enc -out android/DartsScorecard/app/google-services.json -d

- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
Expand Down
19 changes: 11 additions & 8 deletions android/DartsScorecard/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
Expand All @@ -8,32 +9,30 @@ apply from: '../scripts/coverage.gradle'
apply from: '../scripts/android_common.gradle'

android {

def config = rootProject.extensions.getByName("ext")
defaultConfig {
applicationId "nl.entreco.dartsscorecard"
resValue "string", "version", "${config.versionName}"
}

buildTypes {
debug {
applicationIdSuffix ".dev"
}
release {
shrinkResources true
}
}

dataBinding {
enabled = true
}
}

dependencies {

implementation project(":domain")
implementation project(":data")
implementation project(':domain')
implementation project(':data')

// Annotation Processing
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
kapt "com.android.databinding:compiler:$gradleVersion"
kapt "android.arch.persistence.room:compiler:$room"

// Implementation
Expand All @@ -47,6 +46,10 @@ dependencies {
implementation "android.arch.lifecycle:extensions:$architecture"
implementation "android.arch.persistence.room:runtime:$room"
implementation "com.squareup.picasso:picasso:$picasso"
implementation "de.hdodenhof:circleimageview:$circleImageView"
implementation("com.crashlytics.sdk.android:crashlytics:$crash") {
transitive = true
}

// Test
testImplementation "junit:junit:$junit"
Expand All @@ -59,4 +62,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'
Binary file modified android/DartsScorecard/app/google-services.json.enc
Binary file not shown.
5 changes: 5 additions & 0 deletions android/DartsScorecard/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

-keepattributes Signature

# Crashlytics
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

# Google Play Services
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class Play01ActivityTest {
@Test
fun `it should have correct package name`() {
fun itShouldHaveCorrectPackageName() {
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("nl.entreco.dartsscorecard", appContext.packageName)
}
Expand Down
13 changes: 12 additions & 1 deletion android/DartsScorecard/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nl.entreco.dartsscorecard">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:name=".App"
android:allowBackup="true"
Expand Down Expand Up @@ -32,7 +34,16 @@
<activity
android:name=".play.Play01Activity"
android:parentActivityName=".launch.LaunchActivity" />
<activity
android:name=".profile.select.SelectProfileActivity"
android:parentActivityName=".launch.LaunchActivity" />
<activity
android:name=".profile.view.ProfileActivity"
android:parentActivityName=".launch.LaunchActivity" />
<activity
android:name=".profile.edit.EditPlayerNameActivity"
android:parentActivityName=".profile.view.ProfileActivity" />

</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class App : Application() {
private fun initAdMob() {
MobileAds.initialize(this, "ca-app-pub-3793327349392749~1846337901")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package nl.entreco.dartsscorecard.base

import android.support.v7.app.AlertDialog
import nl.entreco.dartsscorecard.R
import nl.entreco.domain.model.players.Team
import javax.inject.Inject

/**
* Created by entreco on 20/02/2018.
*/
class DialogHelper @Inject constructor(private val builder: AlertDialog.Builder) {

fun revanche(previousIndex: Int, teams: Array<Team>, select: (Int) -> Unit) {

if (onlyOneTeam(teams)) {
select(0)
} else if (moreThanOneTeam(teams)) {
var selectedIndex = previousIndex
builder
.setTitle(R.string.select_starting_team)
.setSingleChoiceItems(teams.map { it.toString() }.toTypedArray(), previousIndex, { _, which ->
selectedIndex = which
})
.setPositiveButton(android.R.string.ok, { dialog, _ ->
select(selectedIndex)
dialog.dismiss()
})
.setNegativeButton(R.string.cancel, { dialog, _ ->
dialog.dismiss()
})
.create()
.show()
}
}

private fun onlyOneTeam(teams: Array<Team>) = teams.size == 1
private fun moreThanOneTeam(teams: Array<Team>) = teams.size > 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package nl.entreco.dartsscorecard.base

import android.transition.Transition
import android.transition.TransitionInflater
import android.view.View
import android.view.ViewAnimationUtils
import android.view.Window
import android.view.animation.AccelerateInterpolator
import nl.entreco.dartsscorecard.R
import kotlin.math.max

/**
* Created by entreco on 02/03/2018.
*/
class RevealAnimator(private val target: View) {

fun setupEnterAnimation(inflater: TransitionInflater?, window: Window, root: View, reverse: Boolean = true) {
if (inflater == null) return
val boundsTransition = inflater.inflateTransition(R.transition.change_bound_with_arc)
boundsTransition.duration = 100
window.sharedElementEnterTransition = boundsTransition
boundsTransition.addListener(object : Transition.TransitionListener {
override fun onTransitionEnd(transition: Transition?) {
if (!reverse) {
animateRevealShow(root)
}
boundsTransition.removeListener(this)
}

override fun onTransitionResume(transition: Transition?) {}

override fun onTransitionPause(transition: Transition?) {}

override fun onTransitionCancel(transition: Transition?) {}

override fun onTransitionStart(transition: Transition?) {
if (!reverse) {
root.visibility = View.INVISIBLE
}
}
})
}

private fun animateRevealShow(root: View) {
val cx = (target.left + target.right) / 2
val cy = (target.top + target.bottom) / 2
revealActivity(root, cx, cy)
}

private fun revealActivity(root: View, x: Int, y: Int) {
val radius = max(root.width * 1.0, root.height * 1.1).toFloat()
val circularReveal = ViewAnimationUtils.createCircularReveal(root, x, y, 0F, radius)
circularReveal.duration = 200
circularReveal.interpolator = AccelerateInterpolator()
root.visibility = View.VISIBLE
circularReveal.start()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package nl.entreco.dartsscorecard.base

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.helper.ItemTouchHelper
import nl.entreco.dartsscorecard.R
import kotlin.math.abs
import kotlin.math.min

/**
* Created by entreco on 17/03/2018.
*/
abstract class SwipeToDeleteCallback(context: Context) : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {

private val deleteIcon = ContextCompat.getDrawable(context, R.drawable.ic_swipe_delete)!!
private val intrinsicWidth = deleteIcon.intrinsicWidth
private val intrinsicHeight = deleteIcon.intrinsicHeight
private val background = ColorDrawable()
private val backgroundColor = Color.parseColor("#D9534F") // Pale red

override fun onMove(recyclerView: RecyclerView?, viewHolder: RecyclerView.ViewHolder?, target: RecyclerView.ViewHolder?): Boolean {
return false
}

override fun onChildDraw(canvas: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
val itemView = viewHolder.itemView
val itemHeight = itemView.bottom - itemView.top
background.color = backgroundColor
background.setBounds(itemView.right + dX.toInt(), itemView.top, itemView.right, itemView.bottom)
background.draw(canvas)

val deleteIconTop = itemView.top + (itemHeight - intrinsicHeight) / 2
val deleteIconMargin = (itemHeight - intrinsicHeight) / 2
val deleteIconLeft = itemView.right - deleteIconMargin - intrinsicWidth
val deleteIconRight = itemView.right - deleteIconMargin
val deleteIconBottom = deleteIconTop + intrinsicHeight

deleteIcon.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom)
deleteIcon.alpha = min(255, abs(dX).toInt())
deleteIcon.draw(canvas)

super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ abstract class TestableAdapter<T : RecyclerView.ViewHolder?> : RecyclerView.Adap
} catch (ignore: NullPointerException) {
}
}
protected fun tryNotifyItemRemoved(position: Int) {
try {
notifyItemRemoved(position)
} catch (ignore: NullPointerException) {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nl.entreco.dartsscorecard.base.widget

import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet

/**
* Created by entreco on 24/03/2018.
*/
class WrapContentViewPager(context: Context, attrs: AttributeSet?) : ViewPager(context, attrs) {
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val hms = getChildAt(0)?.let {child ->
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED))
MeasureSpec.makeMeasureSpec(child.measuredHeight, MeasureSpec.EXACTLY)
}
super.onMeasure(widthMeasureSpec, hms ?: heightMeasureSpec)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.os.Bundle
import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.Toolbar
import android.util.Log
import android.widget.Toast
import nl.entreco.dartsscorecard.R
import nl.entreco.dartsscorecard.base.ViewModelActivity
Expand Down Expand Up @@ -77,26 +76,25 @@ class BetaActivity : ViewModelActivity(), DonateCallback {

private fun initRecyclerView(binding: ActivityBetaBinding) {
val recyclerView = binding.betaRecyclerView
recyclerView.layoutManager = GridLayoutManager(binding.root.context!!, 2)
recyclerView.setHasFixedSize(true)
recyclerView.layoutManager = GridLayoutManager(binding.root.context, 2)
recyclerView.itemAnimator = DefaultItemAnimator()
recyclerView.isDrawingCacheEnabled = true
recyclerView.adapter = adapter

binding.swipeRefresh.setColorSchemeResources(R.color.colorPrimary, R.color.colorPrimaryDark)
}

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

override fun onBackPressed() {
animator.onBackPressed() ?: super.onBackPressed()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
Log.w("DONATE", "onActivityResult: $requestCode, $data")
when {
donateOk(requestCode, resultCode, data) -> donateViewModel.onMakeDonationSuccess(data)
requestCode == REQ_CODE_DONATE -> donateViewModel.onMakeDonationFailed(resultCode, data)
requestCode == REQ_CODE_DONATE -> donateViewModel.onMakeDonationFailed()
else -> super.onActivityResult(requestCode, resultCode, data)
}
}
Expand All @@ -122,6 +120,6 @@ class BetaActivity : ViewModelActivity(), DonateCallback {
}

private fun donateOk(requestCode: Int, resultCode: Int, data: Intent?) =
requestCode == REQ_CODE_DONATE && resultCode == Activity.RESULT_OK && data?.getIntExtra("RESPONSE_CODE", 0) != 0
requestCode == REQ_CODE_DONATE && resultCode == Activity.RESULT_OK && data?.getIntExtra("RESPONSE_CODE", -1) == 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class BetaAdapter @Inject constructor() : TestableAdapter<BetaView>(), Observer<
private val items: MutableList<Feature> = mutableListOf()
var betaAnimator: BetaAnimator? = null

override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): BetaView {
val inflater = LayoutInflater.from(parent?.context)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BetaView {
val inflater = LayoutInflater.from(parent.context)
val binding = DataBindingUtil.inflate<BetaViewBinding>(inflater, R.layout.beta_view, parent, false)
return BetaView(binding)
}

override fun getItemCount(): Int {
return items.size
override fun onBindViewHolder(holder: BetaView, position: Int) {
holder.bind(items[position], betaAnimator)
}

override fun onBindViewHolder(holder: BetaView?, position: Int) {
holder?.bind(items[position], betaAnimator)
override fun getItemCount(): Int {
return items.size
}

override fun onChanged(features: List<Feature>?) {
Expand All @@ -41,4 +41,4 @@ class BetaAdapter @Inject constructor() : TestableAdapter<BetaView>(), Observer<
diff.dispatchUpdatesTo(this)
}
}
}
}
Loading

0 comments on commit 5fb4c98

Please sign in to comment.