Skip to content

Commit 37c2a7b

Browse files
committed
refactor: update layouts for improved RTL support and constraint optimization
GitHub Issue #242
1 parent 53fd7f6 commit 37c2a7b

File tree

2 files changed

+122
-165
lines changed

2 files changed

+122
-165
lines changed

app/src/main/res/layout-land/content_main.xml

Lines changed: 60 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@
88

99
<LinearLayout
1010
android:id="@+id/track_info_area"
11-
android:layout_width="wrap_content"
11+
android:layout_width="0dp"
1212
android:layout_height="wrap_content"
13-
android:layout_marginLeft="8dp"
14-
android:layout_marginTop="8dp"
15-
android:layout_marginRight="8dp"
16-
android:layout_marginBottom="8dp"
13+
android:layout_marginStart="16dp"
14+
android:layout_marginTop="16dp"
15+
android:layout_marginEnd="16dp"
16+
android:layout_marginBottom="16dp"
1717
android:orientation="vertical"
1818
app:layout_constraintBottom_toTopOf="@+id/main_track_progress_seeker"
19-
app:layout_constraintHorizontal_bias="0.502"
20-
app:layout_constraintLeft_toLeftOf="parent"
21-
app:layout_constraintRight_toLeftOf="@+id/main_album_cover_image_view"
22-
app:layout_constraintTop_toTopOf="parent"
23-
app:layout_constraintVertical_bias="0.514">
19+
app:layout_constraintEnd_toStartOf="@+id/main_album_cover_image_view"
20+
app:layout_constraintStart_toStartOf="parent"
21+
app:layout_constraintTop_toTopOf="parent">
2422

2523
<TextView
2624
android:id="@+id/main_title_label"
@@ -78,43 +76,35 @@
7876
android:id="@+id/main_track_progress_seeker"
7977
android:layout_width="0dp"
8078
android:layout_height="wrap_content"
81-
android:layout_marginStart="50dp"
82-
android:layout_marginLeft="50dp"
83-
android:layout_marginEnd="50dp"
84-
android:layout_marginRight="50dp"
85-
android:gravity="center"
79+
android:layout_marginStart="8dp"
80+
android:layout_marginEnd="8dp"
8681
android:progress="0"
8782
android:progressTint="@color/progress_tint"
8883
android:secondaryProgress="0"
8984
android:thumbTint="@color/progress_tint"
9085
app:layout_constraintBottom_toBottomOf="parent"
91-
app:layout_constraintLeft_toLeftOf="@+id/main_track_progress_current"
92-
app:layout_constraintRight_toRightOf="@+id/main_track_duration_total"
86+
app:layout_constraintEnd_toStartOf="@+id/main_track_duration_total"
87+
app:layout_constraintStart_toEndOf="@+id/main_track_progress_current"
9388
app:layout_constraintTop_toTopOf="parent"
94-
tools:ignore="UnusedAttribute"
95-
tools:layout_constraintBottom_creator="1"
96-
tools:layout_constraintLeft_creator="1"
97-
tools:layout_constraintRight_creator="1"
98-
tools:layout_constraintTop_creator="1" />
89+
tools:ignore="UnusedAttribute" />
9990

10091
<SeekBar
10192
android:id="@+id/main_volume_seeker"
10293
android:layout_width="0dp"
10394
android:layout_height="wrap_content"
10495
android:layout_marginStart="8dp"
96+
android:layout_marginEnd="16dp"
10597
android:layout_marginBottom="16dp"
106-
android:gravity="center"
10798
android:max="100"
10899
android:progress="0"
109100
android:progressTint="@color/primary"
110101
android:secondaryProgress="0"
111102
android:thumbTint="@color/primary_dark"
112103
app:layout_constraintBottom_toBottomOf="parent"
113-
app:layout_constraintHorizontal_bias="1.0"
114-
app:layout_constraintLeft_toRightOf="@+id/main_mute_button"
115-
app:layout_constraintRight_toRightOf="@+id/main_track_duration_total"
116-
tools:ignore="UnusedAttribute"
117-
tools:layout_constraintLeft_creator="1" />
104+
app:layout_constraintEnd_toStartOf="@+id/main_album_cover_image_view"
105+
app:layout_constraintStart_toEndOf="@+id/main_mute_button"
106+
app:layout_constraintTop_toTopOf="@+id/main_mute_button"
107+
tools:ignore="UnusedAttribute" />
118108

