mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Added the option to set the size of the cover images
This commit is contained in:
parent
34818473da
commit
c522382da2
5 changed files with 40 additions and 9 deletions
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.glide;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
@ -15,6 +14,7 @@ import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.signature.ObjectKey;
|
import com.bumptech.glide.signature.ObjectKey;
|
||||||
import com.cappielloantonio.play.App;
|
import com.cappielloantonio.play.App;
|
||||||
import com.cappielloantonio.play.util.MusicUtil;
|
import com.cappielloantonio.play.util.MusicUtil;
|
||||||
|
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -38,17 +38,23 @@ public class CustomGlideRequest {
|
||||||
.centerCrop();
|
.centerCrop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createUrl(String item) {
|
public static String createUrl(String item, int size) {
|
||||||
String url = App.getSubsonicClientInstance(App.getInstance(), false).getUrl();
|
String url = App.getSubsonicClientInstance(App.getInstance(), false).getUrl();
|
||||||
Map<String, String> params = App.getSubsonicClientInstance(App.getInstance(), false).getParams();
|
Map<String, String> params = App.getSubsonicClientInstance(App.getInstance(), false).getParams();
|
||||||
|
|
||||||
return url + "getCoverArt" +
|
url = url + "getCoverArt" +
|
||||||
"?u=" + params.get("u") +
|
"?u=" + params.get("u") +
|
||||||
"&s=" + params.get("s") +
|
"&s=" + params.get("s") +
|
||||||
"&t=" + params.get("t") +
|
"&t=" + params.get("t") +
|
||||||
"&v=" + params.get("v") +
|
"&v=" + params.get("v") +
|
||||||
"&c=" + params.get("c") +
|
"&c=" + params.get("c") +
|
||||||
"&id=" + item;
|
"&id=" + item;
|
||||||
|
|
||||||
|
if (size != -1) {
|
||||||
|
return url + "&size" + size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
@ -58,13 +64,11 @@ public class CustomGlideRequest {
|
||||||
private Builder(Context context, String item, String category, String custom) {
|
private Builder(Context context, String item, String category, String custom) {
|
||||||
this.requestManager = Glide.with(context);
|
this.requestManager = Glide.with(context);
|
||||||
|
|
||||||
if(item != null) {
|
if (item != null) {
|
||||||
this.item = createUrl(item);
|
this.item = createUrl(item, PreferenceUtil.getInstance(context).getImageSize());
|
||||||
}
|
} else if (custom != null) {
|
||||||
else if(custom != null) {
|
|
||||||
this.item = custom;
|
this.item = custom;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.item = MusicUtil.getDefaultPicPerCategory(category);
|
this.item = MusicUtil.getDefaultPicPerCategory(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public class PreferenceUtil {
|
||||||
public static final String POSITION = "position";
|
public static final String POSITION = "position";
|
||||||
public static final String PROGRESS = "progress";
|
public static final String PROGRESS = "progress";
|
||||||
public static final String IMAGE_CACHE_SIZE = "image_cache_size";
|
public static final String IMAGE_CACHE_SIZE = "image_cache_size";
|
||||||
|
public static final String IMAGE_SIZE = "image_size";
|
||||||
public static final String MEDIA_CACHE_SIZE = "media_cache_size";
|
public static final String MEDIA_CACHE_SIZE = "media_cache_size";
|
||||||
|
|
||||||
private static PreferenceUtil sInstance;
|
private static PreferenceUtil sInstance;
|
||||||
|
|
@ -127,4 +128,8 @@ public class PreferenceUtil {
|
||||||
public final int getMediaCacheSize() {
|
public final int getMediaCacheSize() {
|
||||||
return Integer.parseInt(mPreferences.getString(MEDIA_CACHE_SIZE, "400000000"));
|
return Integer.parseInt(mPreferences.getString(MEDIA_CACHE_SIZE, "400000000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final int getImageSize() {
|
||||||
|
return Integer.parseInt(mPreferences.getString(IMAGE_SIZE, "-1"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -44,4 +44,16 @@
|
||||||
<item>400000000</item>
|
<item>400000000</item>
|
||||||
<item>200000000</item>
|
<item>200000000</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="pref_image_size_titles">
|
||||||
|
<item>High</item>
|
||||||
|
<item>Normal</item>
|
||||||
|
<item>Low</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="pref_image_size_values">
|
||||||
|
<item>-1</item>
|
||||||
|
<item>500</item>
|
||||||
|
<item>300</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
<string name="theme_selection">Choose theme</string>
|
<string name="theme_selection">Choose theme</string>
|
||||||
<string name="covers_cache">Covers cache</string>
|
<string name="covers_cache">Covers cache</string>
|
||||||
<string name="media_cache">Media cache</string>
|
<string name="media_cache">Media cache</string>
|
||||||
|
<string name="image_size">Cover size</string>
|
||||||
<string name="library_menu_label">Library</string>
|
<string name="library_menu_label">Library</string>
|
||||||
<string name="home_menu_label">Home</string>
|
<string name="home_menu_label">Home</string>
|
||||||
<string name="search_menu_label">Search</string>
|
<string name="search_menu_label">Search</string>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,15 @@
|
||||||
app:title="@string/media_cache"
|
app:title="@string/media_cache"
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
app:defaultValue="-1"
|
||||||
|
app:dialogTitle="@string/image_size"
|
||||||
|
app:entries="@array/pref_image_size_titles"
|
||||||
|
app:entryValues="@array/pref_image_size_values"
|
||||||
|
app:key="image_size"
|
||||||
|
app:title="@string/image_size"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:defaultValue="default"
|
app:defaultValue="default"
|
||||||
app:dialogTitle="@string/theme_selection"
|
app:dialogTitle="@string/theme_selection"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue