Separated attrs

main
h4h13 2019-12-27 00:08:19 +05:30
parent fac9d00f47
commit ccad96dd41
12 changed files with 137 additions and 85 deletions

View File

@ -177,8 +177,16 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
}
private fun loadAlbumCover() {
/* Glide.with(this).load(RetroUtil.getAlbumArtUri(album.id)).placeholder(R.drawable.default_album_art)
.error(R.drawable.default_album_art)
.dontTransform()
.dontAnimate().into(image)*/
SongGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong())
.checkIgnoreMediaStore(this).generatePalette(this).build().dontAnimate().dontTransform()
.checkIgnoreMediaStore(this)
.ignoreMediaStore(PreferenceUtil.getInstance(this).ignoreMediaStoreArtwork())
.generatePalette(this)
.build().dontAnimate().dontTransform()
.into(object : RetroMusicColoredTarget(image) {
override fun onColorReady(color: Int) {
setColors(color)

View File

@ -41,15 +41,16 @@ import code.name.monkey.retromusic.util.PreferenceUtil;
*/
public class SongGlideRequest {
public static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
public static final int DEFAULT_ERROR_IMAGE = R.drawable.default_album_art;
public static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_album_art;
private static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
public static class Builder {
final RequestManager requestManager;
final Song song;
boolean ignoreMediaStore;
@NonNull
public static Builder from(@NonNull RequestManager requestManager, Song song) {
return new Builder(requestManager, song);
}
@ -59,23 +60,28 @@ public class SongGlideRequest {
this.song = song;
}
public PaletteBuilder generatePalette(Context context) {
@NonNull
public PaletteBuilder generatePalette(@NonNull Context context) {
return new PaletteBuilder(this, context);
}
@NonNull
public BitmapBuilder asBitmap() {
return new BitmapBuilder(this);
}
public Builder checkIgnoreMediaStore(Context context) {
@NonNull
public Builder checkIgnoreMediaStore(@NonNull Context context) {
return ignoreMediaStore(PreferenceUtil.getInstance(context).ignoreMediaStoreArtwork());
}
@NonNull
public Builder ignoreMediaStore(boolean ignoreMediaStore) {
this.ignoreMediaStore = ignoreMediaStore;
return this;
}
@NonNull
public DrawableRequestBuilder<GlideDrawable> build() {
//noinspection unchecked
return createBaseRequest(requestManager, song, ignoreMediaStore)
@ -125,7 +131,10 @@ public class SongGlideRequest {
}
}
public static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Song song, boolean ignoreMediaStore) {
@NonNull
private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
@NonNull Song song,
boolean ignoreMediaStore) {
if (ignoreMediaStore) {
return requestManager.load(new AudioFileCover(song.getData()));
} else {
@ -133,7 +142,8 @@ public class SongGlideRequest {
}
}
public static Key createSignature(Song song) {
@NonNull
private static Key createSignature(@NonNull Song song) {
return new MediaStoreSignature("", song.getDateModified(), 0);
}
}

View File

@ -58,10 +58,9 @@ public class MusicUtil {
public static final String TAG = MusicUtil.class.getSimpleName();
private static Playlist playlist;
@NonNull
public static Uri getMediaStoreAlbumCoverUri(int albumId) {
final Uri sArtworkUri = Uri
.parse("content://media/external/audio/albumart");
final Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
return ContentUris.withAppendedId(sArtworkUri, albumId);
}

View File

@ -58,10 +58,6 @@ public class RetroUtil {
return (int) (dpWidth / 180);
}
public static Uri getAlbumArtUri(long paramInt) {
return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), paramInt);
}
public static boolean isTablet() {
return App.Companion.getContext().getResources().getConfiguration().smallestScreenWidthDp >= 600;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@ -41,8 +40,7 @@
android:text="@string/history"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/v1"
tools:text="@tools:sample/lorem" />
app:layout_constraintTop_toBottomOf="@+id/v1" />
</androidx.constraintlayout.widget.ConstraintLayout>
@ -78,8 +76,7 @@
android:text="@string/last_added"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/v2"
tools:text="@tools:sample/lorem" />
app:layout_constraintTop_toBottomOf="@+id/v2" />
</androidx.constraintlayout.widget.ConstraintLayout>
@ -115,8 +112,7 @@
android:text="@string/my_top_tracks"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/v3"
tools:text="@tools:sample/lorem" />
app:layout_constraintTop_toBottomOf="@+id/v3" />
</androidx.constraintlayout.widget.ConstraintLayout>
@ -152,8 +148,7 @@
android:text="@string/shuffle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/v4"
tools:text="@tools:sample/lorem" />
app:layout_constraintTop_toBottomOf="@+id/v4" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -57,7 +57,6 @@
android:ellipsize="end"
android:maxLines="1"
android:paddingTop="8dp"
android:textColor="?colorOnBackground"
tools:text="Text" />
</LinearLayout>

View File

@ -5,73 +5,14 @@
<attr name="rectSelector" format="reference" />
<attr name="defaultFooterColor" format="color" />
<attr name="toolbarPopupTheme" format="reference" />
<attr name="dividerColor" format="color" />
<declare-styleable name="BlurLayout">
<attr name="blk_downscaleFactor" format="float" />
<attr name="blk_blurRadius" format="integer" />
<attr name="blk_fps" format="integer" />
<attr name="blk_cornerRadius" format="dimension" />
</declare-styleable>
<attr name="lineHeightHint" format="dimension" />
<declare-styleable name="NetworkImageView">
<attr name="url_link" format="string" />
</declare-styleable>
<declare-styleable name="ContributorsView">
<attr name="profile_url" format="string" />
<attr name="profile_name" format="string" />
<attr name="profile_summary" format="string" />
<attr name="profile_link" format="string" />
</declare-styleable>
<declare-styleable name="InsettableFrameLayout_Layout">
<attr name="layout_ignoreInsets" format="boolean" />
</declare-styleable>
<declare-styleable name="ColorIconsImageView">
<attr name="iconBackgroundColor" format="color" />
<attr name="colorIconColor" format="color" />
<attr name="icon" format="reference" />
</declare-styleable>
<declare-styleable name="OptionMenuItemView">
<attr name="optionTitle" format="reference" />
<attr name="optionIcon" format="reference" />
</declare-styleable>
<declare-styleable name="LrcView">
<attr name="lrcTextSize" format="dimension" />
<attr name="lrcLineSpaceSize" format="dimension" />
<attr name="lrcNormalTextColor" format="reference|color" />
<attr name="lrcCurrentTextColor" format="reference|color" />
<attr name="lrcTouchDelay" format="integer" />
<attr name="noLrcTextSize" format="dimension" />
<attr name="noLrcTextColor" format="reference|color" />
<attr name="indicatorLineHeight" format="dimension" />
<attr name="indicatorTextSize" format="dimension" />
<attr name="indicatorTextColor" format="reference|color" />
<attr name="currentIndicateLrcColor" format="reference|color" />
<attr name="indicatorTouchDelay" format="integer" />
<attr name="indicatorLineColor" format="reference|color" />
<attr name="indicatorStartEndMargin" format="dimension" />
<attr name="iconLineGap" format="dimension" />
<attr name="playIconWidth" format="dimension" />
<attr name="playIconHeight" format="dimension" />
<attr name="playIcon" format="reference" />
</declare-styleable>
<attr name="lineHeightHint" format="dimension" />
<declare-styleable name="BaselineGridTextView">
<attr name="lineHeightMultiplierHint" format="float" />
<attr name="lineHeightHint" />
<attr name="maxLinesByHeight" format="boolean" />
<attr name="android:textAppearance" />
<attr name="android:fontFamily" />
</declare-styleable>
<declare-styleable name="CircleRectView">
<attr name="circleRadius" format="dimension" />
</declare-styleable>
</resources>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<resources>
<declare-styleable name="BaselineGridTextView">
<attr name="lineHeightMultiplierHint" format="float" />
<attr name="lineHeightHint" />
<attr name="maxLinesByHeight" format="boolean" />
<attr name="android:textAppearance" />
<attr name="android:fontFamily" />
</declare-styleable>
</resources>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<resources>
<declare-styleable name="ColorIconsImageView">
<attr name="iconBackgroundColor" format="color" />
<attr name="colorIconColor" format="color" />
<attr name="icon" format="reference" />
</declare-styleable>
</resources>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<resources>
<declare-styleable name="ContributorsView">
<attr name="profile_url" format="string" />
<attr name="profile_name" format="string" />
<attr name="profile_summary" format="string" />
<attr name="profile_link" format="string" />
</declare-styleable>
</resources>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<resources>
<declare-styleable name="LrcView">
<attr name="lrcTextSize" format="dimension" />
<attr name="lrcLineSpaceSize" format="dimension" />
<attr name="lrcNormalTextColor" format="reference|color" />
<attr name="lrcCurrentTextColor" format="reference|color" />
<attr name="lrcTouchDelay" format="integer" />
<attr name="noLrcTextSize" format="dimension" />
<attr name="noLrcTextColor" format="reference|color" />
<attr name="indicatorLineHeight" format="dimension" />
<attr name="indicatorTextSize" format="dimension" />
<attr name="indicatorTextColor" format="reference|color" />
<attr name="currentIndicateLrcColor" format="reference|color" />
<attr name="indicatorTouchDelay" format="integer" />
<attr name="indicatorLineColor" format="reference|color" />
<attr name="indicatorStartEndMargin" format="dimension" />
<attr name="iconLineGap" format="dimension" />
<attr name="playIconWidth" format="dimension" />
<attr name="playIconHeight" format="dimension" />
<attr name="playIcon" format="reference" />
</declare-styleable>
</resources>