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);
}
}
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();
}
}
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);
}
}
}
}
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);
}
}
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();
}
Aggregations