Search in sources :

Example 1 with ThemeEditorView

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

the class BubbleActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    ThemeEditorView editorView = ThemeEditorView.getInstance();
    if (editorView != null) {
        editorView.onActivityResult(requestCode, resultCode, data);
    }
    if (actionBarLayout.fragmentsStack.size() != 0) {
        BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
        fragment.onActivityResultFragment(requestCode, resultCode, data);
    }
}
Also used : ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) BaseFragment(org.telegram.ui.ActionBar.BaseFragment)

Example 2 with ThemeEditorView

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

the class LaunchActivity method onConfigurationChanged.

@Override
public void onConfigurationChanged(Configuration newConfig) {
    AndroidUtilities.checkDisplaySize(this, newConfig);
    super.onConfigurationChanged(newConfig);
    checkLayout();
    PipRoundVideoView pipRoundVideoView = PipRoundVideoView.getInstance();
    if (pipRoundVideoView != null) {
        pipRoundVideoView.onConfigurationChanged();
    }
    EmbedBottomSheet embedBottomSheet = EmbedBottomSheet.getInstance();
    if (embedBottomSheet != null) {
        embedBottomSheet.onConfigurationChanged(newConfig);
    }
    PhotoViewer photoViewer = PhotoViewer.getPipInstance();
    if (photoViewer != null) {
        photoViewer.onConfigurationChanged(newConfig);
    }
    ThemeEditorView editorView = ThemeEditorView.getInstance();
    if (editorView != null) {
        editorView.onConfigurationChanged();
    }
    if (Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SYSTEM) {
        Theme.checkAutoNightThemeConditions();
    }
}
Also used : EmbedBottomSheet(org.telegram.ui.Components.EmbedBottomSheet) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView)

Example 3 with ThemeEditorView

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

the class LaunchActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (SharedConfig.passcodeHash.length() != 0 && SharedConfig.lastPauseTime != 0) {
        SharedConfig.lastPauseTime = 0;
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("reset lastPauseTime onActivityResult");
        }
        UserConfig.getInstance(currentAccount).saveConfig(false);
    }
    if (requestCode == 105) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (ApplicationLoader.canDrawOverlays = Settings.canDrawOverlays(this)) {
                if (GroupCallActivity.groupCallInstance != null) {
                    GroupCallActivity.groupCallInstance.dismissInternal();
                }
                AndroidUtilities.runOnUIThread(() -> {
                    GroupCallPip.clearForce();
                    GroupCallPip.updateVisibility(LaunchActivity.this);
                }, 200);
            }
        }
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == SCREEN_CAPTURE_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            VoIPService service = VoIPService.getSharedInstance();
            if (service != null) {
                VideoCapturerDevice.mediaProjectionPermissionResultData = data;
                service.createCaptureDevice(true);
            }
        }
    } else {
        ThemeEditorView editorView = ThemeEditorView.getInstance();
        if (editorView != null) {
            editorView.onActivityResult(requestCode, resultCode, data);
        }
        if (actionBarLayout.fragmentsStack.size() != 0) {
            BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
            fragment.onActivityResultFragment(requestCode, resultCode, data);
        }
        if (AndroidUtilities.isTablet()) {
            if (rightActionBarLayout.fragmentsStack.size() != 0) {
                BaseFragment fragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
                fragment.onActivityResultFragment(requestCode, resultCode, data);
            }
            if (layersActionBarLayout.fragmentsStack.size() != 0) {
                BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1);
                fragment.onActivityResultFragment(requestCode, resultCode, data);
            }
        }
    }
}
Also used : ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) VoIPService(org.telegram.messenger.voip.VoIPService)

Example 4 with ThemeEditorView

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

the class Theme method applyTheme.

