Fixed artist and album viewers from previous commits, need to re-add translucent status bars there for Lollipop and KitKat

This commit is contained in:
Aidan Follestad 2015-04-18 01:18:46 -05:00
commit 872987bfc5
4 changed files with 43 additions and 24 deletions

View file

@ -56,15 +56,15 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
private Album album; private Album album;
private ObservableRecyclerView recyclerView; private ObservableRecyclerView recyclerView;
private View statusBar;
private ImageView albumArtImageView; private ImageView albumArtImageView;
private View songsBackgroundView; private View songsBackgroundView;
private TextView albumTitleView; private TextView albumTitleView;
private Toolbar toolbar;
private int headerOffset; private int headerOffset;
private int titleViewHeight; private int titleViewHeight;
private int albumArtViewHeight; private int albumArtViewHeight;
private int toolbarColor; private int toolbarColor;
public Toolbar toolbar;
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() { private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
@Override @Override
public void onScrollChanged(int scrollY, boolean b, boolean b2) { public void onScrollChanged(int scrollY, boolean b, boolean b2) {
@ -81,6 +81,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
// Change alpha of overlay // Change alpha of overlay
float alpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange)); float alpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
ViewUtil.setBackgroundAlpha(toolbar, alpha, toolbarColor); ViewUtil.setBackgroundAlpha(toolbar, alpha, toolbarColor);
ViewUtil.setBackgroundAlpha(statusBar, alpha, toolbarColor);
// Translate name text // Translate name text
int maxTitleTranslationY = albumArtViewHeight; int maxTitleTranslationY = albumArtViewHeight;
@ -120,11 +121,8 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
initViews(); initViews();
setUpObservableListViewParams(); setUpObservableListViewParams();
setUpToolBar();
setUpViews(); setUpViews();
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
@ -143,11 +141,12 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
} }
private void initViews() { private void initViews() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
albumArtImageView = (ImageView) findViewById(R.id.album_art); albumArtImageView = (ImageView) findViewById(R.id.album_art);
toolbar = (Toolbar) findViewById(R.id.toolbar);
recyclerView = (ObservableRecyclerView) findViewById(R.id.list); recyclerView = (ObservableRecyclerView) findViewById(R.id.list);
albumTitleView = (TextView) findViewById(R.id.album_title); albumTitleView = (TextView) findViewById(R.id.album_title);
songsBackgroundView = findViewById(R.id.list_background); songsBackgroundView = findViewById(R.id.list_background);
statusBar = findViewById(R.id.statusBar);
} }
private void setUpObservableListViewParams() { private void setUpObservableListViewParams() {
@ -156,8 +155,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
int toolbarHeight = Util.getActionBarSize(this); int toolbarHeight = Util.getActionBarSize(this);
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height); titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
headerOffset = toolbarHeight; headerOffset = toolbarHeight;
if (Util.hasKitKatSDK() && !Util.hasLollipopSDK()) headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
} }
private void setUpViews() { private void setUpViews() {
@ -241,6 +239,12 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
}); });
} }
private void setUpToolBar() {
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
private void setUpSongsAdapter() { private void setUpSongsAdapter() {
final ArrayList<Song> songs = AlbumSongLoader.getAlbumSongList(this, album.id, new SongTrackNumberComparator()); final ArrayList<Song> songs = AlbumSongLoader.getAlbumSongList(this, album.id, new SongTrackNumberComparator());
final AlbumSongAdapter albumSongAdapter = new AlbumSongAdapter(this, songs); final AlbumSongAdapter albumSongAdapter = new AlbumSongAdapter(this, songs);
@ -317,4 +321,4 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
super.onDestroy(); super.onDestroy();
App.bus.unregister(this); App.bus.unregister(this);
} }
} }

View file

