Search in sources :

Example 31 with App

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

the class ProperMultiRepoUpdaterTest method assertCalendarMetadata.

private void assertCalendarMetadata(Repo repo, @RepoIdentifier String id) {
    App calendar = AppProvider.Helper.findSpecificApp(context.getContentResolver(), "org.dgtale.icsimport", repo.getId(), AppMetadataTable.Cols.ALL);
    assertCalendarMetadata(calendar, id);
}
Also used : App(org.fdroid.fdroid.data.App)

Example 32 with App

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

the class ProperMultiRepoUpdaterTest method allApps.

private Map<String, App> allApps() {
    List<App> apps = AppProvider.Helper.all(context.getContentResolver());
    Map<String, App> appsIndexedByPackageName = new HashMap<>(apps.size());
    for (App app : apps) {
        appsIndexedByPackageName.put(app.packageName, app);
    }
    return appsIndexedByPackageName;
}
Also used : App(org.fdroid.fdroid.data.App) HashMap(java.util.HashMap)

Example 33 with App

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

the class ProperMultiRepoUpdaterTest method assertRepoTakesPriority.

private void assertRepoTakesPriority(@RepoIdentifier String higherPriority) {
    Map<String, App> allApps = allApps();
    // Provided by both the "Main" and "Conflicting" repo, so need to fetch metdata from the
    // repo with the higher "Conflicting" repo has a higher priority.
    App adAway = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "org.adaway");
    assertAdAwayMetadata(adAway, higherPriority);
    assertAdAwayMetadata(allApps.get("org.adaway"), higherPriority);
    // This is only provided by the "Main" or "Archive" repo. Both the main and archive repo both
    // pull their metadata from the same build recipe in fdroidserver. The only difference is that
    // the archive repository contains .apks from further back, but their metadata is the same.
    App a2048 = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "com.uberspot.a2048");
    assert2048Metadata(a2048, "Normal");
    assert2048Metadata(allApps.get("com.uberspot.a2048"), "Normal");
    // This is only provided by the "Conflicting" repo.
    App calendar = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "org.dgtale.icsimport");
    assertCalendarMetadata(calendar, "Conflicting");
    assertCalendarMetadata(allApps.get("org.dgtale.icsimport"), "Conflicting");
    // This is only provided by the "Main" repo.
    App adb = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), "siir.es.adbWireless");
    assertAdbMetadata(adb, "Normal");
    assertAdbMetadata(allApps.get("siir.es.adbWireless"), "Normal");
}
Also used : App(org.fdroid.fdroid.data.App)

Example 34 with App

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

the class NotificationHelper method createUpdateNotification.

private Notification createUpdateNotification(AppUpdateStatusManager.AppUpdateStatus entry) {
    App app = entry.app;
    AppUpdateStatusManager.Status status = entry.status;
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_UPDATES).setAutoCancel(true).setContentTitle(getSingleItemTitleString(app, status)).setContentText(getSingleItemContentString(app, status)).setSmallIcon(R.drawable.ic_notification).setColor(ContextCompat.getColor(context, R.color.fdroid_blue)).setLocalOnly(true).setVisibility(NotificationCompat.VISIBILITY_SECRET).setContentIntent(entry.intent);
    /* If using stacked notifications, use groups. Note that this would not work prior to Lollipop,
           because of http://stackoverflow.com/a/34953411, but currently not an issue since stacked
           notifications are used only on >= Nougat.
        */
    if (useStackedNotifications()) {
        builder.setGroup(GROUP_UPDATES);
    }
    // Handle actions
    // 
    NotificationCompat.Action action = getAction(entry);
    if (action != null) {
        builder.addAction(action);
    }
    // 
    if (status == AppUpdateStatusManager.Status.Downloading) {
        if (entry.progressMax == 0) {
            builder.setProgress(100, 0, true);
        } else {
            builder.setProgress(Utils.bytesToKb(entry.progressMax), Utils.bytesToKb(entry.progressCurrent), false);
        }
    } else if (status == AppUpdateStatusManager.Status.Installing) {
        // indeterminate bar
        builder.setProgress(100, 0, true);
    }
    Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_UPDATE_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_UPDATES, 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 35 with App

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

the class NotificationHelper method createInstalledSummaryNotification.

private Notification createInstalledSummaryNotification(ArrayList<AppUpdateStatusManager.AppUpdateStatus> installed) {
    String title = context.getResources().getQuantityString(R.plurals.notification_summary_installed, installed.size(), installed.size());
    StringBuilder text = new StringBuilder();
    NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
    bigTextStyle.setBigContentTitle(title);
    for (int i = 0; i < MAX_INSTALLED_TO_SHOW && i < installed.size(); i++) {
        AppUpdateStatusManager.AppUpdateStatus entry = installed.get(i);
        App app = entry.app;
        if (text.length() > 0) {
            text.append(", ");
        }
        text.append(app.name);
    }
    bigTextStyle.bigText(text);
    if (installed.size() > MAX_INSTALLED_TO_SHOW) {
        int diff = installed.size() - MAX_INSTALLED_TO_SHOW;
        bigTextStyle.setSummaryText(context.getResources().getQuantityString(R.plurals.notification_summary_more, diff, diff));
    }
    // Intent to open main app list
    Intent intentObject = new Intent(context, MainActivity.class);
    PendingIntent piAction = PendingIntent.getActivity(context, 0, intentObject, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_INSTALLS).setAutoCancel(!useStackedNotifications()).setSmallIcon(R.drawable.ic_notification).setColor(ContextCompat.getColor(context, R.color.fdroid_blue)).setContentTitle(title).setContentText(text).setContentIntent(piAction).setLocalOnly(true).setVisibility(NotificationCompat.VISIBILITY_SECRET);
    if (useStackedNotifications()) {
        builder.setGroup(GROUP_INSTALLED).setGroupSummary(true);
    }
    Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_ALL_INSTALLED_CLEARED);
    intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
    PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setDeleteIntent(piDeleted);
    return builder.build();
}
Also used : App(org.fdroid.fdroid.data.App) SpannableStringBuilder(android.text.SpannableStringBuilder) SpannableStringBuilder(android.text.SpannableStringBuilder) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Point(android.graphics.Point) NotificationCompat(androidx.core.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

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