Search in sources :

Example 36 with App

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

the class NotificationHelper method createUpdateSummaryNotification.

private Notification createUpdateSummaryNotification(ArrayList<AppUpdateStatusManager.AppUpdateStatus> updates) {
    String title = context.getResources().getQuantityString(R.plurals.notification_summary_updates, updates.size(), updates.size());
    StringBuilder text = new StringBuilder();
    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.setBigContentTitle(title);
    for (int i = 0; i < MAX_UPDATES_TO_SHOW && i < updates.size(); i++) {
        AppUpdateStatusManager.AppUpdateStatus entry = updates.get(i);
        App app = entry.app;
        AppUpdateStatusManager.Status status = entry.status;
        String content = getMultiItemContentString(app, status);
        SpannableStringBuilder sb = new SpannableStringBuilder(app.name);
        sb.setSpan(new StyleSpan(Typeface.BOLD), 0, sb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        sb.append(" ");
        sb.append(content);
        inboxStyle.addLine(sb);
        if (text.length() > 0) {
            text.append(", ");
        }
        text.append(app.name);
    }
    if (updates.size() > MAX_UPDATES_TO_SHOW) {
        int diff = updates.size() - MAX_UPDATES_TO_SHOW;
        inboxStyle.setSummaryText(context.getResources().getQuantityString(R.plurals.notification_summary_more, diff, diff));
    }
    // Intent to open main app list
    Intent intentObject = new Intent(context, MainActivity.class);
    intentObject.putExtra(MainActivity.EXTRA_VIEW_UPDATES, true);
    PendingIntent piAction = PendingIntent.getActivity(context, 0, intentObject, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_UPDATES).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).setStyle(inboxStyle);
    if (useStackedNotifications()) {
        builder.setGroup(GROUP_UPDATES).setGroupSummary(true);
    }
    Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_ALL_UPDATES_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) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Point(android.graphics.Point) StyleSpan(android.text.style.StyleSpan) NotificationCompat(androidx.core.app.NotificationCompat) PendingIntent(android.app.PendingIntent) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 37 with App

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

the class ApkCache method copyApkFromCacheToFiles.

/**
 * Copy the APK to the safe location inside of the protected area
 * of the app to prevent attacks based on other apps swapping the file
 * out during the install process. Most likely, apkFile was just downloaded,
 * so it should still be in the RAM disk cache.
 */
public static SanitizedFile copyApkFromCacheToFiles(Context context, File apkFile, Apk expectedApk) throws IOException {
    App app = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), expectedApk.packageName);
    String name = app == null ? expectedApk.packageName : app.name;
    String apkFileName = name + "-" + expectedApk.versionName + ".apk";
    return copyApkToFiles(context, apkFile, apkFileName, true, expectedApk.hash, expectedApk.hashType);
}
Also used : App(org.fdroid.fdroid.data.App)

Example 38 with App

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

the class InstalledAppListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull InstalledAppListItemController holder, int position) {
    if (cursor == null) {
        return;
    }
    cursor.moveToPosition(position);
    holder.bindModel(new App(cursor));
}
Also used : App(org.fdroid.fdroid.data.App)

Example 39 with App

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

the class InstalledAppsActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.menu_share:
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("packageName,versionCode,versionName\n");
            for (int i = 0; i < adapter.getItemCount(); i++) {
                App app = adapter.getItem(i);
                if (app != null) {
                    stringBuilder.append(app.packageName).append(',').append(app.installedVersionCode).append(',').append(app.installedVersionName).append('\n');
                }
            }
            ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(this).setSubject(getString(R.string.send_installed_apps)).setChooserTitle(R.string.send_installed_apps).setText(stringBuilder.toString()).setType("text/csv");
            startActivity(intentBuilder.getIntent());
            break;
    }
    return super.onOptionsItemSelected(item);
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) App(org.fdroid.fdroid.data.App) ShareCompat(androidx.core.app.ShareCompat)

Example 40 with App

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

the class AppPreviewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull 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