@ -65,14 +65,15 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
private Artist artist; private Artist artist;
private ObservableListView songListView; private ObservableListView songListView;
private View statusBar;
private ImageView artistImage; private ImageView artistImage;
private View songsBackgroundView; private View songsBackgroundView;
private TextView artistNameTv; private TextView artistNameTv;
private Toolbar toolbar;
private int headerOffset; private int headerOffset;
private int titleViewHeight; private int titleViewHeight;
private int artistImageViewHeight; private int artistImageViewHeight;
private int toolbarColor; private int toolbarColor;
public Toolbar toolbar;
private View songListHeader; private View songListHeader;
private RecyclerView albumRecyclerView; private RecyclerView albumRecyclerView;
@ -94,6 +95,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
// Change alpha of overlay // Change alpha of overlay
float alpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange)); float alpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
ViewUtil.setBackgroundAlpha(toolbar, alpha, toolbarColor); ViewUtil.setBackgroundAlpha(toolbar, alpha, toolbarColor);
ViewUtil.setBackgroundAlpha(statusBar, alpha, toolbarColor);
// Translate name text // Translate name text
int maxTitleTranslationY = artistImageViewHeight; int maxTitleTranslationY = artistImageViewHeight;
@ -108,6 +110,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
} }
}; };
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -145,11 +148,12 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
} }
private void initViews() { private void initViews() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
artistImage = (ImageView) findViewById(R.id.artist_image); artistImage = (ImageView) findViewById(R.id.artist_image);
toolbar = (Toolbar) findViewById(R.id.toolbar);
songListView = (ObservableListView) findViewById(R.id.list); songListView = (ObservableListView) findViewById(R.id.list);
artistNameTv = (TextView) findViewById(R.id.artist_name); artistNameTv = (TextView) findViewById(R.id.artist_name);
songsBackgroundView = findViewById(R.id.list_background); songsBackgroundView = findViewById(R.id.list_background);
statusBar = findViewById(R.id.statusBar);
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false); songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
albumRecyclerView = (RecyclerView) songListHeader.findViewById(R.id.recycler_view); albumRecyclerView = (RecyclerView) songListHeader.findViewById(R.id.recycler_view);
@ -161,8 +165,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
int toolbarHeight = Util.getActionBarSize(this); int toolbarHeight = Util.getActionBarSize(this);
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height); titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
headerOffset = toolbarHeight; headerOffset = toolbarHeight;
if (Util.hasKitKatSDK() && !Util.hasLollipopSDK()) headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
} }
@Override @Override
@ -429,4 +432,4 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
super.onDestroy(); super.onDestroy();
App.bus.unregister(this); App.bus.unregister(this);
} }
} }

View file

@ -16,9 +16,7 @@
android:id="@+id/list_background" android:id="@+id/list_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/colorBackground" android:background="?android:attr/colorBackground" />
android:elevation="@dimen/toolbar_elevation"
tools:ignore="UnusedAttribute" />
<com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView <com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView
android:id="@+id/list" android:id="@+id/list"
@ -32,7 +30,9 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:elevation="@dimen/toolbar_elevation"
tools:ignore="UnusedAttribute">
<TextView <TextView
android:id="@+id/album_title" android:id="@+id/album_title"
@ -62,6 +62,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="@dimen/statusMargin"
android:background="@android:color/transparent"
tools:ignore="ContentDescription" />
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
@ -77,4 +84,4 @@
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
tools:ignore="RtlHardcoded" /> tools:ignore="RtlHardcoded" />
</FrameLayout> </FrameLayout>

View file

@ -16,9 +16,7 @@
android:id="@+id/list_background" android:id="@+id/list_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/colorBackground" android:background="?android:attr/colorBackground" />
android:elevation="@dimen/toolbar_elevation"
tools:ignore="UnusedAttribute" />
<com.github.ksoichiro.android.observablescrollview.ObservableListView <com.github.ksoichiro.android.observablescrollview.ObservableListView
android:id="@+id/list" android:id="@+id/list"
@ -62,6 +60,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="@dimen/statusMargin"
android:background="@android:color/transparent"
tools:ignore="ContentDescription" />
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
@ -77,4 +82,4 @@
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
tools:ignore="RtlHardcoded" /> tools:ignore="RtlHardcoded" />
</FrameLayout> </FrameLayout>