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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_wallPaper . 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: WallpapersListActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private boolean onItemLongClick(WallpaperCell view, Object object, int index) {
    if (actionBar.isActionModeShowed() || getParentActivity() == null || !(object instanceof TLRPC.TL_wallPaper)) {
        return false;
    }
    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) object;
    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
    selectedWallPapers.put(wallPaper.id, wallPaper);
    selectedMessagesCountTextView.setNumber(1, false);
    AnimatorSet animatorSet = new AnimatorSet();
    ArrayList<Animator> animators = new ArrayList<>();
    for (int i = 0; i < actionModeViews.size(); i++) {
        View view2 = actionModeViews.get(i);
        AndroidUtilities.clearDrawableAnimation(view2);
        animators.add(ObjectAnimator.ofFloat(view2, View.SCALE_Y, 0.1f, 1.0f));
    }
    animatorSet.playTogether(animators);
    animatorSet.setDuration(250);
    animatorSet.start();
    scrolling = false;
    actionBar.showActionMode();
    view.setChecked(index, true, true);
    return true;
}
 
Example 2
Source File: ThemePreviewActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void selectPattern(int position) {
    TLRPC.TL_wallPaper wallPaper;
    if (position >= 0 && position < patterns.size()) {
        wallPaper = (TLRPC.TL_wallPaper) patterns.get(position);
    } else {
        wallPaper = lastSelectedPattern;
    }
    if (wallPaper == null) {
        return;
    }
    backgroundImage.setImage(ImageLocation.getForDocument(wallPaper.document), imageFilter, null, null, "jpg", wallPaper.document.size, 1, wallPaper);
    selectedPattern = wallPaper;
    if (screenType == SCREEN_TYPE_ACCENT_COLOR) {
        isMotion = checkBoxView[0].isChecked();
    } else {
        isMotion = checkBoxView[2].isChecked();
    }
    updateButtonState(false, true);
}
 
Example 3
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private boolean onItemLongClick(WallpaperCell view, Object object, int index) {
    if (actionBar.isActionModeShowed() || getParentActivity() == null || !(object instanceof TLRPC.TL_wallPaper)) {
        return false;
    }
    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) object;
    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
    selectedWallPapers.put(wallPaper.id, wallPaper);
    selectedMessagesCountTextView.setNumber(1, false);
    AnimatorSet animatorSet = new AnimatorSet();
    ArrayList<Animator> animators = new ArrayList<>();
    for (int i = 0; i < actionModeViews.size(); i++) {
        View view2 = actionModeViews.get(i);
        AndroidUtilities.clearDrawableAnimation(view2);
        animators.add(ObjectAnimator.ofFloat(view2, View.SCALE_Y, 0.1f, 1.0f));
    }
    animatorSet.playTogether(animators);
    animatorSet.setDuration(250);
    animatorSet.start();
    scrolling = false;
    actionBar.showActionMode();
    view.setChecked(index, true, true);
    return true;
}
 
Example 4
Source File: DocumentObject.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public ThemeDocument(TLRPC.TL_themeSettings settings) {
    themeSettings = settings;
    baseTheme = Theme.getTheme(Theme.getBaseThemeKey(settings));
    accent = baseTheme.createNewAccent(settings);
    if (themeSettings.wallpaper instanceof TLRPC.TL_wallPaper) {
        TLRPC.TL_wallPaper object = (TLRPC.TL_wallPaper) themeSettings.wallpaper;
        wallpaper = object.document;
        id = wallpaper.id;
        access_hash = wallpaper.access_hash;
        file_reference = wallpaper.file_reference;
        user_id = wallpaper.user_id;
        date = wallpaper.date;
        file_name = wallpaper.file_name;
        mime_type = wallpaper.mime_type;
        size = wallpaper.size;
        thumbs = wallpaper.thumbs;
        version = wallpaper.version;
        dc_id = wallpaper.dc_id;
        key = wallpaper.key;
        iv = wallpaper.iv;
        attributes = wallpaper.attributes;
    } else {
        id = Integer.MIN_VALUE;
        dc_id = Integer.MIN_VALUE;
    }
}
 
