Java Code Examples for org.telegram.ui.ActionBar.Theme#OverrideWallpaperInfo

The following examples show how to use org.telegram.ui.ActionBar.Theme#OverrideWallpaperInfo . 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
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    Theme.ThemeInfo themeInfo = Theme.getActiveTheme();
    Theme.OverrideWallpaperInfo overrideWallpaper = themeInfo.overrideWallpaper;
    if (overrideWallpaper != null) {
        selectedBackgroundSlug = overrideWallpaper.slug;
        selectedColor = overrideWallpaper.color;
        selectedGradientColor = overrideWallpaper.gradientColor;
        selectedGradientRotation = overrideWallpaper.rotation;
        selectedIntensity = overrideWallpaper.intensity;
        selectedBackgroundMotion = overrideWallpaper.isMotion;
        selectedBackgroundBlurred = overrideWallpaper.isBlurred;
    } else {
        selectedBackgroundSlug = Theme.hasWallpaperFromTheme() ? Theme.THEME_BACKGROUND_SLUG :  Theme.DEFAULT_BACKGROUND_SLUG;
        selectedColor = 0;
        selectedGradientColor = 0;
        selectedGradientRotation = 45;
        selectedIntensity = 1.0f;
        selectedBackgroundMotion = false;
        selectedBackgroundBlurred = false;
    }
    fillWallpapersWithCustom();
    fixLayout();
}
 
Example 2
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    Theme.ThemeInfo themeInfo = Theme.getActiveTheme();
    Theme.OverrideWallpaperInfo overrideWallpaper = themeInfo.overrideWallpaper;
    if (overrideWallpaper != null) {
        selectedBackgroundSlug = overrideWallpaper.slug;
        selectedColor = overrideWallpaper.color;
        selectedGradientColor = overrideWallpaper.gradientColor;
        selectedGradientRotation = overrideWallpaper.rotation;
        selectedIntensity = overrideWallpaper.intensity;
        selectedBackgroundMotion = overrideWallpaper.isMotion;
        selectedBackgroundBlurred = overrideWallpaper.isBlurred;
    } else {
        selectedBackgroundSlug = Theme.hasWallpaperFromTheme() ? Theme.THEME_BACKGROUND_SLUG :  Theme.DEFAULT_BACKGROUND_SLUG;
        selectedColor = 0;
        selectedGradientColor = 0;
        selectedGradientRotation = 45;
        selectedIntensity = 1.0f;
        selectedBackgroundMotion = false;
        selectedBackgroundBlurred = false;
    }
    fillWallpapersWithCustom();
    fixLayout();
}
 
Example 3
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 4
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;
        }
    }
}