Code Cleanup
This commit is contained in:
parent
6ff3eb2e2a
commit
520b6b74ca
22 changed files with 155 additions and 139 deletions
|
@ -40,7 +40,7 @@ public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapte
|
||||||
implements SwipeAndDragHelper.ActionCompletionContract {
|
implements SwipeAndDragHelper.ActionCompletionContract {
|
||||||
|
|
||||||
private List<CategoryInfo> categoryInfos;
|
private List<CategoryInfo> categoryInfos;
|
||||||
private ItemTouchHelper touchHelper;
|
private final ItemTouchHelper touchHelper;
|
||||||
|
|
||||||
public CategoryInfoAdapter() {
|
public CategoryInfoAdapter() {
|
||||||
SwipeAndDragHelper swipeAndDragHelper = new SwipeAndDragHelper(this);
|
SwipeAndDragHelper swipeAndDragHelper = new SwipeAndDragHelper(this);
|
||||||
|
@ -128,15 +128,15 @@ public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapte
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
private MaterialCheckBox checkBox;
|
private final MaterialCheckBox checkBox;
|
||||||
private View dragView;
|
private final View dragView;
|
||||||
private TextView title;
|
private final TextView title;
|
||||||
|
|
||||||
ViewHolder(View view) {
|
ViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
checkBox = view.findViewById(R.id.checkbox);
|
checkBox = view.findViewById(R.id.checkbox);
|
||||||
checkBox.setButtonTintList(
|
checkBox.setButtonTintList(
|
||||||
ColorStateList.valueOf(ThemeStore.Companion.accentColor(checkBox.getContext())));
|
ColorStateList.valueOf(ThemeStore.Companion.accentColor(checkBox.getContext())));
|
||||||
title = view.findViewById(R.id.title);
|
title = view.findViewById(R.id.title);
|
||||||
dragView = view.findViewById(R.id.drag_view);
|
dragView = view.findViewById(R.id.drag_view);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ open class AlbumAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getName(album: Album): String {
|
override fun getName(album: Album): String {
|
||||||
return album.title!!
|
return album.title
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMultipleItemAction(
|
override fun onMultipleItemAction(
|
||||||
|
|
|
@ -54,7 +54,7 @@ class AlbumDetailsViewModel(
|
||||||
|
|
||||||
fun getAlbumInfo(album: Album): LiveData<Result<LastFmAlbum>> = liveData {
|
fun getAlbumInfo(album: Album): LiveData<Result<LastFmAlbum>> = liveData {
|
||||||
emit(Result.Loading)
|
emit(Result.Loading)
|
||||||
emit(repository.albumInfo(album.artistName ?: "-", album.title ?: "-"))
|
emit(repository.albumInfo(album.artistName, album.title))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMoreAlbums(artist: Artist): LiveData<List<Album>> = liveData(IO) {
|
fun getMoreAlbums(artist: Artist): LiveData<List<Album>> = liveData(IO) {
|
||||||
|
|
|
@ -19,13 +19,15 @@ import android.text.StaticLayout;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
/** 一行歌词实体 */
|
/**
|
||||||
|
* 一行歌词实体
|
||||||
|
*/
|
||||||
class LrcEntry implements Comparable<LrcEntry> {
|
class LrcEntry implements Comparable<LrcEntry> {
|
||||||
public static final int GRAVITY_CENTER = 0;
|
public static final int GRAVITY_CENTER = 0;
|
||||||
public static final int GRAVITY_LEFT = 1;
|
public static final int GRAVITY_LEFT = 1;
|
||||||
public static final int GRAVITY_RIGHT = 2;
|
public static final int GRAVITY_RIGHT = 2;
|
||||||
private long time;
|
private final long time;
|
||||||
private String text;
|
private final String text;
|
||||||
private String secondText;
|
private String secondText;
|
||||||
private StaticLayout staticLayout;
|
private StaticLayout staticLayout;
|
||||||
/** 歌词距离视图顶部的距离 */
|
/** 歌词距离视图顶部的距离 */
|
||||||
|
|
|
@ -43,15 +43,17 @@ import java.util.List;
|
||||||
import code.name.monkey.retromusic.BuildConfig;
|
import code.name.monkey.retromusic.BuildConfig;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
|
|
||||||
/** 歌词 Created by wcy on 2015/11/9. */
|
/**
|
||||||
|
* 歌词 Created by wcy on 2015/11/9.
|
||||||
|
*/
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
public class LrcView extends View {
|
public class LrcView extends View {
|
||||||
private static final long ADJUST_DURATION = 100;
|
private static final long ADJUST_DURATION = 100;
|
||||||
private static final long TIMELINE_KEEP_TIME = 4 * DateUtils.SECOND_IN_MILLIS;
|
private static final long TIMELINE_KEEP_TIME = 4 * DateUtils.SECOND_IN_MILLIS;
|
||||||
|
|
||||||
private List<LrcEntry> mLrcEntryList = new ArrayList<>();
|
private final List<LrcEntry> mLrcEntryList = new ArrayList<>();
|
||||||
private TextPaint mLrcPaint = new TextPaint();
|
private final TextPaint mLrcPaint = new TextPaint();
|
||||||
private TextPaint mTimePaint = new TextPaint();
|
private final TextPaint mTimePaint = new TextPaint();
|
||||||
private Paint.FontMetrics mTimeFontMetrics;
|
private Paint.FontMetrics mTimeFontMetrics;
|
||||||
private Drawable mPlayDrawable;
|
private Drawable mPlayDrawable;
|
||||||
private float mDividerHeight;
|
private float mDividerHeight;
|
||||||
|
@ -78,28 +80,30 @@ public class LrcView extends View {
|
||||||
private boolean isTouching;
|
private boolean isTouching;
|
||||||
private boolean isFling;
|
private boolean isFling;
|
||||||
private int mTextGravity; // 歌词显示位置,靠左/居中/靠右
|
private int mTextGravity; // 歌词显示位置,靠左/居中/靠右
|
||||||
private Runnable hideTimelineRunnable =
|
private final Runnable hideTimelineRunnable =
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (hasLrc() && isShowTimeline) {
|
if (hasLrc() && isShowTimeline) {
|
||||||
isShowTimeline = false;
|
isShowTimeline = false;
|
||||||
smoothScrollTo(mCurrentLine);
|
smoothScrollTo(mCurrentLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/** 手势监听器 */
|
/**
|
||||||
private GestureDetector.SimpleOnGestureListener mSimpleOnGestureListener =
|
* 手势监听器
|
||||||
new GestureDetector.SimpleOnGestureListener() {
|
*/
|
||||||
@Override
|
private final GestureDetector.SimpleOnGestureListener mSimpleOnGestureListener =
|
||||||
public boolean onDown(MotionEvent e) {
|
new GestureDetector.SimpleOnGestureListener() {
|
||||||
if (hasLrc() && mOnPlayClickListener != null) {
|
@Override
|
||||||
mScroller.forceFinished(true);
|
public boolean onDown(MotionEvent e) {
|
||||||
removeCallbacks(hideTimelineRunnable);
|
if (hasLrc() && mOnPlayClickListener != null) {
|
||||||
isTouching = true;
|
mScroller.forceFinished(true);
|
||||||
isShowTimeline = true;
|
removeCallbacks(hideTimelineRunnable);
|
||||||
invalidate();
|
isTouching = true;
|
||||||
return true;
|
isShowTimeline = true;
|
||||||
|
invalidate();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onDown(e);
|
return super.onDown(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,15 +78,17 @@ public abstract class CustomFragmentStatePagerAdapter extends PagerAdapter {
|
||||||
private final FragmentManager mFragmentManager;
|
private final FragmentManager mFragmentManager;
|
||||||
private FragmentTransaction mCurTransaction = null;
|
private FragmentTransaction mCurTransaction = null;
|
||||||
|
|
||||||
private ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
|
private final ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
|
||||||
private ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
|
private final ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
|
||||||
private Fragment mCurrentPrimaryItem = null;
|
private Fragment mCurrentPrimaryItem = null;
|
||||||
|
|
||||||
public CustomFragmentStatePagerAdapter(FragmentManager fm) {
|
public CustomFragmentStatePagerAdapter(FragmentManager fm) {
|
||||||
mFragmentManager = fm;
|
mFragmentManager = fm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the Fragment associated with a specified position. */
|
/**
|
||||||
|
* Return the Fragment associated with a specified position.
|
||||||
|
*/
|
||||||
public abstract Fragment getItem(int position);
|
public abstract Fragment getItem(int position);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class UpdateToastMediaScannerCompletionListener
|
||||||
private final List<String> toBeScanned;
|
private final List<String> toBeScanned;
|
||||||
private int failed = 0;
|
private int failed = 0;
|
||||||
private int scanned = 0;
|
private int scanned = 0;
|
||||||
private Toast toast;
|
private final Toast toast;
|
||||||
|
|
||||||
@SuppressLint("ShowToast")
|
@SuppressLint("ShowToast")
|
||||||
public UpdateToastMediaScannerCompletionListener(Activity activity, List<String> toBeScanned) {
|
public UpdateToastMediaScannerCompletionListener(Activity activity, List<String> toBeScanned) {
|
||||||
|
|
|
@ -30,9 +30,6 @@ data class Artist(
|
||||||
}
|
}
|
||||||
|
|
||||||
var name: String = ""
|
var name: String = ""
|
||||||
set(value) {
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
get() {
|
get() {
|
||||||
val name = if (isAlbumArtist) getAlbumArtistName()
|
val name = if (isAlbumArtist) getAlbumArtistName()
|
||||||
else getArtistName()
|
else getArtistName()
|
||||||
|
|
|
@ -112,7 +112,8 @@ public class LastFmAlbum {
|
||||||
|
|
||||||
public class Tags {
|
public class Tags {
|
||||||
|
|
||||||
@Expose private List<Tag> tag = null;
|
@Expose
|
||||||
|
private final List<Tag> tag = null;
|
||||||
|
|
||||||
public List<Tag> getTag() {
|
public List<Tag> getTag() {
|
||||||
return tag;
|
return tag;
|
||||||
|
|
|
@ -84,7 +84,8 @@ public class LastFmTrack {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Toptags {
|
public static class Toptags {
|
||||||
@Expose private List<Tag> tag = null;
|
@Expose
|
||||||
|
private final List<Tag> tag = null;
|
||||||
|
|
||||||
public List<Tag> getTag() {
|
public List<Tag> getTag() {
|
||||||
return tag;
|
return tag;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class BlacklistStore extends SQLiteOpenHelper {
|
||||||
public static final String DATABASE_NAME = "blacklist.db";
|
public static final String DATABASE_NAME = "blacklist.db";
|
||||||
private static final int VERSION = 2;
|
private static final int VERSION = 2;
|
||||||
private static BlacklistStore sInstance = null;
|
private static BlacklistStore sInstance = null;
|
||||||
private Context context;
|
private final Context context;
|
||||||
|
|
||||||
public BlacklistStore(final Context context) {
|
public BlacklistStore(final Context context) {
|
||||||
super(context, DATABASE_NAME, null, VERSION);
|
super(context, DATABASE_NAME, null, VERSION);
|
||||||
|
|
|
@ -34,24 +34,27 @@ public class SongPlayCountStore extends SQLiteOpenHelper {
|
||||||
private static final int VERSION = 3;
|
private static final int VERSION = 3;
|
||||||
// how many weeks worth of playback to track
|
// how many weeks worth of playback to track
|
||||||
private static final int NUM_WEEKS = 52;
|
private static final int NUM_WEEKS = 52;
|
||||||
@Nullable private static SongPlayCountStore sInstance = null;
|
@Nullable
|
||||||
|
private static SongPlayCountStore sInstance = null;
|
||||||
// interpolator curve applied for measuring the curve
|
// interpolator curve applied for measuring the curve
|
||||||
@NonNull private static Interpolator sInterpolator = new AccelerateInterpolator(1.5f);
|
@NonNull
|
||||||
|
private static final Interpolator sInterpolator = new AccelerateInterpolator(1.5f);
|
||||||
// how high to multiply the interpolation curve
|
// how high to multiply the interpolation curve
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
private static int INTERPOLATOR_HEIGHT = 50;
|
private static final int INTERPOLATOR_HEIGHT = 50;
|
||||||
|
|
||||||
// how high the base value is. The ratio of the Height to Base is what really matters
|
// how high the base value is. The ratio of the Height to Base is what really matters
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
private static int INTERPOLATOR_BASE = 25;
|
private static final int INTERPOLATOR_BASE = 25;
|
||||||
|
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
private static int ONE_WEEK_IN_MS = 1000 * 60 * 60 * 24 * 7;
|
private static final int ONE_WEEK_IN_MS = 1000 * 60 * 60 * 24 * 7;
|
||||||
|
|
||||||
@NonNull private static String WHERE_ID_EQUALS = SongPlayCountColumns.ID + "=?";
|
@NonNull
|
||||||
|
private static final String WHERE_ID_EQUALS = SongPlayCountColumns.ID + "=?";
|
||||||
|
|
||||||
// number of weeks since epoch time
|
// number of weeks since epoch time
|
||||||
private int mNumberOfWeeksSinceEpoch;
|
private final int mNumberOfWeeksSinceEpoch;
|
||||||
|
|
||||||
// used to track if we've walked through the db and updated all the rows
|
// used to track if we've walked through the db and updated all the rows
|
||||||
private boolean mDatabaseUpdated;
|
private boolean mDatabaseUpdated;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class SortedCursor extends AbstractCursor {
|
||||||
// the map of external indices to internal indices
|
// the map of external indices to internal indices
|
||||||
private ArrayList<Integer> mOrderedPositions;
|
private ArrayList<Integer> mOrderedPositions;
|
||||||
// this contains the ids that weren't found in the underlying cursor
|
// this contains the ids that weren't found in the underlying cursor
|
||||||
private ArrayList<String> mMissingValues;
|
private final ArrayList<String> mMissingValues;
|
||||||
// this contains the mapped cursor positions and afterwards the extra ids that weren't found
|
// this contains the mapped cursor positions and afterwards the extra ids that weren't found
|
||||||
private HashMap<String, Integer> mMapCursorPositions;
|
private HashMap<String, Integer> mMapCursorPositions;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class SortedLongCursor extends AbstractCursor {
|
||||||
// the map of external indices to internal indices
|
// the map of external indices to internal indices
|
||||||
private ArrayList<Integer> mOrderedPositions;
|
private ArrayList<Integer> mOrderedPositions;
|
||||||
// this contains the ids that weren't found in the underlying cursor
|
// this contains the ids that weren't found in the underlying cursor
|
||||||
private ArrayList<Long> mMissingIds;
|
private final ArrayList<Long> mMissingIds;
|
||||||
// this contains the mapped cursor positions and afterwards the extra ids that weren't found
|
// this contains the mapped cursor positions and afterwards the extra ids that weren't found
|
||||||
private HashMap<Long, Integer> mMapCursorPositions;
|
private HashMap<Long, Integer> mMapCursorPositions;
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,9 @@ public class MultiPlayer
|
||||||
private MediaPlayer mCurrentMediaPlayer = new MediaPlayer();
|
private MediaPlayer mCurrentMediaPlayer = new MediaPlayer();
|
||||||
private MediaPlayer mNextMediaPlayer;
|
private MediaPlayer mNextMediaPlayer;
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
@Nullable private Playback.PlaybackCallbacks callbacks;
|
@Nullable
|
||||||
|
private Playback.PlaybackCallbacks callbacks;
|
||||||
|
|
||||||
private boolean mIsInitialized = false;
|
private boolean mIsInitialized = false;
|
||||||
|
|
||||||
|
|
|
@ -187,15 +187,15 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
|
|
||||||
public int position = -1;
|
public int position = -1;
|
||||||
|
|
||||||
private AppWidgetBig appWidgetBig = AppWidgetBig.Companion.getInstance();
|
private final AppWidgetBig appWidgetBig = AppWidgetBig.Companion.getInstance();
|
||||||
|
|
||||||
private AppWidgetCard appWidgetCard = AppWidgetCard.Companion.getInstance();
|
private final AppWidgetCard appWidgetCard = AppWidgetCard.Companion.getInstance();
|
||||||
|
|
||||||
private AppWidgetClassic appWidgetClassic = AppWidgetClassic.Companion.getInstance();
|
private final AppWidgetClassic appWidgetClassic = AppWidgetClassic.Companion.getInstance();
|
||||||
|
|
||||||
private AppWidgetSmall appWidgetSmall = AppWidgetSmall.Companion.getInstance();
|
private final AppWidgetSmall appWidgetSmall = AppWidgetSmall.Companion.getInstance();
|
||||||
|
|
||||||
private AppWidgetText appWidgetText = AppWidgetText.Companion.getInstance();
|
private final AppWidgetText appWidgetText = AppWidgetText.Companion.getInstance();
|
||||||
|
|
||||||
private final BroadcastReceiver widgetIntentReceiver =
|
private final BroadcastReceiver widgetIntentReceiver =
|
||||||
new BroadcastReceiver() {
|
new BroadcastReceiver() {
|
||||||
|
@ -229,15 +229,15 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private AudioManager audioManager;
|
private AudioManager audioManager;
|
||||||
private IntentFilter becomingNoisyReceiverIntentFilter =
|
private final IntentFilter becomingNoisyReceiverIntentFilter =
|
||||||
new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
|
new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
|
||||||
private boolean becomingNoisyReceiverRegistered;
|
private boolean becomingNoisyReceiverRegistered;
|
||||||
private IntentFilter bluetoothConnectedIntentFilter =
|
private final IntentFilter bluetoothConnectedIntentFilter =
|
||||||
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
|
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||||
private boolean bluetoothConnectedRegistered = false;
|
private boolean bluetoothConnectedRegistered = false;
|
||||||
private IntentFilter headsetReceiverIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
|
private final IntentFilter headsetReceiverIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
|
||||||
private boolean headsetReceiverRegistered = false;
|
private boolean headsetReceiverRegistered = false;
|
||||||
private MediaSessionCompat mediaSession;
|
private MediaSessionCompat mediaSession;
|
||||||
private ContentObserver mediaStoreObserver;
|
private ContentObserver mediaStoreObserver;
|
||||||
private HandlerThread musicPlayerHandlerThread;
|
private HandlerThread musicPlayerHandlerThread;
|
||||||
|
@ -291,59 +291,59 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
private HandlerThread queueSaveHandlerThread;
|
private HandlerThread queueSaveHandlerThread;
|
||||||
private boolean queuesRestored;
|
private boolean queuesRestored;
|
||||||
private int repeatMode;
|
private int repeatMode;
|
||||||
private int shuffleMode;
|
private int shuffleMode;
|
||||||
private SongPlayCountHelper songPlayCountHelper = new SongPlayCountHelper();
|
private final SongPlayCountHelper songPlayCountHelper = new SongPlayCountHelper();
|
||||||
private final BroadcastReceiver bluetoothReceiver =
|
private final BroadcastReceiver bluetoothReceiver =
|
||||||
new BroadcastReceiver() {
|
new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(final Context context, final Intent intent) {
|
public void onReceive(final Context context, final Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)
|
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)
|
||||||
&& PreferenceUtil.INSTANCE.isBluetoothSpeaker()) {
|
&& PreferenceUtil.INSTANCE.isBluetoothSpeaker()) {
|
||||||
if (VERSION.SDK_INT >= VERSION_CODES.M) {
|
if (VERSION.SDK_INT >= VERSION_CODES.M) {
|
||||||
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
|
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
|
||||||
play();
|
play();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (getAudioManager().isBluetoothA2dpOn()) {
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
};
|
if (getAudioManager().isBluetoothA2dpOn()) {
|
||||||
private PhoneStateListener phoneStateListener =
|
play();
|
||||||
new PhoneStateListener() {
|
|
||||||
@Override
|
|
||||||
public void onCallStateChanged(int state, String incomingNumber) {
|
|
||||||
switch (state) {
|
|
||||||
case TelephonyManager.CALL_STATE_IDLE:
|
|
||||||
// Not in call: Play music
|
|
||||||
play();
|
|
||||||
break;
|
|
||||||
case TelephonyManager.CALL_STATE_RINGING:
|
|
||||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
|
||||||
// A call is dialing, active or on hold
|
|
||||||
pause();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
super.onCallStateChanged(state, incomingNumber);
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
private BroadcastReceiver headsetReceiver =
|
}
|
||||||
new BroadcastReceiver() {
|
};
|
||||||
@Override
|
private final PhoneStateListener phoneStateListener =
|
||||||
public void onReceive(Context context, Intent intent) {
|
new PhoneStateListener() {
|
||||||
String action = intent.getAction();
|
@Override
|
||||||
if (action != null) {
|
public void onCallStateChanged(int state, String incomingNumber) {
|
||||||
if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
|
switch (state) {
|
||||||
int state = intent.getIntExtra("state", -1);
|
case TelephonyManager.CALL_STATE_IDLE:
|
||||||
switch (state) {
|
// Not in call: Play music
|
||||||
case 0:
|
play();
|
||||||
pause();
|
break;
|
||||||
|
case TelephonyManager.CALL_STATE_RINGING:
|
||||||
|
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||||
|
// A call is dialing, active or on hold
|
||||||
|
pause();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
super.onCallStateChanged(state, incomingNumber);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private final BroadcastReceiver headsetReceiver =
|
||||||
|
new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (action != null) {
|
||||||
|
if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
|
||||||
|
int state = intent.getIntExtra("state", -1);
|
||||||
|
switch (state) {
|
||||||
|
case 0:
|
||||||
|
pause();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
play();
|
play();
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class AutoGeneratedPlaylistBitmap {
|
||||||
try {
|
try {
|
||||||
return Glide.with(context)
|
return Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(MusicUtil.INSTANCE.getMediaStoreAlbumCoverUri(id))
|
.load(MusicUtil.getMediaStoreAlbumCoverUri(id))
|
||||||
.submit(200, 200)
|
.submit(200, 200)
|
||||||
.get();
|
.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class CalendarUtil {
|
||||||
private static final long MS_PER_MINUTE = 60 * 1000;
|
private static final long MS_PER_MINUTE = 60 * 1000;
|
||||||
private static final long MS_PER_DAY = 24 * 60 * MS_PER_MINUTE;
|
private static final long MS_PER_DAY = 24 * 60 * MS_PER_MINUTE;
|
||||||
|
|
||||||
private Calendar calendar;
|
private final Calendar calendar;
|
||||||
|
|
||||||
public CalendarUtil() {
|
public CalendarUtil() {
|
||||||
this.calendar = Calendar.getInstance();
|
this.calendar = Calendar.getInstance();
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.xmlpull.v1.XmlPullParserException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.security.NoSuchAlgorithmException
|
import java.security.NoSuchAlgorithmException
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.LinkedHashMap
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates that the calling package is authorized to browse a [MediaBrowserServiceCompat].
|
* Validates that the calling package is authorized to browse a [MediaBrowserServiceCompat].
|
||||||
|
@ -274,7 +276,8 @@ class PackageValidator(
|
||||||
var eventType = parser.next()
|
var eventType = parser.next()
|
||||||
while (eventType != XmlResourceParser.END_TAG) {
|
while (eventType != XmlResourceParser.END_TAG) {
|
||||||
val isRelease = parser.getAttributeBooleanValue(null, "release", false)
|
val isRelease = parser.getAttributeBooleanValue(null, "release", false)
|
||||||
val signature = parser.nextText().replace(WHITESPACE_REGEX, "").toLowerCase()
|
val signature = parser.nextText().replace(WHITESPACE_REGEX, "")
|
||||||
|
.lowercase(Locale.getDefault())
|
||||||
callerSignatures += KnownSignature(signature, isRelease)
|
callerSignatures += KnownSignature(signature, isRelease)
|
||||||
|
|
||||||
eventType = parser.next()
|
eventType = parser.next()
|
||||||
|
@ -319,14 +322,14 @@ class PackageValidator(
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class KnownCallerInfo(
|
private data class KnownCallerInfo(
|
||||||
internal val name: String,
|
val name: String,
|
||||||
internal val packageName: String,
|
val packageName: String,
|
||||||
internal val signatures: MutableSet<KnownSignature>
|
val signatures: MutableSet<KnownSignature>
|
||||||
)
|
)
|
||||||
|
|
||||||
private data class KnownSignature(
|
private data class KnownSignature(
|
||||||
internal val signature: String,
|
val signature: String,
|
||||||
internal val release: Boolean
|
val release: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,11 +337,11 @@ class PackageValidator(
|
||||||
* to see if it's a known caller.
|
* to see if it's a known caller.
|
||||||
*/
|
*/
|
||||||
private data class CallerPackageInfo(
|
private data class CallerPackageInfo(
|
||||||
internal val name: String,
|
val name: String,
|
||||||
internal val packageName: String,
|
val packageName: String,
|
||||||
internal val uid: Int,
|
val uid: Int,
|
||||||
internal val signature: String?,
|
val signature: String?,
|
||||||
internal val permissions: Set<String>
|
val permissions: Set<String>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
||||||
|
|
||||||
private ActionCompletionContract contract;
|
private final ActionCompletionContract contract;
|
||||||
|
|
||||||
public SwipeAndDragHelper(@NonNull ActionCompletionContract contract) {
|
public SwipeAndDragHelper(@NonNull ActionCompletionContract contract) {
|
||||||
this.contract = contract;
|
this.contract = contract;
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class MediaNotificationProcessor {
|
||||||
|
|
||||||
private static final String TAG = "ColorPicking";
|
private static final String TAG = "ColorPicking";
|
||||||
private float[] mFilteredBackgroundHsl = null;
|
private float[] mFilteredBackgroundHsl = null;
|
||||||
private Palette.Filter mBlackWhiteFilter =
|
private final Palette.Filter mBlackWhiteFilter =
|
||||||
(rgb, hsl) -> !isWhiteOrBlack(hsl);
|
(rgb, hsl) -> !isWhiteOrBlack(hsl);
|
||||||
private boolean mIsLowPriority;
|
private boolean mIsLowPriority;
|
||||||
private int backgroundColor;
|
private int backgroundColor;
|
||||||
|
@ -85,7 +85,7 @@ public class MediaNotificationProcessor {
|
||||||
private int primaryTextColor;
|
private int primaryTextColor;
|
||||||
private int actionBarColor;
|
private int actionBarColor;
|
||||||
private Drawable drawable;
|
private Drawable drawable;
|
||||||
private Context context;
|
private final Context context;
|
||||||
|
|
||||||
public MediaNotificationProcessor(Context context, Drawable drawable) {
|
public MediaNotificationProcessor(Context context, Drawable drawable) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
|
@ -38,14 +38,16 @@ import code.name.monkey.retromusic.R;
|
||||||
public class SeekArc extends View {
|
public class SeekArc extends View {
|
||||||
|
|
||||||
private static final String TAG = SeekArc.class.getSimpleName();
|
private static final String TAG = SeekArc.class.getSimpleName();
|
||||||
private static int INVALID_PROGRESS_VALUE = -1;
|
private static final int INVALID_PROGRESS_VALUE = -1;
|
||||||
// The initial rotational offset -90 means we start at 12 o'clock
|
// The initial rotational offset -90 means we start at 12 o'clock
|
||||||
private final int mAngleOffset = -90;
|
private final int mAngleOffset = -90;
|
||||||
private Paint mArcPaint;
|
private Paint mArcPaint;
|
||||||
// Internal variables
|
// Internal variables
|
||||||
private int mArcRadius = 0;
|
private int mArcRadius = 0;
|
||||||
private RectF mArcRect = new RectF();
|
private final RectF mArcRect = new RectF();
|
||||||
/** The Width of the background arc for the SeekArc */
|
/**
|
||||||
|
* The Width of the background arc for the SeekArc
|
||||||
|
*/
|
||||||
private int mArcWidth = 2;
|
private int mArcWidth = 2;
|
||||||
/** Will the progress increase clockwise or anti-clockwise */
|
/** Will the progress increase clockwise or anti-clockwise */
|
||||||
private boolean mClockwise = true;
|
private boolean mClockwise = true;
|
||||||
|
|
Loading…
Reference in a new issue