[Cleanup] Code Cleanup, Removed some unused methods
This commit is contained in:
parent
3df5a77ee8
commit
6ae4c3cae4
32 changed files with 122 additions and 301 deletions
|
@ -37,6 +37,7 @@ object Constants {
|
|||
const val IS_MUSIC =
|
||||
MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"
|
||||
|
||||
@Suppress("Deprecation")
|
||||
val baseProjection = arrayOf(
|
||||
BaseColumns._ID, // 0
|
||||
MediaStore.Audio.AudioColumns.TITLE, // 1
|
||||
|
|
|
@ -82,6 +82,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("Deprecation")
|
||||
private fun lockScreenInit() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(true)
|
||||
|
|
|
@ -172,7 +172,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
|||
v.getGlobalVisibleRect(outRect)
|
||||
if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
|
||||
v.clearFocus()
|
||||
val imm = getSystemService<InputMethodManager>()?.hideSoftInputFromWindow(v.windowToken, 0)
|
||||
getSystemService<InputMethodManager>()?.hideSoftInputFromWindow(v.windowToken, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,16 +137,6 @@ class SearchAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getSongs(playlist: Playlist): List<Song> {
|
||||
val songs = mutableListOf<Song>()
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
songs.addAll(playlist.getSongs())
|
||||
} else {
|
||||
songs.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id))
|
||||
}
|
||||
return songs
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
|
|
@ -28,12 +28,6 @@ fun List<SongEntity>.toSongs(): List<Song> {
|
|||
}
|
||||
}
|
||||
|
||||
fun List<Song>.toSongs(playlistId: Long): List<SongEntity> {
|
||||
return map {
|
||||
it.toSongEntity(playlistId)
|
||||
}
|
||||
}
|
||||
|
||||
fun Song.toHistoryEntity(timePlayed: Long): HistoryEntity {
|
||||
return HistoryEntity(
|
||||
id = id,
|
||||
|
|
|
@ -3,13 +3,9 @@ package code.name.monkey.retromusic.extensions
|
|||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import android.provider.DocumentsContract
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.fragment.app.Fragment
|
||||
import java.io.File
|
||||
import java.io.OutputStream
|
||||
|
||||
fun Fragment.createNewFile(
|
||||
|
|
|
@ -17,9 +17,7 @@ class PlaylistPreviewFetcher(val context: Context, private val playlistPreview:
|
|||
val bitmap =
|
||||
AutoGeneratedPlaylistBitmap.getBitmap(
|
||||
context,
|
||||
playlistPreview.songs.shuffled(),
|
||||
true,
|
||||
false
|
||||
playlistPreview.songs.shuffled()
|
||||
)
|
||||
callback.onDataReady(bitmap)
|
||||
} catch (e: Exception) {
|
||||
|
|
|
@ -92,11 +92,11 @@ public abstract class CustomFragmentStatePagerAdapter extends PagerAdapter {
|
|||
public abstract Fragment getItem(int position);
|
||||
|
||||
@Override
|
||||
public void startUpdate(ViewGroup container) {}
|
||||
public void startUpdate(@NonNull ViewGroup container) {}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||
// If we already have this item instantiated, there is nothing
|
||||
// to do. This can happen when we are restoring the entire pager
|
||||
// from its saved state, where the fragment manager has already
|
||||
|
@ -132,7 +132,7 @@ public abstract class CustomFragmentStatePagerAdapter extends PagerAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||
Fragment fragment = (Fragment) object;
|
||||
|
||||
if (mCurTransaction == null) {
|
||||
|
@ -152,23 +152,21 @@ public abstract class CustomFragmentStatePagerAdapter extends PagerAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
||||
public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||
Fragment fragment = (Fragment) object;
|
||||
if (fragment != mCurrentPrimaryItem) {
|
||||
if (mCurrentPrimaryItem != null) {
|
||||
mCurrentPrimaryItem.setMenuVisibility(false);
|
||||
mCurrentPrimaryItem.setUserVisibleHint(false);
|
||||
}
|
||||
if (fragment != null) {
|
||||
fragment.setMenuVisibility(true);
|
||||
fragment.setUserVisibleHint(true);
|
||||
}
|
||||
fragment.setMenuVisibility(true);
|
||||
fragment.setUserVisibleHint(true);
|
||||
mCurrentPrimaryItem = fragment;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishUpdate(ViewGroup container) {
|
||||
public void finishUpdate(@NonNull ViewGroup container) {
|
||||
if (mCurTransaction != null) {
|
||||
mCurTransaction.commitAllowingStateLoss();
|
||||
mCurTransaction = null;
|
||||
|
@ -177,7 +175,7 @@ public abstract class CustomFragmentStatePagerAdapter extends PagerAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
||||
return ((Fragment) object).getView() == view;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ abstract class WrappedAsyncTaskLoader<D>
|
|||
if (!isReset) {
|
||||
this.mData = data
|
||||
super.deliverResult(data)
|
||||
} else {
|
||||
// An asynchronous query came in while the loader is stopped
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.LockScreenActivity;
|
||||
import code.name.monkey.retromusic.appwidgets.AppWidgetBig;
|
||||
|
@ -1155,7 +1156,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
playback.setNextDataSource(getTrackUri(Objects.requireNonNull(getSongAt(nextPosition))));
|
||||
}
|
||||
this.nextPosition = nextPosition;
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1591,11 +1592,8 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
mediaButtonIntent.setComponent(mediaButtonReceiverComponentName);
|
||||
|
||||
PendingIntent mediaButtonReceiverPendingIntent;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, PendingIntent.FLAG_MUTABLE);
|
||||
} else {
|
||||
mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
|
||||
}
|
||||
mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent,
|
||||
VersionUtils.INSTANCE.hasMarshmallow() ? PendingIntent.FLAG_IMMUTABLE : 0);
|
||||
|
||||
mediaSession = new MediaSessionCompat(
|
||||
this,
|
||||
|
@ -1604,9 +1602,6 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
mediaButtonReceiverPendingIntent);
|
||||
MediaSessionCallback mediasessionCallback =
|
||||
new MediaSessionCallback(getApplicationContext(), this);
|
||||
mediaSession.setFlags(
|
||||
MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS
|
||||
| MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
|
||||
mediaSession.setCallback(mediasessionCallback);
|
||||
mediaSession.setActive(true);
|
||||
mediaSession.setMediaButtonReceiver(mediaButtonReceiverPendingIntent);
|
||||
|
|
|
@ -70,15 +70,11 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent {
|
|||
action.putExtra(MainActivity.EXPAND_PANEL, PreferenceUtil.isExpandPanel)
|
||||
action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
val clickIntent =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
PendingIntent.getActivity(
|
||||
PendingIntent.getActivity(
|
||||
service, 0, action, if (VersionUtils.hasMarshmallow())
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
else 0
|
||||
else 0 or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
}
|
||||
|
||||
val serviceName = ComponentName(service, MusicService::class.java)
|
||||
val intent = Intent(ACTION_QUIT)
|
||||
|
|
|
@ -31,21 +31,23 @@ class HorizontalFlipTransformation : ViewPager.PageTransformer {
|
|||
}
|
||||
|
||||
|
||||
if (position < -1) { // [-Infinity,-1)
|
||||
// This page is way off-screen to the left.
|
||||
page.alpha = 0f
|
||||
|
||||
} else if (position <= 0) { // [-1,0]
|
||||
page.alpha = 1f
|
||||
page.rotationX = 180 * (1 - abs(position) + 1)
|
||||
|
||||
} else if (position <= 1) { // (0,1]
|
||||
page.alpha = 1f
|
||||
page.rotationX = -180 * (1 - abs(position) + 1)
|
||||
|
||||
} else { // (1,+Infinity]
|
||||
// This page is way off-screen to the right.
|
||||
page.alpha = 0f
|
||||
when {
|
||||
position < -1 -> { // [-Infinity,-1)
|
||||
// This page is way off-screen to the left.
|
||||
page.alpha = 0f
|
||||
}
|
||||
position <= 0 -> { // [-1,0]
|
||||
page.alpha = 1f
|
||||
page.rotationX = 180 * (1 - abs(position) + 1)
|
||||
}
|
||||
position <= 1 -> { // (0,1]
|
||||
page.alpha = 1f
|
||||
page.rotationX = -180 * (1 - abs(position) + 1)
|
||||
}
|
||||
else -> { // (1,+Infinity]
|
||||
// This page is way off-screen to the right.
|
||||
page.alpha = 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,32 +29,36 @@ class NormalPageTransformer : ViewPager.PageTransformer {
|
|||
val pageWidth = view.width
|
||||
val pageHeight = view.height
|
||||
|
||||
if (position < -1) { // [-Infinity,-1)
|
||||
// This page is way off-screen to the left.
|
||||
view.alpha = 1f
|
||||
view.scaleY = 0.7f
|
||||
} else if (position <= 1) { // [-1,1]
|
||||
// Modify the default slide transition to shrink the page as well
|
||||
val scaleFactor = max(MIN_SCALE, 1 - abs(position))
|
||||
val vertMargin = pageHeight * (1 - scaleFactor) / 2
|
||||
val horzMargin = pageWidth * (1 - scaleFactor) / 2
|
||||
if (position < 0) {
|
||||
view.translationX = horzMargin - vertMargin / 2
|
||||
} else {
|
||||
view.translationX = -horzMargin + vertMargin / 2
|
||||
when {
|
||||
position < -1 -> { // [-Infinity,-1)
|
||||
// This page is way off-screen to the left.
|
||||
view.alpha = 1f
|
||||
view.scaleY = 0.7f
|
||||
}
|
||||
position <= 1 -> { // [-1,1]
|
||||
// Modify the default slide transition to shrink the page as well
|
||||
val scaleFactor = max(MIN_SCALE, 1 - abs(position))
|
||||
val vertMargin = pageHeight * (1 - scaleFactor) / 2
|
||||
val horzMargin = pageWidth * (1 - scaleFactor) / 2
|
||||
if (position < 0) {
|
||||
view.translationX = horzMargin - vertMargin / 2
|
||||
} else {
|
||||
view.translationX = -horzMargin + vertMargin / 2
|
||||
}
|
||||
|
||||
// Scale the page down (between MIN_SCALE and 1)
|
||||
view.scaleX = scaleFactor
|
||||
view.scaleY = scaleFactor
|
||||
// Scale the page down (between MIN_SCALE and 1)
|
||||
view.scaleX = scaleFactor
|
||||
view.scaleY = scaleFactor
|
||||
|
||||
// Fade the page relative to its size.
|
||||
//view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
|
||||
// Fade the page relative to its size.
|
||||
//view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
|
||||
|
||||
} else { // (1,+Infinity]
|
||||
// This page is way off-screen to the right.
|
||||
view.alpha = 1f
|
||||
view.scaleY = 0.7f
|
||||
}
|
||||
else -> { // (1,+Infinity]
|
||||
// This page is way off-screen to the right.
|
||||
view.alpha = 1f
|
||||
view.scaleY = 0.7f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,22 +31,24 @@ class VerticalFlipTransformation : ViewPager.PageTransformer {
|
|||
}
|
||||
|
||||
|
||||
if (position < -1) { // [-Infinity,-1)
|
||||
// This page is way off-screen to the left.
|
||||
page.alpha = 0f
|
||||
|
||||
} else if (position <= 0) { // [-1,0]
|
||||
page.alpha = 1f
|
||||
page.rotationY = 180 * (1 - abs(position) + 1)
|
||||
|
||||
} else if (position <= 1) { // (0,1]
|
||||
page.alpha = 1f
|
||||
page.rotationY = -180 * (1 - abs(position) + 1)
|
||||
|
||||
} else { // (1,+Infinity]
|
||||
// This page is way off-screen to the right.
|
||||
page.alpha = 0f
|
||||
when {
|
||||
position < -1 -> { // [-Infinity,-1)
|
||||
// This page is way off-screen to the left.
|
||||
page.alpha = 0f
|
||||
}
|
||||
position <= 0 -> { // [-1,0]
|
||||
page.alpha = 1f
|
||||
page.rotationY = 180 * (1 - abs(position) + 1)
|
||||
}
|
||||
position <= 1 -> { // (0,1]
|
||||
page.alpha = 1f
|
||||
page.rotationY = -180 * (1 - abs(position) + 1)
|
||||
}
|
||||
else -> { // (1,+Infinity]
|
||||
// This page is way off-screen to the right.
|
||||
page.alpha = 0f
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -79,26 +79,4 @@ object AppRater {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showRateDialog(context: Context, editor: SharedPreferences.Editor) {
|
||||
MaterialAlertDialogBuilder(context)
|
||||
.setTitle("Rate this App")
|
||||
.setMessage("If you enjoy using Retro Music, please take a moment to rate it. Thanks for your support!")
|
||||
.setPositiveButton(R.string.app_name) { _, _ ->
|
||||
context.startActivity(
|
||||
Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("market://details?id=${context.packageName}")
|
||||
)
|
||||
)
|
||||
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||
editor.commit()
|
||||
}
|
||||
.setNeutralButton("Not now", null)
|
||||
.setNegativeButton("No thanks") { _, _ ->
|
||||
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||
editor.commit()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
}
|
|
@ -3,11 +3,6 @@ package code.name.monkey.retromusic.util;
|
|||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
@ -20,19 +15,12 @@ import code.name.monkey.retromusic.R;
|
|||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
public class AutoGeneratedPlaylistBitmap {
|
||||
private static final String TAG = "AutoGeneratedPB";
|
||||
|
||||
/*
|
||||
public static Bitmap getBitmapWithCollectionFrame(Context context, List<Song> songPlaylist, boolean round, boolean blur) {
|
||||
Bitmap bitmap = getBitmap(context,songPlaylist,round,blur);
|
||||
int w = bitmap.getWidth();
|
||||
Bitmap ret = Bitmap.createBitmap(w,w,Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
*/
|
||||
public static Bitmap getBitmap(
|
||||
Context context, List<Song> songPlaylist, boolean round, boolean blur) {
|
||||
if (songPlaylist == null || songPlaylist.isEmpty()) return getDefaultBitmap(context, round);
|
||||
if (songPlaylist.size() == 1) return getBitmapWithAlbumId(context, songPlaylist.get(0).getAlbumId());
|
||||
Context context, List<Song> songPlaylist) {
|
||||
if (songPlaylist == null || songPlaylist.isEmpty()) return getDefaultBitmap(context);
|
||||
if (songPlaylist.size() == 1)
|
||||
return getBitmapWithAlbumId(context, songPlaylist.get(0).getAlbumId());
|
||||
List<Long> albumID = new ArrayList<>();
|
||||
for (Song song : songPlaylist) {
|
||||
if (!albumID.contains(song.getAlbumId())) albumID.add(song.getAlbumId());
|
||||
|
@ -46,102 +34,6 @@ public class AutoGeneratedPlaylistBitmap {
|
|||
return MergedImageUtils.INSTANCE.joinImages(art);
|
||||
}
|
||||
|
||||
private static Bitmap getBitmapCollection(ArrayList<Bitmap> art, boolean round) {
|
||||
long start = System.currentTimeMillis();
|
||||
// lấy kích thước là kích thước của bitmap lớn nhất
|
||||
int max_width = art.get(0).getWidth();
|
||||
for (Bitmap b : art) if (max_width < b.getWidth()) max_width = b.getWidth();
|
||||
Bitmap bitmap = Bitmap.createBitmap(max_width, max_width, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(false);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(max_width / 100);
|
||||
paint.setColor(0xffffffff);
|
||||
switch (art.size()) {
|
||||
case 2:
|
||||
canvas.drawBitmap(art.get(1), null, new Rect(0, 0, max_width, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(0), null, new Rect(-max_width / 2, 0, max_width / 2, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
break;
|
||||
case 3:
|
||||
canvas.drawBitmap(
|
||||
art.get(0), null, new Rect(-max_width / 4, 0, 3 * max_width / 4, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(1), null, new Rect(max_width / 2, 0, max_width, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(2), null, new Rect(max_width / 2, max_width / 2, max_width, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
canvas.drawLine(max_width / 2, max_width / 2, max_width, max_width / 2, paint);
|
||||
break;
|
||||
case 4:
|
||||
canvas.drawBitmap(art.get(0), null, new Rect(0, 0, max_width / 2, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(1), null, new Rect(max_width / 2, 0, max_width, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(2), null, new Rect(0, max_width / 2, max_width / 2, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(3), null, new Rect(max_width / 2, max_width / 2, max_width, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
canvas.drawLine(0, max_width / 2, max_width, max_width / 2, paint);
|
||||
break;
|
||||
// default: canvas.drawBitmap(art.get(0),null,new Rect(0,0,max_width,max_width),null);
|
||||
default:
|
||||
|
||||
// độ rộng của des bitmap
|
||||
float w = (float) (Math.sqrt(2) / 2 * max_width);
|
||||
float b = (float) (max_width / Math.sqrt(5));
|
||||
// khoảng cách định nghĩa, dùng để tính vị trí tâm của 4 bức hình xung quanh
|
||||
float d = (float) (max_width * (0.5f - 1 / Math.sqrt(10)));
|
||||
float deg = 45;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
canvas.save();
|
||||
switch (i) {
|
||||
case 0:
|
||||
canvas.translate(max_width / 2, max_width / 2);
|
||||
canvas.rotate(deg);
|
||||
// b = (float) (max_width*Math.sqrt(2/5f));
|
||||
canvas.drawBitmap(art.get(0), null, new RectF(-b / 2, -b / 2, b / 2, b / 2), null);
|
||||
break;
|
||||
case 1:
|
||||
canvas.translate(d, 0);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(w / 2, -w / 2, w / 2, w / 2, paint);
|
||||
break;
|
||||
case 2:
|
||||
canvas.translate(max_width, d);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, w / 2, w / 2, w / 2, paint);
|
||||
break;
|
||||
case 3:
|
||||
canvas.translate(max_width - d, max_width);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, -w / 2, -w / 2, w / 2, paint);
|
||||
break;
|
||||
case 4:
|
||||
canvas.translate(0, max_width - d);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, -w / 2, w / 2, -w / 2, paint);
|
||||
break;
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "getBitmapCollection: smalltime = " + (System.currentTimeMillis() - start));
|
||||
if (round) return BitmapEditor.getRoundedCornerBitmap(bitmap, bitmap.getWidth() / 40);
|
||||
else return bitmap;
|
||||
}
|
||||
|
||||
private static Bitmap getBitmapWithAlbumId(@NonNull Context context, Long id) {
|
||||
try {
|
||||
return Glide.with(context)
|
||||
|
@ -154,7 +46,7 @@ public class AutoGeneratedPlaylistBitmap {
|
|||
}
|
||||
}
|
||||
|
||||
public static Bitmap getDefaultBitmap(@NonNull Context context, boolean round) {
|
||||
public static Bitmap getDefaultBitmap(@NonNull Context context) {
|
||||
return BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -594,7 +594,7 @@ public final class BitmapEditor {
|
|||
/**
|
||||
* getResizedBitmap method is used to Resized the Image according to custom width and height
|
||||
*
|
||||
* @param image
|
||||
* @param image image to be resized
|
||||
* @param newHeight (new desired height)
|
||||
* @param newWidth (new desired Width)
|
||||
* @return image (new resized image)
|
||||
|
@ -609,22 +609,21 @@ public final class BitmapEditor {
|
|||
// onTap the bit map
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
// recreate the new Bitmap
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(image, 0, 0, width, height, matrix, false);
|
||||
return resizedBitmap;
|
||||
return Bitmap.createBitmap(image, 0, 0, width, height, matrix, false);
|
||||
}
|
||||
|
||||
public static boolean TrueIfBitmapBigger(Bitmap bitmap, int size) {
|
||||
int sizeBitmap =
|
||||
(bitmap.getHeight() > bitmap.getWidth()) ? bitmap.getHeight() : bitmap.getWidth();
|
||||
Math.max(bitmap.getHeight(), bitmap.getWidth());
|
||||
return sizeBitmap > size;
|
||||
}
|
||||
|
||||
public static Bitmap GetRoundedBitmapWithBlurShadow(
|
||||
public static Bitmap getRoundedBitmapWithBlurShadow(
|
||||
Bitmap original, int paddingTop, int paddingBottom, int paddingLeft, int paddingRight) {
|
||||
int original_width = original.getWidth();
|
||||
int orginal_height = original.getHeight();
|
||||
int original_height = original.getHeight();
|
||||
int bitmap_width = original_width + paddingLeft + paddingRight;
|
||||
int bitmap_height = orginal_height + paddingTop + paddingBottom;
|
||||
int bitmap_height = original_height + paddingTop + paddingBottom;
|
||||
Bitmap bitmap = Bitmap.createBitmap(bitmap_width, bitmap_height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
|
|
|
@ -25,13 +25,11 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
|
|
@ -191,6 +191,7 @@ class PackageValidator(
|
|||
*
|
||||
* @return [PackageInfo] for the package name or null if it's not found.
|
||||
*/
|
||||
@Suppress("Deprecation")
|
||||
@SuppressLint("PackageManagerGetSignatures")
|
||||
private fun getPackageInfo(callingPackage: String): PackageInfo? =
|
||||
packageManager.getPackageInfo(callingPackage,
|
||||
|
|
|
@ -166,8 +166,8 @@ public class PlaylistsUtil {
|
|||
Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
} catch (SecurityException ignored) {
|
||||
ignored.printStackTrace();
|
||||
} catch (SecurityException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,13 +234,13 @@ public class PlaylistsUtil {
|
|||
for (int i = 0; i < selectionArgs.length; i++) {
|
||||
selectionArgs[i] = String.valueOf(songs.get(i).getIdInPlayList());
|
||||
}
|
||||
String selection = MediaStore.Audio.Playlists.Members._ID + " in (";
|
||||
//noinspection unused
|
||||
for (String selectionArg : selectionArgs) selection += "?, ";
|
||||
selection = selection.substring(0, selection.length() - 2) + ")";
|
||||
StringBuilder selection = new StringBuilder(MediaStore.Audio.Playlists.Members._ID + " in (");
|
||||
|
||||
for (String selectionArg : selectionArgs) selection.append("?, ");
|
||||
selection = new StringBuilder(selection.substring(0, selection.length() - 2) + ")");
|
||||
|
||||
try {
|
||||
context.getContentResolver().delete(uri, selection, selectionArgs);
|
||||
context.getContentResolver().delete(uri, selection.toString(), selectionArgs);
|
||||
} catch (SecurityException ignored) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RetroColorUtil {
|
|||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
|
||||
hsv[1] = (hsv[1] / 1 * ratio) + (0.2f * (1.0f - ratio));
|
||||
hsv[1] = (hsv[1] * ratio) + (0.2f * (1.0f - ratio));
|
||||
|
||||
return Color.HSVToColor(hsv);
|
||||
}
|
||||
|
|
|
@ -29,22 +29,22 @@ public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
|
||||
return makeMovementFlags(dragFlags, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMove(
|
||||
RecyclerView recyclerView,
|
||||
RecyclerView.ViewHolder viewHolder,
|
||||
RecyclerView.ViewHolder target) {
|
||||
@NonNull RecyclerView recyclerView,
|
||||
RecyclerView.ViewHolder viewHolder,
|
||||
RecyclerView.ViewHolder target) {
|
||||
contract.onViewMoved(viewHolder.getLayoutPosition(), target.getLayoutPosition());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {}
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {}
|
||||
|
||||
@Override
|
||||
public boolean isLongPressDragEnabled() {
|
||||
|
@ -53,13 +53,13 @@ public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
|||
|
||||
@Override
|
||||
public void onChildDraw(
|
||||
Canvas c,
|
||||
RecyclerView recyclerView,
|
||||
RecyclerView.ViewHolder viewHolder,
|
||||
float dX,
|
||||
float dY,
|
||||
int actionState,
|
||||
boolean isCurrentlyActive) {
|
||||
@NonNull Canvas c,
|
||||
@NonNull RecyclerView recyclerView,
|
||||
@NonNull RecyclerView.ViewHolder viewHolder,
|
||||
float dX,
|
||||
float dY,
|
||||
int actionState,
|
||||
boolean isCurrentlyActive) {
|
||||
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
|
||||
float alpha = 1 - (Math.abs(dX) / recyclerView.getWidth());
|
||||
viewHolder.itemView.setAlpha(alpha);
|
||||
|
|
|
@ -76,11 +76,6 @@ object ViewUtil {
|
|||
)
|
||||
}
|
||||
|
||||
fun setProgressDrawable(indicator: CircularProgressIndicator, newColor: Int) {
|
||||
indicator.setIndicatorColor(newColor)
|
||||
indicator.trackColor = ColorUtil.withAlpha(newColor, 0.2f)
|
||||
}
|
||||
|
||||
fun hitTest(v: View, x: Int, y: Int): Boolean {
|
||||
val tx = (v.translationX + 0.5f).toInt()
|
||||
val ty = (v.translationY + 0.5f).toInt()
|
||||
|
|
|
@ -353,11 +353,7 @@ public class NotificationColorUtil {
|
|||
|
||||
public static int resolvePrimaryColor(Context context, int backgroundColor) {
|
||||
boolean useDark = shouldUseDark(backgroundColor);
|
||||
if (useDark) {
|
||||
return ContextCompat.getColor(context, android.R.color.primary_text_light);
|
||||
} else {
|
||||
return ContextCompat.getColor(context, android.R.color.primary_text_light);
|
||||
}
|
||||
return ContextCompat.getColor(context, android.R.color.primary_text_light);
|
||||
}
|
||||
|
||||
public static int resolveSecondaryColor(Context context, int backgroundColor) {
|
||||
|
|
|
@ -399,6 +399,7 @@ public class BreadCrumbLayout extends HorizontalScrollView implements View.OnCli
|
|||
return file.getPath().equals("/") ? "root" : file.getName();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Crumb{" + "file=" + file + ", scrollPos=" + scrollPos + '}';
|
||||
|
|
|
@ -31,8 +31,6 @@ class RetroShapeableImageView @JvmOverloads constructor(
|
|||
init {
|
||||
val typedArray =
|
||||
context.obtainStyledAttributes(attrs, R.styleable.RetroShapeableImageView, defStyle, -1)
|
||||
val cornerSize = typedArray.getDimension(R.styleable.RetroShapeableImageView_retroCornerSize, 0f)
|
||||
val circleShape = typedArray.getBoolean(R.styleable.RetroShapeableImageView_circleShape, false)
|
||||
addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
|
||||
val radius = width / 2f
|
||||
shapeAppearanceModel = ShapeAppearanceModel().withCornerSize(radius)
|
||||
|
|
|
@ -452,8 +452,8 @@ public class SeekArc extends View {
|
|||
return;
|
||||
}
|
||||
|
||||
progress = (progress > mMax) ? mMax : progress;
|
||||
progress = (progress < 0) ? 0 : progress;
|
||||
progress = Math.min(progress, mMax);
|
||||
progress = Math.max(progress, 0);
|
||||
mProgress = progress;
|
||||
|
||||
if (mOnSeekArcChangeListener != null) {
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.FrameLayout;
|
||||
|
|
|
@ -17,20 +17,11 @@ import android.content.Context
|
|||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
|
||||
class WidthFitSquareLayout : FrameLayout {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(
|
||||
context: Context, attrs: AttributeSet?,
|
||||
defStyleAttr: Int
|
||||
) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(
|
||||
context: Context, attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
class WidthFitSquareLayout @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = -1
|
||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec)
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_begin="@dimen/list_pref_guideline_begin" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.BorderCircleView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<code.name.monkey.appthemehelper.common.prefs.BorderCircleView
|
||||
android:id="@+id/circle"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
|
|
|
@ -4,8 +4,6 @@ import android.content.res.ColorStateList
|
|||
import androidx.annotation.ColorInt
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
|
||||
import java.lang.reflect.Field
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
|
|
|
@ -244,14 +244,14 @@ public final class ToolbarContentTintHelper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
|
||||
public void onCloseMenu(@NonNull MenuBuilder menu, boolean allMenusAreClosing) {
|
||||
if (mParentCb != null) {
|
||||
mParentCb.onCloseMenu(menu, allMenusAreClosing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOpenSubMenu(MenuBuilder subMenu) {
|
||||
public boolean onOpenSubMenu(@NonNull MenuBuilder subMenu) {
|
||||
InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor);
|
||||
return mParentCb != null && mParentCb.onOpenSubMenu(subMenu);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue