Skip to content

Commit 148583f

Browse files
committed
feat: improve artist and album activity design
1 parent f560694 commit 148583f

File tree

5 files changed

+113
-40
lines changed

5 files changed

+113
-40
lines changed

app/src/main/java/io/compactd/player/ui/activities/AlbumActivity.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
import android.view.View;
1414
import android.widget.FrameLayout;
1515
import android.widget.ImageView;
16+
import android.widget.TextView;
1617

1718
import com.bumptech.glide.Glide;
1819
import com.couchbase.lite.CouchbaseLiteException;
1920

21+
import org.w3c.dom.Text;
22+
2023
import java.lang.reflect.InvocationTargetException;
2124

2225
import butterknife.BindView;
@@ -42,6 +45,9 @@ public class AlbumActivity extends SlidingMusicActivity {
4245
@BindView(R.id.app_bar)
4346
AppBarLayout appBarLayout;
4447

48+
@BindView(R.id.title)
49+
TextView titleView;
50+
4551
private Unbinder unbinder;
4652

4753
@Override
@@ -51,7 +57,6 @@ protected void onCreate(Bundle savedInstanceState) {
5157

5258
unbinder = ButterKnife.bind(this);
5359

54-
5560
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
5661
setSupportActionBar(toolbar);
5762

@@ -64,6 +69,8 @@ public void onClick(View view) {
6469
}
6570
});
6671

72+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
73+
getSupportActionBar().setDisplayShowHomeEnabled(true);
6774

