drop some cruft
This commit is contained in:
parent
c3175f756d
commit
0925e04a5b
@ -293,7 +293,8 @@ public class BottomBarControls extends LinearLayout
|
|||||||
* Because ...reasons.
|
* Because ...reasons.
|
||||||
*/
|
*/
|
||||||
private boolean menuMargin() {
|
private boolean menuMargin() {
|
||||||
return ThemeHelper.usesHoloTheme() == false;
|
// Was false for holo, maybe will be true again in the future? ;-)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -527,9 +527,7 @@ public final class PlaybackService extends Service
|
|||||||
mAccelLast = SensorManager.GRAVITY_EARTH;
|
mAccelLast = SensorManager.GRAVITY_EARTH;
|
||||||
setupSensor();
|
setupSensor();
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
ScheduledLibraryUpdate.scheduleUpdate(this);
|
||||||
ScheduledLibraryUpdate.scheduleUpdate(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -800,9 +798,6 @@ public final class PlaybackService extends Service
|
|||||||
if(mMediaPlayerInitialized != true)
|
if(mMediaPlayerInitialized != true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
|
||||||
return; /* setNextMediaPlayer is supported since JB */
|
|
||||||
|
|
||||||
boolean doGapless = false;
|
boolean doGapless = false;
|
||||||
int fa = finishAction(mState);
|
int fa = finishAction(mState);
|
||||||
Song nextSong = getSong(1);
|
Song nextSong = getSong(1);
|
||||||
|
@ -152,11 +152,7 @@ public class PlaylistObserver extends SQLiteOpenHelper implements Handler.Callba
|
|||||||
MediaLibrary.unregisterLibraryObserver(mLibraryObserver);
|
MediaLibrary.unregisterLibraryObserver(mLibraryObserver);
|
||||||
mFileObserver.stopWatching();
|
mFileObserver.stopWatching();
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
mHandlerThread.quitSafely();
|
||||||
mHandlerThread.quitSafely();
|
|
||||||
} else {
|
|
||||||
mHandlerThread.quit();
|
|
||||||
}
|
|
||||||
mHandlerThread = null;
|
mHandlerThread = null;
|
||||||
mHandler = null;
|
mHandler = null;
|
||||||
}
|
}
|
||||||
|
@ -86,9 +86,7 @@ public class PreferencesActivity extends PreferenceActivity
|
|||||||
loadHeadersFromResource(R.xml.preference_headers, tmp);
|
loadHeadersFromResource(R.xml.preference_headers, tmp);
|
||||||
|
|
||||||
for(Header obj : tmp) {
|
for(Header obj : tmp) {
|
||||||
// Themes are 5.x only, so do not add PreferencesTheme on holo devices
|
target.add(obj);
|
||||||
if (!ThemeHelper.usesHoloTheme() || !obj.fragment.equals(PreferencesTheme.class.getName()))
|
|
||||||
target.add(obj);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,7 @@ public class RemoteControl {
|
|||||||
* Returns a RemoteControl.Client implementation
|
* Returns a RemoteControl.Client implementation
|
||||||
*/
|
*/
|
||||||
public RemoteControl.Client getClient(Context context) {
|
public RemoteControl.Client getClient(Context context) {
|
||||||
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
return new RemoteControlImplLp(context);
|
||||||
new RemoteControlImplLp(context) :
|
|
||||||
new RemoteControlImplICS(context) // legacy implementation, kept until we drop 4.x support
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,156 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
|
||||||
* Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ch.blinkenlights.android.vanilla;
|
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.media.MediaMetadataRetriever;
|
|
||||||
import android.media.RemoteControlClient;
|
|
||||||
|
|
||||||
public class RemoteControlImplICS implements RemoteControl.Client {
|
|
||||||
/**
|
|
||||||
* Context of this instance
|
|
||||||
*/
|
|
||||||
private final Context mContext;
|
|
||||||
/**
|
|
||||||
* Used with updateRemote method.
|
|
||||||
*/
|
|
||||||
private RemoteControlClient mRemote;
|
|
||||||
/**
|
|
||||||
* Whether the cover should be shown. 1 for yes, 0 for no, -1 for
|
|
||||||
* uninitialized.
|
|
||||||
*/
|
|
||||||
private int mShowCover = -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance
|
|
||||||
*
|
|
||||||
* @param context The context to use
|
|
||||||
*/
|
|
||||||
public RemoteControlImplICS(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform initialization required for RemoteControlClient.
|
|
||||||
*/
|
|
||||||
public void initializeRemote() {
|
|
||||||
// make sure there is only one registered remote
|
|
||||||
unregisterRemote();
|
|
||||||
|
|
||||||
// Receive 'background' play button events
|
|
||||||
AudioManager audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
ComponentName receiver = new ComponentName(mContext.getPackageName(), MediaButtonReceiver.class.getName());
|
|
||||||
audioManager.registerMediaButtonEventReceiver(receiver);
|
|
||||||
|
|
||||||
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
|
||||||
mediaButtonIntent.setComponent(new ComponentName(mContext.getPackageName(), MediaButtonReceiver.class.getName()));
|
|
||||||
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(mContext, 0, mediaButtonIntent, 0);
|
|
||||||
RemoteControlClient remote = new RemoteControlClient(mediaPendingIntent);
|
|
||||||
|
|
||||||
// Things we can do (eg: buttons to display on lock screen)
|
|
||||||
int flags = RemoteControlClient.FLAG_KEY_MEDIA_NEXT
|
|
||||||
| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
|
|
||||||
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
|
|
||||||
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY
|
|
||||||
| RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
|
|
||||||
remote.setTransportControlFlags(flags);
|
|
||||||
|
|
||||||
audioManager.registerRemoteControlClient(remote);
|
|
||||||
mRemote = remote;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters a remote control client
|
|
||||||
*/
|
|
||||||
public void unregisterRemote() {
|
|
||||||
if (mRemote != null) {
|
|
||||||
AudioManager audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
ComponentName receiver = new ComponentName(mContext.getPackageName(), MediaButtonReceiver.class.getName());
|
|
||||||
audioManager.unregisterMediaButtonEventReceiver(receiver);
|
|
||||||
audioManager.unregisterRemoteControlClient(mRemote);
|
|
||||||
mRemote = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uninitializes our cached preferences, forcing a reload
|
|
||||||
*/
|
|
||||||
public void reloadPreference()
|
|
||||||
{
|
|
||||||
mShowCover = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the remote with new metadata.
|
|
||||||
* {@link #initializeRemote()} must have been called
|
|
||||||
* first.
|
|
||||||
*
|
|
||||||
* @param song The song containing the new metadata.
|
|
||||||
* @param state PlaybackService state, used to determine playback state.
|
|
||||||
* @param keepPaused whether or not to keep the remote updated in paused mode
|
|
||||||
*/
|
|
||||||
public void updateRemote(Song song, int state, boolean keepPaused)
|
|
||||||
{
|
|
||||||
RemoteControlClient remote = mRemote;
|
|
||||||
if (remote == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
boolean isPlaying = ((state & PlaybackService.FLAG_PLAYING) != 0);
|
|
||||||
|
|
||||||
if (mShowCover == -1) {
|
|
||||||
SharedPreferences settings = SharedPrefHelper.getSettings(mContext);
|
|
||||||
mShowCover = settings.getBoolean(PrefKeys.COVER_ON_LOCKSCREEN, PrefDefaults.COVER_ON_LOCKSCREEN) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
remote.setPlaybackState(isPlaying ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
|
|
||||||
RemoteControlClient.MetadataEditor editor = remote.editMetadata(true);
|
|
||||||
if (song != null && song.artist != null && song.album != null) {
|
|
||||||
String artist_album = song.artist + " - " + song.album;
|
|
||||||
artist_album = (song.artist.length() == 0 ? song.album : artist_album); // no artist ? -> only display album
|
|
||||||
artist_album = (song.album.length() == 0 ? song.artist : artist_album); // no album ? -> only display artist
|
|
||||||
|
|
||||||
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, artist_album);
|
|
||||||
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, song.title);
|
|
||||||
Bitmap bitmap = song.getMediumCover(mContext);
|
|
||||||
if (bitmap != null && mShowCover == 1 && (isPlaying || keepPaused)) {
|
|
||||||
// Create a copy of the cover art, since RemoteControlClient likes
|
|
||||||
// to recycle what we give it.
|
|
||||||
bitmap = bitmap.copy(Bitmap.Config.RGB_565, false);
|
|
||||||
} else {
|
|
||||||
// Some lockscreen implementations fail to clear the cover artwork
|
|
||||||
// if we send a null bitmap. We are creating a 16x16 transparent
|
|
||||||
// bitmap to work around this limitation.
|
|
||||||
bitmap = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888);
|
|
||||||
}
|
|
||||||
editor.putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, bitmap);
|
|
||||||
}
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
}
|
|
@ -38,31 +38,28 @@ public class ThemeHelper {
|
|||||||
* and platform API.
|
* and platform API.
|
||||||
*/
|
*/
|
||||||
final public static int getThemeResource(Context context, int theme) {
|
final public static int getThemeResource(Context context, int theme) {
|
||||||
if(usesHoloTheme() == false) {
|
TypedArray ar = null;
|
||||||
TypedArray ar = null;
|
switch (theme) {
|
||||||
|
case R.style.Playback:
|
||||||
switch (theme) {
|
ar = context.getResources().obtainTypedArray(R.array.theme_category_playback);
|
||||||
case R.style.Playback:
|
break;
|
||||||
ar = context.getResources().obtainTypedArray(R.array.theme_category_playback);
|
case R.style.Library:
|
||||||
break;
|
ar = context.getResources().obtainTypedArray(R.array.theme_category_library);
|
||||||
case R.style.Library:
|
break;
|
||||||
ar = context.getResources().obtainTypedArray(R.array.theme_category_library);
|
case R.style.BackActionBar:
|
||||||
break;
|
ar = context.getResources().obtainTypedArray(R.array.theme_category_backactionbar);
|
||||||
case R.style.BackActionBar:
|
break;
|
||||||
ar = context.getResources().obtainTypedArray(R.array.theme_category_backactionbar);
|
case R.style.PopupDialog:
|
||||||
break;
|
ar = context.getResources().obtainTypedArray(R.array.theme_category_popupdialog);
|
||||||
case R.style.PopupDialog:
|
break;
|
||||||
ar = context.getResources().obtainTypedArray(R.array.theme_category_popupdialog);
|
case R.style.BottomSheetDialog:
|
||||||
break;
|
ar = context.getResources().obtainTypedArray(R.array.theme_category_bottomsheetdialog);
|
||||||
case R.style.BottomSheetDialog:
|
break;
|
||||||
ar = context.getResources().obtainTypedArray(R.array.theme_category_bottomsheetdialog);
|
default:
|
||||||
break;
|
throw new IllegalArgumentException("setTheme() called with unknown theme!");
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("setTheme() called with unknown theme!");
|
|
||||||
}
|
|
||||||
theme = ar.getResourceId(getSelectedThemeIndex(context), -1);
|
|
||||||
ar.recycle();
|
|
||||||
}
|
}
|
||||||
|
theme = ar.getResourceId(getSelectedThemeIndex(context), -1);
|
||||||
|
ar.recycle();
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,14 +70,7 @@ public class ThemeHelper {
|
|||||||
*/
|
*/
|
||||||
final public static int getPlayButtonResource(boolean playing)
|
final public static int getPlayButtonResource(boolean playing)
|
||||||
{
|
{
|
||||||
int playButton = 0;
|
return playing ? R.drawable.widget_pause : R.drawable.widget_play;
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
// Android >= 5.0 uses the dark version of this drawable
|
|
||||||
playButton = playing ? R.drawable.widget_pause : R.drawable.widget_play;
|
|
||||||
} else {
|
|
||||||
playButton = playing ? R.drawable.pause : R.drawable.play;
|
|
||||||
}
|
|
||||||
return playButton;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,12 +79,9 @@ public class ThemeHelper {
|
|||||||
*/
|
*/
|
||||||
final private static boolean usesDarkTheme(Context context)
|
final private static boolean usesDarkTheme(Context context)
|
||||||
{
|
{
|
||||||
boolean useDark = false;
|
final int idx = getSelectedThemeIndex(context);
|
||||||
if(usesHoloTheme() == false) {
|
final String[] variants = context.getResources().getStringArray(R.array.theme_variant);
|
||||||
final int idx = getSelectedThemeIndex(context);
|
boolean useDark = variants[idx].equals("dark");
|
||||||
final String[] variants = context.getResources().getStringArray(R.array.theme_variant);
|
|
||||||
useDark = variants[idx].equals("dark");
|
|
||||||
}
|
|
||||||
return useDark;
|
return useDark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,13 +104,6 @@ public class ThemeHelper {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if this device uses the HOLO (android 4) theme
|
|
||||||
*/
|
|
||||||
final public static boolean usesHoloTheme() {
|
|
||||||
return (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a color resource from the current theme
|
* Fetches a color resource from the current theme
|
||||||
*/
|
*/
|
||||||
@ -138,9 +118,6 @@ public class ThemeHelper {
|
|||||||
* Returns the color to be used to draw the placeholder cover.
|
* Returns the color to be used to draw the placeholder cover.
|
||||||
*/
|
*/
|
||||||
final public static int[] getDefaultCoverColors(Context context) {
|
final public static int[] getDefaultCoverColors(Context context) {
|
||||||
if (usesHoloTheme()) // pre material device
|
|
||||||
return new int[] { 0xff000000, 0xff404040 };
|
|
||||||
|
|
||||||
int bg = fetchThemeColor(context, android.R.attr.colorBackground);
|
int bg = fetchThemeColor(context, android.R.attr.colorBackground);
|
||||||
int diff = 0x00171717 * (bg > 0xFF888888 ? -1 : 1);
|
int diff = 0x00171717 * (bg > 0xFF888888 ? -1 : 1);
|
||||||
return new int[]{ bg, bg+diff };
|
return new int[]{ bg, bg+diff };
|
||||||
|
@ -151,13 +151,9 @@ public class FancyMenu {
|
|||||||
*/
|
*/
|
||||||
private Adapter assembleAdapter(ArrayList<ArrayList<FancyMenuItem>> items) {
|
private Adapter assembleAdapter(ArrayList<ArrayList<FancyMenuItem>> items) {
|
||||||
final Adapter adapter = new Adapter(mContext, 0);
|
final Adapter adapter = new Adapter(mContext, 0);
|
||||||
// spacers look awful on holo themes
|
|
||||||
final boolean usesSpacers = !ThemeHelper.usesHoloTheme();
|
|
||||||
for (ArrayList<FancyMenuItem> sub : items) {
|
for (ArrayList<FancyMenuItem> sub : items) {
|
||||||
for (FancyMenuItem item : sub ) {
|
for (FancyMenuItem item : sub ) {
|
||||||
if (usesSpacers || !item.isSpacer()) {
|
adapter.add(item);
|
||||||
adapter.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return adapter;
|
return adapter;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user