Search in sources :

Example 1 with AppUpdateStatus

use of org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus in project fdroidclient by f-droid.

the class AppListItemController method bindModel.

public void bindModel(@NonNull App app) {
    currentApp = app;
    if (actionButton != null)
        actionButton.setEnabled(true);
    Utils.setIconFromRepoOrPM(app, icon, activity);
    // Figures out the current install/update/download/etc status for the app we are viewing.
    // Then, asks the view to update itself to reflect this status.
    Iterator<AppUpdateStatus> statuses = AppUpdateStatusManager.getInstance(activity).getByPackageName(app.packageName).iterator();
    if (statuses.hasNext()) {
        AppUpdateStatus status = statuses.next();
        updateAppStatus(app, status);
    } else {
        updateAppStatus(app, null);
    }
    final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(activity.getApplicationContext());
    broadcastManager.unregisterReceiver(onStatusChanged);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED);
    intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
    intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
    broadcastManager.registerReceiver(onStatusChanged, intentFilter);
}
Also used : IntentFilter(android.content.IntentFilter) AppUpdateStatus(org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Example 2 with AppUpdateStatus

use of org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus in project fdroidclient by f-droid.

the class AppStatusListItemController method onDismissApp.

@NonNull
@Override
protected DismissResult onDismissApp(@NonNull App app) {
    AppUpdateStatus status = getCurrentStatus();
    CharSequence message = null;
    if (status != null) {
        AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(activity);
        manager.removeApk(status.getUniqueKey());
        switch(status.status) {
            case ReadyToInstall:
                manager.markAsNoLongerPendingInstall(status);
                // of a "Ready to install" app being dismissed.
                break;
            case Downloading:
                cancelDownload();
                message = activity.getString(R.string.app_list__dismiss_downloading_app);
                break;
        }
    }
    return new DismissResult(message, true);
}
Also used : DismissResult(org.fdroid.fdroid.views.updates.DismissResult) AppUpdateStatus(org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus) AppUpdateStatusManager(org.fdroid.fdroid.AppUpdateStatusManager) NonNull(android.support.annotation.NonNull)

Example 3 with AppUpdateStatus

use of org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus in project fdroidclient by f-droid.

the class AppStatusListItemController method onDismissApp.

@Override
protected void onDismissApp(@NonNull final App app, final UpdatesAdapter adapter) {
    AppUpdateStatus status = getCurrentStatus();
    if (status != null) {
        final AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(activity);
        final AppUpdateStatus appUpdateStatus = manager.get(status.getCanonicalUrl());
        manager.removeApk(status.getCanonicalUrl());
        switch(status.status) {
            case Downloading:
                cancelDownload();
                Snackbar.make(itemView, R.string.app_list__dismiss_downloading_app, Snackbar.LENGTH_SHORT).show();
                break;
            case ReadyToInstall:
                if (appUpdateStatus != null) {
                    Snackbar.make(itemView, R.string.app_list__dismiss_installing_app, Snackbar.LENGTH_LONG).setAction(R.string.undo, new View.OnClickListener() {

                        @Override
                        public void onClick(View view) {
                            manager.addApk(appUpdateStatus.apk, appUpdateStatus.status, appUpdateStatus.intent);
                            adapter.refreshStatuses();
                        }
                    }).show();
                    break;
                }
        }
    }
    adapter.refreshStatuses();
}
Also used : AppUpdateStatus(org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus) AppUpdateStatusManager(org.fdroid.fdroid.AppUpdateStatusManager) View(android.view.View)

Aggregations

AppUpdateStatus (org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus)3 AppUpdateStatusManager (org.fdroid.fdroid.AppUpdateStatusManager)2 IntentFilter (android.content.IntentFilter)1 NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 LocalBroadcastManager (androidx.localbroadcastmanager.content.LocalBroadcastManager)1 DismissResult (org.fdroid.fdroid.views.updates.DismissResult)1