Java Code Examples for org.telegram.tgnet.TLRPC#TL_autoDownloadSettings

The following examples show how to use org.telegram.tgnet.TLRPC#TL_autoDownloadSettings . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadController.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void set(TLRPC.TL_autoDownloadSettings settings) {
    preloadMusic = settings.audio_preload_next;
    preloadVideo = settings.video_preload_large;
    lessCallData = settings.phonecalls_less_data;
    maxVideoBitrate = settings.video_upload_maxbitrate;
    sizes[PRESET_SIZE_NUM_PHOTO] = Math.max(500 * 1024, settings.photo_size_max);
    sizes[PRESET_SIZE_NUM_VIDEO] = Math.max(500 * 1024, settings.video_size_max);
    sizes[PRESET_SIZE_NUM_DOCUMENT] = Math.max(500 * 1024, settings.file_size_max);
    for (int a = 0; a < mask.length; a++) {
        if (settings.photo_size_max != 0 && !settings.disabled) {
            mask[a] |= AUTODOWNLOAD_TYPE_PHOTO;
        } else {
            mask[a] &=~ AUTODOWNLOAD_TYPE_PHOTO;
        }
        if (settings.video_size_max != 0 && !settings.disabled) {
            mask[a] |= AUTODOWNLOAD_TYPE_VIDEO;
        } else {
            mask[a] &=~ AUTODOWNLOAD_TYPE_VIDEO;
        }
        if (settings.file_size_max != 0 && !settings.disabled) {
            mask[a] |= AUTODOWNLOAD_TYPE_DOCUMENT;
        } else {
            mask[a] &=~ AUTODOWNLOAD_TYPE_DOCUMENT;
        }
    }
}
 
Example 2
Source File: DownloadController.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void set(TLRPC.TL_autoDownloadSettings settings) {
    preloadMusic = settings.audio_preload_next;
    preloadVideo = settings.video_preload_large;
    lessCallData = settings.phonecalls_less_data;
    maxVideoBitrate = settings.video_upload_maxbitrate;
    sizes[PRESET_SIZE_NUM_PHOTO] = Math.max(500 * 1024, settings.photo_size_max);
    sizes[PRESET_SIZE_NUM_VIDEO] = Math.max(500 * 1024, settings.video_size_max);
    sizes[PRESET_SIZE_NUM_DOCUMENT] = Math.max(500 * 1024, settings.file_size_max);
    for (int a = 0; a < mask.length; a++) {
        if (settings.photo_size_max != 0 && !settings.disabled) {
            mask[a] |= AUTODOWNLOAD_TYPE_PHOTO;
        } else {
            mask[a] &=~ AUTODOWNLOAD_TYPE_PHOTO;
        }
        if (settings.video_size_max != 0 && !settings.disabled) {
            mask[a] |= AUTODOWNLOAD_TYPE_VIDEO;
        } else {
            mask[a] &=~ AUTODOWNLOAD_TYPE_VIDEO;
        }
        if (settings.file_size_max != 0 && !settings.disabled) {
            mask[a] |= AUTODOWNLOAD_TYPE_DOCUMENT;
        } else {
            mask[a] &=~ AUTODOWNLOAD_TYPE_DOCUMENT;
        }
    }
}
 
Example 3
Source File: DownloadController.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void savePresetToServer(int type) {
    TLRPC.TL_account_saveAutoDownloadSettings req = new TLRPC.TL_account_saveAutoDownloadSettings();
    Preset preset;
    boolean enabled;
    if (type == 0) {
        preset = getCurrentMobilePreset();
        enabled = mobilePreset.enabled;
    } else if (type == 1) {
        preset = getCurrentWiFiPreset();
        enabled = wifiPreset.enabled;
    } else {
        preset = getCurrentRoamingPreset();
        enabled = roamingPreset.enabled;
    }
    req.settings = new TLRPC.TL_autoDownloadSettings();
    req.settings.audio_preload_next = preset.preloadMusic;
    req.settings.video_preload_large = preset.preloadVideo;
    req.settings.phonecalls_less_data = preset.lessCallData;
    req.settings.video_upload_maxbitrate = preset.maxVideoBitrate;
    req.settings.disabled = !enabled;
    boolean photo = false;
    boolean video = false;
    boolean document = false;
    for (int a = 0; a < preset.mask.length; a++) {
        if ((preset.mask[a] & AUTODOWNLOAD_TYPE_PHOTO) != 0) {
            photo = true;
        }
        if ((preset.mask[a] & AUTODOWNLOAD_TYPE_VIDEO) != 0) {
            video = true;
        }
        if ((preset.mask[a] & AUTODOWNLOAD_TYPE_DOCUMENT) != 0) {
            document = true;
        }
        if (photo && video && document) {
            break;
        }
    }
    req.settings.photo_size_max = photo ? preset.sizes[PRESET_SIZE_NUM_PHOTO] : 0;
    req.settings.video_size_max = video ? preset.sizes[PRESET_SIZE_NUM_VIDEO] : 0;
    req.settings.file_size_max = document ? preset.sizes[PRESET_SIZE_NUM_DOCUMENT] : 0;
    getConnectionsManager().sendRequest(req, (response, error) -> {

    });
}
 
Example 4
Source File: DownloadController.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void savePresetToServer(int type) {
    TLRPC.TL_account_saveAutoDownloadSettings req = new TLRPC.TL_account_saveAutoDownloadSettings();
    Preset preset;
    boolean enabled;
    if (type == 0) {
        preset = getCurrentMobilePreset();
        enabled = mobilePreset.enabled;
    } else if (type == 1) {
        preset = getCurrentWiFiPreset();
        enabled = wifiPreset.enabled;
    } else {
        preset = getCurrentRoamingPreset();
        enabled = roamingPreset.enabled;
    }
    req.settings = new TLRPC.TL_autoDownloadSettings();
    req.settings.audio_preload_next = preset.preloadMusic;
    req.settings.video_preload_large = preset.preloadVideo;
    req.settings.phonecalls_less_data = preset.lessCallData;
    req.settings.video_upload_maxbitrate = preset.maxVideoBitrate;
    req.settings.disabled = !enabled;
    boolean photo = false;
    boolean video = false;
    boolean document = false;
    for (int a = 0; a < preset.mask.length; a++) {
        if ((preset.mask[a] & AUTODOWNLOAD_TYPE_PHOTO) != 0) {
            photo = true;
        }
        if ((preset.mask[a] & AUTODOWNLOAD_TYPE_VIDEO) != 0) {
            video = true;
        }
        if ((preset.mask[a] & AUTODOWNLOAD_TYPE_DOCUMENT) != 0) {
            document = true;
        }
        if (photo && video && document) {
            break;
        }
    }
    req.settings.photo_size_max = photo ? preset.sizes[PRESET_SIZE_NUM_PHOTO] : 0;
    req.settings.video_size_max = video ? preset.sizes[PRESET_SIZE_NUM_VIDEO] : 0;
    req.settings.file_size_max = document ? preset.sizes[PRESET_SIZE_NUM_DOCUMENT] : 0;
    getConnectionsManager().sendRequest(req, (response, error) -> {

    });
}