private static void applyTheme(ThemeInfo themeInfo, boolean save, boolean removeWallpaperOverride, final boolean nightTheme) {
    if (themeInfo == null) {
        return;
    }
    ThemeEditorView editorView = ThemeEditorView.getInstance();
    if (editorView != null) {
        editorView.destroy();
    }
    try {
        if (themeInfo.pathToFile != null || themeInfo.assetName != null) {
            if (!nightTheme && save) {
                SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                SharedPreferences.Editor editor = preferences.edit();
                editor.putString("theme", themeInfo.getKey());
                editor.commit();
            }
            String[] wallpaperLink = new String[1];
            if (themeInfo.assetName != null) {
                currentColorsNoAccent = getThemeFileValues(null, themeInfo.assetName, null);
            } else {
                currentColorsNoAccent = getThemeFileValues(new File(themeInfo.pathToFile), null, wallpaperLink);
            }
            Integer offset = currentColorsNoAccent.get("wallpaperFileOffset");
            themedWallpaperFileOffset = offset != null ? offset : -1;
            if (!TextUtils.isEmpty(wallpaperLink[0])) {
                themedWallpaperLink = wallpaperLink[0];
                String newPathToFile = new File(ApplicationLoader.getFilesDirFixed(), Utilities.MD5(themedWallpaperLink) + ".wp").getAbsolutePath();
                try {
                    if (themeInfo.pathToWallpaper != null && !themeInfo.pathToWallpaper.equals(newPathToFile)) {
                        new File(themeInfo.pathToWallpaper).delete();
                    }
                } catch (Exception ignore) {
                }
                themeInfo.pathToWallpaper = newPathToFile;
                try {
                    Uri data = Uri.parse(themedWallpaperLink);
                    themeInfo.slug = data.getQueryParameter("slug");
                    String mode = data.getQueryParameter("mode");
                    if (mode != null) {
                        mode = mode.toLowerCase();
                        String[] modes = mode.split(" ");
                        if (modes != null && modes.length > 0) {
                            for (int a = 0; a < modes.length; a++) {
                                if ("blur".equals(modes[a])) {
                                    themeInfo.isBlured = true;
                                } else if ("motion".equals(modes[a])) {
                                    themeInfo.isMotion = true;
                                }
                            }
                        }
                    }
                    int intensity = Utilities.parseInt(data.getQueryParameter("intensity"));
                    themeInfo.patternBgGradientRotation = 45;
                    try {
                        String bgColor = data.getQueryParameter("bg_color");
                        if (!TextUtils.isEmpty(bgColor)) {
                            themeInfo.patternBgColor = Integer.parseInt(bgColor.substring(0, 6), 16) | 0xff000000;
                            if (bgColor.length() >= 13 && AndroidUtilities.isValidWallChar(bgColor.charAt(6))) {
                                themeInfo.patternBgGradientColor1 = Integer.parseInt(bgColor.substring(7, 13), 16) | 0xff000000;
                            }
                            if (bgColor.length() >= 20 && AndroidUtilities.isValidWallChar(bgColor.charAt(13))) {
                                themeInfo.patternBgGradientColor2 = Integer.parseInt(bgColor.substring(14, 20), 16) | 0xff000000;
                            }
                            if (bgColor.length() == 27 && AndroidUtilities.isValidWallChar(bgColor.charAt(20))) {
                                themeInfo.patternBgGradientColor3 = Integer.parseInt(bgColor.substring(21), 16) | 0xff000000;
                            }
                        }
                    } catch (Exception ignore) {
                    }
                    try {
                        String rotation = data.getQueryParameter("rotation");
                        if (!TextUtils.isEmpty(rotation)) {
                            themeInfo.patternBgGradientRotation = Utilities.parseInt(rotation);
                        }
                    } catch (Exception ignore) {
                    }
                } catch (Throwable e) {
                    FileLog.e(e);
                }
            } else {
                try {
                    if (themeInfo.pathToWallpaper != null) {
                        new File(themeInfo.pathToWallpaper).delete();
                    }
                } catch (Exception ignore) {
                }
                themeInfo.pathToWallpaper = null;
                themedWallpaperLink = null;
            }
        } else {
            if (!nightTheme && save) {
                SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                SharedPreferences.Editor editor = preferences.edit();
                editor.remove("theme");
                editor.commit();
            }
            currentColorsNoAccent.clear();
            themedWallpaperFileOffset = 0;
            themedWallpaperLink = null;
            wallpaper = null;
            themedWallpaper = null;
        }
        if (!nightTheme && previousTheme == null) {
            currentDayTheme = themeInfo;
            if (isCurrentThemeNight()) {
                switchNightThemeDelay = 2000;
                lastDelayUpdateTime = SystemClock.elapsedRealtime();
                AndroidUtilities.runOnUIThread(Theme::checkAutoNightThemeConditions, 2100);
            }
        }
        currentTheme = themeInfo;
        refreshThemeColors();
    } catch (Exception e) {
        FileLog.e(e);
    }
    if (previousTheme == null && save && !switchingNightTheme) {
        MessagesController.getInstance(themeInfo.account).saveTheme(themeInfo, themeInfo.getAccent(false), nightTheme, false);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) File(java.io.File) Uri(android.net.Uri) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 5 with ThemeEditorView

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

the class LaunchActivity method onDestroy.

@Override
protected void onDestroy() {
    if (PhotoViewer.getPipInstance() != null) {
        PhotoViewer.getPipInstance().destroyPhotoViewer();
    }
    if (PhotoViewer.hasInstance()) {
        PhotoViewer.getInstance().destroyPhotoViewer();
    }
    if (SecretMediaViewer.hasInstance()) {
        SecretMediaViewer.getInstance().destroyPhotoViewer();
    }
    if (ArticleViewer.hasInstance()) {
        ArticleViewer.getInstance().destroyArticleViewer();
    }
    if (ContentPreviewViewer.hasInstance()) {
        ContentPreviewViewer.getInstance().destroy();
    }
    if (GroupCallActivity.groupCallInstance != null) {
        GroupCallActivity.groupCallInstance.dismissInternal();
    }
    PipRoundVideoView pipRoundVideoView = PipRoundVideoView.getInstance();
    MediaController.getInstance().setBaseActivity(this, false);
    MediaController.getInstance().setFeedbackView(actionBarLayout, false);
    if (pipRoundVideoView != null) {
        pipRoundVideoView.close(false);
    }
    Theme.destroyResources();
    EmbedBottomSheet embedBottomSheet = EmbedBottomSheet.getInstance();
    if (embedBottomSheet != null) {
        embedBottomSheet.destroy();
    }
    ThemeEditorView editorView = ThemeEditorView.getInstance();
    if (editorView != null) {
        editorView.destroy();
    }
    try {
        if (visibleDialog != null) {
            visibleDialog.dismiss();
            visibleDialog = null;
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
    try {
        if (onGlobalLayoutListener != null) {
            final View view = getWindow().getDecorView().getRootView();
            view.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
    super.onDestroy();
    onFinish();
}
Also used : EmbedBottomSheet(org.telegram.ui.Components.EmbedBottomSheet) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) ImageView(android.widget.ImageView) UndoView(org.telegram.ui.Components.UndoView) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) PasscodeView(org.telegram.ui.Components.PasscodeView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TermsOfServiceView(org.telegram.ui.Components.TermsOfServiceView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BlockingUpdateView(org.telegram.ui.Components.BlockingUpdateView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ParseException(java.text.ParseException)

Aggregations

ThemeEditorView (org.telegram.ui.Components.ThemeEditorView)5 BaseFragment (org.telegram.ui.ActionBar.BaseFragment)2 EmbedBottomSheet (org.telegram.ui.Components.EmbedBottomSheet)2 PipRoundVideoView (org.telegram.ui.Components.PipRoundVideoView)2 SuppressLint (android.annotation.SuppressLint)1 SharedPreferences (android.content.SharedPreferences)1 Paint (android.graphics.Paint)1 Uri (android.net.Uri)1 TextPaint (android.text.TextPaint)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 File (java.io.File)1 ParseException (java.text.ParseException)1 VoIPService (org.telegram.messenger.voip.VoIPService)1 SimpleTextView (org.telegram.ui.ActionBar.SimpleTextView)1 BlockingUpdateView (org.telegram.ui.Components.BlockingUpdateView)1 PasscodeView (org.telegram.ui.Components.PasscodeView)1 RLottieImageView (org.telegram.ui.Components.RLottieImageView)1