Search in sources :

Example 1 with UpdateAppAlertDialog

use of org.telegram.ui.Components.UpdateAppAlertDialog in project Telegram-FOSS by Telegram-FOSS-Team.

the class LaunchActivity method checkAppUpdate.

public void checkAppUpdate(boolean force) {
    if (!force && BuildVars.DEBUG_VERSION || !force && !BuildVars.CHECK_UPDATES) {
        return;
    }
    if (!force && Math.abs(System.currentTimeMillis() - SharedConfig.lastUpdateCheckTime) < MessagesController.getInstance(0).updateCheckDelay * 1000) {
        return;
    }
    TLRPC.TL_help_getAppUpdate req = new TLRPC.TL_help_getAppUpdate();
    try {
        req.source = ApplicationLoader.applicationContext.getPackageManager().getInstallerPackageName(ApplicationLoader.applicationContext.getPackageName());
    } catch (Exception ignore) {
    }
    if (req.source == null) {
        req.source = "";
    }
    final int accountNum = currentAccount;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        SharedConfig.lastUpdateCheckTime = System.currentTimeMillis();
        SharedConfig.saveConfig();
        if (response instanceof TLRPC.TL_help_appUpdate) {
            final TLRPC.TL_help_appUpdate res = (TLRPC.TL_help_appUpdate) response;
            AndroidUtilities.runOnUIThread(() -> {
                if (SharedConfig.pendingAppUpdate != null && SharedConfig.pendingAppUpdate.version.equals(res.version)) {
                    return;
                }
                if (SharedConfig.setNewAppVersionAvailable(res)) {
                    if (res.can_not_skip) {
                        showUpdateActivity(accountNum, res, false);
                    } else {
                        drawerLayoutAdapter.notifyDataSetChanged();
                        try {
                            (new UpdateAppAlertDialog(LaunchActivity.this, res, accountNum)).show();
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    }
                    NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.appUpdateAvailable);
                }
            });
        }
    });
}
Also used : UpdateAppAlertDialog(org.telegram.ui.Components.UpdateAppAlertDialog) TLRPC(org.telegram.tgnet.TLRPC) ParseException(java.text.ParseException) Paint(android.graphics.Paint) Point(android.graphics.Point)

Aggregations

Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 ParseException (java.text.ParseException)1 TLRPC (org.telegram.tgnet.TLRPC)1 UpdateAppAlertDialog (org.telegram.ui.Components.UpdateAppAlertDialog)1