Example 5
Source File: ThemePreviewActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void selectPattern(int position) {
    TLRPC.TL_wallPaper wallPaper;
    if (position >= 0 && position < patterns.size()) {
        wallPaper = (TLRPC.TL_wallPaper) patterns.get(position);
    } else {
        wallPaper = lastSelectedPattern;
    }
    if (wallPaper == null) {
        return;
    }
    backgroundImage.setImage(ImageLocation.getForDocument(wallPaper.document), imageFilter, null, null, "jpg", wallPaper.document.size, 1, wallPaper);
    selectedPattern = wallPaper;
    if (screenType == SCREEN_TYPE_ACCENT_COLOR) {
        isMotion = checkBoxView[0].isChecked();
    } else {
        isMotion = checkBoxView[2].isChecked();
    }
    updateButtonState(false, true);
}
 
Example 6
Source File: ThemePreviewActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setPatterns(ArrayList<Object> arrayList) {
    patterns = arrayList;
    if (screenType == SCREEN_TYPE_ACCENT_COLOR || currentWallpaper instanceof WallpapersListActivity.ColorWallpaper) {
        WallpapersListActivity.ColorWallpaper wallPaper = (WallpapersListActivity.ColorWallpaper) currentWallpaper;
        if (wallPaper.patternId != 0) {
            for (int a = 0, N = patterns.size(); a < N; a++) {
                TLRPC.TL_wallPaper pattern = (TLRPC.TL_wallPaper) patterns.get(a);
                if (pattern.id == wallPaper.patternId) {
                    selectedPattern = pattern;
                    break;
                }
            }
            currentIntensity = wallPaper.intensity;
        }
    }
}
 
Example 7
Source File: DocumentObject.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public ThemeDocument(TLRPC.TL_themeSettings settings) {
    themeSettings = settings;
    baseTheme = Theme.getTheme(Theme.getBaseThemeKey(settings));
    accent = baseTheme.createNewAccent(settings);
    if (themeSettings.wallpaper instanceof TLRPC.TL_wallPaper) {
        TLRPC.TL_wallPaper object = (TLRPC.TL_wallPaper) themeSettings.wallpaper;
        wallpaper = object.document;
        id = wallpaper.id;
        access_hash = wallpaper.access_hash;
        file_reference = wallpaper.file_reference;
        user_id = wallpaper.user_id;
        date = wallpaper.date;
        file_name = wallpaper.file_name;
        mime_type = wallpaper.mime_type;
        size = wallpaper.size;
        thumbs = wallpaper.thumbs;
        version = wallpaper.version;
        dc_id = wallpaper.dc_id;
        key = wallpaper.key;
        iv = wallpaper.iv;
        attributes = wallpaper.attributes;
    } else {
        id = Integer.MIN_VALUE;
        dc_id = Integer.MIN_VALUE;
    }
}
 
Example 8
Source File: PatternCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setPattern(TLRPC.TL_wallPaper wallPaper) {
    currentPattern = wallPaper;
    if (wallPaper != null) {
        TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(wallPaper.document.thumbs, 100);
        setImage(ImageLocation.getForDocument(thumb, wallPaper.document), "100_100", null, null, "jpg", 0, 1, wallPaper);
    } else {
        setImageDrawable(null);
    }
    updateSelected(false);
}
 
Example 9
Source File: PatternCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updateSelected(boolean animated) {
    TLRPC.TL_wallPaper selectedPattern = delegate.getSelectedPattern();
    boolean isSelected = currentPattern == null && selectedPattern == null || selectedPattern != null && currentPattern != null && currentPattern.id == selectedPattern.id;
    if (isSelected) {
        updateButtonState(selectedPattern, false, animated);
    } else {
        radialProgress.setIcon(MediaActionDrawable.ICON_NONE, false, animated);
    }
    invalidate();
}
 
Example 10
Source File: WallpapersListActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.wallpapersDidLoad) {
        ArrayList<TLRPC.TL_wallPaper> arrayList = (ArrayList<TLRPC.TL_wallPaper>) args[0];
        patterns.clear();
        if (currentType != TYPE_COLOR) {
            wallPapers.clear();
            allWallPapers.clear();
            allWallPapersDict.clear();
            allWallPapers.addAll(arrayList);
        }
        for (int a = 0, N = arrayList.size(); a < N; a++) {
            TLRPC.TL_wallPaper wallPaper = arrayList.get(a);
            if (wallPaper.pattern) {
                patterns.add(wallPaper);
            }
            if (currentType != TYPE_COLOR && (!wallPaper.pattern || wallPaper.settings != null && wallPaper.settings.background_color != 0)) {
                allWallPapersDict.put(wallPaper.slug, wallPaper);
                wallPapers.add(wallPaper);
            }
        }
        selectedBackgroundSlug = Theme.getSelectedBackgroundSlug();
        fillWallpapersWithCustom();
        loadWallpapers();
    } else if (id == NotificationCenter.didSetNewWallpapper) {
        if (listView != null) {
            listView.invalidateViews();
        }
        if (actionBar != null) {
            actionBar.closeSearchField();
        }
    } else if (id == NotificationCenter.wallpapersNeedReload) {
        MessagesStorage.getInstance(currentAccount).getWallpapers();
    }
}
 
Example 11
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private String getWallPaperSlug(Object object) {
    if (object instanceof TLRPC.TL_wallPaper) {
        return ((TLRPC.TL_wallPaper) object).slug;
    } else if (object instanceof ColorWallpaper) {
        return ((ColorWallpaper) object).slug;
    } else if (object instanceof FileWallpaper) {
        return ((FileWallpaper) object).slug;
    } else {
        return null;
    }
}
 
Example 12
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.wallpapersDidLoad) {
        ArrayList<TLRPC.TL_wallPaper> arrayList = (ArrayList<TLRPC.TL_wallPaper>) args[0];
        patterns.clear();
        if (currentType != TYPE_COLOR) {
            wallPapers.clear();
            allWallPapers.clear();
            allWallPapersDict.clear();
            allWallPapers.addAll(arrayList);
        }
        for (int a = 0, N = arrayList.size(); a < N; a++) {
            TLRPC.TL_wallPaper wallPaper = arrayList.get(a);
            if (wallPaper.pattern) {
                patterns.add(wallPaper);
            }
            if (currentType != TYPE_COLOR && (!wallPaper.pattern || wallPaper.settings != null && wallPaper.settings.background_color != 0)) {
                allWallPapersDict.put(wallPaper.slug, wallPaper);
                wallPapers.add(wallPaper);
            }
        }
        selectedBackgroundSlug = Theme.getSelectedBackgroundSlug();
        fillWallpapersWithCustom();
        loadWallpapers();
    } else if (id == NotificationCenter.didSetNewWallpapper) {
        if (listView != null) {
            listView.invalidateViews();
        }
        if (actionBar != null) {
            actionBar.closeSearchField();
        }
    } else if (id == NotificationCenter.wallpapersNeedReload) {
        MessagesStorage.getInstance(currentAccount).getWallpapers();
    }
}
 
Example 13
Source File: PatternCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setPattern(TLRPC.TL_wallPaper wallPaper) {
    currentPattern = wallPaper;
    if (wallPaper != null) {
        TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(wallPaper.document.thumbs, 100);
        setImage(ImageLocation.getForDocument(thumb, wallPaper.document), "100_100", null, null, "jpg", 0, 1, wallPaper);
    } else {
        setImageDrawable(null);
    }
    updateSelected(false);
}
 
Example 14
Source File: PatternCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void updateSelected(boolean animated) {
    TLRPC.TL_wallPaper selectedPattern = delegate.getSelectedPattern();
    boolean isSelected = currentPattern == null && selectedPattern == null || selectedPattern != null && currentPattern != null && currentPattern.id == selectedPattern.id;
    if (isSelected) {
        updateButtonState(selectedPattern, false, animated);
    } else {
        radialProgress.setIcon(MediaActionDrawable.ICON_NONE, false, animated);
    }
    invalidate();
}
 
Example 15
Source File: WallpapersListActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            TextCell textCell = (TextCell) holder.itemView;
            if (position == uploadImageRow) {
                textCell.setTextAndIcon(LocaleController.getString("SelectFromGallery", R.string.SelectFromGallery), R.drawable.profile_photos, true);
            } else if (position == setColorRow) {
                textCell.setTextAndIcon(LocaleController.getString("SetColor", R.string.SetColor), R.drawable.menu_palette, false);
            } else if (position == resetRow) {
                textCell.setText(LocaleController.getString("ResetChatBackgrounds", R.string.ResetChatBackgrounds), false);
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            if (position == resetInfoRow) {
                cell.setText(LocaleController.getString("ResetChatBackgroundsInfo", R.string.ResetChatBackgroundsInfo));
            }
            break;
        }
        case 2: {
            WallpaperCell wallpaperCell = (WallpaperCell) holder.itemView;
            position = (position - wallPaperStartRow) * columnsCount;
            wallpaperCell.setParams(columnsCount, position == 0, position / columnsCount == totalWallpaperRows - 1);
            for (int a = 0; a < columnsCount; a++) {
                int p = position + a;
                Object object = p < wallPapers.size() ? wallPapers.get(p) : null;
                String slugFinal;
                long id;
                if (object instanceof TLRPC.TL_wallPaper) {
                    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) object;
                    Theme.OverrideWallpaperInfo info = Theme.getActiveTheme().overrideWallpaper;
                    if (selectedBackgroundSlug.equals(wallPaper.slug) && wallPaper.settings != null &&
                            (selectedColor != wallPaper.settings.background_color ||
                            selectedGradientColor != wallPaper.settings.second_background_color ||
                            (selectedGradientColor != 0 && selectedGradientRotation != AndroidUtilities.getWallpaperRotation(wallPaper.settings.rotation, false)) &&
                            (wallPaper.settings.intensity - selectedIntensity) > 0.001f)) {
                        slugFinal = "";
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = wallPaper.id;
                } else {
                    if (object instanceof ColorWallpaper) {
                        ColorWallpaper colorWallpaper = (ColorWallpaper) object;
                        if (colorWallpaper.color != selectedColor || colorWallpaper.gradientColor != selectedGradientColor) {
                            slugFinal = "";
                        } else {
                            slugFinal = selectedBackgroundSlug;
                        }
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = 0;
                }
                wallpaperCell.setWallpaper(currentType, a, object, slugFinal, null, false);
                if (actionBar.isActionModeShowed()) {
                    wallpaperCell.setChecked(a, selectedWallPapers.indexOfKey(id) >= 0, !scrolling);
                } else {
                    wallpaperCell.setChecked(a, false, !scrolling);
                }
            }
            break;
        }
    }
}
 
Example 16
Source File: ThemePreviewActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    PatternCell view = new PatternCell(mContext, maxWallpaperSize, new PatternCell.PatternCellDelegate() {
        @Override
        public TLRPC.TL_wallPaper getSelectedPattern() {
            return selectedPattern;
        }

        @Override
        public int getPatternColor() {
            return patternColor;
        }

        @Override
        public int getBackgroundColor() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundColor;
            }
            int defaultBackground = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper);
            int backgroundOverrideColor = (int) accent.backgroundOverrideColor;
            return backgroundOverrideColor != 0 ? backgroundOverrideColor : defaultBackground;
        }

        @Override
        public int getBackgroundGradientColor() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundGradientColor;
            }
            int defaultBackgroundGradient = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to);
            int backgroundGradientOverrideColor = (int) accent.backgroundGradientOverrideColor;
            return backgroundGradientOverrideColor != 0 ? backgroundGradientOverrideColor : defaultBackgroundGradient;
        }

        @Override
        public int getBackgroundGradientAngle() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundRotation;
            }
            return accent.backgroundRotation;
        }
    });
    return new RecyclerListView.Holder(view);
}
 
