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();
}
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);
}
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));
}
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);
}
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));
}
Aggregations