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
|
|
@ -0,0 +1,15 @@
|
|||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
interface BlurProcess {
|
||||
/**
|
||||
* Process the given image, blurring by the supplied radius.
|
||||
* If radius is 0, this will return original
|
||||
*
|
||||
* @param original the bitmap to be blurred
|
||||
* @param radius the radius in pixels to blur the image
|
||||
* @return the blurred version of the image.
|
||||
*/
|
||||
Bitmap blur(Bitmap original, float radius);
|
||||
}
|
||||
|
|
@ -0,0 +1,329 @@
|
|||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Blur using Java code.
|
||||
* <p/>
|
||||
* This is a compromise between Gaussian Blur and Box blur
|
||||
* It creates much better looking blurs than Box Blur, but is
|
||||
* 7x faster than my Gaussian Blur implementation.
|
||||
* <p/>
|
||||
* I called it Stack Blur because this describes best how this
|
||||
* filter works internally: it creates a kind of moving stack
|
||||
* of colors whilst scanning through the image. Thereby it
|
||||
* just has to add one new block of color to the right side
|
||||
* of the stack and remove the leftmost color. The remaining
|
||||
* colors on the topmost layer of the stack are either added on
|
||||
* or reduced by one, depending on if they are on the right or
|
||||
* on the left side of the stack.
|
||||
*
|
||||
* @author Enrique López Mañas <eenriquelopez@gmail.com>
|
||||
* http://www.neo-tech.es
|
||||
* <p/>
|
||||
* Author of the original algorithm: Mario Klingemann <mario.quasimondo.com>
|
||||
* <p/>
|
||||
* Based heavily on http://vitiy.info/Code/stackblur.cpp
|
||||
* See http://vitiy.info/stackblur-algorithm-multi-threaded-blur-for-cpp/
|
||||
* @copyright: Enrique López Mañas
|
||||
* @license: Apache License 2.0
|
||||
*/
|
||||
class JavaBlurProcess implements BlurProcess {
|
||||
|
||||
private static final short[] stackblur_mul = {
|
||||
512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512,
|
||||
454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512,
|
||||
482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456,
|
||||
437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512,
|
||||
497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328,
|
||||
320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456,
|
||||
446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335,
|
||||
329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512,
|
||||
505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405,
|
||||
399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328,
|
||||
324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271,
|
||||
268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456,
|
||||
451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388,
|
||||
385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335,
|
||||
332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
|
||||
289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259
|
||||
};
|
||||
|
||||
private static final byte[] stackblur_shr = {
|
||||
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
||||
};
|
||||
|
||||
@Override
|
||||
public Bitmap blur(Bitmap original, float radius) {
|
||||
int w = original.getWidth();
|
||||
int h = original.getHeight();
|
||||
int[] currentPixels = new int[w * h];
|
||||
original.getPixels(currentPixels, 0, w, 0, 0, w, h);
|
||||
int cores = StackBlurManager.EXECUTOR_THREADS;
|
||||
|
||||
ArrayList<BlurTask> horizontal = new ArrayList<BlurTask>(cores);
|
||||
ArrayList<BlurTask> vertical = new ArrayList<BlurTask>(cores);
|
||||
for (int i = 0; i < cores; i++) {
|
||||
horizontal.add(new BlurTask(currentPixels, w, h, (int) radius, cores, i, 1));
|
||||
vertical.add(new BlurTask(currentPixels, w, h, (int) radius, cores, i, 2));
|
||||
}
|
||||
|
||||
try {
|
||||
StackBlurManager.EXECUTOR.invokeAll(horizontal);
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
StackBlurManager.EXECUTOR.invokeAll(vertical);
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Bitmap.createBitmap(currentPixels, w, h, Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
private static void blurIteration(int[] src, int w, int h, int radius, int cores, int core, int step) {
|
||||
int x, y, xp, yp, i;
|
||||
int sp;
|
||||
int stack_start;
|
||||
int stack_i;
|
||||
|
||||
int src_i;
|
||||
int dst_i;
|
||||
|
||||
long sum_r, sum_g, sum_b,
|
||||
sum_in_r, sum_in_g, sum_in_b,
|
||||
sum_out_r, sum_out_g, sum_out_b;
|
||||
|
||||
int wm = w - 1;
|
||||
int hm = h - 1;
|
||||
int div = (radius * 2) + 1;
|
||||
int mul_sum = stackblur_mul[radius];
|
||||
byte shr_sum = stackblur_shr[radius];
|
||||
int[] stack = new int[div];
|
||||
|
||||
if (step == 1) {
|
||||
int minY = core * h / cores;
|
||||
int maxY = (core + 1) * h / cores;
|
||||
|
||||
for (y = minY; y < maxY; y++) {
|
||||
sum_r = sum_g = sum_b =
|
||||
sum_in_r = sum_in_g = sum_in_b =
|
||||
sum_out_r = sum_out_g = sum_out_b = 0;
|
||||
|
||||
src_i = w * y; // start of line (0,y)
|
||||
|
||||
for (i = 0; i <= radius; i++) {
|
||||
stack_i = i;
|
||||
stack[stack_i] = src[src_i];
|
||||
sum_r += ((src[src_i] >>> 16) & 0xff) * (i + 1);
|
||||
sum_g += ((src[src_i] >>> 8) & 0xff) * (i + 1);
|
||||
sum_b += (src[src_i] & 0xff) * (i + 1);
|
||||
sum_out_r += ((src[src_i] >>> 16) & 0xff);
|
||||
sum_out_g += ((src[src_i] >>> 8) & 0xff);
|
||||
sum_out_b += (src[src_i] & 0xff);
|
||||
}
|
||||
|
||||
|
||||
for (i = 1; i <= radius; i++) {
|
||||
if (i <= wm) src_i += 1;
|
||||
stack_i = i + radius;
|
||||
stack[stack_i] = src[src_i];
|
||||
sum_r += ((src[src_i] >>> 16) & 0xff) * (radius + 1 - i);
|
||||
sum_g += ((src[src_i] >>> 8) & 0xff) * (radius + 1 - i);
|
||||
sum_b += (src[src_i] & 0xff) * (radius + 1 - i);
|
||||
sum_in_r += ((src[src_i] >>> 16) & 0xff);
|
||||
sum_in_g += ((src[src_i] >>> 8) & 0xff);
|
||||
sum_in_b += (src[src_i] & 0xff);
|
||||
}
|
||||
|
||||
|
||||
sp = radius;
|
||||
xp = radius;
|
||||
if (xp > wm) xp = wm;
|
||||
src_i = xp + y * w; // img.pix_ptr(xp, y);
|
||||
dst_i = y * w; // img.pix_ptr(0, y);
|
||||
for (x = 0; x < w; x++) {
|
||||
src[dst_i] = (int)
|
||||
((src[dst_i] & 0xff000000) |
|
||||
((((sum_r * mul_sum) >>> shr_sum) & 0xff) << 16) |
|
||||
((((sum_g * mul_sum) >>> shr_sum) & 0xff) << 8) |
|
||||
((((sum_b * mul_sum) >>> shr_sum) & 0xff)));
|
||||
dst_i += 1;
|
||||
|
||||
sum_r -= sum_out_r;
|
||||
sum_g -= sum_out_g;
|
||||
sum_b -= sum_out_b;
|
||||
|
||||
stack_start = sp + div - radius;
|
||||
if (stack_start >= div) stack_start -= div;
|
||||
stack_i = stack_start;
|
||||
|
||||
sum_out_r -= ((stack[stack_i] >>> 16) & 0xff);
|
||||
sum_out_g -= ((stack[stack_i] >>> 8) & 0xff);
|
||||
sum_out_b -= (stack[stack_i] & 0xff);
|
||||
|
||||
if (xp < wm) {
|
||||
src_i += 1;
|
||||
++xp;
|
||||
}
|
||||
|
||||
stack[stack_i] = src[src_i];
|
||||
|
||||
sum_in_r += ((src[src_i] >>> 16) & 0xff);
|
||||
sum_in_g += ((src[src_i] >>> 8) & 0xff);
|
||||
sum_in_b += (src[src_i] & 0xff);
|
||||
sum_r += sum_in_r;
|
||||
sum_g += sum_in_g;
|
||||
sum_b += sum_in_b;
|
||||
|
||||
++sp;
|
||||
if (sp >= div) sp = 0;
|
||||
stack_i = sp;
|
||||
|
||||
sum_out_r += ((stack[stack_i] >>> 16) & 0xff);
|
||||
sum_out_g += ((stack[stack_i] >>> 8) & 0xff);
|
||||
sum_out_b += (stack[stack_i] & 0xff);
|
||||
sum_in_r -= ((stack[stack_i] >>> 16) & 0xff);
|
||||
sum_in_g -= ((stack[stack_i] >>> 8) & 0xff);
|
||||
sum_in_b -= (stack[stack_i] & 0xff);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// step 2
|
||||
else if (step == 2) {
|
||||
int minX = core * w / cores;
|
||||
int maxX = (core + 1) * w / cores;
|
||||
|
||||
for (x = minX; x < maxX; x++) {
|
||||
sum_r = sum_g = sum_b =
|
||||
sum_in_r = sum_in_g = sum_in_b =
|
||||
sum_out_r = sum_out_g = sum_out_b = 0;
|
||||
|
||||
src_i = x; // x,0
|
||||
for (i = 0; i <= radius; i++) {
|
||||
stack_i = i;
|
||||
stack[stack_i] = src[src_i];
|
||||
sum_r += ((src[src_i] >>> 16) & 0xff) * (i + 1);
|
||||
sum_g += ((src[src_i] >>> 8) & 0xff) * (i + 1);
|
||||
sum_b += (src[src_i] & 0xff) * (i + 1);
|
||||
sum_out_r += ((src[src_i] >>> 16) & 0xff);
|
||||
sum_out_g += ((src[src_i] >>> 8) & 0xff);
|
||||
sum_out_b += (src[src_i] & 0xff);
|
||||
}
|
||||
for (i = 1; i <= radius; i++) {
|
||||
if (i <= hm) src_i += w; // +stride
|
||||
|
||||
stack_i = i + radius;
|
||||
stack[stack_i] = src[src_i];
|
||||
sum_r += ((src[src_i] >>> 16) & 0xff) * (radius + 1 - i);
|
||||
sum_g += ((src[src_i] >>> 8) & 0xff) * (radius + 1 - i);
|
||||
sum_b += (src[src_i] & 0xff) * (radius + 1 - i);
|
||||
sum_in_r += ((src[src_i] >>> 16) & 0xff);
|
||||
sum_in_g += ((src[src_i] >>> 8) & 0xff);
|
||||
sum_in_b += (src[src_i] & 0xff);
|
||||
}
|
||||
|
||||
sp = radius;
|
||||
yp = radius;
|
||||
if (yp > hm) yp = hm;
|
||||
src_i = x + yp * w; // img.pix_ptr(x, yp);
|
||||
dst_i = x; // img.pix_ptr(x, 0);
|
||||
for (y = 0; y < h; y++) {
|
||||
src[dst_i] = (int)
|
||||
((src[dst_i] & 0xff000000) |
|
||||
((((sum_r * mul_sum) >>> shr_sum) & 0xff) << 16) |
|
||||
((((sum_g * mul_sum) >>> shr_sum) & 0xff) << 8) |
|
||||
((((sum_b * mul_sum) >>> shr_sum) & 0xff)));
|
||||
dst_i += w;
|
||||
|
||||
sum_r -= sum_out_r;
|
||||
sum_g -= sum_out_g;
|
||||
sum_b -= sum_out_b;
|
||||
|
||||
stack_start = sp + div - radius;
|
||||
if (stack_start >= div) stack_start -= div;
|
||||
stack_i = stack_start;
|
||||
|
||||
sum_out_r -= ((stack[stack_i] >>> 16) & 0xff);
|
||||
sum_out_g -= ((stack[stack_i] >>> 8) & 0xff);
|
||||
sum_out_b -= (stack[stack_i] & 0xff);
|
||||
|
||||
if (yp < hm) {
|
||||
src_i += w; // stride
|
||||
++yp;
|
||||
}
|
||||
|
||||
stack[stack_i] = src[src_i];
|
||||
|
||||
sum_in_r += ((src[src_i] >>> 16) & 0xff);
|
||||
sum_in_g += ((src[src_i] >>> 8) & 0xff);
|
||||
sum_in_b += (src[src_i] & 0xff);
|
||||
sum_r += sum_in_r;
|
||||
sum_g += sum_in_g;
|
||||
sum_b += sum_in_b;
|
||||
|
||||
++sp;
|
||||
if (sp >= div) sp = 0;
|
||||
stack_i = sp;
|
||||
|
||||
sum_out_r += ((stack[stack_i] >>> 16) & 0xff);
|
||||
sum_out_g += ((stack[stack_i] >>> 8) & 0xff);
|
||||
sum_out_b += (stack[stack_i] & 0xff);
|
||||
sum_in_r -= ((stack[stack_i] >>> 16) & 0xff);
|
||||
sum_in_g -= ((stack[stack_i] >>> 8) & 0xff);
|
||||
sum_in_b -= (stack[stack_i] & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class BlurTask implements Callable<Void> {
|
||||
private final int[] _src;
|
||||
private final int _w;
|
||||
private final int _h;
|
||||
private final int _radius;
|
||||
private final int _totalCores;
|
||||
private final int _coreIndex;
|
||||
private final int _round;
|
||||
|
||||
public BlurTask(int[] src, int w, int h, int radius, int totalCores, int coreIndex, int round) {
|
||||
_src = src;
|
||||
_w = w;
|
||||
_h = h;
|
||||
_radius = radius;
|
||||
_totalCores = totalCores;
|
||||
_coreIndex = coreIndex;
|
||||
_round = round;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
blurIteration(_src, _w, _h, _radius, _totalCores, _coreIndex, _round);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* StackBlur v1.0 for Android
|
||||
*
|
||||
* @Author: Enrique López Mañas <eenriquelopez@gmail.com>
|
||||
* http://www.lopez-manas.com
|
||||
* <p/>
|
||||
* Author of the original algorithm: Mario Klingemann <mario.quasimondo.com>
|
||||
* <p/>
|
||||
* This is a compromise between Gaussian Blur and Box blur
|
||||
* It creates much better looking blurs than Box Blur, but is
|
||||
* 7x faster than my Gaussian Blur implementation.
|
||||
* <p/>
|
||||
* I called it Stack Blur because this describes best how this
|
||||
* filter works internally: it creates a kind of moving stack
|
||||
* of colors whilst scanning through the image. Thereby it
|
||||
* just has to add one new block of color to the right side
|
||||
* of the stack and remove the leftmost color. The remaining
|
||||
* colors on the topmost layer of the stack are either added on
|
||||
* or reduced by one, depending on if they are on the right or
|
||||
* on the left side of the stack.
|
||||
* @copyright: Enrique López Mañas
|
||||
* @license: Apache License 2.0
|
||||
*/
|
||||
|
||||
|
||||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class StackBlurManager {
|
||||
static final int EXECUTOR_THREADS = Runtime.getRuntime().availableProcessors();
|
||||
static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(EXECUTOR_THREADS);
|
||||
|
||||
/**
|
||||
* Original image
|
||||
*/
|
||||
private final Bitmap _image;
|
||||
|
||||
/**
|
||||
* Most recent result of blurring
|
||||
*/
|
||||
private Bitmap _result;
|
||||
|
||||
/**
|
||||
* Method of blurring
|
||||
*/
|
||||
private final BlurProcess _blurProcess;
|
||||
|
||||
/**
|
||||
* Constructor method (basic initialization and construction of the pixel array)
|
||||
*
|
||||
* @param image The image that will be analyed
|
||||
*/
|
||||
public StackBlurManager(Bitmap image) {
|
||||
_image = image;
|
||||
_blurProcess = new JavaBlurProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the image on the given radius. Radius must be at least 1
|
||||
*
|
||||
* @param radius
|
||||
*/
|
||||
public Bitmap process(int radius) {
|
||||
_result = _blurProcess.blur(_image, radius);
|
||||
return _result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blurred image as a bitmap
|
||||
*
|
||||
* @return blurred image
|
||||
*/
|
||||
public Bitmap returnBlurredImage() {
|
||||
return _result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original image as a bitmap
|
||||
*
|
||||
* @return the original bitmap image
|
||||
*/
|
||||
public Bitmap getImage() {
|
||||
return this._image;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,8 +13,7 @@ public class UIPreferenceChangedEvent {
|
|||
public static final int COLORED_NAVIGATION_BAR_CURRENT_PLAYING_CHANGED = 6;
|
||||
public static final int COLORED_NAVIGATION_BAR_CHANGED = 10;
|
||||
public static final int COLORED_NAVIGATION_BAR_OTHER_SCREENS_CHANGED = 7;
|
||||
public static final int PLAYBACK_CONTROLLER_CARD_CHANGED = 8;
|
||||
public static final int TOOLBAR_TRANSPARENT_CHANGED = 9;
|
||||
public static final int TOOLBAR_TRANSPARENT_CHANGED = 8;
|
||||
|
||||
private final int action;
|
||||
private final Object value;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public final class PreferenceUtils {
|
|||
public static final String ALBUM_SORT_ORDER = "album_sort_order";
|
||||
public static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
||||
public static final String SONG_SORT_ORDER = "song_sort_order";
|
||||
public static final String ONLY_ON_WIFI = "auto_download_artist_images";
|
||||
// public static final String ONLY_ON_WIFI = "auto_download_artist_images";
|
||||
// public static final String DOWNLOAD_MISSING_ARTIST_IMAGES = "auto_download_artist_images";
|
||||
public static final String COLORED_ALBUM_FOOTERS = "colored_album_footers";
|
||||
public static final String COLORED_NAVIGATION_BAR = "colored_navigation_bar";
|
||||
|
|
@ -33,7 +33,6 @@ public final class PreferenceUtils {
|
|||
public static final String COLORED_NAVIGATION_BAR_PLAYIST = "colored_navigation_bar_playlist";
|
||||
public static final String COLORED_NAVIGATION_BAR_TAG_EDITOR = "colored_navigation_bar_tag_editor";
|
||||
public static final String COLORED_NAVIGATION_BAR_OTHER_SCREENS = "colored_navigation_bar_other_screens";
|
||||
public static final String PLAYBACK_CONTROLLER_BOX = "playback_controller_card";
|
||||
public static final String TRANSPARENT_TOOLBAR = "transparent_toolbar";
|
||||
public static final String ALBUM_GRID_COLUMNS = "album_grid_columns";
|
||||
public static final String ALBUM_GRID_COLUMNS_LAND = "album_grid_columns_land";
|
||||
|
|
@ -136,7 +135,7 @@ public final class PreferenceUtils {
|
|||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
private boolean coloredNavigationBarFor(String key) {
|
||||
Set<String> defaultVals = new HashSet<>();
|
||||
final Set<String> defaultVals = new HashSet<>();
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_ALBUM);
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_ARTIST);
|
||||
defaultVals.add(COLORED_NAVIGATION_BAR_CURRENT_PLAYING);
|
||||
|
|
@ -148,6 +147,7 @@ public final class PreferenceUtils {
|
|||
mPreferences.edit().putStringSet(COLORED_NAVIGATION_BAR, defaultVals).commit();
|
||||
|
||||
try {
|
||||
//noinspection ConstantConditions
|
||||
return mPreferences.getStringSet(COLORED_NAVIGATION_BAR, defaultVals).contains(key);
|
||||
} catch (NullPointerException e) {
|
||||
return false;
|
||||
|
|
@ -159,10 +159,6 @@ public final class PreferenceUtils {
|
|||
// mPreferences.edit().putBoolean(COLORED_NAVIGATION_BAR_OTHER_SCREENS, coloredNavbar).commit();
|
||||
// }
|
||||
|
||||
public final boolean playbackControllerBoxEnabled() {
|
||||
return mPreferences.getBoolean(PLAYBACK_CONTROLLER_BOX, false);
|
||||
}
|
||||
|
||||
public final boolean transparentToolbar() {
|
||||
return mPreferences.getBoolean(TRANSPARENT_TOOLBAR, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package com.kabouzeid.gramophone.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class HeightAndWidthFitSquarePlaceLeftRightImageView extends ImageView {
|
||||
|
||||
public HeightAndWidthFitSquarePlaceLeftRightImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public HeightAndWidthFitSquarePlaceLeftRightImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public HeightAndWidthFitSquarePlaceLeftRightImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
final int small = Math.min(widthMeasureSpec, heightMeasureSpec);
|
||||
super.onMeasure(small, small);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,25 +7,24 @@ import android.widget.ImageView;
|
|||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class SquareFitImageView extends ImageView {
|
||||
public class HeightFitSquareImageView extends ImageView {
|
||||
|
||||
public SquareFitImageView(Context context) {
|
||||
public HeightFitSquareImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SquareFitImageView(Context context, AttributeSet attrs) {
|
||||
public HeightFitSquareImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SquareFitImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
public HeightFitSquareImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
final int newWidth = Math.min(widthMeasureSpec, heightMeasureSpec);
|
||||
//noinspection SuspiciousNameCombination
|
||||
super.onMeasure(newWidth, newWidth);
|
||||
super.onMeasure(heightMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.kabouzeid.gramophone.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class SquareIfPlaceLeftRightImageView extends ImageView {
|
||||
|
||||
public SquareIfPlaceLeftRightImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SquareIfPlaceLeftRightImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SquareIfPlaceLeftRightImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
final int small = Math.min(widthMeasureSpec, heightMeasureSpec);
|
||||
final int large = Math.max(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
if (View.MeasureSpec.getSize(large) > View.MeasureSpec.getSize(small) * 1.5)
|
||||
super.onMeasure(small, small);
|
||||
else super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,17 +7,17 @@ import android.widget.ImageView;
|
|||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class SquareImageView extends ImageView {
|
||||
public class WidthFitSquareImageView extends ImageView {
|
||||
|
||||
public SquareImageView(Context context) {
|
||||
public WidthFitSquareImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SquareImageView(Context context, AttributeSet attrs) {
|
||||
public WidthFitSquareImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
public WidthFitSquareImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue