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

Commit dbcd155

Browse files
authored
Merge pull request #538 from squanchy-dev/add_padding_below_speaker_details
Fix text cut in Speaker Details when scrollable
2 parents 27544e7 + 20a44f5 commit dbcd155

5 files changed

Lines changed: 44 additions & 53 deletions

File tree

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)

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

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

33
import android.content.Context
4+
import android.support.constraint.ConstraintLayout
45
import android.util.AttributeSet
56
import android.view.View
6-
import android.widget.LinearLayout
77
import arrow.core.Option
88
import kotlinx.android.synthetic.main.activity_speaker_details.view.*
99
import net.squanchy.R
@@ -16,9 +16,8 @@ import net.squanchy.support.unwrapToActivityContext
1616
class SpeakerHeaderView @JvmOverloads constructor(
1717
context: Context,
1818
attrs: AttributeSet,
19-
defStyleAttr: Int = 0,
20-
defStyleRes: Int = 0
21-
) : LinearLayout(context, attrs, defStyleAttr, defStyleRes) {
19+
defStyleAttr: Int = 0
20+
) : ConstraintLayout(context, attrs, defStyleAttr) {
2221

2322
private var imageLoader: ImageLoader? = null
2423

@@ -27,12 +26,6 @@ class SpeakerHeaderView @JvmOverloads constructor(
2726
val activity = context.unwrapToActivityContext()
2827
imageLoader = imageLoaderComponent(activity).imageLoader()
2928
}
30-
31-
super.setOrientation(LinearLayout.HORIZONTAL)
32-
}
33-
34-
override fun setOrientation(orientation: Int): Nothing {
35-
throw UnsupportedOperationException("Changing orientation is not supported for SpeakerHeaderView")
3629
}
3730

3831
fun updateWith(speaker: Speaker) {

app/src/main/res/layout/activity_speaker_details.xml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/speakerDetailsLayout"
66
android:layout_width="match_parent"
7-
android:layout_height="wrap_content">
7+
android:layout_height="match_parent">
88

99
<android.support.design.widget.AppBarLayout
10+
android:id="@+id/appbar"
1011
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
11-
android:layout_width="match_parent"
12-
android:layout_height="wrap_content">
12+
android:layout_width="@dimen/match_constraint"
13+
android:layout_height="wrap_content"
14+
app:layout_constraintStart_toStartOf="parent"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintTop_toTopOf="parent">
1317

1418
<android.support.v7.widget.Toolbar
1519
android:id="@+id/toolbar"
@@ -29,49 +33,50 @@
2933
style="@style/SpeakerDetails.Header.Speaker.Photo"
3034
android:layout_width="@dimen/speaker_details_speaker_photo"
3135
android:layout_height="@dimen/speaker_details_speaker_photo"
32-
android:layout_gravity="start|center_vertical"
33-
android:layout_marginEnd="@dimen/speaker_details_speaker_photo_margin_end"
36+
app:layout_constraintStart_toStartOf="parent"
37+
app:layout_constraintTop_toTopOf="parent"
3438
tools:src="?colorAccent" />
3539

36-
<LinearLayout
37-
android:layout_width="match_parent"
40+
<TextView
41+
android:id="@+id/speakerName"
42+
style="@style/SpeakerDetails.Header.Speaker.Name"
43+
android:layout_width="wrap_content"
3844
android:layout_height="wrap_content"
39-
android:layout_gravity="fill_horizontal|center_vertical"
40-
android:orientation="vertical">
45+
android:layout_marginStart="@dimen/speaker_details_speaker_photo_margin_end"
46+
app:layout_constraintTop_toTopOf="@+id/speakerPhoto"
47+
app:layout_constraintStart_toEndOf="@+id/speakerPhoto"
48+
app:layout_constraintBottom_toTopOf="@+id/speakerCompany"
49+
app:layout_constraintVertical_chainStyle="packed"
50+
tools:text="Qi Qu" />
4151

42-
<TextView
43-
android:id="@+id/speakerName"
44-
style="@style/SpeakerDetails.Header.Speaker.Name"
45-
android:layout_width="wrap_content"
46-
android:layout_height="wrap_content"
47-
tools:text="Qi Qu" />
48-
49-
<TextView
50-
android:id="@+id/speakerCompany"
51-
style="@style/SpeakerDetails.Header.Speaker.Company"
52-
android:layout_width="wrap_content"
53-
android:layout_height="wrap_content"
54-
tools:text="Novoda" />
55-
56-
</LinearLayout>
52+
<TextView
53+
android:id="@+id/speakerCompany"
54+
style="@style/SpeakerDetails.Header.Speaker.Company"
55+
android:layout_width="wrap_content"
56+
android:layout_height="@dimen/match_constraint"
57+
app:layout_constraintTop_toBottomOf="@+id/speakerName"
58+
app:layout_constraintStart_toStartOf="@+id/speakerName"
59+
tools:text="Novoda" />
5760

5861
</net.squanchy.speaker.widget.SpeakerHeaderView>
5962

6063
</android.support.design.widget.AppBarLayout>
6164

6265
<android.support.v4.widget.NestedScrollView
6366
style="@style/SpeakerDetails.Bio"
64-
android:layout_width="match_parent"
65-
android:layout_height="match_parent">
67+
android:layout_width="@dimen/match_constraint"
68+
android:layout_height="@dimen/match_constraint"
69+
app:layout_constraintStart_toStartOf="parent"
70+
app:layout_constraintEnd_toEndOf="parent"
71+
app:layout_constraintTop_toBottomOf="@+id/appbar"
72+
app:layout_constraintBottom_toBottomOf="parent">
6673

6774
<TextView
6875
android:id="@+id/speakerBio"
6976
style="@style/SpeakerDetails.Bio.Text"
7077
android:layout_width="match_parent"
7178
android:layout_height="wrap_content"
72-
android:layout_marginStart="@dimen/speaker_details_bio_padding"
73-
android:layout_marginTop="@dimen/speaker_details_bio_padding"
74-
android:layout_marginEnd="@dimen/speaker_details_bio_padding"
79+
android:padding="@dimen/speaker_details_bio_padding_horizontal"
7580
tools:text="Now this is a story all about how\nMy life got flipped-turned upside down\nAnd I'd like to take a minute\nJust sit right there\nI'll tell you how I became the prince of a town called Bel-Air" />
7681

7782
</android.support.v4.widget.NestedScrollView>

app/src/main/res/values/dimens.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
<dimen name="speaker_details_speaker_margin_start">32dp</dimen>
9393
<dimen name="speaker_details_speaker_margin_bottom">8dp</dimen>
9494
<dimen name="speaker_details_bio">14sp</dimen>
95-
<dimen name="speaker_details_bio_padding">32dp</dimen>
95+
<dimen name="speaker_details_bio_padding_horizontal">32dp</dimen>
96+
<dimen name="speaker_details_bio_padding_vertical">48dp</dimen>
9697
<dimen name="speaker_details_bio_line_spacing_extra">4sp</dimen>
9798

9899
<dimen name="venue_info_content_padding_horizontal">16dp</dimen>

app/src/main/res/values/styles.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,15 @@
341341
</style>
342342

343343
<style name="SpeakerDetails.Bio" parent="None">
344-
<item name="android:requiresFadingEdge">vertical</item>
345-
<item name="android:fadingEdgeLength">64dp</item>
346344
<item name="android:colorBackgroundCacheHint">@color/white</item>
345+
<item name="android:fadingEdgeLength">@dimen/speaker_details_bio_padding_vertical</item>
346+
<item name="android:requiresFadingEdge">vertical</item>
347347
</style>
348348

349349
<style name="SpeakerDetails.Bio.Text" parent="None">
350350
<item name="android:lineSpacingExtra">@dimen/speaker_details_bio_line_spacing_extra</item>
351351
<item name="android:lineSpacingMultiplier">1</item>
352-
<item name="android:paddingBottom">@dimen/speaker_details_bio_padding</item>
352+
<item name="android:paddingBottom">@dimen/speaker_details_bio_padding_vertical</item>
353353
<item name="android:textAppearance">@style/TextAppearance.Squanchy.SpeakerDetails.Bio</item>
354354
</style>
355355

0 commit comments

Comments
 (0)