sort "new" app entries based on lastUpdate time of Repo

https://gitlab.com/fdroid/fdroidclient/-/issues/939#note_504169741
This commit is contained in:
Hans-Christoph Steiner 2021-02-09 10:06:40 +01:00
parent e9b03e5a2a
commit 2a4c9f0fcb
2 changed files with 8 additions and 5 deletions

View File

@ -1,20 +1,18 @@
package org.fdroid.fdroid.views.categories; package org.fdroid.fdroid.views.categories;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityOptionsCompat; import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.util.Pair; import androidx.core.util.Pair;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.fdroid.fdroid.R; import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.App; import org.fdroid.fdroid.data.App;
@ -33,7 +31,7 @@ public class AppCardController extends RecyclerView.ViewHolder
/** /**
* After this many days, don't consider showing the "New" tag next to an app. * After this many days, don't consider showing the "New" tag next to an app.
*/ */
private static final int DAYS_TO_CONSIDER_NEW = 14; public static final int DAYS_TO_CONSIDER_NEW = 14;
@NonNull @NonNull
private final ImageView icon; private final ImageView icon;

View File

@ -25,8 +25,10 @@ import org.fdroid.fdroid.data.AppProvider;
import org.fdroid.fdroid.data.RepoProvider; import org.fdroid.fdroid.data.RepoProvider;
import org.fdroid.fdroid.data.Schema.AppMetadataTable; import org.fdroid.fdroid.data.Schema.AppMetadataTable;
import org.fdroid.fdroid.data.Schema.AppMetadataTable.Cols; import org.fdroid.fdroid.data.Schema.AppMetadataTable.Cols;
import org.fdroid.fdroid.data.Schema.RepoTable;
import org.fdroid.fdroid.panic.HidingManager; import org.fdroid.fdroid.panic.HidingManager;
import org.fdroid.fdroid.views.apps.AppListActivity; import org.fdroid.fdroid.views.apps.AppListActivity;
import org.fdroid.fdroid.views.categories.AppCardController;
import java.util.Date; import java.util.Date;
@ -134,7 +136,10 @@ class LatestViewBinder implements LoaderManager.LoaderCallbacks<Cursor> {
+ " AND " + table + "." + Cols.TV_BANNER + " IS NULL" + " AND " + table + "." + Cols.TV_BANNER + " IS NULL"
+ " THEN 1 ELSE 0 END" + " THEN 1 ELSE 0 END"
+ ", CASE WHEN date(" + added + ") >= date(" + lastUpdated + ")" + ", CASE WHEN date(" + added + ") >= date(" + lastUpdated + ")"
+ " AND date('now','-7 days') < date(" + lastUpdated + ")" + " AND date((SELECT " + RepoTable.Cols.LAST_UPDATED + " FROM " + RepoTable.NAME
+ " WHERE _id=" + table + "." + Cols.REPO_ID
+ " ),'-" + AppCardController.DAYS_TO_CONSIDER_NEW + " days') "
+ " < date(" + lastUpdated + ")"
+ " THEN 0 ELSE 1 END" + " THEN 0 ELSE 1 END"
+ ", " + table + "." + Cols.WHATSNEW + " IS NULL ASC" + ", " + table + "." + Cols.WHATSNEW + " IS NULL ASC"
+ ", " + lastUpdated + " DESC" + ", " + lastUpdated + " DESC"