6875
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
6976
getWindow().setStatusBarColor(Color.TRANSPARENT);
@@ -85,7 +92,7 @@ public void onClick(View view) {
8592
FragmentTransaction fragmentTransaction = manager.beginTransaction();
8693

8794
TracksFragment tracksFragment = TracksFragment.newInstance(ModelFragment.VERTICAL_LAYOUT, model.getId());
88-
fragmentTransaction.add(R.id.frame, tracksFragment);
95+
fragmentTransaction.add(R.id.tracks_frame, tracksFragment);
8996
fragmentTransaction.commit();
9097

9198
} catch (NoSuchMethodException e) {
@@ -102,6 +109,12 @@ public void onClick(View view) {
102109

103110
}
104111

112+
@Override
113+
public boolean onSupportNavigateUp() {
114+
this.onBackPressed();
115+
return true;
116+
}
117+
105118
private void setAlbum(CompactdAlbum model) {
106119
try {
107120
model.fetch();
@@ -111,7 +124,8 @@ private void setAlbum(CompactdAlbum model) {
111124
}
112125

113126
Glide.with(this).load(new MediaCover(model)).into(albumCoverView);
114-
setTitle(model.getName());
127+
setTitle("");
128+
titleView.setText(model.getName());
115129
}
116130

117131
@Override

app/src/main/java/io/compactd/player/ui/activities/ArtistActivity.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.support.design.widget.CollapsingToolbarLayout;
77
import android.support.design.widget.FloatingActionButton;
88
import android.support.design.widget.Snackbar;
9+
import android.support.v4.app.Fragment;
910
import android.support.v4.app.FragmentManager;
1011
import android.support.v4.app.FragmentTransaction;
1112
import android.support.v7.app.AppCompatActivity;
@@ -49,9 +50,6 @@ public class ArtistActivity extends SlidingMusicActivity {
4950
@BindView(R.id.artist_cover_view)
5051
ImageView artistCoverView;
5152

52-
@BindView(R.id.albums_frame)
53-
LinearLayout albumsFrame;
54-
5553
@BindView(R.id.title)
5654
TextView titleView;
5755

@@ -84,6 +82,9 @@ public void onClick(View view) {
8482
}
8583
});
8684

85+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
86+
getSupportActionBar().setDisplayShowHomeEnabled(true);
87+
8788
Bundle bundle = getIntent().getExtras();
8889
assert bundle != null;
8990

@@ -101,7 +102,7 @@ public void onClick(View view) {
101102
AlbumsFragment albumsFragment = AlbumsFragment.newInstance(ModelFragment.HORIZONTAL_LAYOUT, model.getId());
102103
TracksFragment tracksFragment = TracksFragment.newInstance(ModelFragment.VERTICAL_LAYOUT, model.getId());
103104
fragmentTransaction.add(R.id.albums_frame, albumsFragment);
104-
fragmentTransaction.add(R.id.albums_frame, tracksFragment);
105+
fragmentTransaction.add(R.id.tracks_frame, tracksFragment);
105106
fragmentTransaction.commit();
106107

107108
} catch (NoSuchMethodException e) {
@@ -117,6 +118,12 @@ public void onClick(View view) {
117118
setShowStatusBarDummy(false);
118119
}
119120

121+
@Override
122+
public boolean onSupportNavigateUp() {
123+
this.onBackPressed();
124+
return true;
125+
}
126+
120127
private void setArtist(CompactdArtist model) {
121128
try {
122129
model.fetch();
Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,48 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:orientation="vertical"
78
app:layout_behavior="@string/appbar_scrolling_view_behavior"
8-
tools:context="io.compactd.player.ui.activities.AlbumActivity"
9-
tools:showIn="@layout/activity_album">
9+
tools:context="io.compactd.player.ui.activities.ArtistActivity"
10+
tools:showIn="@layout/activity_artist">
1011

11-
<LinearLayout
12+
<TextView
13+
android:id="@+id/title"
1214
android:layout_width="match_parent"
13-
android:layout_height="wrap_content"
14-
android:orientation="vertical">
15+
android:layout_height="@dimen/title_view_height"
16+
android:height="@dimen/title_view_height"
17+
android:background="@color/cardview_light_background"
18+
android:elevation="@dimen/toolbar_elevation"
19+
android:fontFamily="sans-serif-medium"
20+
android:gravity="center_vertical"
21+
android:paddingLeft="72dp"
22+
android:paddingRight="72dp"
23+
android:singleLine="true"
24+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
25+
tools:ignore="UnusedAttribute" />
26+
27+
<android.support.v4.widget.NestedScrollView
28+
android:id="@+id/album_content"
29+
android:layout_width="match_parent"
30+
android:layout_height="match_parent"
31+
android:layout_marginLeft="4dp"
32+
android:layout_marginRight="4dp"
33+
android:layout_marginTop="4dp"
34+
android:fillViewport="true">
35+
1536

1637
<FrameLayout
17-
android:id="@+id/frame"
38+
android:id="@+id/tracks_frame"
1839
android:layout_width="match_parent"
19-
android:layout_height="match_parent">
40+
android:layout_height="wrap_content">
2041

2142
</FrameLayout>
2243

23-
</LinearLayout>
2444

25-
</android.support.v4.widget.NestedScrollView>
45+
</android.support.v4.widget.NestedScrollView>
46+
47+
48+
</LinearLayout>
Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,66 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:orientation="vertical"
78
app:layout_behavior="@string/appbar_scrolling_view_behavior"
89
tools:context="io.compactd.player.ui.activities.ArtistActivity"
910
tools:showIn="@layout/activity_artist">
1011

11-
<LinearLayout
12+
<TextView
13+
android:id="@+id/title"
1214
android:layout_width="match_parent"
13-
android:layout_height="wrap_content"
14-
android:orientation="vertical">
15+
android:layout_height="@dimen/title_view_height"
16+
android:height="@dimen/title_view_height"
17+
android:background="@color/cardview_light_background"
18+
android:elevation="@dimen/toolbar_elevation"
19+
android:fontFamily="sans-serif-medium"
20+
android:gravity="center_vertical"
21+
android:paddingLeft="72dp"
22+
android:paddingRight="72dp"
23+
android:singleLine="true"
24+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
25+
tools:ignore="UnusedAttribute" />
1526

16-
<TextView
17-
android:id="@+id/title"
18-
android:layout_width="match_parent"
19-
android:layout_height="@dimen/title_view_height"
20-
android:height="@dimen/title_view_height"
21-
android:background="@color/cardview_light_background"
22-
android:elevation="@dimen/toolbar_elevation"
23-
android:fontFamily="sans-serif-medium"
24-
android:gravity="center_vertical"
25-
android:paddingLeft="72dp"
26-
android:paddingRight="72dp"
27-
android:singleLine="true"
28-
android:textAppearance="@style/TextAppearance.AppCompat.Title"
29-
tools:ignore="UnusedAttribute" />
27+
<android.support.v4.widget.NestedScrollView
28+
android:id="@+id/artist_content"
29+
android:layout_width="match_parent"
30+
android:layout_height="match_parent"
31+
android:layout_marginLeft="4dp"
32+
android:layout_marginRight="4dp"
33+
android:layout_marginTop="4dp"
34+
android:fillViewport="true">
3035

3136
<LinearLayout
32-
android:id="@+id/albums_frame"
3337
android:layout_width="match_parent"
34-
android:layout_height="wrap_content"
38+
android:layout_height="match_parent"
3539
android:orientation="vertical">
3640

41+
<FrameLayout
42+
android:id="@+id/albums_frame"
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:orientation="vertical">
46+
47+
</FrameLayout>
48+
49+
<View
50+
style="@style/Divider"
51+
android:layout_marginBottom="4dp"
52+
android:layout_marginTop="4dp" />
53+
54+
<FrameLayout
55+
android:id="@+id/tracks_frame"
56+
android:layout_width="match_parent"
57+
android:layout_height="wrap_content">
58+
59+
</FrameLayout>
60+
3761
</LinearLayout>
3862

63+
</android.support.v4.widget.NestedScrollView>
64+
3965

40-
</LinearLayout>
41-
</android.support.v4.widget.NestedScrollView>
66+
</LinearLayout>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@
4646
<item name="android:layout_width">wrap_content</item>
4747
<item name="android:layout_height">wrap_content</item>
4848
</style>
49-
49+
<style name="Divider">
50+
<item name="android:layout_width">match_parent</item>
51+
<item name="android:layout_height">1dp</item>
52+
<item name="android:background">?android:attr/listDivider</item>
53+
</style>
5054
</resources>

0 commit comments

Comments
 (0)