119109

120110
<TextView
@@ -123,9 +113,8 @@
123113
android:layout_height="wrap_content"
124114
android:layout_marginStart="16dp"
125115
android:fontFamily="sans-serif-medium"
126-
android:paddingLeft="@dimen/small_margin"
116+
android:paddingStart="@dimen/small_margin"
127117
android:paddingEnd="@dimen/small_margin"
128-
android:paddingRight="@dimen/small_margin"
129118
android:shadowColor="@android:color/black"
130119
android:shadowDx="1"
131120
android:shadowDy="1"
@@ -134,23 +123,18 @@
134123
android:textColor="?android:attr/textColorPrimary"
135124
android:textSize="12sp"
136125
app:layout_constraintBottom_toBottomOf="@+id/main_track_progress_seeker"
137-
app:layout_constraintHorizontal_chainStyle="spread_inside"
138-
app:layout_constraintLeft_toLeftOf="parent"
126+
app:layout_constraintStart_toStartOf="parent"
139127
app:layout_constraintTop_toTopOf="@+id/main_track_progress_seeker"
140-
app:layout_constraintVertical_bias="0.0"
141-
tools:ignore="MissingPrefix"
142-
tools:layout_constraintBottom_creator="1"
143-
tools:layout_constraintTop_creator="1" />
128+
tools:ignore="MissingPrefix,RtlSymmetry" />
144129

145130
<TextView
146131
android:id="@+id/main_track_duration_total"
147132
android:layout_width="wrap_content"
148133
android:layout_height="wrap_content"
149-
android:layout_marginEnd="8dp"
134+
android:layout_marginEnd="16dp"
150135
android:fontFamily="sans-serif-medium"
151-
android:paddingLeft="@dimen/small_margin"
136+
android:paddingStart="@dimen/small_margin"
152137
android:paddingEnd="@dimen/small_margin"
153-
android:paddingRight="@dimen/small_margin"
154138
android:shadowColor="@android:color/black"
155139
android:shadowDx="1"
156140
android:shadowDy="1"
@@ -159,118 +143,101 @@
159143
android:textColor="?android:attr/textColorPrimary"
160144
android:textSize="12sp"
161145
app:layout_constraintBottom_toBottomOf="@+id/main_track_progress_seeker"
162-
app:layout_constraintRight_toLeftOf="@+id/main_album_cover_image_view"
146+
app:layout_constraintEnd_toStartOf="@+id/main_album_cover_image_view"
163147
app:layout_constraintTop_toTopOf="@+id/main_track_progress_seeker"
164-
app:layout_constraintVertical_bias="0.0"
165-
tools:ignore="MissingPrefix,RelativeOverlap"
166-
tools:layout_constraintBottom_creator="1"
167-
tools:layout_constraintTop_creator="1" />
148+
tools:ignore="MissingPrefix,RelativeOverlap,RtlSymmetry" />
168149

169150

170-
<com.kelsos.mbrc.common.ui.SquareImageButton
151+
<ImageButton
171152
android:id="@+id/main_mute_button"
172153
android:layout_width="48dp"
173154
android:layout_height="48dp"
174-
android:layout_centerVertical="true"
175-
android:layout_marginBottom="8dp"
155+
android:layout_marginStart="16dp"
156+
android:layout_marginBottom="16dp"
176157
android:background="?attr/selectableItemBackgroundBorderless"
177158
android:contentDescription="@string/main_button_mute_description"
178-
android:scaleType="centerInside"
159+
android:padding="@dimen/small_margin"
179160
android:src="@drawable/ic_volume_off_black_24dp"
180161
app:layout_constraintBottom_toBottomOf="parent"
181-
app:layout_constraintLeft_toLeftOf="@+id/main_repeat_button"
182-
app:layout_constraintTop_toTopOf="@+id/main_volume_seeker"
183-
app:layout_constraintVertical_bias="0.0"
162+
app:layout_constraintStart_toStartOf="parent"
184163
app:tint="?attr/colorControlNormal" />
185164

186-
<com.kelsos.mbrc.common.ui.SquareImageButton
165+
<ImageButton
187166
android:id="@+id/main_repeat_button"
188167
android:layout_width="0dp"
189-
android:layout_height="0dp"
190-
android:layout_gravity="center_vertical"
168+
android:layout_height="48dp"
169+
android:layout_marginStart="16dp"
191170
android:background="?attr/selectableItemBackgroundBorderless"
192171
android:contentDescription="@string/main_button_repeat_description"
193-
android:scaleType="centerInside"
172+
android:padding="@dimen/small_margin"
194173
android:src="@drawable/ic_repeat_black_24dp"
195174
app:layout_constraintBottom_toBottomOf="@+id/main_button_play_pause"
196-
app:layout_constraintHorizontal_bias="0.0"
175+
app:layout_constraintEnd_toStartOf="@+id/main_button_previous"
197176
app:layout_constraintHorizontal_weight="1"
198-
app:layout_constraintLeft_toLeftOf="@+id/main_track_progress_current"
199-
app:layout_constraintRight_toLeftOf="@+id/main_button_previous"
177+
app:layout_constraintStart_toStartOf="parent"
200178
app:layout_constraintTop_toTopOf="@+id/main_button_play_pause"
201-
app:layout_constraintVertical_bias="0.0"
202179
app:tint="?attr/colorControlNormal" />
203180

204181

205-
<com.kelsos.mbrc.common.ui.SquareImageButton
182+
<ImageButton
206183
android:id="@+id/main_button_previous"
207184
android:layout_width="0dp"
208-
android:layout_height="0dp"
209-
android:layout_marginStart="8dp"
210-
android:layout_marginLeft="8dp"
211-
android:layout_marginEnd="8dp"
212-
android:layout_marginRight="8dp"
185+
android:layout_height="48dp"
213186
android:background="?attr/selectableItemBackgroundBorderless"
214187
android:contentDescription="@string/main_button_previous_description"
215-
android:scaleType="centerInside"
188+
android:padding="@dimen/small_margin"
216189
android:src="@drawable/ic_skip_previous_black_24dp"
217190
app:layout_constraintBottom_toBottomOf="@+id/main_button_play_pause"
191+
app:layout_constraintEnd_toStartOf="@+id/main_button_play_pause"
218192
app:layout_constraintHorizontal_weight="1"
219-
app:layout_constraintLeft_toRightOf="@+id/main_repeat_button"
220-
app:layout_constraintRight_toLeftOf="@+id/main_button_play_pause"
193+
app:layout_constraintStart_toEndOf="@+id/main_repeat_button"
221194
app:layout_constraintTop_toTopOf="@+id/main_button_play_pause"
222195
app:tint="?attr/colorControlNormal" />
223196

224-
<com.kelsos.mbrc.common.ui.SquareImageButton
197+
<ImageButton
225198
android:id="@+id/main_button_play_pause"
226199
android:layout_width="0dp"
227-
android:layout_height="wrap_content"
228-
android:layout_marginTop="8dp"
229-
android:layout_marginEnd="8dp"
230-
android:layout_marginBottom="8dp"
200+
android:layout_height="48dp"
231201
android:background="?attr/selectableItemBackgroundBorderless"
232202
android:contentDescription="@string/main_button_play_pause_description"
233-
android:scaleType="fitCenter"
203+
android:padding="@dimen/small_margin"
234204
android:src="@drawable/ic_play_circle_filled_black_24dp"
235205
app:layout_constraintBottom_toTopOf="@+id/main_volume_seeker"
206+
app:layout_constraintEnd_toStartOf="@+id/main_button_next"
236207
app:layout_constraintHorizontal_weight="1"
237-
app:layout_constraintLeft_toRightOf="@+id/main_button_previous"
238-
app:layout_constraintRight_toLeftOf="@+id/main_button_next"
208+
app:layout_constraintStart_toEndOf="@+id/main_button_previous"
239209
app:layout_constraintTop_toBottomOf="@+id/main_track_progress_seeker"
240210
app:tint="@color/accent" />
241211

242-
<com.kelsos.mbrc.common.ui.SquareImageButton
212+
<ImageButton
243213
android:id="@+id/main_button_next"
244214
android:layout_width="0dp"
245-
android:layout_height="0dp"
246-
android:layout_marginEnd="8dp"
215+
android:layout_height="48dp"
247216
android:background="?attr/selectableItemBackgroundBorderless"
248217
android:contentDescription="@string/main_button_next_description"
249-
android:scaleType="centerInside"
218+
android:padding="@dimen/small_margin"
250219
android:src="@drawable/ic_skip_next_black_24dp"
251220
app:layout_constraintBottom_toBottomOf="@+id/main_button_play_pause"
221+
app:layout_constraintEnd_toStartOf="@+id/main_shuffle_button"
252222
app:layout_constraintHorizontal_weight="1"
253-
app:layout_constraintLeft_toRightOf="@+id/main_button_play_pause"
254-
app:layout_constraintRight_toLeftOf="@+id/main_shuffle_button"
223+
app:layout_constraintStart_toEndOf="@+id/main_button_play_pause"
255224
app:layout_constraintTop_toTopOf="@+id/main_button_play_pause"
256225
app:tint="?attr/colorControlNormal" />
257226

258-
<com.kelsos.mbrc.common.ui.SquareImageButton
227+
<ImageButton
259228
android:id="@+id/main_shuffle_button"
260229
android:layout_width="0dp"
261-
android:layout_height="0dp"
262-
android:layout_gravity="center_vertical"
230+
android:layout_height="48dp"
231+
android:layout_marginEnd="16dp"
263232
android:background="?attr/selectableItemBackgroundBorderless"
264233
android:contentDescription="@string/main_button_shuffle_description"
265-
android:scaleType="centerInside"
234+
android:padding="@dimen/small_margin"
266235
android:src="@drawable/ic_shuffle_black_24dp"
267236
app:layout_constraintBottom_toBottomOf="@+id/main_button_play_pause"
268-
app:layout_constraintHorizontal_bias="1.0"
237+
app:layout_constraintEnd_toStartOf="@+id/main_album_cover_image_view"
269238
app:layout_constraintHorizontal_weight="1"
270-
app:layout_constraintLeft_toRightOf="@+id/main_button_next"
271-
app:layout_constraintRight_toRightOf="@+id/main_track_duration_total"
239+
app:layout_constraintStart_toEndOf="@+id/main_button_next"
272240
app:layout_constraintTop_toTopOf="@+id/main_button_play_pause"
273-
app:layout_constraintVertical_bias="1.0"
274241
app:tint="?attr/colorControlNormal" />
275242

276243

@@ -279,21 +246,16 @@
279246
android:layout_width="0dp"
280247
android:layout_height="0dp"
281248
android:layout_marginTop="16dp"
282-
android:layout_marginEnd="8dp"
249+
android:layout_marginEnd="16dp"
283250
android:layout_marginBottom="16dp"
284251
android:adjustViewBounds="true"
285252
android:contentDescription="@string/description_album_cover"
286-
android:longClickable="true"
287253
android:scaleType="centerCrop"
288254
android:src="@drawable/ic_image_no_cover"
289255
app:layout_constraintBottom_toBottomOf="parent"
290256
app:layout_constraintDimensionRatio="h,1:1"
291-
app:layout_constraintRight_toRightOf="parent"
257+
app:layout_constraintEnd_toEndOf="parent"
292258
app:layout_constraintTop_toTopOf="parent"
293-
app:siv_use_height="true"
294-
tools:layout_constraintBottom_creator="1"
295-
tools:layout_constraintRight_creator="1"
296-
tools:layout_constraintTop_creator="1" />
297-
259+
app:siv_use_height="true" />
298260

299261
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)