Redesign of MusicControllerActivity, AlbumDetailActivity and ArtistDetailActivity. A lot of bugs and other small things fixed as well.
This commit is contained in:
parent
1b702eae07
commit
9fe36b0a35
51 changed files with 1019 additions and 688 deletions
|
|
@ -1,8 +1,10 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -10,9 +12,12 @@ import android.support.v4.util.Pair;
|
|||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.transition.Transition;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -23,12 +28,14 @@ import com.kabouzeid.gramophone.App;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.AlbumSongAdapter;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.helper.bitmapblur.StackBlurManager;
|
||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||
import com.kabouzeid.gramophone.loader.AlbumSongLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.misc.SmallObservableScrollViewCallbacks;
|
||||
import com.kabouzeid.gramophone.misc.SmallTransitionListener;
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
import com.kabouzeid.gramophone.model.DataBaseChangedEvent;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
|
@ -65,6 +72,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
private ArrayList<Song> songs;
|
||||
private View statusBar;
|
||||
private ImageView albumArtImageView;
|
||||
private ImageView albumArtBackground;
|
||||
private View songsBackgroundView;
|
||||
private TextView albumTitleView;
|
||||
private Toolbar toolbar;
|
||||
|
|
@ -106,7 +114,6 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(true);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_album_detail);
|
||||
|
||||
|
|
@ -115,7 +122,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
if (Util.isAtLeastLollipop()) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbumEnabled())
|
||||
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
Bundle intentExtras = getIntent().getExtras();
|
||||
|
|
@ -132,6 +139,29 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
setUpObservableListViewParams();
|
||||
setUpToolBar();
|
||||
setUpViews();
|
||||
|
||||
if (Util.isAtLeastLollipop()) {
|
||||
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
|
||||
|
|
@ -144,6 +174,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
@ -151,11 +186,12 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
|
||||
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);
|
||||
statusBar = findViewById(R.id.statusBar);
|
||||
statusBar = findViewById(R.id.status_bar);
|
||||
}
|
||||
|
||||
private void setUpObservableListViewParams() {
|
||||
|
|
@ -166,7 +202,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
||||
headerOffset = toolbarHeight;
|
||||
if (Util.isAtLeastKitKat())
|
||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
|
||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
||||
}
|
||||
|
||||
private void setUpViews() {
|
||||
|
|
@ -190,6 +226,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
applyPalette(null);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art)).process(10));
|
||||
if (Util.isAtLeastLollipop()) startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
|
|
@ -197,6 +234,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
applyPalette(loadedImage);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
if (Util.isAtLeastLollipop()) startPostponedEnterTransition();
|
||||
}
|
||||
}
|
||||
|
|
@ -216,7 +254,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
albumTitleView.setBackgroundColor(toolbarColor);
|
||||
albumTitleView.setTextColor(vibrantSwatch.getTitleTextColor());
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AlbumDetailActivity.this).coloredNavigationBarAlbumEnabled())
|
||||
getWindow().setNavigationBarColor(toolbarColor);
|
||||
setNavigationBarColor(toolbarColor);
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
} else {
|
||||
resetColors();
|
||||
|
|
@ -238,7 +276,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
albumTitleView.setTextColor(titleTextColor);
|
||||
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
}
|
||||
|
|
@ -256,9 +294,9 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void setNavigationBarColored(boolean colored) {
|
||||
if (colored) {
|
||||
if (Util.isAtLeastLollipop()) getWindow().setNavigationBarColor(toolbarColor);
|
||||
setNavigationBarColor(toolbarColor);
|
||||
} else {
|
||||
if (Util.isAtLeastLollipop()) getWindow().setNavigationBarColor(Color.BLACK);
|
||||
setNavigationBarColor(Color.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -405,4 +443,10 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
});
|
||||
return cab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (cab != null && cab.isActive()) cab.finish();
|
||||
else super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -17,6 +19,8 @@ import android.view.LayoutInflater;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
|
@ -30,6 +34,7 @@ import com.kabouzeid.gramophone.R;
|
|||
import com.kabouzeid.gramophone.adapter.ArtistAlbumAdapter;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.ArtistSongAdapter;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.helper.bitmapblur.StackBlurManager;
|
||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistBiographyLoader;
|
||||
|
|
@ -39,6 +44,7 @@ import com.kabouzeid.gramophone.loader.ArtistLoader;
|
|||
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.misc.SmallObservableScrollViewCallbacks;
|
||||
import com.kabouzeid.gramophone.misc.SmallTransitionListener;
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
import com.kabouzeid.gramophone.model.Artist;
|
||||
import com.kabouzeid.gramophone.model.DataBaseChangedEvent;
|
||||
|
|
@ -71,6 +77,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
private ObservableListView songListView;
|
||||
private View statusBar;
|
||||
private ImageView artistImage;
|
||||
private ImageView artistImageBackground;
|
||||
private View songsBackgroundView;
|
||||
private TextView artistNameTv;
|
||||
private Toolbar toolbar;
|
||||
|
|
@ -121,7 +128,6 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(true);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_artist_detail);
|
||||
|
||||
|
|
@ -130,7 +136,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
if (Util.isAtLeastLollipop()) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
getIntentExtras();
|
||||
|
|
@ -146,6 +152,29 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
fixLollipopTransitionImageWrongSize();
|
||||
startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
if (Util.isAtLeastLollipop()) {
|
||||
getWindow().getEnterTransition().addListener(new SmallTransitionListener() {
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
artistImageBackground.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
int cx = (artistImageBackground.getLeft() + artistImageBackground.getRight()) / 2;
|
||||
int cy = (artistImageBackground.getTop() + artistImageBackground.getBottom()) / 2;
|
||||
int finalRadius = Math.max(artistImageBackground.getWidth(), artistImageBackground.getHeight());
|
||||
|
||||
Animator animator = ViewAnimationUtils.createCircularReveal(artistImageBackground, cx, cy, artistImage.getWidth() / 2, finalRadius);
|
||||
animator.setInterpolator(new DecelerateInterpolator());
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
|
||||
artistImageBackground.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -158,13 +187,19 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
artistImage = (ImageView) findViewById(R.id.artist_image);
|
||||
artistImageBackground = (ImageView) findViewById(R.id.artist_image_background);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
songListView = (ObservableListView) findViewById(R.id.list);
|
||||
artistNameTv = (TextView) findViewById(R.id.artist_name);
|
||||
songsBackgroundView = findViewById(R.id.list_background);
|
||||
statusBar = findViewById(R.id.statusBar);
|
||||
statusBar = findViewById(R.id.status_bar);
|
||||
|
||||
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
|
||||
albumRecyclerView = (RecyclerView) songListHeader.findViewById(R.id.recycler_view);
|
||||
|
|
@ -178,7 +213,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
||||
headerOffset = toolbarHeight;
|
||||
if (Util.isAtLeastKitKat())
|
||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
|
||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -203,9 +238,9 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void setNavigationBarColored(boolean colored) {
|
||||
if (colored) {
|
||||
if (Util.isAtLeastLollipop()) getWindow().setNavigationBarColor(toolbarColor);
|
||||
setNavigationBarColor(toolbarColor);
|
||||
} else {
|
||||
if (Util.isAtLeastLollipop()) getWindow().setNavigationBarColor(Color.BLACK);
|
||||
setNavigationBarColor(Color.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +292,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
}
|
||||
|
||||
private void setUpArtistImageAndApplyPalette(final boolean forceDownload) {
|
||||
final StackBlurManager defaultArtistImageBlurManager = new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_artist_image));
|
||||
artistImageBackground.setImageBitmap(defaultArtistImageBlurManager.process(10));
|
||||
LastFMArtistImageUrlLoader.loadArtistImageUrl(this, artist.name, forceDownload, new LastFMArtistImageUrlLoader.ArtistImageUrlLoaderCallback() {
|
||||
@Override
|
||||
public void onArtistImageUrlLoaded(final String url) {
|
||||
|
|
@ -272,11 +309,13 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
applyPalette(null);
|
||||
artistImageBackground.setImageBitmap(defaultArtistImageBlurManager.returnBlurredImage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
applyPalette(loadedImage);
|
||||
artistImageBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -297,7 +336,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
artistNameTv.setBackgroundColor(vibrantSwatch.getRgb());
|
||||
artistNameTv.setTextColor(vibrantSwatch.getTitleTextColor());
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(ArtistDetailActivity.this).coloredNavigationBarArtistEnabled())
|
||||
getWindow().setNavigationBarColor(vibrantSwatch.getRgb());
|
||||
setNavigationBarColor(vibrantSwatch.getRgb());
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
} else {
|
||||
resetColors();
|
||||
|
|
@ -336,7 +375,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
artistNameTv.setTextColor(titleTextColor);
|
||||
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
}
|
||||
|
|
@ -491,4 +530,10 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
});
|
||||
return cab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (cab != null && cab.isActive()) cab.finish();
|
||||
else super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ import android.view.KeyEvent;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.afollestad.materialcab.MaterialCab;
|
||||
|
|
@ -72,10 +73,10 @@ public class MainActivity extends AbsFabActivity
|
|||
private PagerSlidingTabStrip slidingTabLayout;
|
||||
private int currentPage = -1;
|
||||
private MaterialCab cab;
|
||||
private View statusBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(!Util.isAtLeastLollipop());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
|
|
@ -92,7 +93,7 @@ public class MainActivity extends AbsFabActivity
|
|||
|
||||
@Override
|
||||
protected boolean shouldColorStatusBar() {
|
||||
return !Util.isAtLeastLollipop();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -100,6 +101,11 @@ public class MainActivity extends AbsFabActivity
|
|||
return PreferenceUtils.getInstance(this).coloredNavigationBarOtherScreensEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setUpViewPager() {
|
||||
pagerAdapter = new PagerAdapter(this, getSupportFragmentManager());
|
||||
final PagerAdapter.MusicFragments[] fragments = PagerAdapter.MusicFragments.values();
|
||||
|
|
@ -144,6 +150,7 @@ public class MainActivity extends AbsFabActivity
|
|||
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
navigationDrawerFragment = (NavigationDrawerFragment)
|
||||
getFragmentManager().findFragmentById(R.id.navigation_drawer);
|
||||
statusBar = findViewById(R.id.status_bar);
|
||||
}
|
||||
|
||||
private void setUpToolBar() {
|
||||
|
|
@ -159,6 +166,7 @@ public class MainActivity extends AbsFabActivity
|
|||
final int colorPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||
ViewUtil.setBackgroundAlpha(toolbar, alpha, colorPrimary);
|
||||
ViewUtil.setBackgroundAlpha(slidingTabLayout, alpha, colorPrimary);
|
||||
ViewUtil.setBackgroundAlpha(statusBar, alpha, colorPrimary);
|
||||
}
|
||||
|
||||
private void setUpDrawerToggle() {
|
||||
|
|
@ -178,9 +186,6 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
private void setUpDrawerLayout() {
|
||||
drawerLayout.setStatusBarBackgroundColor(PreferenceUtils
|
||||
.getInstance(this).getThemeColorPrimaryDarker());
|
||||
|
||||
FrameLayout navDrawerFrame = (FrameLayout) findViewById(R.id.nav_drawer_frame);
|
||||
int navDrawerMargin = getResources().getDimensionPixelSize(R.dimen.nav_drawer_margin);
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
|
|
@ -364,11 +369,9 @@ public class MainActivity extends AbsFabActivity
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (navigationDrawerFragment.isDrawerOpen()) {
|
||||
drawerLayout.closeDrawers();
|
||||
return;
|
||||
}
|
||||
super.onBackPressed();
|
||||
if (navigationDrawerFragment.isDrawerOpen()) drawerLayout.closeDrawers();
|
||||
else if (cab != null && cab.isActive()) cab.finish();
|
||||
else super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,37 +1,41 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.transition.Transition;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.dialogs.AddToPlaylistDialog;
|
||||
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||
import com.kabouzeid.gramophone.dialogs.SongDetailDialog;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistImageUrlLoader;
|
||||
import com.kabouzeid.gramophone.helper.bitmapblur.StackBlurManager;
|
||||
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.misc.SmallTransitionListener;
|
||||
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
||||
|
|
@ -45,7 +49,6 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
|||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
|
@ -57,42 +60,65 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
|
||||
private Song song;
|
||||
private ImageView albumArt;
|
||||
private ImageView artistImage;
|
||||
private ImageView albumArtBackground;
|
||||
private TextView songTitle;
|
||||
private TextView songArtist;
|
||||
private TextView currentSongProgress;
|
||||
private TextView totalSongDuration;
|
||||
private View footer;
|
||||
private View progressContainer;
|
||||
private SeekBar progressSlider;
|
||||
private ImageButton nextButton;
|
||||
private ImageButton prevButton;
|
||||
private ImageButton repeatButton;
|
||||
private ImageButton shuffleButton;
|
||||
private View mediaControllerContainer;
|
||||
private Toolbar toolbar;
|
||||
private int lastFooterColor = -1;
|
||||
private boolean killThreads = false;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(true);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_music_controller);
|
||||
|
||||
App.bus.register(this);
|
||||
|
||||
initViews();
|
||||
albumArtBackground.setAlpha(0.7f);
|
||||
|
||||
moveSeekBarIntoPlace();
|
||||
|
||||
setUpMusicControllers();
|
||||
|
||||
prepareViewsForOpenAnimation();
|
||||
|
||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setTitle(null);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (Util.isAtLeastLollipop()) {
|
||||
getWindow().getEnterTransition().addListener(new SmallTransitionListener() {
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
mediaControllerContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
int cx = (getFab().getLeft() + getFab().getRight()) / 2;
|
||||
int cy = (getFab().getTop() + getFab().getBottom()) / 2;
|
||||
int finalRadius = Math.max(mediaControllerContainer.getWidth(), mediaControllerContainer.getHeight());
|
||||
|
||||
Animator animator = ViewAnimationUtils.createCircularReveal(mediaControllerContainer, cx, cy, getFab().getWidth() / 2, finalRadius);
|
||||
animator.setInterpolator(new DecelerateInterpolator());
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
|
||||
int i = footer.getHeight();
|
||||
|
||||
mediaControllerContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -111,11 +137,16 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
return false; // let other code handle this below
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void moveSeekBarIntoPlace() {
|
||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) progressSlider.getLayoutParams();
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) progressSlider.getLayoutParams();
|
||||
progressSlider.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
|
||||
final int seekBarMarginLeftRight = getResources().getDimensionPixelSize(R.dimen.seek_bar_margin_left_right);
|
||||
lp.setMargins(seekBarMarginLeftRight, 0, seekBarMarginLeftRight, -(progressSlider.getMeasuredHeight() / 2));
|
||||
lp.setMargins(seekBarMarginLeftRight, getResources().getDimensionPixelSize(R.dimen.progress_container_height) - (progressSlider.getMeasuredHeight() / 2), seekBarMarginLeftRight, 0);
|
||||
progressSlider.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +156,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
repeatButton = (ImageButton) findViewById(R.id.repeat_button);
|
||||
shuffleButton = (ImageButton) findViewById(R.id.shuffle_button);
|
||||
albumArt = (ImageView) findViewById(R.id.album_art);
|
||||
artistImage = (ImageView) findViewById(R.id.artist_image);
|
||||
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);
|
||||
|
|
@ -133,6 +164,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
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);
|
||||
progressContainer = findViewById(R.id.progress_container);
|
||||
}
|
||||
|
||||
private void setUpMusicControllers() {
|
||||
|
|
@ -140,26 +173,6 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
setUpRepeatButton();
|
||||
setUpShuffleButton();
|
||||
setUpProgressSlider();
|
||||
setUpBox(PreferenceUtils.getInstance(this).playbackControllerBoxEnabled());
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void setUpBox(boolean boxEnabled) {
|
||||
if (boxEnabled) {
|
||||
if (Util.isAtLeastLollipop()) {
|
||||
mediaControllerContainer.setElevation(getResources().getDimensionPixelSize(R.dimen.cardview_default_elevation));
|
||||
}
|
||||
mediaControllerContainer.setBackgroundColor(
|
||||
DialogUtils.resolveColor(this, R.attr.music_controller_container_color));
|
||||
} else {
|
||||
if (Util.isAtLeastLollipop() && !Util.isInPortraitMode(this)) {
|
||||
mediaControllerContainer.setElevation(getResources().getDimensionPixelSize(R.dimen.cardview_default_elevation));
|
||||
mediaControllerContainer.setBackgroundColor(
|
||||
DialogUtils.resolveColor(this, R.attr.music_controller_container_color));
|
||||
} else {
|
||||
mediaControllerContainer.setBackground(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setTint(SeekBar seekBar, int color) {
|
||||
|
|
@ -264,10 +277,6 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void prepareViewsForOpenAnimation() {
|
||||
footer.setPivotY(0);
|
||||
footer.setScaleY(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
|
|
@ -277,6 +286,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateControllerState();
|
||||
startMusicControllerStateUpdateThread();
|
||||
updateCurrentSong();
|
||||
}
|
||||
|
|
@ -284,7 +294,6 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
private void updateCurrentSong() {
|
||||
getCurrentSong();
|
||||
setHeadersText();
|
||||
setUpArtistArt();
|
||||
setUpAlbumArtAndApplyPalette();
|
||||
totalSongDuration.setText(MusicUtil.getReadableDurationString(song.duration));
|
||||
currentSongProgress.setText(MusicUtil.getReadableDurationString(-1));
|
||||
|
|
@ -307,17 +316,18 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
new DisplayImageOptions.Builder()
|
||||
.cacheInMemory(true)
|
||||
.showImageOnFail(R.drawable.default_album_art)
|
||||
.resetViewBeforeLoading(true)
|
||||
.build(),
|
||||
new SimpleImageLoadingListener() {
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
applyPalette(null);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art)).process(10));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
applyPalette(loadedImage);
|
||||
albumArtBackground.setImageBitmap(new StackBlurManager(loadedImage).process(10));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -335,6 +345,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
animateColorChange(swatchRgb);
|
||||
songTitle.setTextColor(vibrantSwatch.getTitleTextColor());
|
||||
songArtist.setTextColor(vibrantSwatch.getBodyTextColor());
|
||||
currentSongProgress.setTextColor(vibrantSwatch.getTitleTextColor());
|
||||
totalSongDuration.setTextColor(vibrantSwatch.getTitleTextColor());
|
||||
notifyTaskColorChange(swatchRgb);
|
||||
} else {
|
||||
resetColors();
|
||||
|
|
@ -355,6 +367,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
|
||||
songTitle.setTextColor(songTitleTextColor);
|
||||
songArtist.setTextColor(artistNameTextColor);
|
||||
currentSongProgress.setTextColor(artistNameTextColor);
|
||||
totalSongDuration.setTextColor(artistNameTextColor);
|
||||
|
||||
notifyTaskColorChange(defaultBarColor);
|
||||
}
|
||||
|
|
@ -363,34 +377,19 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
private void animateColorChange(final int newColor) {
|
||||
if (lastFooterColor != -1 && lastFooterColor != newColor) {
|
||||
ViewUtil.animateViewColor(footer, lastFooterColor, newColor, 300);
|
||||
ViewUtil.animateViewColor(progressContainer, ColorChooserDialog.shiftColorDown(lastFooterColor), ColorChooserDialog.shiftColorDown(newColor), 300);
|
||||
ViewUtil.animateViewColor(toolbar, lastFooterColor, newColor, 300);
|
||||
} else {
|
||||
footer.setBackgroundColor(newColor);
|
||||
progressContainer.setBackgroundColor(ColorChooserDialog.shiftColorDown(newColor));
|
||||
toolbar.setBackgroundColor(newColor);
|
||||
}
|
||||
setStatusBarColor(newColor);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarCurrentPlayingEnabled())
|
||||
getWindow().setNavigationBarColor(newColor);
|
||||
setNavigationBarColor(newColor);
|
||||
lastFooterColor = newColor;
|
||||
}
|
||||
|
||||
private void setUpArtistArt() {
|
||||
if (artistImage != null) {
|
||||
artistImage.setImageResource(R.drawable.default_artist_image);
|
||||
LastFMArtistImageUrlLoader.loadArtistImageUrl(this, song.artistName, false, new LastFMArtistImageUrlLoader.ArtistImageUrlLoaderCallback() {
|
||||
@Override
|
||||
public void onArtistImageUrlLoaded(String url) {
|
||||
ImageLoader.getInstance().displayImage(url,
|
||||
artistImage,
|
||||
new DisplayImageOptions.Builder()
|
||||
.cacheInMemory(true)
|
||||
.cacheOnDisk(true)
|
||||
.showImageOnFail(R.drawable.default_artist_image)
|
||||
.resetViewBeforeLoading(true)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void getCurrentSong() {
|
||||
song = MusicPlayerRemote.getCurrentSong();
|
||||
if (song.id == -1) {
|
||||
|
|
@ -430,9 +429,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateControllerState() {
|
||||
super.updateControllerState();
|
||||
updateFabState();
|
||||
updateRepeatState();
|
||||
updateShuffleState();
|
||||
}
|
||||
|
|
@ -522,19 +520,4 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
.setStartDelay(startDelay)
|
||||
.start();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onUIPrefsChanged(UIPreferenceChangedEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case UIPreferenceChangedEvent.PLAYBACK_CONTROLLER_CARD_CHANGED:
|
||||
setUpBox((boolean) event.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
App.bus.unregister(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,6 @@ import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
|||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -42,7 +41,6 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(!Util.isAtLeastLollipop());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_playlist_detail);
|
||||
|
||||
|
|
@ -94,6 +92,11 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
return PreferenceUtils.getInstance(this).coloredNavigationBarPlaylistEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void getIntentExtras() {
|
||||
Bundle intentExtras = getIntent().getExtras();
|
||||
final int playlistId = intentExtras.getInt(AppKeys.E_PLAYLIST);
|
||||
|
|
@ -163,4 +166,10 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (cab != null && cab.isActive()) cab.finish();
|
||||
else super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(false);
|
||||
setTitle(null);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_search);
|
||||
|
|
@ -72,6 +71,11 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.kabouzeid.gramophone.prefs.ColorChooserPreference;
|
|||
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -31,7 +30,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(!Util.isAtLeastLollipop());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_preferences);
|
||||
|
||||
|
|
@ -54,6 +52,11 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
return PreferenceUtils.getInstance(this).coloredNavigationBarOtherScreensEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onColorSelection(int title, int color) {
|
||||
if (title == R.string.primary_color) {
|
||||
|
|
@ -137,14 +140,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
}
|
||||
});
|
||||
|
||||
findPreference("playback_controller_card").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.PLAYBACK_CONTROLLER_CARD_CHANGED, o));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Preference colorNavBar = findPreference("colored_navigation_bar");
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
colorNavBar.setEnabled(false);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private void updateFabState() {
|
||||
protected void updateFabState() {
|
||||
if (MusicPlayerRemote.isPlaying()) {
|
||||
playPauseDrawable.setPause();
|
||||
} else {
|
||||
|
|
@ -135,10 +135,6 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateControllerState();
|
||||
}
|
||||
|
||||
protected void updateControllerState() {
|
||||
updateFabState();
|
||||
}
|
||||
|
||||
|
|
@ -190,4 +186,8 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
|||
private void setFabPause() {
|
||||
playPauseDrawable.animatedPause();
|
||||
}
|
||||
|
||||
private void setFabColor() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,45 +3,28 @@ package com.kabouzeid.gramophone.ui.activities.base;
|
|||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
|
||||
/**
|
||||
* READ!
|
||||
* <p/>
|
||||
* Instructions:
|
||||
* <p/>
|
||||
* KitKat or Lollipop solid statusBar with the right color (primaryDark):
|
||||
* - shouldColorStatusBar return true OR return false and call setStatusBarColor() in the activity with a custom color
|
||||
* - setStatusBarTranslucent(!Util.isAtLeastLollipop())
|
||||
* <p/>
|
||||
* KitKat or Lollipop translucent statusBar (not the color is too dark on Lollipop and KitKat only does fading but MUCH better performance the setStatusBarColor in onScrollCallback)
|
||||
* - shouldColorStatusBar return false DO NOT return true and do not call setStatusBarColor() in this case at all here
|
||||
* - setStatusBarTranslucent(true)
|
||||
* - use a view below the statusBar to color it
|
||||
* @author Aidan Follestad (afollestad), Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
|
||||
public abstract class ThemeBaseActivity extends AppCompatActivity implements KabViewsDisableAble {
|
||||
|
||||
// private boolean mLastDarkTheme;
|
||||
// private int mLastPrimary;
|
||||
// private int mLastAccent;
|
||||
private final boolean statusBarTranslucent = shouldSetStatusBarTranslucent();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(statusBarTranslucent);
|
||||
setTheme(PreferenceUtils.getInstance(this).getGeneralTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
setupTheme();
|
||||
|
|
@ -53,11 +36,6 @@ public abstract class ThemeBaseActivity extends AppCompatActivity implements Kab
|
|||
setShouldColorNavBar(shouldColorNavBar());
|
||||
setShouldColorStatusBar(shouldColorStatusBar());
|
||||
|
||||
// Persist current values so the Activity knows if they change
|
||||
// mLastDarkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
|
||||
// mLastPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||
// mLastAccent = PreferenceUtils.getInstance(this).getThemeColorAccent();
|
||||
|
||||
// Accent colors in dialogs, and any dynamic views that pull from this singleton
|
||||
ThemeSingleton.get().positiveColor = PreferenceUtils.getInstance(this).getThemeColorAccent();
|
||||
ThemeSingleton.get().negativeColor = ThemeSingleton.get().positiveColor;
|
||||
|
|
@ -71,10 +49,6 @@ public abstract class ThemeBaseActivity extends AppCompatActivity implements Kab
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean overridesTaskColor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void notifyTaskColorChange(int color) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
// Sets color of entry in the system recents page
|
||||
|
|
@ -86,30 +60,22 @@ public abstract class ThemeBaseActivity extends AppCompatActivity implements Kab
|
|||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected void onResume() {
|
||||
// super.onResume();
|
||||
// if (mLastDarkTheme != (PreferenceUtils.getInstance(this).getGeneralTheme() == 1) ||
|
||||
// mLastPrimary != PreferenceUtils.getInstance(this).getThemeColorPrimary() ||
|
||||
// mLastAccent != PreferenceUtils.getInstance(this).getThemeColorAccent()) {
|
||||
// // Theme colors changed, recreate the Activity
|
||||
// recreate();
|
||||
// }
|
||||
// }
|
||||
|
||||
protected void setStatusBarTranslucent(boolean statusBarTranslucent) {
|
||||
private void setStatusBarTranslucent(boolean statusBarTranslucent) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
Util.setStatusBarTranslucent(getWindow(), statusBarTranslucent);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean shouldColorStatusBar();
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
protected final void setNavigationBarColor(int color) {
|
||||
if (Util.isAtLeastLollipop())
|
||||
getWindow().setNavigationBarColor(ColorChooserDialog.shiftColorDown(color));
|
||||
|
||||
protected abstract boolean shouldColorNavBar();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
protected final void setStatusBarColor(int color, boolean forceSystemBarTint) {
|
||||
if (!forceSystemBarTint && Util.isAtLeastLollipop()) {
|
||||
protected final void setStatusBarColor(int color) {
|
||||
if (!statusBarTranslucent && Util.isAtLeastLollipop()) {
|
||||
getWindow().setStatusBarColor(color);
|
||||
} else {
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(this);
|
||||
|
|
@ -122,10 +88,9 @@ public abstract class ThemeBaseActivity extends AppCompatActivity implements Kab
|
|||
protected final void setShouldColorNavBar(boolean shouldColorNavBar) {
|
||||
if (Util.isAtLeastLollipop()) {
|
||||
if (shouldColorNavBar) {
|
||||
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
|
||||
getWindow().setNavigationBarColor(primaryDark);
|
||||
setNavigationBarColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
||||
} else {
|
||||
getWindow().setNavigationBarColor(Color.BLACK);
|
||||
getWindow().setNavigationBarColor(Util.resolveColor(this, android.R.attr.navigationBarColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -133,8 +98,8 @@ public abstract class ThemeBaseActivity extends AppCompatActivity implements Kab
|
|||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
protected final void setShouldColorStatusBar(boolean shouldColorStatusBar) {
|
||||
if (shouldColorStatusBar) {
|
||||
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
|
||||
setStatusBarColor(primaryDark, false);
|
||||
final int primary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||
setStatusBarColor(primary);
|
||||
} else {
|
||||
if (Util.isAtLeastLollipop()) {
|
||||
getWindow().setStatusBarColor(Util.resolveColor(this, android.R.attr.statusBarColor));
|
||||
|
|
@ -144,4 +109,14 @@ public abstract class ThemeBaseActivity extends AppCompatActivity implements Kab
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean shouldColorStatusBar();
|
||||
|
||||
protected abstract boolean shouldColorNavBar();
|
||||
|
||||
protected abstract boolean shouldSetStatusBarTranslucent();
|
||||
|
||||
protected boolean overridesTaskColor() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +90,6 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setStatusBarTranslucent(!Util.isAtLeastLollipop());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getContentViewResId());
|
||||
|
||||
|
|
@ -123,6 +122,11 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldSetStatusBarTranslucent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
scrollView = (ObservableScrollView) findViewById(R.id.observableScrollView);
|
||||
|
|
@ -212,9 +216,9 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
final int primaryColor = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||
paletteColorPrimary = primaryColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(ColorChooserDialog.shiftColorDown(primaryColor), false);
|
||||
setStatusBarColor(primaryColor);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarTagEditorEnabled())
|
||||
getWindow().setNavigationBarColor(primaryColor);
|
||||
setNavigationBarColor(primaryColor);
|
||||
notifyTaskColorChange(primaryColor);
|
||||
}
|
||||
|
||||
|
|
@ -264,10 +268,9 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
toolBar.setBackgroundColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
|
||||
int primaryDark = ColorChooserDialog.shiftColorDown(paletteColorPrimary);
|
||||
setStatusBarColor(primaryDark, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarTagEditorEnabled())
|
||||
getWindow().setNavigationBarColor(primaryDark);
|
||||
setNavigationBarColor(ColorChooserDialog.shiftColorDown(paletteColorPrimary));
|
||||
}
|
||||
|
||||
protected void dataChanged() {
|
||||
|
|
@ -309,9 +312,9 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
final int vibrantColor = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||
paletteColorPrimary = vibrantColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(ColorChooserDialog.shiftColorDown(vibrantColor), false);
|
||||
setStatusBarColor(vibrantColor);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditorEnabled())
|
||||
getWindow().setNavigationBarColor(vibrantColor);
|
||||
setNavigationBarColor(vibrantColor);
|
||||
notifyTaskColorChange(vibrantColor);
|
||||
} else {
|
||||
resetColors();
|
||||
|
|
|
|||
|
|
@ -15,15 +15,10 @@ public abstract class AbsMainActivityFragment extends Fragment implements KabVie
|
|||
private boolean areViewsEnabled;
|
||||
|
||||
protected int getTopPadding() {
|
||||
final int norm = Util.getActionBarSize(getActivity()) +
|
||||
return Util.getActionBarSize(getActivity()) +
|
||||
Util.getStatusBarHeight(getActivity()) +
|
||||
getResources().getDimensionPixelSize(R.dimen.tab_height) +
|
||||
getResources().getDimensionPixelSize(R.dimen.list_padding_vertical);
|
||||
if (Util.isAtLeastKitKat() && !Util.isAtLeastLollipop()) {
|
||||
if (Util.isInPortraitMode(getActivity()) || Util.isTablet(getActivity())) {
|
||||
return norm + Util.getStatusBarHeight(getActivity());
|
||||
}
|
||||
}
|
||||
return norm;
|
||||
}
|
||||
|
||||
protected int getBottomPadding() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue