Search in sources :

Example 21 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class AppUpdateStatusManager method createAppEntry.

private AppUpdateStatus createAppEntry(Apk apk, Status status, PendingIntent intent) {
    synchronized (appMapping) {
        ContentResolver resolver = context.getContentResolver();
        App app = AppProvider.Helper.findSpecificApp(resolver, apk.packageName, apk.repoId);
        AppUpdateStatus ret = new AppUpdateStatus(app, apk, status, intent);
        appMapping.put(apk.getCanonicalUrl(), ret);
        return ret;
    }
}
Also used : App(org.fdroid.fdroid.data.App) ContentResolver(android.content.ContentResolver)

Example 22 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class UpdateService method showAppUpdatesNotification.

private void showAppUpdatesNotification(List<App> canUpdate) {
    if (canUpdate.size() > 0) {
        List<Apk> apksToUpdate = new ArrayList<>(canUpdate.size());
        for (App app : canUpdate) {
            apksToUpdate.add(ApkProvider.Helper.findSuggestedApk(this, app));
        }
        appUpdateStatusManager.addApks(apksToUpdate, AppUpdateStatusManager.Status.UpdateAvailable);
    }
}
Also used : App(org.fdroid.fdroid.data.App) ArrayList(java.util.ArrayList) Apk(org.fdroid.fdroid.data.Apk)

Example 23 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class UpdateService method autoDownloadUpdates.

/**
 * Queues all apps needing update.  If this app itself (e.g. F-Droid) needs
 * to be updated, it is queued last.
 */
public static void autoDownloadUpdates(Context context) {
    List<App> canUpdate = AppProvider.Helper.findCanUpdate(context, Schema.AppMetadataTable.Cols.ALL);
    String packageName = context.getPackageName();
    App updateLastApp = null;
    Apk updateLastApk = null;
    for (App app : canUpdate) {
        if (TextUtils.equals(packageName, app.packageName)) {
            updateLastApp = app;
            updateLastApk = ApkProvider.Helper.findSuggestedApk(context, app);
            continue;
        }
        Apk apk = ApkProvider.Helper.findSuggestedApk(context, app);
        InstallManagerService.queue(context, app, apk);
    }
    if (updateLastApp != null && updateLastApk != null) {
        InstallManagerService.queue(context, updateLastApp, updateLastApk);
    }
}
Also used : App(org.fdroid.fdroid.data.App) Apk(org.fdroid.fdroid.data.Apk)

Example 24 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class NotificationHelper method createInstalledNotification.

private Notification createInstalledNotification(AppUpdateStatusManager.AppUpdateStatus entry) {
    App app = entry.app;
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_INSTALLS).setAutoCancel(true).setSmallIcon(R.drawable.ic_notification).setColor(ContextCompat.getColor(context, R.color.fdroid_blue)).setContentTitle(app.name).setContentText(context.getString(R.string.notification_content_single_installed)).setLocalOnly(true).setVisibility(NotificationCompat.VISIBILITY_SECRET).setContentIntent(entry.intent);
    if (useStackedNotifications()) {
        builder.setGroup(GROUP_INSTALLED);
    }
    Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED);
    intentDeleted.putExtra(org.fdroid.fdroid.net.Downloader.EXTRA_CANONICAL_URL, entry.getCanonicalUrl());
    intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
    PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setDeleteIntent(piDeleted);
    loadLargeIconForEntry(entry, builder, NOTIFY_ID_INSTALLED, entry.getCanonicalUrl());
    return builder.build();
}
Also used : App(org.fdroid.fdroid.data.App) SpannableStringBuilder(android.text.SpannableStringBuilder) NotificationCompat(androidx.core.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 25 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class WhatsNewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(AppCardController holder, int position) {
    cursor.moveToPosition(position);
    holder.bindApp(new App(cursor));
}
Also used : App(org.fdroid.fdroid.data.App)

Aggregations

App (org.fdroid.fdroid.data.App)53 FDroidApp (org.fdroid.fdroid.FDroidApp)10 Apk (org.fdroid.fdroid.data.Apk)10 Test (org.junit.Test)6 Intent (android.content.Intent)5 PackageInfo (android.content.pm.PackageInfo)5 PackageManager (android.content.pm.PackageManager)5 ArrayList (java.util.ArrayList)5 FDroidProviderTest (org.fdroid.fdroid.data.FDroidProviderTest)5 PendingIntent (android.app.PendingIntent)4 SpannableStringBuilder (android.text.SpannableStringBuilder)4 NotificationCompat (androidx.core.app.NotificationCompat)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 IOException (java.io.IOException)4 Repo (org.fdroid.fdroid.data.Repo)4 RepoXMLHandlerTest (org.fdroid.fdroid.data.RepoXMLHandlerTest)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 ContentResolver (android.content.ContentResolver)3 ContentValues (android.content.ContentValues)3 JsonFactory (com.fasterxml.jackson.core.JsonFactory)3