Example 17
Source File: ThemePreviewActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    PatternCell view = new PatternCell(mContext, maxWallpaperSize, new PatternCell.PatternCellDelegate() {
        @Override
        public TLRPC.TL_wallPaper getSelectedPattern() {
            return selectedPattern;
        }

        @Override
        public int getPatternColor() {
            return patternColor;
        }

        @Override
        public int getBackgroundColor() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundColor;
            }
            int defaultBackground = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper);
            int backgroundOverrideColor = (int) accent.backgroundOverrideColor;
            return backgroundOverrideColor != 0 ? backgroundOverrideColor : defaultBackground;
        }

        @Override
        public int getBackgroundGradientColor() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundGradientColor;
            }
            int defaultBackgroundGradient = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to);
            int backgroundGradientOverrideColor = (int) accent.backgroundGradientOverrideColor;
            return backgroundGradientOverrideColor != 0 ? backgroundGradientOverrideColor : defaultBackgroundGradient;
        }

        @Override
        public int getBackgroundGradientAngle() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundRotation;
            }
            return accent.backgroundRotation;
        }
    });
    return new RecyclerListView.Holder(view);
}
 
Example 18
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            TextCell textCell = (TextCell) holder.itemView;
            if (position == uploadImageRow) {
                textCell.setTextAndIcon(LocaleController.getString("SelectFromGallery", R.string.SelectFromGallery), R.drawable.profile_photos, true);
            } else if (position == setColorRow) {
                textCell.setTextAndIcon(LocaleController.getString("SetColor", R.string.SetColor), R.drawable.menu_palette, false);
            } else if (position == resetRow) {
                textCell.setText(LocaleController.getString("ResetChatBackgrounds", R.string.ResetChatBackgrounds), false);
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            if (position == resetInfoRow) {
                cell.setText(LocaleController.getString("ResetChatBackgroundsInfo", R.string.ResetChatBackgroundsInfo));
            }
            break;
        }
        case 2: {
            WallpaperCell wallpaperCell = (WallpaperCell) holder.itemView;
            position = (position - wallPaperStartRow) * columnsCount;
            wallpaperCell.setParams(columnsCount, position == 0, position / columnsCount == totalWallpaperRows - 1);
            for (int a = 0; a < columnsCount; a++) {
                int p = position + a;
                Object object = p < wallPapers.size() ? wallPapers.get(p) : null;
                String slugFinal;
                long id;
                if (object instanceof TLRPC.TL_wallPaper) {
                    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) object;
                    Theme.OverrideWallpaperInfo info = Theme.getActiveTheme().overrideWallpaper;
                    if (selectedBackgroundSlug.equals(wallPaper.slug) && wallPaper.settings != null &&
                            (selectedColor != wallPaper.settings.background_color ||
                            selectedGradientColor != wallPaper.settings.second_background_color ||
                            (selectedGradientColor != 0 && selectedGradientRotation != AndroidUtilities.getWallpaperRotation(wallPaper.settings.rotation, false)) &&
                            (wallPaper.settings.intensity - selectedIntensity) > 0.001f)) {
                        slugFinal = "";
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = wallPaper.id;
                } else {
                    if (object instanceof ColorWallpaper) {
                        ColorWallpaper colorWallpaper = (ColorWallpaper) object;
                        if (colorWallpaper.color != selectedColor || colorWallpaper.gradientColor != selectedGradientColor) {
                            slugFinal = "";
                        } else {
                            slugFinal = selectedBackgroundSlug;
                        }
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = 0;
                }
                wallpaperCell.setWallpaper(currentType, a, object, slugFinal, null, false);
                if (actionBar.isActionModeShowed()) {
                    wallpaperCell.setChecked(a, selectedWallPapers.indexOfKey(id) >= 0, !scrolling);
                } else {
                    wallpaperCell.setChecked(a, false, !scrolling);
                }
            }
            break;
        }
    }
}
 
Example 19
Source File: PatternCell.java    From Telegram-FOSS with GNU General Public License v2.0 votes vote down vote up
TLRPC.TL_wallPaper getSelectedPattern(); 
Example 20
Source File: PatternCell.java    From Telegram with GNU General Public License v2.0 votes vote down vote up
TLRPC.TL_wallPaper getSelectedPattern();