Now using "butterknife" library in all activities.
This commit is contained in:
parent
ee235f1b5d
commit
6880710920
14 changed files with 317 additions and 282 deletions
|
|
@ -67,4 +67,6 @@ dependencies {
|
||||||
|
|
||||||
compile 'com.afollestad:material-dialogs:0.7.6.0'
|
compile 'com.afollestad:material-dialogs:0.7.6.0'
|
||||||
compile 'com.afollestad:material-cab:0.1.4'
|
compile 'com.afollestad:material-cab:0.1.4'
|
||||||
|
|
||||||
|
compile 'com.jakewharton:butterknife:6.1.0'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.activities;
|
package com.kabouzeid.gramophone.ui.activities;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
|
@ -54,9 +55,12 @@ import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
||||||
* <p/>
|
* <p>
|
||||||
* Should be kinda stable ONLY AS IT IS!!!
|
* Should be kinda stable ONLY AS IT IS!!!
|
||||||
*/
|
*/
|
||||||
public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
|
public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
|
||||||
|
|
@ -65,14 +69,22 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
||||||
private static final int TAG_EDITOR_REQUEST = 2001;
|
private static final int TAG_EDITOR_REQUEST = 2001;
|
||||||
private Album album;
|
private Album album;
|
||||||
|
|
||||||
private ObservableRecyclerView recyclerView;
|
@InjectView(R.id.list)
|
||||||
|
ObservableRecyclerView recyclerView;
|
||||||
|
@InjectView(R.id.album_art)
|
||||||
|
ImageView albumArtImageView;
|
||||||
|
@InjectView(R.id.album_art_background)
|
||||||
|
ImageView albumArtBackground;
|
||||||
|
@InjectView(R.id.toolbar)
|
||||||
|
Toolbar toolbar;
|
||||||
|
@InjectView(R.id.album_title)
|
||||||
|
TextView albumTitleView;
|
||||||
|
@InjectView(R.id.list_background)
|
||||||
|
View songsBackgroundView;
|
||||||
|
|
||||||
private AlbumSongAdapter adapter;
|
private AlbumSongAdapter adapter;
|
||||||
private ArrayList<Song> songs;
|
private ArrayList<Song> songs;
|
||||||
private ImageView albumArtImageView;
|
|
||||||
private ImageView albumArtBackground;
|
|
||||||
private View songsBackgroundView;
|
|
||||||
private TextView albumTitleView;
|
|
||||||
private Toolbar toolbar;
|
|
||||||
private MaterialCab cab;
|
private MaterialCab cab;
|
||||||
private int headerOffset;
|
private int headerOffset;
|
||||||
private int titleViewHeight;
|
private int titleViewHeight;
|
||||||
|
|
@ -81,6 +93,63 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
||||||
private float toolbarAlpha;
|
private float toolbarAlpha;
|
||||||
private int bottomOffset;
|
private int bottomOffset;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
setStatusBarTransparent();
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_album_detail);
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
|
App.bus.register(this);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
postponeEnterTransition();
|
||||||
|
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbum())
|
||||||
|
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||||
|
}
|
||||||
|
|
||||||
|
Bundle intentExtras = getIntent().getExtras();
|
||||||
|
int albumId = -1;
|
||||||
|
if (intentExtras != null) {
|
||||||
|
albumId = intentExtras.getInt(AppKeys.E_ALBUM);
|
||||||
|
}
|
||||||
|
album = AlbumLoader.getAlbum(this, albumId);
|
||||||
|
if (album.id == -1) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpObservableListViewParams();
|
||||||
|
setUpToolBar();
|
||||||
|
setUpViews();
|
||||||
|
animateFabCircularRevealOnEnterTransitionEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void animateFabCircularRevealOnEnterTransitionEnd() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
getWindow().getEnterTransition().addListener(new SmallTransitionListener() {
|
||||||
|
@Override
|
||||||
|
public void onTransitionStart(Transition transition) {
|
||||||
|
albumArtBackground.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
@Override
|
||||||
|
public void onTransitionEnd(Transition transition) {
|
||||||
|
int cx = (albumArtBackground.getLeft() + albumArtBackground.getRight()) / 2;
|
||||||
|
int cy = (albumArtBackground.getTop() + albumArtBackground.getBottom()) / 2;
|
||||||
|
int finalRadius = Math.max(albumArtBackground.getWidth(), albumArtBackground.getHeight());
|
||||||
|
|
||||||
|
Animator animator = ViewAnimationUtils.createCircularReveal(albumArtBackground, cx, cy, albumArtImageView.getWidth() / 2, finalRadius);
|
||||||
|
animator.setInterpolator(new DecelerateInterpolator());
|
||||||
|
animator.setDuration(1000);
|
||||||
|
animator.start();
|
||||||
|
|
||||||
|
albumArtBackground.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
@ -108,73 +177,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
setStatusBarTransparent();
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_album_detail);
|
|
||||||
|
|
||||||
App.bus.register(this);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
postponeEnterTransition();
|
|
||||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbum())
|
|
||||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
|
||||||
}
|
|
||||||
|
|
||||||
Bundle intentExtras = getIntent().getExtras();
|
|
||||||
int albumId = -1;
|
|
||||||
if (intentExtras != null) {
|
|
||||||
albumId = intentExtras.getInt(AppKeys.E_ALBUM);
|
|
||||||
}
|
|
||||||
album = AlbumLoader.getAlbum(this, albumId);
|
|
||||||
if (album.id == -1) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
initViews();
|
|
||||||
setUpObservableListViewParams();
|
|
||||||
setUpToolBar();
|
|
||||||
setUpViews();
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
getWindow().getEnterTransition().addListener(new SmallTransitionListener() {
|
|
||||||
@Override
|
|
||||||
public void onTransitionStart(Transition transition) {
|
|
||||||
albumArtBackground.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTransitionEnd(Transition transition) {
|
|
||||||
int cx = (albumArtBackground.getLeft() + albumArtBackground.getRight()) / 2;
|
|
||||||
int cy = (albumArtBackground.getTop() + albumArtBackground.getBottom()) / 2;
|
|
||||||
int finalRadius = Math.max(albumArtBackground.getWidth(), albumArtBackground.getHeight());
|
|
||||||
|
|
||||||
Animator animator = ViewAnimationUtils.createCircularReveal(albumArtBackground, cx, cy, albumArtImageView.getWidth() / 2, finalRadius);
|
|
||||||
animator.setInterpolator(new DecelerateInterpolator());
|
|
||||||
animator.setDuration(1000);
|
|
||||||
animator.start();
|
|
||||||
|
|
||||||
albumArtBackground.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
|
||||||
albumArtImageView = (ImageView) findViewById(R.id.album_art);
|
|
||||||
albumArtBackground = (ImageView) findViewById(R.id.album_art_background);
|
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
recyclerView = (ObservableRecyclerView) findViewById(R.id.list);
|
|
||||||
albumTitleView = (TextView) findViewById(R.id.album_title);
|
|
||||||
songsBackgroundView = findViewById(R.id.list_background);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpObservableListViewParams() {
|
private void setUpObservableListViewParams() {
|
||||||
bottomOffset = getResources().getDimensionPixelSize(R.dimen.bottom_offset_fab_activity);
|
bottomOffset = getResources().getDimensionPixelSize(R.dimen.bottom_offset_fab_activity);
|
||||||
albumArtViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
albumArtViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.activities;
|
package com.kabouzeid.gramophone.ui.activities;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
|
@ -54,6 +55,7 @@ import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||||
|
import com.kabouzeid.gramophone.views.SquareIfPlaceImageView;
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||||
|
|
@ -62,22 +64,34 @@ import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
||||||
* <p/>
|
* <p>
|
||||||
* Should be kinda stable ONLY AS IT IS!!!
|
* Should be kinda stable ONLY AS IT IS!!!
|
||||||
*/
|
*/
|
||||||
public class ArtistDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
|
public class ArtistDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
|
||||||
|
|
||||||
public static final String TAG = ArtistDetailActivity.class.getSimpleName();
|
public static final String TAG = ArtistDetailActivity.class.getSimpleName();
|
||||||
private Artist artist;
|
|
||||||
|
|
||||||
private ObservableListView songListView;
|
@InjectView(R.id.artist_image_background)
|
||||||
private ImageView artistImage;
|
ImageView artistImageBackground;
|
||||||
private ImageView artistImageBackground;
|
@InjectView(R.id.artist_image)
|
||||||
private View songsBackgroundView;
|
SquareIfPlaceImageView artistImage;
|
||||||
private TextView artistNameTv;
|
@InjectView(R.id.list_background)
|
||||||
private Toolbar toolbar;
|
View songListBackground;
|
||||||
|
@InjectView(R.id.list)
|
||||||
|
ObservableListView songListView;
|
||||||
|
@InjectView(R.id.artist_name)
|
||||||
|
TextView artistName;
|
||||||
|
@InjectView(R.id.toolbar)
|
||||||
|
Toolbar toolbar;
|
||||||
|
|
||||||
|
View songListHeader;
|
||||||
|
RecyclerView albumRecyclerView;
|
||||||
|
|
||||||
private MaterialCab cab;
|
private MaterialCab cab;
|
||||||
private int headerOffset;
|
private int headerOffset;
|
||||||
private int titleViewHeight;
|
private int titleViewHeight;
|
||||||
|
|
@ -86,47 +100,19 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
private float toolbarAlpha;
|
private float toolbarAlpha;
|
||||||
private int bottomOffset;
|
private int bottomOffset;
|
||||||
|
|
||||||
private View songListHeader;
|
private Artist artist;
|
||||||
private RecyclerView albumRecyclerView;
|
|
||||||
private Spanned biography;
|
private Spanned biography;
|
||||||
private ArtistAlbumAdapter albumAdapter;
|
private ArtistAlbumAdapter albumAdapter;
|
||||||
private ArtistSongAdapter songAdapter;
|
private ArtistSongAdapter songAdapter;
|
||||||
private ArrayList<Song> songs;
|
private ArrayList<Song> songs;
|
||||||
private ArrayList<Album> albums;
|
private ArrayList<Album> albums;
|
||||||
|
|
||||||
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
|
||||||
@Override
|
|
||||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
|
||||||
scrollY += artistImageViewHeight + titleViewHeight;
|
|
||||||
super.onScrollChanged(scrollY, b, b2);
|
|
||||||
float flexibleRange = artistImageViewHeight - headerOffset;
|
|
||||||
|
|
||||||
// Translate album cover
|
|
||||||
artistImage.setTranslationY(Math.max(-artistImageViewHeight, -scrollY / 2));
|
|
||||||
|
|
||||||
// Translate list background
|
|
||||||
songsBackgroundView.setTranslationY(Math.max(0, -scrollY + artistImageViewHeight));
|
|
||||||
|
|
||||||
// Change alpha of overlay
|
|
||||||
toolbarAlpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
|
||||||
ViewUtil.setBackgroundAlpha(toolbar, toolbarAlpha, toolbarColor);
|
|
||||||
setStatusBarColor(Util.getColorWithAlpha(cab != null && cab.isActive() ? 1 : toolbarAlpha, toolbarColor));
|
|
||||||
|
|
||||||
// Translate name text
|
|
||||||
int maxTitleTranslationY = artistImageViewHeight;
|
|
||||||
int titleTranslationY = maxTitleTranslationY - scrollY;
|
|
||||||
titleTranslationY = Math.max(headerOffset, titleTranslationY);
|
|
||||||
|
|
||||||
artistNameTv.setTranslationY(titleTranslationY);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setStatusBarTransparent();
|
setStatusBarTransparent();
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_artist_detail);
|
setContentView(R.layout.activity_artist_detail);
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
App.bus.register(this);
|
App.bus.register(this);
|
||||||
|
|
||||||
|
|
@ -158,6 +144,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
artistImageBackground.setVisibility(View.INVISIBLE);
|
artistImageBackground.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
public void onTransitionEnd(Transition transition) {
|
public void onTransitionEnd(Transition transition) {
|
||||||
int cx = (artistImageBackground.getLeft() + artistImageBackground.getRight()) / 2;
|
int cx = (artistImageBackground.getLeft() + artistImageBackground.getRight()) / 2;
|
||||||
|
|
@ -175,17 +162,32 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||||
artistImage = (ImageView) findViewById(R.id.artist_image);
|
@Override
|
||||||
artistImageBackground = (ImageView) findViewById(R.id.artist_image_background);
|
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
scrollY += artistImageViewHeight + titleViewHeight;
|
||||||
songListView = (ObservableListView) findViewById(R.id.list);
|
super.onScrollChanged(scrollY, b, b2);
|
||||||
artistNameTv = (TextView) findViewById(R.id.artist_name);
|
float flexibleRange = artistImageViewHeight - headerOffset;
|
||||||
songsBackgroundView = findViewById(R.id.list_background);
|
|
||||||
|
|
||||||
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
|
// Translate album cover
|
||||||
albumRecyclerView = (RecyclerView) songListHeader.findViewById(R.id.recycler_view);
|
artistImage.setTranslationY(Math.max(-artistImageViewHeight, -scrollY / 2));
|
||||||
}
|
|
||||||
|
// Translate list background
|
||||||
|
songListBackground.setTranslationY(Math.max(0, -scrollY + artistImageViewHeight));
|
||||||
|
|
||||||
|
// Change alpha of overlay
|
||||||
|
toolbarAlpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
||||||
|
ViewUtil.setBackgroundAlpha(toolbar, toolbarAlpha, toolbarColor);
|
||||||
|
setStatusBarColor(Util.getColorWithAlpha(cab != null && cab.isActive() ? 1 : toolbarAlpha, toolbarColor));
|
||||||
|
|
||||||
|
// Translate name text
|
||||||
|
int maxTitleTranslationY = artistImageViewHeight;
|
||||||
|
int titleTranslationY = maxTitleTranslationY - scrollY;
|
||||||
|
titleTranslationY = Math.max(headerOffset, titleTranslationY);
|
||||||
|
|
||||||
|
artistName.setTranslationY(titleTranslationY);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private void setUpObservableListViewParams() {
|
private void setUpObservableListViewParams() {
|
||||||
bottomOffset = getResources().getDimensionPixelSize(R.dimen.bottom_offset_fab_activity);
|
bottomOffset = getResources().getDimensionPixelSize(R.dimen.bottom_offset_fab_activity);
|
||||||
|
|
@ -198,13 +200,18 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
headerOffset += getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initViews() {
|
||||||
|
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
|
||||||
|
albumRecyclerView = ButterKnife.findById(songListHeader, R.id.recycler_view);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpViews() {
|
private void setUpViews() {
|
||||||
artistNameTv.setText(artist.name);
|
artistName.setText(artist.name);
|
||||||
|
|
||||||
ViewUtil.addOnGlobalLayoutListener(artistImage, new Runnable() {
|
ViewUtil.addOnGlobalLayoutListener(artistImage, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -239,7 +246,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
contentView.post(new Runnable() {
|
contentView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
songsBackgroundView.getLayoutParams().height = contentView.getHeight();
|
songListBackground.getLayoutParams().height = contentView.getHeight();
|
||||||
observableScrollViewCallbacks.onScrollChanged(-(artistImageViewHeight + titleViewHeight), false, false);
|
observableScrollViewCallbacks.onScrollChanged(-(artistImageViewHeight + titleViewHeight), false, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -315,8 +322,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||||
if (vibrantSwatch != null) {
|
if (vibrantSwatch != null) {
|
||||||
toolbarColor = vibrantSwatch.getRgb();
|
toolbarColor = vibrantSwatch.getRgb();
|
||||||
artistNameTv.setBackgroundColor(vibrantSwatch.getRgb());
|
artistName.setBackgroundColor(vibrantSwatch.getRgb());
|
||||||
artistNameTv.setTextColor(Util.getOpaqueColor(vibrantSwatch.getTitleTextColor()));
|
artistName.setTextColor(Util.getOpaqueColor(vibrantSwatch.getTitleTextColor()));
|
||||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(ArtistDetailActivity.this).coloredNavigationBarArtist())
|
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(ArtistDetailActivity.this).coloredNavigationBarArtist())
|
||||||
setNavigationBarColor(vibrantSwatch.getRgb());
|
setNavigationBarColor(vibrantSwatch.getRgb());
|
||||||
notifyTaskColorChange(toolbarColor);
|
notifyTaskColorChange(toolbarColor);
|
||||||
|
|
@ -353,8 +360,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
int defaultBarColor = DialogUtils.resolveColor(this, R.attr.default_bar_color);
|
int defaultBarColor = DialogUtils.resolveColor(this, R.attr.default_bar_color);
|
||||||
|
|
||||||
toolbarColor = defaultBarColor;
|
toolbarColor = defaultBarColor;
|
||||||
artistNameTv.setBackgroundColor(defaultBarColor);
|
artistName.setBackgroundColor(defaultBarColor);
|
||||||
artistNameTv.setTextColor(titleTextColor);
|
artistName.setTextColor(titleTextColor);
|
||||||
|
|
||||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtist())
|
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtist())
|
||||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||||
|
|
@ -426,6 +433,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
private void fixLollipopTransitionImageWrongSize() {
|
private void fixLollipopTransitionImageWrongSize() {
|
||||||
getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
|
getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -62,29 +62,39 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
public class MainActivity extends AbsFabActivity
|
public class MainActivity extends AbsFabActivity
|
||||||
implements KabViewsDisableAble, CabHolder, View.OnClickListener {
|
implements KabViewsDisableAble, CabHolder, View.OnClickListener {
|
||||||
|
|
||||||
public static final String TAG = MainActivity.class.getSimpleName();
|
public static final String TAG = MainActivity.class.getSimpleName();
|
||||||
|
|
||||||
private DrawerLayout drawerLayout;
|
@InjectView(R.id.toolbar)
|
||||||
|
Toolbar toolbar;
|
||||||
|
@InjectView(R.id.tabs)
|
||||||
|
TabLayout tabs;
|
||||||
|
@InjectView(R.id.appbar)
|
||||||
|
AppBarLayout appbar;
|
||||||
|
@InjectView(R.id.pager)
|
||||||
|
ViewPager pager;
|
||||||
|
@InjectView(R.id.navigation_view)
|
||||||
|
NavigationView navigationView;
|
||||||
|
@InjectView(R.id.drawer_layout)
|
||||||
|
DrawerLayout drawerLayout;
|
||||||
|
|
||||||
private ActionBarDrawerToggle drawerToggle;
|
private ActionBarDrawerToggle drawerToggle;
|
||||||
private AppBarLayout appBar;
|
|
||||||
private Toolbar toolbar;
|
|
||||||
private PagerAdapter pagerAdapter;
|
private PagerAdapter pagerAdapter;
|
||||||
private ViewPager viewPager;
|
|
||||||
private TabLayout tabLayout;
|
|
||||||
private int currentPage = -1;
|
private int currentPage = -1;
|
||||||
private MaterialCab cab;
|
private MaterialCab cab;
|
||||||
private NavigationView navigationView;
|
|
||||||
private View navigationDrawerHeader;
|
private View navigationDrawerHeader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
initViews();
|
|
||||||
setUpDrawerLayout();
|
setUpDrawerLayout();
|
||||||
setUpToolbar();
|
setUpToolbar();
|
||||||
setUpViewPager();
|
setUpViewPager();
|
||||||
|
|
@ -102,8 +112,8 @@ public class MainActivity extends AbsFabActivity
|
||||||
pagerAdapter.add(fragment.getFragmentClass(), null);
|
pagerAdapter.add(fragment.getFragmentClass(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewPager.setAdapter(pagerAdapter);
|
pager.setAdapter(pagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
|
pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
|
||||||
|
|
||||||
int startPosition = PreferenceUtils.getInstance(this).getDefaultStartPage();
|
int startPosition = PreferenceUtils.getInstance(this).getDefaultStartPage();
|
||||||
startPosition = startPosition == -1 ? PreferenceUtils.getInstance(this).getLastStartPage() : startPosition;
|
startPosition = startPosition == -1 ? PreferenceUtils.getInstance(this).getLastStartPage() : startPosition;
|
||||||
|
|
@ -111,8 +121,8 @@ public class MainActivity extends AbsFabActivity
|
||||||
|
|
||||||
navigationView.getMenu().getItem(startPosition).setChecked(true);
|
navigationView.getMenu().getItem(startPosition).setChecked(true);
|
||||||
|
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
tabs.setupWithViewPager(pager);
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
||||||
|
|
@ -130,16 +140,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
viewPager.setCurrentItem(startPosition);
|
pager.setCurrentItem(startPosition);
|
||||||
}
|
|
||||||
|
|
||||||
private void initViews() {
|
|
||||||
viewPager = (ViewPager) findViewById(R.id.pager);
|
|
||||||
tabLayout = (TabLayout) findViewById(R.id.tabs);
|
|
||||||
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
||||||
navigationView = (NavigationView) findViewById(R.id.nav_view);
|
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
appBar = (AppBarLayout) findViewById(R.id.appbar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpToolbar() {
|
private void setUpToolbar() {
|
||||||
|
|
@ -150,7 +151,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAppBarColor() {
|
private void setAppBarColor() {
|
||||||
appBar.setBackgroundColor(getThemeColorPrimary());
|
appbar.setBackgroundColor(getThemeColorPrimary());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpNavigationView() {
|
private void setUpNavigationView() {
|
||||||
|
|
@ -186,19 +187,19 @@ public class MainActivity extends AbsFabActivity
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case R.id.nav_songs:
|
case R.id.nav_songs:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.SONG.ordinal(), true);
|
pager.setCurrentItem(PagerAdapter.MusicFragments.SONG.ordinal(), true);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_albums:
|
case R.id.nav_albums:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.ALBUM.ordinal(), true);
|
pager.setCurrentItem(PagerAdapter.MusicFragments.ALBUM.ordinal(), true);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_artists:
|
case R.id.nav_artists:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.ARTIST.ordinal(), true);
|
pager.setCurrentItem(PagerAdapter.MusicFragments.ARTIST.ordinal(), true);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_playlists:
|
case R.id.nav_playlists:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
viewPager.setCurrentItem(PagerAdapter.MusicFragments.PLAYLIST.ordinal(), true);
|
pager.setCurrentItem(PagerAdapter.MusicFragments.PLAYLIST.ordinal(), true);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_settings:
|
case R.id.nav_settings:
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
|
@ -278,7 +279,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
try {
|
try {
|
||||||
super.enableViews();
|
super.enableViews();
|
||||||
toolbar.setEnabled(true);
|
toolbar.setEnabled(true);
|
||||||
((AbsMainActivityFragment) pagerAdapter.getItem(viewPager.getCurrentItem())).enableViews();
|
((AbsMainActivityFragment) pagerAdapter.getItem(pager.getCurrentItem())).enableViews();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
//Log.e(TAG, "wasn't able to enable the views", e);
|
//Log.e(TAG, "wasn't able to enable the views", e);
|
||||||
}
|
}
|
||||||
|
|
@ -288,7 +289,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
public void disableViews() {
|
public void disableViews() {
|
||||||
try {
|
try {
|
||||||
super.disableViews();
|
super.disableViews();
|
||||||
((AbsMainActivityFragment) pagerAdapter.getItem(viewPager.getCurrentItem())).disableViews();
|
((AbsMainActivityFragment) pagerAdapter.getItem(pager.getCurrentItem())).disableViews();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
//Log.e(TAG, "wasn't able to disable the views", e);
|
//Log.e(TAG, "wasn't able to disable the views", e);
|
||||||
}
|
}
|
||||||
|
|
@ -459,7 +460,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
// private boolean isArtistPage() {
|
// private boolean isArtistPage() {
|
||||||
// return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.ARTIST.ordinal();
|
// return pager.getCurrentItem() == PagerAdapter.MusicFragments.ARTIST.ordinal();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public ArtistViewFragment getArtistFragment() {
|
// public ArtistViewFragment getArtistFragment() {
|
||||||
|
|
@ -467,7 +468,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private boolean isAlbumPage() {
|
private boolean isAlbumPage() {
|
||||||
return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.ALBUM.ordinal();
|
return pager.getCurrentItem() == PagerAdapter.MusicFragments.ALBUM.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlbumViewFragment getAlbumFragment() {
|
public AlbumViewFragment getAlbumFragment() {
|
||||||
|
|
@ -475,7 +476,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
// private boolean isSongPage() {
|
// private boolean isSongPage() {
|
||||||
// return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.SONG.ordinal();
|
// return pager.getCurrentItem() == PagerAdapter.MusicFragments.SONG.ordinal();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public SongViewFragment getSongFragment() {
|
// public SongViewFragment getSongFragment() {
|
||||||
|
|
@ -483,7 +484,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private boolean isPlaylistPage() {
|
private boolean isPlaylistPage() {
|
||||||
return viewPager.getCurrentItem() == PagerAdapter.MusicFragments.PLAYLIST.ordinal();
|
return pager.getCurrentItem() == PagerAdapter.MusicFragments.PLAYLIST.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public PlaylistViewFragment getPlaylistFragment() {
|
// public PlaylistViewFragment getPlaylistFragment() {
|
||||||
|
|
@ -604,14 +605,14 @@ public class MainActivity extends AbsFabActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOnAppBarOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
public void addOnAppBarOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
||||||
appBar.addOnOffsetChangedListener(onOffsetChangedListener);
|
appbar.addOnOffsetChangedListener(onOffsetChangedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeOnAppBArOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
public void removeOnAppBArOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
||||||
appBar.removeOnOffsetChangedListener(onOffsetChangedListener);
|
appbar.removeOnOffsetChangedListener(onOffsetChangedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalAppBarScrollingRange() {
|
public int getTotalAppBarScrollingRange() {
|
||||||
return appBar.getTotalScrollRange();
|
return appbar.getTotalScrollRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.activities;
|
package com.kabouzeid.gramophone.ui.activities;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
@ -26,6 +27,7 @@ import android.view.ViewGroup;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
@ -59,30 +61,49 @@ import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListene
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
public class MusicControllerActivity extends AbsFabActivity {
|
public class MusicControllerActivity extends AbsFabActivity {
|
||||||
|
|
||||||
public static final String TAG = MusicControllerActivity.class.getSimpleName();
|
public static final String TAG = MusicControllerActivity.class.getSimpleName();
|
||||||
private static final int COLOR_TRANSITION_TIME = 400;
|
private static final int COLOR_TRANSITION_TIME = 400;
|
||||||
private static final int UPDATE_PROGRESS_VIEWS = 1;
|
private static final int UPDATE_PROGRESS_VIEWS = 1;
|
||||||
|
|
||||||
private Song song;
|
@InjectView(R.id.song_title)
|
||||||
private SquareIfPlaceImageView albumArt;
|
TextView songTitle;
|
||||||
private ImageView albumArtBackground;
|
@InjectView(R.id.song_artist)
|
||||||
private TextView songTitle;
|
TextView songArtist;
|
||||||
private TextView songArtist;
|
@InjectView(R.id.footer)
|
||||||
private TextView currentSongProgress;
|
LinearLayout footer;
|
||||||
private TextView totalSongDuration;
|
@InjectView(R.id.playback_controller_card)
|
||||||
private View footer;
|
CardView playbackControllerCard;
|
||||||
private SeekBar progressSlider;
|
@InjectView(R.id.prev_button)
|
||||||
private ImageButton nextButton;
|
ImageButton prevButton;
|
||||||
private ImageButton prevButton;
|
@InjectView(R.id.next_button)
|
||||||
private ImageButton repeatButton;
|
ImageButton nextButton;
|
||||||
private ImageButton shuffleButton;
|
@InjectView(R.id.repeat_button)
|
||||||
private View mediaControllerContainer;
|
ImageButton repeatButton;
|
||||||
private CardView playbackControllerCard;
|
@InjectView(R.id.shuffle_button)
|
||||||
private Toolbar toolbar;
|
ImageButton shuffleButton;
|
||||||
|
@InjectView(R.id.media_controller_container)
|
||||||
|
RelativeLayout mediaControllerContainer;
|
||||||
|
@InjectView(R.id.album_art_background)
|
||||||
|
ImageView albumArtBackground;
|
||||||
|
@InjectView(R.id.album_art)
|
||||||
|
SquareIfPlaceImageView albumArt;
|
||||||
|
@InjectView(R.id.song_current_progress)
|
||||||
|
TextView songCurrentProgress;
|
||||||
|
@InjectView(R.id.song_total_time)
|
||||||
|
TextView songTotalTime;
|
||||||
|
@InjectView(R.id.progress_slider)
|
||||||
|
SeekBar progressSlider;
|
||||||
|
@InjectView(R.id.toolbar)
|
||||||
|
Toolbar toolbar;
|
||||||
|
|
||||||
private int lastFooterColor = -1;
|
private int lastFooterColor = -1;
|
||||||
private int lastTextColor = -2;
|
private int lastTextColor = -2;
|
||||||
|
|
||||||
private Handler progressViewsUpdateHandler;
|
private Handler progressViewsUpdateHandler;
|
||||||
private HandlerThread handlerThread;
|
private HandlerThread handlerThread;
|
||||||
|
|
||||||
|
|
@ -93,6 +114,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
private boolean alternativeProgressSlider;
|
private boolean alternativeProgressSlider;
|
||||||
private boolean showPlaybackControllerCard;
|
private boolean showPlaybackControllerCard;
|
||||||
|
|
||||||
|
private Song song;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setStatusBarTransparent();
|
setStatusBarTransparent();
|
||||||
|
|
@ -102,8 +125,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
initAppearanceVarsFromSharedPrefs();
|
initAppearanceVarsFromSharedPrefs();
|
||||||
|
|
||||||
setContentView(alternativeProgressSlider ? R.layout.activity_music_controller_alternative_progress_slider : R.layout.activity_music_controller);
|
setContentView(alternativeProgressSlider ? R.layout.activity_music_controller_alternative_progress_slider : R.layout.activity_music_controller);
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
initViews();
|
|
||||||
moveSeekBarIntoPlace();
|
moveSeekBarIntoPlace();
|
||||||
adjustTitleBoxSize();
|
adjustTitleBoxSize();
|
||||||
setUpPlaybackControllerCard();
|
setUpPlaybackControllerCard();
|
||||||
|
|
@ -142,6 +165,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
mediaControllerContainer.setVisibility(View.INVISIBLE);
|
mediaControllerContainer.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
public void onTransitionEnd(Transition transition) {
|
public void onTransitionEnd(Transition transition) {
|
||||||
int cx = (getFab().getLeft() + getFab().getRight()) / 2;
|
int cx = (getFab().getLeft() + getFab().getRight()) / 2;
|
||||||
|
|
@ -225,24 +249,6 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
mediaControllerContainer.setBackgroundColor(showPlaybackControllerCard ? Color.TRANSPARENT : Util.resolveColor(this, R.attr.music_controller_container_color));
|
mediaControllerContainer.setBackgroundColor(showPlaybackControllerCard ? Color.TRANSPARENT : Util.resolveColor(this, R.attr.music_controller_container_color));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
|
||||||
nextButton = (ImageButton) findViewById(R.id.next_button);
|
|
||||||
prevButton = (ImageButton) findViewById(R.id.prev_button);
|
|
||||||
repeatButton = (ImageButton) findViewById(R.id.repeat_button);
|
|
||||||
shuffleButton = (ImageButton) findViewById(R.id.shuffle_button);
|
|
||||||
albumArt = (SquareIfPlaceImageView) findViewById(R.id.album_art);
|
|
||||||
albumArtBackground = (ImageView) findViewById(R.id.album_art_background);
|
|
||||||
songTitle = (TextView) findViewById(R.id.song_title);
|
|
||||||
songArtist = (TextView) findViewById(R.id.song_artist);
|
|
||||||
currentSongProgress = (TextView) findViewById(R.id.song_current_progress);
|
|
||||||
totalSongDuration = (TextView) findViewById(R.id.song_total_time);
|
|
||||||
footer = findViewById(R.id.footer);
|
|
||||||
progressSlider = (SeekBar) findViewById(R.id.progress_slider);
|
|
||||||
mediaControllerContainer = findViewById(R.id.media_controller_container);
|
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
playbackControllerCard = (CardView) findViewById(R.id.playback_controller_card);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpMusicControllers() {
|
private void setUpMusicControllers() {
|
||||||
setUpPrevNext();
|
setUpPrevNext();
|
||||||
setUpRepeatButton();
|
setUpRepeatButton();
|
||||||
|
|
@ -376,8 +382,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
getCurrentSong();
|
getCurrentSong();
|
||||||
setHeadersText();
|
setHeadersText();
|
||||||
setUpAlbumArtAndApplyPalette();
|
setUpAlbumArtAndApplyPalette();
|
||||||
totalSongDuration.setText(MusicUtil.getReadableDurationString(song.duration));
|
songTotalTime.setText(MusicUtil.getReadableDurationString(song.duration));
|
||||||
currentSongProgress.setText(MusicUtil.getReadableDurationString(0));
|
songCurrentProgress.setText(MusicUtil.getReadableDurationString(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHeadersText() {
|
private void setHeadersText() {
|
||||||
|
|
@ -497,8 +503,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
public void run() {
|
public void run() {
|
||||||
progressSlider.setMax(totalMillis);
|
progressSlider.setMax(totalMillis);
|
||||||
progressSlider.setProgress(progressMillis);
|
progressSlider.setProgress(progressMillis);
|
||||||
currentSongProgress.setText(MusicUtil.getReadableDurationString(progressMillis));
|
songCurrentProgress.setText(MusicUtil.getReadableDurationString(progressMillis));
|
||||||
totalSongDuration.setText(MusicUtil.getReadableDurationString(totalMillis));
|
songTotalTime.setText(MusicUtil.getReadableDurationString(totalMillis));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ import java.util.ArrayList;
|
||||||
public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder {
|
public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder {
|
||||||
|
|
||||||
public static final String TAG = PlaylistDetailActivity.class.getSimpleName();
|
public static final String TAG = PlaylistDetailActivity.class.getSimpleName();
|
||||||
|
|
||||||
private Playlist playlist;
|
private Playlist playlist;
|
||||||
private MaterialCab cab;
|
private MaterialCab cab;
|
||||||
private PlaylistSongAdapter adapter;
|
private PlaylistSongAdapter adapter;
|
||||||
private ArrayList<PlaylistSong> songs;
|
private ArrayList<PlaylistSong> songs;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.SearchAdapter;
|
import com.kabouzeid.gramophone.adapter.SearchAdapter;
|
||||||
|
|
@ -23,13 +24,23 @@ import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
public class SearchActivity extends AbsBaseActivity {
|
public class SearchActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
public static final String TAG = SearchActivity.class.getSimpleName();
|
public static final String TAG = SearchActivity.class.getSimpleName();
|
||||||
private RecyclerView recyclerView;
|
@InjectView(R.id.recycler_view)
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
@InjectView(R.id.toolbar)
|
||||||
|
Toolbar toolbar;
|
||||||
|
@SuppressWarnings("ButterKnifeNoViewWithId")
|
||||||
|
@InjectView(android.R.id.empty)
|
||||||
|
TextView empty;
|
||||||
|
|
||||||
|
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
private SearchAdapter searchAdapter;
|
private SearchAdapter searchAdapter;
|
||||||
private View noResults;
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -37,9 +48,8 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
setTitle(null);
|
setTitle(null);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_search);
|
setContentView(R.layout.activity_search);
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
noResults = findViewById(android.R.id.empty);
|
|
||||||
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
searchAdapter = new SearchAdapter(this);
|
searchAdapter = new SearchAdapter(this);
|
||||||
recyclerView.setAdapter(searchAdapter);
|
recyclerView.setAdapter(searchAdapter);
|
||||||
|
|
@ -55,7 +65,6 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
toolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
toolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
|
|
@ -136,7 +145,7 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
private void search(String query) {
|
private void search(String query) {
|
||||||
if (searchAdapter != null) {
|
if (searchAdapter != null) {
|
||||||
searchAdapter.search(query);
|
searchAdapter.search(query);
|
||||||
noResults.setVisibility(searchAdapter.getItemCount() < 1 ? View.VISIBLE : View.GONE);
|
empty.setVisibility(searchAdapter.getItemCount() < 1 ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import com.squareup.otto.Subscribe;
|
||||||
*/
|
*/
|
||||||
public abstract class AbsBaseActivity extends AbsThemeActivity implements KabViewsDisableAble {
|
public abstract class AbsBaseActivity extends AbsThemeActivity implements KabViewsDisableAble {
|
||||||
|
|
||||||
private App app;
|
|
||||||
private boolean areViewsEnabled;
|
private boolean areViewsEnabled;
|
||||||
private final Object uiPreferenceChangeListener = new Object() {
|
private final Object uiPreferenceChangeListener = new Object() {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
@ -34,13 +33,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected App getApp() {
|
|
||||||
if (app == null) {
|
|
||||||
app = (App) getApplicationContext();
|
|
||||||
}
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract String getTag();
|
protected abstract String getTag();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -64,7 +56,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
return areViewsEnabled;
|
return areViewsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
protected void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case UIPreferenceChangedEvent.THEME_CHANGED:
|
case UIPreferenceChangedEvent.THEME_CHANGED:
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,26 @@ import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
import com.kabouzeid.gramophone.views.PlayPauseDrawable;
|
import com.kabouzeid.gramophone.views.PlayPauseDrawable;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
import butterknife.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsFabActivity extends AbsPlaybackStatusActivity {
|
public abstract class AbsFabActivity extends AbsPlaybackStatusActivity {
|
||||||
public static final String TAG = AbsFabActivity.class.getSimpleName();
|
public static final String TAG = AbsFabActivity.class.getSimpleName();
|
||||||
|
|
||||||
private FloatingActionButton fab;
|
@Optional
|
||||||
|
@InjectView(R.id.fab)
|
||||||
|
FloatingActionButton fab;
|
||||||
|
|
||||||
private PlayPauseDrawable playPauseDrawable;
|
private PlayPauseDrawable playPauseDrawable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
super.onPostCreate(savedInstanceState);
|
super.onPostCreate(savedInstanceState);
|
||||||
|
ButterKnife.inject(this);
|
||||||
setUpFab();
|
setUpFab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.OvershootInterpolator;
|
import android.view.animation.OvershootInterpolator;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.afollestad.materialdialogs.ThemeSingleton;
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
|
|
@ -50,6 +51,10 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
import butterknife.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
|
|
@ -63,31 +68,25 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
private int paletteColorPrimary;
|
private int paletteColorPrimary;
|
||||||
private boolean isInNoImageMode;
|
private boolean isInNoImageMode;
|
||||||
|
|
||||||
private FloatingActionButton fab;
|
@InjectView(R.id.fab)
|
||||||
private ObservableScrollView scrollView;
|
FloatingActionButton fab;
|
||||||
private Toolbar toolBar;
|
@InjectView(R.id.observableScrollView)
|
||||||
private ImageView image;
|
ObservableScrollView observableScrollView;
|
||||||
private View header;
|
@InjectView(R.id.toolbar)
|
||||||
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
Toolbar toolbar;
|
||||||
@Override
|
@Optional
|
||||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
@InjectView(R.id.image)
|
||||||
float alpha;
|
ImageView image;
|
||||||
if (!isInNoImageMode) {
|
@InjectView(R.id.header)
|
||||||
alpha = 1 - (float) Math.max(0, headerVariableSpace - scrollY) / headerVariableSpace;
|
LinearLayout header;
|
||||||
} else {
|
|
||||||
header.setTranslationY(scrollY);
|
|
||||||
alpha = 1;
|
|
||||||
}
|
|
||||||
ViewUtil.setBackgroundAlpha(toolBar, alpha, paletteColorPrimary);
|
|
||||||
image.setTranslationY(scrollY / 2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private List<String> songPaths;
|
private List<String> songPaths;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getContentViewLayout());
|
setContentView(getContentViewLayout());
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
getIntentExtras();
|
getIntentExtras();
|
||||||
|
|
||||||
|
|
@ -99,23 +98,13 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
headerVariableSpace = getResources().getDimensionPixelSize(R.dimen.tagEditorHeaderVariableSpace);
|
headerVariableSpace = getResources().getDimensionPixelSize(R.dimen.tagEditorHeaderVariableSpace);
|
||||||
|
|
||||||
|
|
||||||
initViews();
|
|
||||||
setUpViews();
|
setUpViews();
|
||||||
|
|
||||||
setSupportActionBar(toolBar);
|
setSupportActionBar(toolbar);
|
||||||
getSupportActionBar().setTitle(getResources().getString(R.string.tag_editor));
|
getSupportActionBar().setTitle(getResources().getString(R.string.tag_editor));
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
|
||||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
|
||||||
scrollView = (ObservableScrollView) findViewById(R.id.observableScrollView);
|
|
||||||
toolBar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
image = (ImageView) findViewById(R.id.image);
|
|
||||||
header = findViewById(R.id.header);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpViews() {
|
private void setUpViews() {
|
||||||
resetColors();
|
resetColors();
|
||||||
setUpScrollView();
|
setUpScrollView();
|
||||||
|
|
@ -124,9 +113,24 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpScrollView() {
|
private void setUpScrollView() {
|
||||||
scrollView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
observableScrollView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||||
|
@Override
|
||||||
|
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||||
|
float alpha;
|
||||||
|
if (!isInNoImageMode) {
|
||||||
|
alpha = 1 - (float) Math.max(0, headerVariableSpace - scrollY) / headerVariableSpace;
|
||||||
|
} else {
|
||||||
|
header.setTranslationY(scrollY);
|
||||||
|
alpha = 1;
|
||||||
|
}
|
||||||
|
ViewUtil.setBackgroundAlpha(toolbar, alpha, paletteColorPrimary);
|
||||||
|
image.setTranslationY(scrollY / 2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private void setUpImageView() {
|
private void setUpImageView() {
|
||||||
loadCurrentImage();
|
loadCurrentImage();
|
||||||
image.setOnClickListener(new View.OnClickListener() {
|
image.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
@ -189,9 +193,8 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
|
|
||||||
private void resetColors() {
|
private void resetColors() {
|
||||||
final int primaryColor = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
paletteColorPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||||
paletteColorPrimary = primaryColor;
|
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
|
||||||
setStatusBarColor(paletteColorPrimary);
|
setStatusBarColor(paletteColorPrimary);
|
||||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarTagEditor())
|
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarTagEditor())
|
||||||
setNavigationBarColor(paletteColorPrimary);
|
setNavigationBarColor(paletteColorPrimary);
|
||||||
|
|
@ -237,12 +240,12 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
isInNoImageMode = true;
|
isInNoImageMode = true;
|
||||||
image.setVisibility(View.GONE);
|
image.setVisibility(View.GONE);
|
||||||
image.setEnabled(false);
|
image.setEnabled(false);
|
||||||
scrollView.setPadding(0, Util.getActionBarSize(this), 0, 0);
|
observableScrollView.setPadding(0, Util.getActionBarSize(this), 0, 0);
|
||||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||||
|
|
||||||
paletteColorPrimary = getIntent().getIntExtra(AppKeys.E_PALETTE,
|
paletteColorPrimary = getIntent().getIntExtra(AppKeys.E_PALETTE,
|
||||||
PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
||||||
toolBar.setBackgroundColor(paletteColorPrimary);
|
toolbar.setBackgroundColor(paletteColorPrimary);
|
||||||
header.setBackgroundColor(paletteColorPrimary);
|
header.setBackgroundColor(paletteColorPrimary);
|
||||||
|
|
||||||
setStatusBarColor(paletteColorPrimary);
|
setStatusBarColor(paletteColorPrimary);
|
||||||
|
|
@ -285,9 +288,8 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
public void onGenerated(Palette palette) {
|
public void onGenerated(Palette palette) {
|
||||||
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
|
||||||
if (vibrantSwatch != null) {
|
if (vibrantSwatch != null) {
|
||||||
final int vibrantColor = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
paletteColorPrimary = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||||
paletteColorPrimary = vibrantColor;
|
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
|
||||||
setStatusBarColor(paletteColorPrimary);
|
setStatusBarColor(paletteColorPrimary);
|
||||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditor())
|
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditor())
|
||||||
setNavigationBarColor(paletteColorPrimary);
|
setNavigationBarColor(paletteColorPrimary);
|
||||||
|
|
|
||||||
|
|
@ -33,22 +33,30 @@ import java.util.EnumMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
||||||
|
|
||||||
public static final String TAG = AlbumTagEditorActivity.class.getSimpleName();
|
public static final String TAG = AlbumTagEditorActivity.class.getSimpleName();
|
||||||
|
|
||||||
|
@InjectView(R.id.album_title)
|
||||||
|
EditText albumTitle;
|
||||||
|
@InjectView(R.id.album_artist)
|
||||||
|
EditText albumArtist;
|
||||||
|
@InjectView(R.id.genre)
|
||||||
|
EditText genre;
|
||||||
|
@InjectView(R.id.year)
|
||||||
|
EditText year;
|
||||||
|
|
||||||
private Bitmap albumArtBitmap;
|
private Bitmap albumArtBitmap;
|
||||||
private boolean deleteAlbumArt;
|
private boolean deleteAlbumArt;
|
||||||
|
|
||||||
private EditText albumTitle;
|
|
||||||
private EditText albumArtistName;
|
|
||||||
private EditText genreName;
|
|
||||||
private EditText year;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
initViews();
|
|
||||||
setUpViews();
|
setUpViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,26 +65,19 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
|
||||||
albumTitle = (EditText) findViewById(R.id.album_title);
|
|
||||||
albumArtistName = (EditText) findViewById(R.id.album_artist);
|
|
||||||
genreName = (EditText) findViewById(R.id.genre);
|
|
||||||
year = (EditText) findViewById(R.id.year);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpViews() {
|
private void setUpViews() {
|
||||||
fillViewsWithFileTags();
|
fillViewsWithFileTags();
|
||||||
albumTitle.addTextChangedListener(this);
|
albumTitle.addTextChangedListener(this);
|
||||||
albumArtistName.addTextChangedListener(this);
|
albumArtist.addTextChangedListener(this);
|
||||||
genreName.addTextChangedListener(this);
|
genre.addTextChangedListener(this);
|
||||||
year.addTextChangedListener(this);
|
year.addTextChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void fillViewsWithFileTags() {
|
private void fillViewsWithFileTags() {
|
||||||
albumTitle.setText(getAlbumTitle());
|
albumTitle.setText(getAlbumTitle());
|
||||||
albumArtistName.setText(getAlbumArtistName());
|
albumArtist.setText(getAlbumArtistName());
|
||||||
genreName.setText(getGenreName());
|
genre.setText(getGenreName());
|
||||||
year.setText(getSongYear());
|
year.setText(getSongYear());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,7 +90,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
||||||
@Override
|
@Override
|
||||||
protected void getImageFromLastFM() {
|
protected void getImageFromLastFM() {
|
||||||
String albumTitleStr = albumTitle.getText().toString();
|
String albumTitleStr = albumTitle.getText().toString();
|
||||||
String albumArtistNameStr = albumArtistName.getText().toString();
|
String albumArtistNameStr = albumArtist.getText().toString();
|
||||||
if (albumArtistNameStr.trim().equals("") || albumTitleStr.trim().equals("")) {
|
if (albumArtistNameStr.trim().equals("") || albumTitleStr.trim().equals("")) {
|
||||||
Toast.makeText(this, getResources().getString(R.string.album_or_artist_empty), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getResources().getString(R.string.album_or_artist_empty), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
|
|
@ -130,7 +131,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
||||||
protected void searchImageOnWeb() {
|
protected void searchImageOnWeb() {
|
||||||
List<String> query = new ArrayList<>();
|
List<String> query = new ArrayList<>();
|
||||||
query.add(albumTitle.getText().toString());
|
query.add(albumTitle.getText().toString());
|
||||||
query.add(albumArtistName.getText().toString());
|
query.add(albumArtist.getText().toString());
|
||||||
searchWebFor(query);
|
searchWebFor(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,9 +148,9 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
||||||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||||
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
||||||
//android seems not to recognize album_artist field so we additionally write the normal artist field
|
//android seems not to recognize album_artist field so we additionally write the normal artist field
|
||||||
fieldKeyValueMap.put(FieldKey.ARTIST, albumArtistName.getText().toString());
|
fieldKeyValueMap.put(FieldKey.ARTIST, albumArtist.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.ALBUM_ARTIST, albumArtistName.getText().toString());
|
fieldKeyValueMap.put(FieldKey.ALBUM_ARTIST, albumArtist.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
fieldKeyValueMap.put(FieldKey.GENRE, genre.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
||||||
|
|
||||||
File albumArtFile = MusicUtil.createAlbumArtFile(String.valueOf(getId()));
|
File albumArtFile = MusicUtil.createAlbumArtFile(String.valueOf(getId()));
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,32 @@ import java.util.EnumMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
public class SongTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
public class SongTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
||||||
|
|
||||||
public static final String TAG = SongTagEditorActivity.class.getSimpleName();
|
public static final String TAG = SongTagEditorActivity.class.getSimpleName();
|
||||||
private EditText songTitle;
|
|
||||||
private EditText albumTitle;
|
@InjectView(R.id.title1)
|
||||||
private EditText artistName;
|
EditText songTitle;
|
||||||
private EditText genreName;
|
@InjectView(R.id.title2)
|
||||||
private EditText year;
|
EditText albumTitle;
|
||||||
private EditText trackNumber;
|
@InjectView(R.id.artist)
|
||||||
|
EditText artist;
|
||||||
|
@InjectView(R.id.genre)
|
||||||
|
EditText genre;
|
||||||
|
@InjectView(R.id.year)
|
||||||
|
EditText year;
|
||||||
|
@InjectView(R.id.track_number)
|
||||||
|
EditText trackNumber;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
setNoImageMode();
|
setNoImageMode();
|
||||||
initViews();
|
|
||||||
setUpViews();
|
setUpViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,31 +49,21 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
|
||||||
songTitle = (EditText) findViewById(R.id.title1);
|
|
||||||
albumTitle = (EditText) findViewById(R.id.title2);
|
|
||||||
artistName = (EditText) findViewById(R.id.artist);
|
|
||||||
genreName = (EditText) findViewById(R.id.genre);
|
|
||||||
year = (EditText) findViewById(R.id.year);
|
|
||||||
trackNumber = (EditText) findViewById(R.id.track_number);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpViews() {
|
private void setUpViews() {
|
||||||
fillViewsWithFileTags();
|
fillViewsWithFileTags();
|
||||||
songTitle.addTextChangedListener(this);
|
songTitle.addTextChangedListener(this);
|
||||||
albumTitle.addTextChangedListener(this);
|
albumTitle.addTextChangedListener(this);
|
||||||
artistName.addTextChangedListener(this);
|
artist.addTextChangedListener(this);
|
||||||
genreName.addTextChangedListener(this);
|
genre.addTextChangedListener(this);
|
||||||
year.addTextChangedListener(this);
|
year.addTextChangedListener(this);
|
||||||
trackNumber.addTextChangedListener(this);
|
trackNumber.addTextChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void fillViewsWithFileTags() {
|
private void fillViewsWithFileTags() {
|
||||||
songTitle.setText(getSongTitle());
|
songTitle.setText(getSongTitle());
|
||||||
albumTitle.setText(getAlbumTitle());
|
albumTitle.setText(getAlbumTitle());
|
||||||
artistName.setText(getArtistName());
|
artist.setText(getArtistName());
|
||||||
genreName.setText(getGenreName());
|
genre.setText(getGenreName());
|
||||||
year.setText(getSongYear());
|
year.setText(getSongYear());
|
||||||
trackNumber.setText(getTrackNumber());
|
trackNumber.setText(getTrackNumber());
|
||||||
}
|
}
|
||||||
|
|
@ -93,8 +93,8 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
||||||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||||
fieldKeyValueMap.put(FieldKey.TITLE, songTitle.getText().toString());
|
fieldKeyValueMap.put(FieldKey.TITLE, songTitle.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.ARTIST, artistName.getText().toString());
|
fieldKeyValueMap.put(FieldKey.ARTIST, artist.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
fieldKeyValueMap.put(FieldKey.GENRE, genre.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.TRACK, trackNumber.getText().toString());
|
fieldKeyValueMap.put(FieldKey.TRACK, trackNumber.getText().toString());
|
||||||
writeValuesToFiles(fieldKeyValueMap);
|
writeValuesToFiles(fieldKeyValueMap);
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|
||||||
<android.support.design.widget.NavigationView
|
<android.support.design.widget.NavigationView
|
||||||
android:id="@+id/nav_view"
|
android:id="@+id/navigation_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
|
|
@ -23,11 +23,11 @@
|
||||||
android:id="@android:id/empty"
|
android:id="@android:id/empty"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/empty_text_size"
|
android:layout_gravity="center"
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:fontFamily="sans-serif-light"
|
android:fontFamily="sans-serif-light"
|
||||||
android:text="@string/no_results"
|
android:text="@string/no_results"
|
||||||
android:layout_gravity="center" />
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/empty_text_size" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue