Java Code Examples for org.telegram.messenger.AndroidUtilities#getWallpaperRotation()

The following examples show how to use org.telegram.messenger.AndroidUtilities#getWallpaperRotation() . 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
public String getUrl() {
    String color2 = gradientColor != 0 ? String.format("%02x%02x%02x", (byte) (gradientColor >> 16) & 0xff, (byte) (gradientColor >> 8) & 0xff, (byte) (gradientColor & 0xff)).toLowerCase() : null;
    String color1 = String.format("%02x%02x%02x", (byte) (color >> 16) & 0xff, (byte) (color >> 8) & 0xff, (byte) (color & 0xff)).toLowerCase();
    if (color2 != null) {
        color1 += "-" + color2;
        if (pattern != null) {
            color1 += "&rotation=" + AndroidUtilities.getWallpaperRotation(gradientRotation, true);
        } else {
            color1 += "?rotation=" + AndroidUtilities.getWallpaperRotation(gradientRotation, true);
        }
    }
    if (pattern != null) {
        String link = "https://" + MessagesController.getInstance(UserConfig.selectedAccount).linkPrefix + "/bg/" + pattern.slug + "?intensity=" + (int) (intensity * 100) + "&bg_color=" + color1;
        if (motion) {
            link += "&mode=motion";
        }
        return link;
    } else {
        return "https://" + MessagesController.getInstance(UserConfig.selectedAccount).linkPrefix + "/bg/" + color1;
    }
}
 
Example 2
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public String getUrl() {
    String color2 = gradientColor != 0 ? String.format("%02x%02x%02x", (byte) (gradientColor >> 16) & 0xff, (byte) (gradientColor >> 8) & 0xff, (byte) (gradientColor & 0xff)).toLowerCase() : null;
    String color1 = String.format("%02x%02x%02x", (byte) (color >> 16) & 0xff, (byte) (color >> 8) & 0xff, (byte) (color & 0xff)).toLowerCase();
    if (color2 != null) {
        color1 += "-" + color2;
        if (pattern != null) {
            color1 += "&rotation=" + AndroidUtilities.getWallpaperRotation(gradientRotation, true);
        } else {
            color1 += "?rotation=" + AndroidUtilities.getWallpaperRotation(gradientRotation, true);
        }
    }
    if (pattern != null) {
        String link = "https://" + MessagesController.getInstance(UserConfig.selectedAccount).linkPrefix + "/bg/" + pattern.slug + "?intensity=" + (int) (intensity * 100) + "&bg_color=" + color1;
        if (motion) {
            link += "&mode=motion";
        }
        return link;
    } else {
        return "https://" + MessagesController.getInstance(UserConfig.selectedAccount).linkPrefix + "/bg/" + color1;
    }
}
 
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;
        }
    }
}