diff --git a/app/src/main/java/org/fdroid/fdroid/views/categories/AppCardController.java b/app/src/main/java/org/fdroid/fdroid/views/categories/AppCardController.java index 1fe5828c2..14efb9d81 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/categories/AppCardController.java +++ b/app/src/main/java/org/fdroid/fdroid/views/categories/AppCardController.java @@ -33,10 +33,9 @@ import org.fdroid.fdroid.views.apps.FeatureImage; * + {@link R.id#icon} ({@link ImageView}, required) * + {@link R.id#summary} ({@link TextView}, required) * + {@link R.id#new_tag} ({@link TextView}, optional) - * + {@link R.id#featured_image} ({@link ImageView}, optional) */ public class AppCardController extends RecyclerView.ViewHolder - implements ImageLoadingListener, View.OnClickListener { + implements View.OnClickListener { /** * After this many days, don't consider showing the "New" tag next to an app. @@ -58,13 +57,6 @@ public class AppCardController extends RecyclerView.ViewHolder @Nullable private final TextView newTag; - /** - * Wide and short image for branding the app. If it is not present in the metadata then F-Droid - * will draw some abstract art instead. - */ - @Nullable - private final FeatureImage featuredImage; - @Nullable private App currentApp; @@ -78,7 +70,6 @@ public class AppCardController extends RecyclerView.ViewHolder icon = (ImageView) findViewAndEnsureNonNull(itemView, R.id.icon); summary = (TextView) findViewAndEnsureNonNull(itemView, R.id.summary); - featuredImage = (FeatureImage) itemView.findViewById(R.id.featured_image); newTag = (TextView) itemView.findViewById(R.id.new_tag); itemView.setOnClickListener(this); @@ -113,25 +104,7 @@ public class AppCardController extends RecyclerView.ViewHolder } } - ImageLoader.getInstance().displayImage(app.iconUrl, icon, Utils.getRepoAppDisplayImageOptions(), this); - - if (featuredImage != null) { - featuredImage.setColour(ContextCompat.getColor(activity, R.color.fdroid_blue)); - featuredImage.setImageDrawable(null); - - // Note: We could call the convenience function - // loadImageAndDisplay(ImageLoader, DisplayImageOptions, String, String) - // which includes a fallback for when currentApp.featureGraphic is empty. However we need - // to take care of also loading the icon (regardless of whether there is a featureGraphic - // or not for this app) so that we can display the icon to the user. We will use the - // load complete listener for the icon to decide whether we need to extract the colour - // from that icon and assign to the `FeatureImage` (or whether we should wait for the - // feature image to be loaded). - if (!TextUtils.isEmpty(app.featureGraphic)) { - featuredImage.loadImageAndDisplay(ImageLoader.getInstance(), - Utils.getRepoAppDisplayImageOptions(), app.getFeatureGraphicUrl(activity)); - } - } + ImageLoader.getInstance().displayImage(app.iconUrl, icon, Utils.getRepoAppDisplayImageOptions()); } private boolean isConsideredNew(@NonNull App app) { @@ -166,44 +139,4 @@ public class AppCardController extends RecyclerView.ViewHolder activity.startActivity(intent); } } - - // ============================================================================================= - // Icon loader callbacks - // - // Most are unused, the main goal is to specify a background colour for the featured image if - // no featured image is specified in the apps metadata. If an image is specified, then it will - // get loaded using the `FeatureImage.loadImageAndDisplay()` method and so we don't need to do - // anything special here. - // ============================================================================================= - - @Override - public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { - if (currentApp != null - && TextUtils.isEmpty(currentApp.featureGraphic) - && featuredImage != null - && loadedImage != null) { - new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() { - @Override - public void onGenerated(@NonNull Palette palette) { - featuredImage.setColorAndAnimateChange(palette.getDominantColor(Color.LTGRAY)); - } - }); - } - } - - @Override - public void onLoadingStarted(String imageUri, View view) { - // Do nothing - } - - @Override - public void onLoadingCancelled(String imageUri, View view) { - // Do nothing - } - - @Override - public void onLoadingFailed(String imageUri, View view, FailReason failReason) { - // Do nothing - } - } diff --git a/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java index fbec4c440..fde14387a 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java @@ -44,16 +44,18 @@ public class WhatsNewAdapter extends RecyclerView.Adapter { @Override public AppCardController onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { int layout; - if (viewType == R.id.whats_new_feature) { - layout = R.layout.app_card_featured; - } else if (viewType == R.id.whats_new_large_tile) { - layout = R.layout.app_card_large; - } else if (viewType == R.id.whats_new_small_tile) { - layout = R.layout.app_card_horizontal; - } else if (viewType == R.id.whats_new_regular_list) { - layout = R.layout.app_card_list_item; - } else { - throw new IllegalArgumentException("Unknown view type when rendering \"Whats New\": " + viewType); + switch (viewType) { + case R.id.whats_new_large_tile: + layout = R.layout.app_card_large; + break; + case R.id.whats_new_small_tile: + layout = R.layout.app_card_horizontal; + break; + case R.id.whats_new_regular_list: + layout = R.layout.app_card_list_item; + break; + default: + throw new IllegalArgumentException("Unknown view type when rendering \"Whats New\": " + viewType); } return new AppCardController(activity, activity.getLayoutInflater().inflate(layout, parent, false)); @@ -72,7 +74,7 @@ public class WhatsNewAdapter extends RecyclerView.Adapter { } if (position == 0) { - return R.id.whats_new_feature; + return R.id.whats_new_regular_list; } else { switch (relativePositionInCycle) { case 1: @@ -145,11 +147,7 @@ public class WhatsNewAdapter extends RecyclerView.Adapter { int verticalPadding = (int) resources.getDimension(R.dimen.whats_new__padding__app_card__vertical); int relativePositionInCycle = position % 5; - if (position == 0) { - // Don't set any padding for the first item as the FeatureImage behind it needs to butt right - // up against the left/top/right of the screen. - outRect.set(0, 0, 0, verticalPadding); - } else if (relativePositionInCycle != 0) { + if (relativePositionInCycle != 0) { // The item on the left will have both left and right padding. The item on the right // will only have padding on the right. This will allow the same amount of padding // on the left, centre, and right of the grid, rather than double the padding in the @@ -161,7 +159,7 @@ public class WhatsNewAdapter extends RecyclerView.Adapter { int paddingRight = isLtr ? horizontalPadding : paddingStart; outRect.set(paddingLeft, 0, paddingRight, verticalPadding); } else { - outRect.set(horizontalPadding, 0, horizontalPadding, verticalPadding); + outRect.set(horizontalPadding, position == 0 ? verticalPadding : 0, horizontalPadding, verticalPadding); } } } diff --git a/app/src/main/res/layout/app_card_featured.xml b/app/src/main/res/layout/app_card_featured.xml deleted file mode 100644 index 0e07ae805..000000000 --- a/app/src/main/res/layout/app_card_featured.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index ead5065e6..b58bc5ba3 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -2,7 +2,6 @@ -