Various fixes and improvements
This commit is contained in:
parent
5f0bfdb14b
commit
6b68c17ae2
26 changed files with 142 additions and 121 deletions
|
|
@ -67,7 +67,7 @@ public class ShuffleButtonSongAdapter extends SongAdapter {
|
|||
if (holder.image != null) {
|
||||
final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin) / 2;
|
||||
holder.image.setPadding(padding, padding, padding, padding);
|
||||
holder.image.setColorFilter(ThemeSingleton.get().positiveColor);
|
||||
holder.image.setColorFilter(ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
holder.image.setImageResource(R.drawable.ic_shuffle_white_24dp);
|
||||
}
|
||||
if (holder.separator != null) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public class WidgetMedium extends AppWidgetProvider {
|
|||
linkButtons(context, widgetLayout);
|
||||
widgetLayout.setTextViewText(R.id.title, song.title);
|
||||
widgetLayout.setTextViewText(R.id.song_secondary_information, song.artistName + " | " + song.albumName);
|
||||
|
||||
updateWidgetsPlayState(context, isPlaying);
|
||||
loadAlbumArt(context, song);
|
||||
}
|
||||
|
|
@ -123,29 +124,24 @@ public class WidgetMedium extends AppWidgetProvider {
|
|||
}
|
||||
|
||||
private static PendingIntent retrievePlaybackActions(@NonNull final Context context, final int which) {
|
||||
Intent action;
|
||||
PendingIntent pendingIntent;
|
||||
final ComponentName serviceName = new ComponentName(context, MusicService.class);
|
||||
Intent intent;
|
||||
switch (which) {
|
||||
case 0:
|
||||
action = new Intent(context, MainActivity.class);
|
||||
pendingIntent = PendingIntent.getActivity(context, 0, action, 0);
|
||||
return pendingIntent;
|
||||
intent = new Intent(context, MainActivity.class);
|
||||
return PendingIntent.getActivity(context, 0, intent, 0);
|
||||
case 1:
|
||||
action = new Intent(MusicService.ACTION_TOGGLE_PAUSE);
|
||||
action.setComponent(serviceName);
|
||||
pendingIntent = PendingIntent.getService(context, 1, action, 0);
|
||||
return pendingIntent;
|
||||
intent = new Intent(MusicService.ACTION_TOGGLE_PAUSE);
|
||||
intent.setComponent(serviceName);
|
||||
return PendingIntent.getService(context, 1, intent, 0);
|
||||
case 2:
|
||||
action = new Intent(MusicService.ACTION_SKIP);
|
||||
action.setComponent(serviceName);
|
||||
pendingIntent = PendingIntent.getService(context, 2, action, 0);
|
||||
return pendingIntent;
|
||||
intent = new Intent(MusicService.ACTION_SKIP);
|
||||
intent.setComponent(serviceName);
|
||||
return PendingIntent.getService(context, 2, intent, 0);
|
||||
case 3:
|
||||
action = new Intent(MusicService.ACTION_REWIND);
|
||||
action.setComponent(serviceName);
|
||||
pendingIntent = PendingIntent.getService(context, 3, action, 0);
|
||||
return pendingIntent;
|
||||
intent = new Intent(MusicService.ACTION_REWIND);
|
||||
intent.setComponent(serviceName);
|
||||
return PendingIntent.getService(context, 3, intent, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ public class SleepTimerDialog extends DialogFragment {
|
|||
Field f1 = SeekArc.class.getDeclaredField("mThumb");
|
||||
f1.setAccessible(true);
|
||||
Drawable thumb = (Drawable) f1.get(seekArc);
|
||||
thumb.setColorFilter(ThemeSingleton.get().positiveColor, PorterDuff.Mode.SRC_IN);
|
||||
thumb.setColorFilter(ThemeSingleton.get().positiveColor.getDefaultColor(), PorterDuff.Mode.SRC_IN);
|
||||
|
||||
Field f2 = SeekArc.class.getDeclaredField("mProgressPaint");
|
||||
f2.setAccessible(true);
|
||||
Paint progressPaint = (Paint) f2.get(seekArc);
|
||||
progressPaint.setColor(ThemeSingleton.get().positiveColor);
|
||||
progressPaint.setColor(ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ public class PlayingNotificationHelper {
|
|||
}
|
||||
|
||||
private PendingIntent getOpenMusicControllerPendingIntent() {
|
||||
return PendingIntent.getActivity(service, 0, new Intent(service, MainActivity.class), 0);
|
||||
Intent intent = new Intent(service, MainActivity.class);
|
||||
return PendingIntent.getActivity(service, 0, intent, 0);
|
||||
}
|
||||
|
||||
private void setUpExpandedPlaybackActions() {
|
||||
|
|
|
|||
|
|
@ -590,6 +590,8 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
if (restoredPositionInTrack > 0) seek(restoredPositionInTrack);
|
||||
|
||||
notNotifiedMetaChangedForCurrentTrack = true;
|
||||
sendChangeIntent(META_CHANGED);
|
||||
updateWidgets();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -801,6 +803,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
}
|
||||
|
||||
private void notifyChange(@NonNull final String what) {
|
||||
sendChangeIntent(what);
|
||||
handleChange(what);
|
||||
}
|
||||
|
||||
private void sendChangeIntent(@NonNull final String what) {
|
||||
final Intent internalIntent = new Intent(what);
|
||||
|
||||
final Song currentSong = getCurrentSong();
|
||||
|
|
@ -813,11 +820,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
internalIntent.putExtra("playing", isPlaying());
|
||||
sendStickyBroadcast(internalIntent);
|
||||
|
||||
//to let other apps know whats playing. i.E. last.fm (scrobbling) or musixmatch
|
||||
// to let other apps know whats playing. i.E. last.fm (scrobbling) or musixmatch
|
||||
final Intent publicMusicIntent = new Intent(internalIntent);
|
||||
publicMusicIntent.setAction(what.replace(PHONOGRAPH_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
|
||||
sendStickyBroadcast(publicMusicIntent);
|
||||
}
|
||||
|
||||
private void handleChange(@NonNull final String what) {
|
||||
if (what.equals(PLAY_STATE_CHANGED)) {
|
||||
final boolean isPlaying = isPlaying();
|
||||
playingNotificationHelper.updatePlayState(isPlaying);
|
||||
|
|
@ -833,6 +842,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
updateRemoteControlClient();
|
||||
savePosition();
|
||||
savePositionInTrack();
|
||||
final Song currentSong = getCurrentSong();
|
||||
recentlyPlayedStore.addSongId(currentSong.id);
|
||||
songPlayCountStore.bumpSongCount(currentSong.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, @Nullable FailReason failReason) {
|
||||
setUpBackground("drawable://" + R.drawable.default_album_art);
|
||||
setColors(ColorUtil.resolveColor(AlbumDetailActivity.this, R.attr.default_bar_color));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
startPostponedEnterTransition();
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, @Nullable FailReason failReason) {
|
||||
setUpBackground("drawable://" + R.drawable.default_artist_image);
|
||||
setColors(ColorUtil.resolveColor(ArtistDetailActivity.this, R.attr.default_bar_color));
|
||||
|
||||
toastUpdatedArtistImageIfDownloadWasForced();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import android.support.v7.app.ActionBar;
|
|||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
|
|
@ -170,9 +169,9 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
tabStripField.setAccessible(true);
|
||||
Object tabStrip = tabStripField.get(tabs);
|
||||
|
||||
Method setSelectedIndicatorColorMethod = tabStrip.getClass().getDeclaredMethod("setSelectedIndicatorColor", int.class);
|
||||
Method setSelectedIndicatorColorMethod = tabStrip.getClass().getDeclaredMethod("setSelectedIndicatorColor", Integer.TYPE);
|
||||
setSelectedIndicatorColorMethod.setAccessible(true);
|
||||
setSelectedIndicatorColorMethod.invoke(tabStrip, ThemeSingleton.get().positiveColor);
|
||||
setSelectedIndicatorColorMethod.invoke(tabStrip, ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -190,7 +189,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
}
|
||||
|
||||
private void setUpNavigationView() {
|
||||
final int colorAccent = ThemeSingleton.get().positiveColor;
|
||||
final int colorAccent = ThemeSingleton.get().positiveColor.getDefaultColor();
|
||||
navigationView.setItemTextColor(new ColorStateList(
|
||||
new int[][]{
|
||||
//{-android.R.attr.state_enabled}, // disabled
|
||||
|
|
@ -476,10 +475,10 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
String mimeType = intent.getType();
|
||||
boolean handled = false;
|
||||
|
||||
if (intent.getAction() != null
|
||||
&& intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
|
||||
if (intent.getAction() != null && intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
|
||||
MusicPlayerRemote.openQueue(SearchQueryHelper.getSongs(this, intent.getExtras()), 0, true);
|
||||
}
|
||||
|
||||
if (uri != null && uri.toString().length() > 0) {
|
||||
MusicPlayerRemote.playFile(new File(uri.getPath()).getAbsolutePath());
|
||||
handled = true;
|
||||
|
|
@ -564,14 +563,12 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
// return (PlaylistViewFragment) pagerAdapter.getFragment(PagerAdapter.MusicFragments.PLAYLIST.ordinal());
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (toolbar != null)
|
||||
toolbar.showOverflowMenu();
|
||||
return true;
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
protected void showOverflowMenu() {
|
||||
super.showOverflowMenu();
|
||||
if (toolbar != null && getSlidingUpPanelLayout().getPanelState() != SlidingUpPanelLayout.PanelState.EXPANDED)
|
||||
toolbar.showOverflowMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
setStatusBarTransparent();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_preferences);
|
||||
setStatusBarTransparent();
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setBackgroundColor(getThemeColorPrimary());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.kabouzeid.gramophone.ui.activities.base;
|
|||
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
|
||||
|
|
@ -24,9 +26,22 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
|||
enableViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_UP) {
|
||||
showOverflowMenu();
|
||||
return true;
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
protected void showOverflowMenu() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be overwritten and re enable all {@link android.view.View} to ensure they are accessible again
|
||||
* <p>
|
||||
* <p/>
|
||||
* This is necessary because of a bug with the shared element transition
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -36,7 +51,7 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
|||
|
||||
/**
|
||||
* Should be overwritten and disable all views that start a new activity on click to prevent opening an activity multiple times
|
||||
* <p>
|
||||
* <p/>
|
||||
* This is necessary because of a bug with the shared element transition
|
||||
*/
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,41 +27,48 @@ public abstract class AbsMusicStateActivity extends AbsBaseActivity implements S
|
|||
|
||||
private MusicPlayerRemote.ServiceToken serviceToken;
|
||||
private MusicStateReceiver musicStateReceiver;
|
||||
private boolean receiverRegistered;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
serviceToken = MusicPlayerRemote.bindToService(this, this);
|
||||
musicStateReceiver = new MusicStateReceiver(this);
|
||||
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(MusicService.PLAY_STATE_CHANGED);
|
||||
filter.addAction(MusicService.SHUFFLE_MODE_CHANGED);
|
||||
filter.addAction(MusicService.REPEAT_MODE_CHANGED);
|
||||
filter.addAction(MusicService.META_CHANGED);
|
||||
filter.addAction(MusicService.MEDIA_STORE_CHANGED);
|
||||
|
||||
registerReceiver(musicStateReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
onPlayStateChanged();
|
||||
onRepeatModeChanged();
|
||||
onShuffleModeChanged();
|
||||
onPlayingMetaChanged();
|
||||
if (!receiverRegistered) {
|
||||
musicStateReceiver = new MusicStateReceiver(this);
|
||||
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(MusicService.PLAY_STATE_CHANGED);
|
||||
filter.addAction(MusicService.SHUFFLE_MODE_CHANGED);
|
||||
filter.addAction(MusicService.REPEAT_MODE_CHANGED);
|
||||
filter.addAction(MusicService.META_CHANGED);
|
||||
filter.addAction(MusicService.MEDIA_STORE_CHANGED);
|
||||
|
||||
registerReceiver(musicStateReceiver, filter);
|
||||
|
||||
receiverRegistered = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
||||
if (receiverRegistered) {
|
||||
unregisterReceiver(musicStateReceiver);
|
||||
receiverRegistered = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
MusicPlayerRemote.unbindFromService(serviceToken);
|
||||
unregisterReceiver(musicStateReceiver);
|
||||
if (receiverRegistered) {
|
||||
unregisterReceiver(musicStateReceiver);
|
||||
receiverRegistered = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void addMusicStateListenerListener(final MusicStateListener listener) {
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
private static final int FAB_CIRCULAR_REVEAL_ANIMATION_TIME = 1000;
|
||||
private static final long DEFAULT_PROGRESS_VIEW_REFRESH_INTERVAL = 500;
|
||||
private static final int CMD_REFRESH_PROGRESS_VIEWS = 1;
|
||||
private static final String PANEL_EXPANDED_KEY = "panel_state";
|
||||
|
||||
@Bind(R.id.play_pause_fab)
|
||||
FloatingActionButton playPauseFab;
|
||||
|
|
@ -161,6 +162,17 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
setUpPlayerToolbar();
|
||||
|
||||
progressViewsUpdateHandler = new MusicProgressViewsUpdateHandler(this);
|
||||
|
||||
slidingUpPanelLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||
mediaControllerContainer.setVisibility(View.VISIBLE);
|
||||
onPanelSlide(slidingUpPanelLayout, 1);
|
||||
onPanelExpanded(slidingUpPanelLayout);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract View createContentView();
|
||||
|
|
@ -201,10 +213,9 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
updateFabState(false);
|
||||
|
||||
playPauseFab.setImageDrawable(playPauseDrawable);
|
||||
final int accentColor = ThemeSingleton.get().positiveColor;
|
||||
playPauseFab.setBackgroundTintList(ColorUtil.getEmptyColorStateList(accentColor));
|
||||
if (accentColor == Color.WHITE) {
|
||||
playPauseFab.getDrawable().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
|
||||
playPauseFab.setBackgroundTintList(ThemeSingleton.get().positiveColor);
|
||||
if (getThemeColorAccent() == Color.WHITE) {
|
||||
playPauseFab.getDrawable().setColorFilter(getResources().getColor(R.color.primary_text_default_material_light), PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
playPauseFab.getDrawable().clearColorFilter();
|
||||
}
|
||||
|
|
@ -315,6 +326,10 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
|
||||
@Override
|
||||
public void onPanelExpanded(View view) {
|
||||
onPanelSlide(view, 1);
|
||||
if (!progressViewsUpdateHandler.hasMessages(CMD_REFRESH_PROGRESS_VIEWS)) {
|
||||
startUpdatingProgressViews();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (mediaControllerContainer.getVisibility() == View.INVISIBLE) {
|
||||
int cx = (dummyFab.getLeft() + dummyFab.getRight()) / 2;
|
||||
|
|
@ -474,7 +489,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
}
|
||||
|
||||
private void setUpSeekBar() {
|
||||
setTint(seekBar, !ThemeSingleton.get().darkTheme && getThemeColorAccent() == Color.WHITE ? Color.BLACK : getThemeColorAccent());
|
||||
setTint(seekBar, getThemeColorAccent());
|
||||
seekBar.setOnSeekBarChangeListener(new SimpleOnSeekbarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
|
@ -520,11 +535,11 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
switch (MusicPlayerRemote.getShuffleMode()) {
|
||||
case MusicService.SHUFFLE_MODE_SHUFFLE:
|
||||
shuffleButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_shuffle_white_36dp,
|
||||
getThemeColorAccent() == Color.WHITE ? Color.BLACK : getThemeColorAccent()));
|
||||
getThemeColorAccent() == Color.WHITE ? getResources().getColor(R.color.primary_text_default_material_light) : getThemeColorAccent()));
|
||||
break;
|
||||
default:
|
||||
shuffleButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_shuffle_white_36dp,
|
||||
DialogUtils.resolveColor(this, R.attr.themed_drawable_color)));
|
||||
ColorUtil.resolveColor(this, R.attr.themed_drawable_color)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -547,11 +562,11 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
break;
|
||||
case MusicService.REPEAT_MODE_ALL:
|
||||
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_white_36dp,
|
||||
getThemeColorAccent() == Color.WHITE ? Color.BLACK : getThemeColorAccent()));
|
||||
getThemeColorAccent() == Color.WHITE ? getResources().getColor(R.color.primary_text_default_material_light) : getThemeColorAccent()));
|
||||
break;
|
||||
default:
|
||||
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_one_white_36dp,
|
||||
getThemeColorAccent() == Color.WHITE ? Color.BLACK : getThemeColorAccent()));
|
||||
getThemeColorAccent() == Color.WHITE ? getResources().getColor(R.color.primary_text_default_material_light) : getThemeColorAccent()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -740,7 +755,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
}
|
||||
|
||||
private void startUpdatingProgressViews() {
|
||||
queueNextRefresh(0);
|
||||
queueNextRefresh(1);
|
||||
}
|
||||
|
||||
private void stopUpdatingProgressViews() {
|
||||
|
|
@ -789,7 +804,11 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicStateActivity
|
|||
public void handleMessage(@NonNull Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == CMD_REFRESH_PROGRESS_VIEWS) {
|
||||
activityReference.get().queueNextRefresh(activityReference.get().refreshProgressViews());
|
||||
AbsSlidingMusicPanelActivity activity = activityReference.get();
|
||||
if (activity != null) {
|
||||
long nextDelay = activityReference.get().refreshProgressViews();
|
||||
activityReference.get().queueNextRefresh(nextDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.kabouzeid.gramophone.ui.activities.base;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
|
|
@ -49,9 +50,10 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
darkTheme = PreferenceUtil.getInstance(this).getGeneralTheme() == R.style.Theme_MaterialMusic;
|
||||
coloredNavigationBar = PreferenceUtil.getInstance(this).shouldUseColoredNavigationBar();
|
||||
|
||||
ThemeSingleton.get().positiveColor = colorAccent;
|
||||
ThemeSingleton.get().negativeColor = colorAccent;
|
||||
ThemeSingleton.get().neutralColor = colorAccent;
|
||||
final ColorStateList accentColorStateList = ColorStateList.valueOf(colorAccent);
|
||||
ThemeSingleton.get().positiveColor = accentColorStateList;
|
||||
ThemeSingleton.get().negativeColor = accentColorStateList;
|
||||
ThemeSingleton.get().neutralColor = accentColorStateList;
|
||||
ThemeSingleton.get().widgetColor = colorAccent;
|
||||
ThemeSingleton.get().darkTheme = darkTheme;
|
||||
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
save();
|
||||
}
|
||||
});
|
||||
fab.setRippleColor(ThemeSingleton.get().positiveColor);
|
||||
fab.setBackgroundTintList(ThemeSingleton.get().positiveColor);
|
||||
}
|
||||
|
||||
protected abstract void save();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.kabouzeid.gramophone.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
|
|
@ -50,16 +49,6 @@ public class ColorUtil {
|
|||
return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static ColorStateList getEmptyColorStateList(@ColorInt int color) {
|
||||
return new ColorStateList(
|
||||
new int[][]{
|
||||
new int[]{}
|
||||
},
|
||||
new int[]{color}
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean useDarkTextColorOnBackground(@ColorInt int backgroundColor) {
|
||||
return (Color.red(backgroundColor) * 0.299 + Color.green(backgroundColor) * 0.587 + Color.blue(backgroundColor) * 0.114) > (255 / 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,22 +67,6 @@ public class ViewUtil {
|
|||
view.setBackgroundColor(a + rgb);
|
||||
}
|
||||
|
||||
public static void addOnGlobalLayoutListener(@NonNull final View view, @NonNull final Runnable runnable) {
|
||||
ViewTreeObserver vto = view.getViewTreeObserver();
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||
//noinspection deprecation
|
||||
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
} else {
|
||||
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
runnable.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called in {@link android.app.Activity#onPrepareOptionsMenu(Menu)} and {@link android.app.Activity#onOptionsItemSelected(MenuItem)}
|
||||
*
|
||||
|
|
@ -136,7 +120,7 @@ public class ViewUtil {
|
|||
|
||||
CheckBox check = (CheckBox) checkboxField.get(iv);
|
||||
if (check != null) {
|
||||
MDTintHelper.setTint(check, ThemeSingleton.get().positiveColor);
|
||||
MDTintHelper.setTint(check, ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
check.setBackground(null);
|
||||
}
|
||||
|
|
@ -144,7 +128,7 @@ public class ViewUtil {
|
|||
|
||||
RadioButton radioButton = (RadioButton) radioButtonField.get(iv);
|
||||
if (radioButton != null) {
|
||||
MDTintHelper.setTint(radioButton, ThemeSingleton.get().positiveColor);
|
||||
MDTintHelper.setTint(radioButton, ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
radioButton.setBackground(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class DynamicCheckBox extends AppCompatCheckBox {
|
|||
}
|
||||
|
||||
private void init() {
|
||||
final int color = ThemeSingleton.get().positiveColor;
|
||||
final int color = ThemeSingleton.get().positiveColor.getDefaultColor();
|
||||
MDTintHelper.setTint(this, color);
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ public class DynamicEditText extends AppCompatEditText {
|
|||
}
|
||||
|
||||
private void init() {
|
||||
final int color = ThemeSingleton.get().positiveColor;
|
||||
final int color = ThemeSingleton.get().positiveColor.getDefaultColor();
|
||||
MDTintHelper.setTint(this, color);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class DynamicSwitch extends SwitchCompat {
|
|||
}
|
||||
|
||||
private void init() {
|
||||
final int color = ThemeSingleton.get().positiveColor;
|
||||
final int color = ThemeSingleton.get().positiveColor.getDefaultColor();
|
||||
setTint(this, color);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class FastScroller extends FrameLayout {
|
|||
handle = findViewById(R.id.scroll_handle);
|
||||
bar = findViewById(R.id.scroll_bar);
|
||||
handle.setEnabled(true);
|
||||
setPressedHandleColor(ThemeSingleton.get().positiveColor);
|
||||
setPressedHandleColor(ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
setUpBarBackground();
|
||||
postDelayed(handleHider, HANDLE_HIDE_DELAY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue