Skip to content
This repository was archived by the owner on Feb 17, 2020. It is now read-only.

Commit 9b5bfea

Browse files
committed
Merge branch 'develop' into conf/droidcon-turin-2018
2 parents 011bcac + dbcd155 commit 9b5bfea

File tree

23 files changed

+237
-159
lines changed

23 files changed

+237
-159
lines changed

app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ android {
2525
compileSdkVersion Integer.parseInt(project.COMPILE_SDK_VERSION)
2626

2727
compileOptions {
28-
sourceCompatibility JavaVersion.VERSION_1_8
29-
targetCompatibility JavaVersion.VERSION_1_8
28+
sourceCompatibility JavaVersion.VERSION_1_7
29+
targetCompatibility JavaVersion.VERSION_1_7
3030
}
3131

3232
defaultConfig {
@@ -153,6 +153,7 @@ dependencies {
153153

154154
implementation libraries.app.jodaTimeAndroid
155155
implementation libraries.app.kotlin
156+
implementation libraries.app.kotlinReflect
156157

157158
implementation libraries.app.playServicesAuth
158159
implementation libraries.app.rxJava

app/proguard-rules.pro

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
-dontobfuscate
22

3-
-keep class com.bumptech.glide.load.model.stream.StreamModelLoader
4-
-dontwarn com.bumptech.glide.load.model.stream.StreamModelLoader
3+
# Glide rules
4+
-keep public class * implements com.bumptech.glide.module.GlideModule
5+
-keep public class * extends com.bumptech.glide.module.AppGlideModule
6+
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
7+
**[] $VALUES;
8+
public *;
9+
}
510

11+
# Preserve API models
612
-keep class net.squanchy.service.firebase.model.** { *; }
13+
14+
# Moshi rules
15+
-dontwarn okio.**
16+
-dontwarn javax.annotation.**
17+
-keepclasseswithmembers class * {
18+
@com.squareup.moshi.* <methods>;
19+
}
20+
-keep @com.squareup.moshi.JsonQualifier interface *
21+
22+
-keepclassmembers class kotlin.Metadata {
23+
public <methods>;
24+
}
25+
26+
# Arrow rules
27+
-dontwarn java.util.concurrent.**

app/src/main/java/net/squanchy/favorites/FavoritesPageView.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ class FavoritesPageView @JvmOverloads constructor(
8080
showSettings()
8181
true
8282
}
83-
R.id.action_filter -> {
84-
navigator.toScheduleFiltering(context)
85-
true
86-
}
8783
else -> false
8884
}
8985
}

app/src/main/java/net/squanchy/navigation/Navigator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.squanchy.navigation
22

33
import android.app.Activity
4-
import android.content.Context
54
import android.content.Intent
65
import android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK
76
import android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP
@@ -21,6 +20,7 @@ import net.squanchy.settings.SettingsActivity
2120
import net.squanchy.signin.SignInActivity
2221
import net.squanchy.signin.SignInOrigin
2322
import net.squanchy.speaker.SpeakerDetailsActivity
23+
import net.squanchy.support.widget.OriginCoordinates
2424
import net.squanchy.tweets.domain.TweetLinkInfo
2525
import net.squanchy.venue.domain.view.Venue
2626
import timber.log.Timber
@@ -62,8 +62,8 @@ class Navigator(
6262
attemptDeeplinkOrFallback(deeplinkStatusUrl, fallbackStatusUrl)
6363
}
6464

65-
fun toScheduleFiltering(ctx: Context) {
66-
start(Intent(ctx, ScheduleTracksFilterActivity::class.java))
65+
fun toScheduleFiltering(originCoordinates: OriginCoordinates?) {
66+
start(ScheduleTracksFilterActivity.createIntent(activity, originCoordinates))
6767
}
6868

6969
private fun attemptDeeplinkOrFallback(deeplinkUrl: String, fallbackUrl: String) {

app/src/main/java/net/squanchy/schedule/SchedulePageView.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import net.squanchy.support.text.applyTypeface
2525
import net.squanchy.support.text.getFontFor
2626
import net.squanchy.support.text.hasTypefaceSpan
2727
import net.squanchy.support.unwrapToActivityContext
28+
import net.squanchy.support.widget.calculateMenuItemCenterCoordinates
2829
import timber.log.Timber
2930

3031
class SchedulePageView @JvmOverloads constructor(
@@ -64,6 +65,8 @@ class SchedulePageView @JvmOverloads constructor(
6465
private fun setupToolbar() {
6566
toolbar.setTitle(R.string.activity_schedule)
6667
toolbar.inflateMenu(R.menu.homepage)
68+
toolbar.menu.findItem(R.id.action_filter).isVisible = true
69+
6770
toolbar.setOnMenuItemClickListener { item ->
6871
when (item.itemId) {
6972
R.id.action_search -> {
@@ -75,7 +78,7 @@ class SchedulePageView @JvmOverloads constructor(
7578
true
7679
}
7780
R.id.action_filter -> {
78-
navigate.toScheduleFiltering(context)
81+
navigate.toScheduleFiltering(toolbar.calculateMenuItemCenterCoordinates(R.id.action_filter))
7982
true
8083
}
8184
else -> false

app/src/main/java/net/squanchy/schedule/tracksfilter/ScheduleTracksFilter.kt

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.squanchy.schedule.tracksfilter
22

3+
import android.content.Context
4+
import android.content.Intent
35
import android.os.Bundle
46
import android.support.v7.app.AppCompatActivity
57
import android.view.View
@@ -21,7 +23,7 @@ import net.squanchy.R
2123
import net.squanchy.schedule.domain.view.Track
2224
import net.squanchy.service.repository.TracksRepository
2325
import net.squanchy.support.view.setAdapterIfNone
24-
import java.util.concurrent.atomic.AtomicBoolean
26+
import net.squanchy.support.widget.OriginCoordinates
2527
import kotlin.math.hypot
2628

2729
class ScheduleTracksFilterActivity : AppCompatActivity() {
@@ -35,20 +37,22 @@ class ScheduleTracksFilterActivity : AppCompatActivity() {
3537
private var subscription: Disposable? = null
3638
private var checkableTracks: List<CheckableTrack> = emptyList()
3739

38-
private val needsAppearAnimation: AtomicBoolean = AtomicBoolean(true)
40+
private var needsAppearAnimation = true
41+
private var appearAnimationOrigin: OriginCoordinates? = null
3942

4043
override fun onCreate(savedInstanceState: Bundle?) {
4144
super.onCreate(savedInstanceState)
4245

4346
setContentView(R.layout.activity_track_filters)
4447

4548
savedInstanceState?.apply {
46-
val restoredNeedsAppearAnimation = getBoolean(EXTRA_NEEDS_APPEAR_ANIMATION, true)
47-
needsAppearAnimation.set(restoredNeedsAppearAnimation)
49+
needsAppearAnimation = getBoolean(EXTRA_NEEDS_APPEAR_ANIMATION, true)
50+
appearAnimationOrigin = getParcelable(EXTRA_APPEAR_ANIMATION_ORIGIN)
4851
}
4952

50-
backgroundDim.setOnClickListener { animateDisappearance() }
51-
closeButton.setOnClickListener { animateDisappearance() }
53+
appearAnimationOrigin = appearAnimationOrigin ?: intent.getParcelableExtra(EXTRA_APPEAR_ANIMATION_ORIGIN)
54+
55+
backgroundDim.setOnClickListener { closeFilters() }
5256

5357
val component = tracksFilterComponent(this)
5458
tracksRepository = component.tracksRepository()
@@ -68,14 +72,18 @@ class ScheduleTracksFilterActivity : AppCompatActivity() {
6872
trackFiltersList.itemAnimator = null
6973
}
7074

71-
private fun Set<Track>.addOrRemove(track: Track, selected: Boolean): Set<Track> =
72-
if (selected) this + track else this - track
75+
private fun closeFilters() {
76+
if (appearAnimationOrigin == null) {
77+
finish()
78+
} else {
79+
animateDisappearance(appearAnimationOrigin!!)
80+
}
81+
}
7382

74-
private fun animateDisappearance() {
83+
private fun animateDisappearance(origin: OriginCoordinates) {
7584
backgroundDim.isEnabled = false
7685

77-
val centerX = closeButton.x + closeButton.width / 2
78-
val centerY = closeButton.y + closeButton.height / 2
86+
val (centerX, centerY) = origin
7987

8088
ViewAnimationUtils.createCircularReveal(
8189
filtersRoot,
@@ -93,12 +101,16 @@ class ScheduleTracksFilterActivity : AppCompatActivity() {
93101
}.start()
94102
}
95103

104+
private fun Set<Track>.addOrRemove(track: Track, selected: Boolean): Set<Track> =
105+
if (selected) this + track else this - track
106+
96107
override fun onStart() {
97108
super.onStart()
98109

99-
if (needsAppearAnimation.getAndSet(false)) {
110+
if (needsAppearAnimation && appearAnimationOrigin != null) {
111+
needsAppearAnimation = false
100112
prepareAppearAnimation()
101-
filtersRoot.postOnAnimation { animateAppearing() }
113+
filtersRoot.postOnAnimation { animateAppearing(appearAnimationOrigin!!) }
102114
}
103115

104116
subscription = Observable.combineLatest(tracksRepository.tracks(), tracksFilter.selectedTracks, combineIntoCheckableTracks())
@@ -113,10 +125,32 @@ class ScheduleTracksFilterActivity : AppCompatActivity() {
113125
}
114126
}
115127

128+
private fun prepareAppearAnimation() {
129+
appearInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)
130+
filtersRoot.visibility = View.VISIBLE
131+
132+
val titleDeltaY = resources.getDimension(R.dimen.track_filters_title_appear_delta_y)
133+
dialogTitle.apply {
134+
translationY = -titleDeltaY
135+
alpha = 0F
136+
}
137+
138+
val subtitleDeltaY = resources.getDimension(R.dimen.track_filters_subtitle_appear_delta_y)
139+
dialogSubtitle.apply {
140+
translationY = -subtitleDeltaY
141+
alpha = 0F
142+
}
143+
144+
val tracksDeltaY = resources.getDimension(R.dimen.track_filters_tracks_appear_delta_y)
145+
trackFiltersList.apply {
146+
translationY = -tracksDeltaY
147+
alpha = 0F
148+
}
149+
}
150+
116151
@Suppress("MagicNumber") // Just animation code… needs a few magic numbers
117-
private fun animateAppearing() {
118-
val centerX = closeButton.x + closeButton.width / 2
119-
val centerY = closeButton.y + closeButton.height / 2
152+
private fun animateAppearing(origin: OriginCoordinates) {
153+
val (centerX, centerY) = origin
120154

121155
ViewAnimationUtils.createCircularReveal(
122156
filtersRoot,
@@ -146,29 +180,6 @@ class ScheduleTracksFilterActivity : AppCompatActivity() {
146180
.setStartDelay(delay)
147181
.start()
148182

149-
private fun prepareAppearAnimation() {
150-
appearInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)
151-
filtersRoot.visibility = View.VISIBLE
152-
153-
val titleDeltaY = resources.getDimension(R.dimen.track_filters_title_appear_delta_y)
154-
dialogTitle.apply {
155-
translationY = -titleDeltaY
156-
alpha = 0F
157-
}
158-
159-
val subtitleDeltaY = resources.getDimension(R.dimen.track_filters_subtitle_appear_delta_y)
160-
dialogSubtitle.apply {
161-
translationY = -subtitleDeltaY
162-
alpha = 0F
163-
}
164-
165-
val tracksDeltaY = resources.getDimension(R.dimen.track_filters_tracks_appear_delta_y)
166-
trackFiltersList.apply {
167-
translationY = -tracksDeltaY
168-
alpha = 0F
169-
}
170-
}
171-
172183
private fun combineIntoCheckableTracks(): BiFunction<List<Track>, Set<Track>, List<CheckableTrack>> {
173184
return BiFunction { tracks, selectedTracks ->
174185
tracks.map { track -> CheckableTrack(track, selectedTracks.contains(track)) }
@@ -177,7 +188,8 @@ class ScheduleTracksFilterActivity : AppCompatActivity() {
177188

178189
override fun onSaveInstanceState(outState: Bundle?) {
179190
super.onSaveInstanceState(outState)
180-
outState?.putBoolean(EXTRA_NEEDS_APPEAR_ANIMATION, needsAppearAnimation.get())
191+
outState?.putBoolean(EXTRA_NEEDS_APPEAR_ANIMATION, needsAppearAnimation)
192+
outState?.putParcelable(EXTRA_APPEAR_ANIMATION_ORIGIN, appearAnimationOrigin)
181193
}
182194

183195
override fun onStop() {
@@ -187,5 +199,12 @@ class ScheduleTracksFilterActivity : AppCompatActivity() {
187199

188200
companion object {
189201
private const val EXTRA_NEEDS_APPEAR_ANIMATION = "ScheduleTracksFilterActivity.EXTRA_NEEDS_APPEAR_ANIMATION"
202+
private const val EXTRA_APPEAR_ANIMATION_ORIGIN = "ScheduleTracksFilterActivity.EXTRA_APPEAR_ANIMATION_ORIGIN"
203+
204+
fun createIntent(context: Context, originCoordinates: OriginCoordinates?): Intent {
205+
return Intent(context, ScheduleTracksFilterActivity::class.java).apply {
206+
putExtra(EXTRA_APPEAR_ANIMATION_ORIGIN, originCoordinates)
207+
}
208+
}
190209
}
191210
}

app/src/main/java/net/squanchy/search/SearchActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ class SearchActivity : AppCompatActivity(), SearchRecyclerView.OnSearchResultCli
211211
searchField.setText("")
212212
}
213213

214-
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
214+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
215215
if (requestCode == SPEECH_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
216-
val results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
217-
searchField.setText(results[0])
216+
val results = data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
217+
if (results != null) searchField.setText(results[0])
218218
return
219219
}
220220
super.onActivityResult(requestCode, resultCode, data)

app/src/main/java/net/squanchy/service/firebase/model/schedule/FirestoreSchedule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package net.squanchy.service.firebase.model.schedule
22

3+
import com.google.firebase.firestore.IgnoreExtraProperties
34
import java.util.Date
45

56
class FirestoreSchedulePage {
67
lateinit var day: FirestoreDay
78
var events: List<FirestoreEvent> = emptyList()
89
}
910

11+
@IgnoreExtraProperties
1012
class FirestoreDay {
1113
lateinit var id: String
1214
lateinit var date: Date
1315
}
1416

17+
@IgnoreExtraProperties
1518
class FirestoreEvent {
1619
lateinit var id: String
1720
lateinit var title: String

app/src/main/java/net/squanchy/signin/SignInActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class SignInActivity : AppCompatActivity() {
9292
window.setGravity(Gravity.FILL_HORIZONTAL or Gravity.BOTTOM)
9393
}
9494

95-
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
95+
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
9696
super.onActivityResult(requestCode, resultCode, data)
9797

9898
if (requestCode == RC_SIGN_IN) {

app/src/main/java/net/squanchy/speaker/widget/SpeakerDetailsLayout.kt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
package net.squanchy.speaker.widget
22

33
import android.content.Context
4+
import android.support.constraint.ConstraintLayout
45
import android.util.AttributeSet
5-
import android.widget.LinearLayout
66
import kotlinx.android.synthetic.main.activity_speaker_details.view.*
77
import net.squanchy.speaker.domain.view.Speaker
88
import net.squanchy.support.text.parseHtml
99

10-
class SpeakerDetailsLayout(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
11-
12-
init {
13-
super.setOrientation(LinearLayout.VERTICAL)
14-
}
15-
16-
override fun setOrientation(orientation: Int): Nothing {
17-
throw UnsupportedOperationException("Changing orientation is not supported for SpeakerDetailsLayout")
18-
}
10+
class SpeakerDetailsLayout(context: Context, attrs: AttributeSet) : ConstraintLayout(context, attrs) {
1911

2012
fun updateWith(speaker: Speaker) {
2113
speakerDetailsHeader.updateWith(speaker)

0 commit comments

Comments
 (0)