Fixed status bar coloring and cleaned up some code.

This commit is contained in:
Karim Abou Zeid 2015-08-25 16:40:29 +02:00
commit 9e306b3f91
6 changed files with 10 additions and 13 deletions

View file

@ -25,7 +25,11 @@
<p>You can view the changelog dialog again at any time from the <i>about</i> section.</p>
<h3>Version 0.9.44 beta1</h3>
<h3>Version 0.9.44 beta2</h3>
<ol>
<li><b>FIX:</b> Fixed status bar coloring for Lollipop and Marshmallow.</li>
</ol>
<ol>
<li><b>IMPROVEMENT:</b> Completely rewritten color chooser. Had great help from <a

View file

@ -44,7 +44,6 @@ import com.kabouzeid.gramophone.util.ColorUtil;
import com.kabouzeid.gramophone.util.MusicUtil;
import com.kabouzeid.gramophone.util.NavigationUtil;
import com.kabouzeid.gramophone.util.Util;
import com.kabouzeid.gramophone.util.ViewUtil;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
@ -156,7 +155,7 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
// Change alpha of overlay
toolbarAlpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
ViewUtil.setBackgroundAlpha(toolbar, toolbarAlpha, toolbarColor);
toolbar.setBackgroundColor(ColorUtil.getColorWithAlpha(toolbarAlpha, toolbarColor));
setStatusBarColor(ColorUtil.getColorWithAlpha(cab != null && cab.isActive() ? 1 : toolbarAlpha, toolbarColor));
// Translate name text

View file

@ -172,7 +172,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
// Change alpha of overlay
toolbarAlpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
ViewUtil.setBackgroundAlpha(toolbar, toolbarAlpha, toolbarColor);
toolbar.setBackgroundColor(ColorUtil.getColorWithAlpha(toolbarAlpha, toolbarColor));
setStatusBarColor(ColorUtil.getColorWithAlpha(cab != null && cab.isActive() ? 1 : toolbarAlpha, toolbarColor));
// Translate name text

View file

@ -32,7 +32,6 @@ import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
import com.kabouzeid.gramophone.util.ColorUtil;
import com.kabouzeid.gramophone.util.MusicUtil;
import com.kabouzeid.gramophone.util.Util;
import com.kabouzeid.gramophone.util.ViewUtil;
import com.nostra13.universalimageloader.core.ImageLoader;
import org.jaudiotagger.audio.AudioFile;
@ -88,7 +87,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
header.setTranslationY(scrollY);
alpha = 1;
}
ViewUtil.setBackgroundAlpha(toolbar, alpha, paletteColorPrimary);
toolbar.setBackgroundColor(ColorUtil.getColorWithAlpha(alpha, paletteColorPrimary));
image.setTranslationY(scrollY / 2);
}
};

View file

@ -78,7 +78,8 @@ public class ColorUtil {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] *= by; // value component
return getColorWithAlpha(alpha, Color.HSVToColor(hsv));
// don't use getColorWithAlpha(float alpha, int baseColor) here
return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
}
@SuppressWarnings("ResourceType")

View file

@ -57,12 +57,6 @@ public class ViewUtil {
return animator;
}
public static void setBackgroundAlpha(@NonNull View view, float alpha, int baseColor) {
int a = Math.min(255, Math.max(0, (int) (alpha * 255))) << 24;
int rgb = 0x00ffffff & baseColor;
view.setBackgroundColor(a + rgb);
}
/**
* Should be called in {@link android.app.Activity#onPrepareOptionsMenu(Menu)} and {@link android.app.Activity#onOptionsItemSelected(MenuItem)}
*