use icon from pm, when there's none from the metadata
This was already done for list views because of the panic uninstall list but we can easily apply the same logic to the tile view and app detail view as well.
This commit is contained in:
parent
56c05933a2
commit
4a5bee3e84
@ -49,12 +49,15 @@ import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||
import com.nostra13.universalimageloader.utils.StorageUtils;
|
||||
import org.fdroid.fdroid.compat.FileCompat;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.fdroid.data.Repo;
|
||||
import org.fdroid.fdroid.data.SanitizedFile;
|
||||
import org.xml.sax.XMLReader;
|
||||
@ -486,6 +489,26 @@ public final class Utils {
|
||||
return repoAppDisplayImageOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* If app has an iconUrl we feed that to UIL, otherwise we ask the PackageManager which will
|
||||
* return the app's icon directly when the app is installed.
|
||||
* We fall back to the placeholder icon otherwise.
|
||||
*/
|
||||
public static void setIconFromRepoOrPM(@NonNull App app, ImageView iv, Context context) {
|
||||
if (app.getIconUrl(iv.getContext()) == null) {
|
||||
try {
|
||||
iv.setImageDrawable(context.getPackageManager().getApplicationIcon(app.packageName));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
DisplayImageOptions options = Utils.getRepoAppDisplayImageOptions();
|
||||
iv.setImageDrawable(options.shouldShowImageForEmptyUri()
|
||||
? options.getImageForEmptyUri(FDroidApp.getInstance().getResources())
|
||||
: null);
|
||||
}
|
||||
} else {
|
||||
ImageLoader.getInstance().displayImage(app.getIconUrl(iv.getContext()), iv, Utils.getRepoAppDisplayImageOptions());
|
||||
}
|
||||
}
|
||||
|
||||
// this is all new stuff being added
|
||||
public static String hashBytes(byte[] input, String algo) {
|
||||
try {
|
||||
|
@ -480,7 +480,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
|
||||
public void bindModel() {
|
||||
ImageLoader.getInstance().displayImage(app.getIconUrl(iconView.getContext()), iconView, Utils.getRepoAppDisplayImageOptions());
|
||||
Utils.setIconFromRepoOrPM(app, iconView, iconView.getContext());
|
||||
titleView.setText(app.name);
|
||||
if (!TextUtils.isEmpty(app.authorName)) {
|
||||
authorView.setText(context.getString(R.string.by_author_format, app.authorName));
|
||||
|
@ -191,18 +191,7 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
|
||||
|
||||
if (actionButton != null) actionButton.setEnabled(true);
|
||||
|
||||
if (app.getIconUrl(icon.getContext()) == null) {
|
||||
try {
|
||||
icon.setImageDrawable(activity.getPackageManager().getApplicationIcon(app.packageName));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
DisplayImageOptions options = Utils.getRepoAppDisplayImageOptions();
|
||||
icon.setImageDrawable(options.shouldShowImageForEmptyUri()
|
||||
? options.getImageForEmptyUri(FDroidApp.getInstance().getResources())
|
||||
: null);
|
||||
}
|
||||
} else {
|
||||
ImageLoader.getInstance().displayImage(app.getIconUrl(icon.getContext()), icon, Utils.getRepoAppDisplayImageOptions());
|
||||
}
|
||||
Utils.setIconFromRepoOrPM(app, icon, activity);
|
||||
|
||||
// Figures out the current install/update/download/etc status for the app we are viewing.
|
||||
// Then, asks the view to update itself to reflect this status.
|
||||
|
@ -95,8 +95,7 @@ public class AppCardController extends RecyclerView.ViewHolder
|
||||
newTag.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
ImageLoader.getInstance().displayImage(app.getIconUrl(icon.getContext()), icon, Utils.getRepoAppDisplayImageOptions());
|
||||
Utils.setIconFromRepoOrPM(app, icon, icon.getContext());
|
||||
}
|
||||
|
||||
private boolean isConsideredNew(@NonNull App app) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user