update to 10.1.1 (3926)

This commit is contained in:
xaxtix 2023-09-23 22:46:49 +04:00
parent 750eedfc96
commit fea5ca949a
55 changed files with 680 additions and 277 deletions

View file

@ -34,10 +34,11 @@ CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && \
cd /home/gradle && \ cd /home/gradle && \
gradle :TMessagesProj_App:bundleBundleAfat_SDK23Release && \ gradle :TMessagesProj_App:bundleBundleAfat_SDK23Release && \
gradle :TMessagesProj_App:bundleBundleAfatRelease && \ gradle :TMessagesProj_App:bundleBundleAfatRelease && \
gradle :TMessagesProj_App:assembleAfatStandalone && \ gradle :TMessagesProj_AppStandalone:assembleAfatStandalone && \
gradle :TMessagesProj_App:assembleAfatRelease && \ gradle :TMessagesProj_App:assembleAfatRelease && \
gradle :TMessagesProj_AppHuawei:assembleAfatRelease && \ gradle :TMessagesProj_AppHuawei:assembleAfatRelease && \
cp -R /home/gradle/TMessagesProj_App/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && \ cp -R /home/gradle/TMessagesProj_App/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && \
cp -R /home/gradle/TMessagesProj_AppHuawei/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && \ cp -R /home/gradle/TMessagesProj_AppHuawei/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && \
cp -R /home/gradle/TMessagesProj_AppStandalone/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && \
cp -R /home/gradle/TMessagesProj_App/build/outputs/bundle/. /home/source/TMessagesProj/build/outputs/bundle && \ cp -R /home/gradle/TMessagesProj_App/build/outputs/bundle/. /home/source/TMessagesProj/build/outputs/bundle && \
cp -R /home/gradle/TMessagesProj_App/build/outputs/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols cp -R /home/gradle/TMessagesProj_App/build/outputs/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols

View file

@ -24,8 +24,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 3919; public static int BUILD_VERSION = 3926;
public static String BUILD_VERSION_STRING = "10.1.0"; public static String BUILD_VERSION_STRING = "10.1.1";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -1046,13 +1046,14 @@ public class FileRefController extends BaseController {
TLRPC.TL_stories_stories stories = (TLRPC.TL_stories_stories) response; TLRPC.TL_stories_stories stories = (TLRPC.TL_stories_stories) response;
TLRPC.StoryItem newStoryItem = null; TLRPC.StoryItem newStoryItem = null;
if (!stories.stories.isEmpty()) { if (!stories.stories.isEmpty()) {
if (stories.stories.get(0).media != null) { TLRPC.StoryItem storyItem = stories.stories.get(0);
newStoryItem = stories.stories.get(0); if (storyItem.media != null) {
if (stories.stories.get(0).media.photo != null) { newStoryItem = storyItem;
result = getFileReference(stories.stories.get(0).media.photo, requester.location, needReplacement, locationReplacement); if (storyItem.media.photo != null) {
result = getFileReference(storyItem.media.photo, requester.location, needReplacement, locationReplacement);
} }
if (stories.stories.get(0).media.document != null) { if (storyItem.media.document != null) {
result = getFileReference(stories.stories.get(0).media.document, requester.location, needReplacement, locationReplacement); result = getFileReference(storyItem.media.document, requester.location, needReplacement, locationReplacement);
} }
} }
} }
@ -1075,6 +1076,14 @@ public class FileRefController extends BaseController {
MessagesController.getInstance(currentAccount).getStoriesController().getStoriesStorage().updateStoryItem(storyItem.dialogId, newStoryItem); MessagesController.getInstance(currentAccount).getStoriesController().getStoriesStorage().updateStoryItem(storyItem.dialogId, newStoryItem);
} }
} }
if (newStoryItem != null && result == null) {
TLRPC.TL_updateStory updateStory = new TLRPC.TL_updateStory();
updateStory.peer = MessagesController.getInstance(currentAccount).getPeer(storyItem.dialogId);
updateStory.story = newStoryItem;
ArrayList<TLRPC.Update> updates = new ArrayList<>();
updates.add(updateStory);
MessagesController.getInstance(currentAccount).processUpdateArray(updates, null, null, false, 0);
}
} }
} }
} }

View file

@ -294,7 +294,7 @@ public class NotificationCenter {
public static final int uploadStoryEnd = totalEvents++; public static final int uploadStoryEnd = totalEvents++;
public static final int customTypefacesLoaded = totalEvents++; public static final int customTypefacesLoaded = totalEvents++;
public static final int stealthModeChanged = totalEvents++; public static final int stealthModeChanged = totalEvents++;
public static final int onReceivedChannelDifference = totalEvents++; public static final int onReceivedChannelDifference = totalEvents++;;
public static boolean alreadyLogged; public static boolean alreadyLogged;

View file

@ -44,6 +44,7 @@ import android.media.AudioManager;
import android.media.SoundPool; import android.media.SoundPool;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Looper;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.provider.Settings; import android.provider.Settings;
@ -284,6 +285,24 @@ public class NotificationsController extends BaseController {
private static final LongSparseArray<String> sharedPrefCachedKeys = new LongSparseArray<>(); private static final LongSparseArray<String> sharedPrefCachedKeys = new LongSparseArray<>();
public static String getSharedPrefKey(long dialog_id, int topicId) { public static String getSharedPrefKey(long dialog_id, int topicId) {
return getSharedPrefKey(dialog_id, topicId, false);
}
public static String getSharedPrefKey(long dialog_id, int topicId, boolean backgroundThread) {
if (backgroundThread) {
String key;
if (topicId != 0) {
key = String.format(Locale.US, "%d_%d",dialog_id, topicId);
} else {
key = String.valueOf(dialog_id);
}
return key;
}
// if (BuildVars.DEBUG_PRIVATE_VERSION) {
// if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
// throw new IllegalStateException("Not on main thread!");
// }
// }
long hash = dialog_id + ((long) topicId << 12); long hash = dialog_id + ((long) topicId << 12);
int index = sharedPrefCachedKeys.indexOfKey(hash); int index = sharedPrefCachedKeys.indexOfKey(hash);
if (index >= 0) { if (index >= 0) {

View file

@ -25,12 +25,12 @@ public class NotificationsSettingsFacade {
public boolean isDefault(long dialogId, int topicId) { public boolean isDefault(long dialogId, int topicId) {
String key = NotificationsController.getSharedPrefKey(dialogId, topicId); String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
return false; return false;
} }
public void clearPreference(long dialogId, int topicId) { public void clearPreference(long dialogId, int topicId) {
String key = NotificationsController.getSharedPrefKey(dialogId, topicId); String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
getPreferences().edit() getPreferences().edit()
.remove(PROPERTY_NOTIFY + key) .remove(PROPERTY_NOTIFY + key)
.remove(PROPERTY_CUSTOM + key) .remove(PROPERTY_CUSTOM + key)
@ -44,20 +44,20 @@ public class NotificationsSettingsFacade {
public int getProperty(String property, long dialogId, int topicId, int defaultValue) { public int getProperty(String property, long dialogId, int topicId, int defaultValue) {
String key = NotificationsController.getSharedPrefKey(dialogId, topicId); String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
if (getPreferences().contains(property + key)) { if (getPreferences().contains(property + key)) {
return getPreferences().getInt(property + key, defaultValue); return getPreferences().getInt(property + key, defaultValue);
} }
key = NotificationsController.getSharedPrefKey(dialogId, 0); key = NotificationsController.getSharedPrefKey(dialogId, 0, true);
return getPreferences().getInt(property + key, defaultValue); return getPreferences().getInt(property + key, defaultValue);
} }
public long getProperty(String property, long dialogId, int topicId, long defaultValue) { public long getProperty(String property, long dialogId, int topicId, long defaultValue) {
String key = NotificationsController.getSharedPrefKey(dialogId, topicId); String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
if (getPreferences().contains(property + key)) { if (getPreferences().contains(property + key)) {
return getPreferences().getLong(property + key, defaultValue); return getPreferences().getLong(property + key, defaultValue);
} }
key = NotificationsController.getSharedPrefKey(dialogId, 0); key = NotificationsController.getSharedPrefKey(dialogId, 0, true);
return getPreferences().getLong(property + key, defaultValue); return getPreferences().getLong(property + key, defaultValue);
} }
@ -94,7 +94,7 @@ public class NotificationsSettingsFacade {
return; return;
} }
Utilities.globalQueue.postRunnable(() -> { Utilities.globalQueue.postRunnable(() -> {
String key = NotificationsController.getSharedPrefKey(dialogId, topicId); String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
MessagesController messagesController = MessagesController.getInstance(currentAccount); MessagesController messagesController = MessagesController.getInstance(currentAccount);
ConnectionsManager connectionsManager = ConnectionsManager.getInstance(currentAccount); ConnectionsManager connectionsManager = ConnectionsManager.getInstance(currentAccount);
MessagesStorage messagesStorage = MessagesStorage.getInstance(currentAccount); MessagesStorage messagesStorage = MessagesStorage.getInstance(currentAccount);
@ -191,7 +191,7 @@ public class NotificationsSettingsFacade {
String soundPathPref; String soundPathPref;
String soundDocPref; String soundDocPref;
if (dialogId != 0) { if (dialogId != 0) {
String key = NotificationsController.getSharedPrefKey(dialogId, topicId); String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
soundPref = "sound_" + key; soundPref = "sound_" + key;
soundPathPref = "sound_path_" + key; soundPathPref = "sound_path_" + key;
soundDocPref = "sound_document_id_" + key; soundDocPref = "sound_document_id_" + key;

View file

@ -104,10 +104,13 @@ public class VideoPlayerHolderBase {
}); });
} }
public void start(boolean paused, Uri uri, long t, boolean audioDisabled) { public void start(boolean paused, Uri uri, long position, boolean audioDisabled) {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
this.audioDisabled = audioDisabled; this.audioDisabled = audioDisabled;
this.paused = paused; this.paused = paused;
if (position > 0) {
currentPosition = position;
}
dispatchQueue.postRunnable(initRunnable = () -> { dispatchQueue.postRunnable(initRunnable = () -> {
if (released) { if (released) {
return; return;
@ -134,8 +137,8 @@ public class VideoPlayerHolderBase {
videoPlayer.play(); videoPlayer.play();
} }
} }
if (t > 0) { if (position > 0) {
videoPlayer.seekTo(t); videoPlayer.seekTo(position);
} }
// videoPlayer.setVolume(isInSilentMode ? 0 : 1f); // videoPlayer.setVolume(isInSilentMode ? 0 : 1f);

View file

@ -416,6 +416,7 @@ public abstract class BaseFragment {
FileLog.e(e); FileLog.e(e);
} }
if (storyViewer != null) { if (storyViewer != null) {
storyViewer.onPause();
storyViewer.updatePlayingMode(); storyViewer.updatePlayingMode();
} }
if (overlayStoryViewer != null) { if (overlayStoryViewer != null) {

View file

@ -782,7 +782,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private int descriptionX; private int descriptionX;
private int titleX; private int titleX;
private int authorX; private int authorX;
private boolean siteNameRtl; private float siteNameLeft, siteNameLayoutWidth;
private int siteNameWidth; private int siteNameWidth;
private StaticLayout siteNameLayout; private StaticLayout siteNameLayout;
private StaticLayout titleLayout; private StaticLayout titleLayout;
@ -5046,7 +5046,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
siteNameLayout = generateStaticLayout(site_name, Theme.chat_replyNamePaint, linkPreviewMaxWidth, linkPreviewMaxWidth - smallImageSide - smallSideMargin, restLinesCount, 1); siteNameLayout = generateStaticLayout(site_name, Theme.chat_replyNamePaint, linkPreviewMaxWidth, linkPreviewMaxWidth - smallImageSide - smallSideMargin, restLinesCount, 1);
restLinesCount -= siteNameLayout.getLineCount(); restLinesCount -= siteNameLayout.getLineCount();
} }
siteNameRtl = Math.max(siteNameLayout.getLineLeft(0), 0) != 0; siteNameLeft = siteNameLayoutWidth = 0;
for (int i = 0; i < siteNameLayout.getLineCount(); ++i) {
siteNameLeft = siteNameLayout.getLineLeft(i);
siteNameLayoutWidth = siteNameLayout.getLineWidth(i);
}
int height = siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1); int height = siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1);
linkPreviewHeight += height; linkPreviewHeight += height;
totalHeight += height; totalHeight += height;
@ -7675,7 +7679,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
try { try {
int width = siteNameWidth = (int) Math.ceil(Theme.chat_replyNamePaint.measureText(webPage.site_name) + 1); int width = siteNameWidth = (int) Math.ceil(Theme.chat_replyNamePaint.measureText(webPage.site_name) + 1);
siteNameLayout = new StaticLayout(webPage.site_name, Theme.chat_replyNamePaint, Math.min(width, linkPreviewMaxWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); siteNameLayout = new StaticLayout(webPage.site_name, Theme.chat_replyNamePaint, Math.min(width, linkPreviewMaxWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
siteNameRtl = siteNameLayout.getLineLeft(0) != 0; siteNameLeft = siteNameLayoutWidth = 0;
for (int i = 0; i < siteNameLayout.getLineCount(); ++i) {
siteNameLeft = siteNameLayout.getLineLeft(i);
siteNameLayoutWidth = siteNameLayout.getLineWidth(i);
}
int height = siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1); int height = siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1);
linkPreviewHeight += height; linkPreviewHeight += height;
totalHeight += height; totalHeight += height;
@ -10233,12 +10241,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (siteNameLayout != null) { if (siteNameLayout != null) {
Theme.chat_replyNamePaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outSiteNameText : Theme.key_chat_inSiteNameText)); Theme.chat_replyNamePaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outSiteNameText : Theme.key_chat_inSiteNameText));
canvas.save(); canvas.save();
int x; float x = -siteNameLeft + (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
if (siteNameRtl) {
x = backgroundWidth - siteNameWidth - AndroidUtilities.dp(32);
} else {
x = (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
}
canvas.translate(linkX + x, linkPreviewY - AndroidUtilities.dp(3)); canvas.translate(linkX + x, linkPreviewY - AndroidUtilities.dp(3));
siteNameLayout.draw(canvas); siteNameLayout.draw(canvas);
canvas.restore(); canvas.restore();
@ -10599,15 +10602,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
Theme.chat_replyNamePaint.setAlpha((int) (alpha * Theme.chat_replyLinePaint.getAlpha())); Theme.chat_replyNamePaint.setAlpha((int) (alpha * Theme.chat_replyLinePaint.getAlpha()));
} }
canvas.save(); canvas.save();
int x; float x = -siteNameLeft + (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
if (siteNameRtl) {
x = backgroundWidth - siteNameWidth - AndroidUtilities.dp(32);
if (isSmallImage) {
x -= AndroidUtilities.dp(48 + 6);
}
} else {
x = (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
}
canvas.translate(linkX + x, linkPreviewY - AndroidUtilities.dp(3)); canvas.translate(linkX + x, linkPreviewY - AndroidUtilities.dp(3));
siteNameLayout.draw(canvas); siteNameLayout.draw(canvas);
canvas.restore(); canvas.restore();

View file

@ -115,7 +115,7 @@ public class FeaturedStickerSetCell2 extends FrameLayout implements Notification
delButton.setText(LocaleController.getString("StickersRemove", R.string.StickersRemove)); delButton.setText(LocaleController.getString("StickersRemove", R.string.StickersRemove));
addView(delButton, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 16, 14, 0)); addView(delButton, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 16, 14, 0));
unlockButton = new PremiumButtonView(context, AndroidUtilities.dp(4), false); unlockButton = new PremiumButtonView(context, AndroidUtilities.dp(4), false, resourcesProvider);
unlockButton.setIcon(R.raw.unlock_icon); unlockButton.setIcon(R.raw.unlock_icon);
unlockButton.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> onPremiumButtonClick()); unlockButton.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> onPremiumButtonClick());
unlockButton.setVisibility(View.GONE); unlockButton.setVisibility(View.GONE);

View file

@ -76,6 +76,10 @@ public class ReactedUserHolderView extends FrameLayout {
public static final MessageSeenCheckDrawable reactDrawable = new MessageSeenCheckDrawable(R.drawable.msg_reactions, Theme.key_windowBackgroundWhiteGrayText, 16, 16, 5.66f); public static final MessageSeenCheckDrawable reactDrawable = new MessageSeenCheckDrawable(R.drawable.msg_reactions, Theme.key_windowBackgroundWhiteGrayText, 16, 16, 5.66f);
public ReactedUserHolderView(int style, int currentAccount, @NonNull Context context, Theme.ResourcesProvider resourcesProvider) { public ReactedUserHolderView(int style, int currentAccount, @NonNull Context context, Theme.ResourcesProvider resourcesProvider) {
this(style, currentAccount, context, resourcesProvider, true);
}
public ReactedUserHolderView(int style, int currentAccount, @NonNull Context context, Theme.ResourcesProvider resourcesProvider, boolean useOverlaySelector) {
super(context); super(context);
this.style = style; this.style = style;
this.currentAccount = currentAccount; this.currentAccount = currentAccount;
@ -145,9 +149,11 @@ public class ReactedUserHolderView extends FrameLayout {
reactView = new BackupImageView(context); reactView = new BackupImageView(context);
addView(reactView, LayoutHelper.createFrameRelatively(24, 24, Gravity.END | Gravity.CENTER_VERTICAL, 0, 0, 12, 0)); addView(reactView, LayoutHelper.createFrameRelatively(24, 24, Gravity.END | Gravity.CENTER_VERTICAL, 0, 0, 12, 0));
overlaySelectorView = new View(context); if (useOverlaySelector) {
overlaySelectorView.setBackground(Theme.getSelectorDrawable(false)); overlaySelectorView = new View(context);
addView(overlaySelectorView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); overlaySelectorView.setBackground(Theme.getSelectorDrawable(false));
addView(overlaySelectorView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
} }
public void setUserReaction(TLRPC.User user, TLRPC.Chat chat, TLRPC.Reaction reaction, boolean like, long date, boolean dateIsSeen, boolean animated) { public void setUserReaction(TLRPC.User user, TLRPC.Chat chat, TLRPC.Reaction reaction, boolean like, long date, boolean dateIsSeen, boolean animated) {

View file

@ -149,7 +149,7 @@ public class StickerSetCell extends FrameLayout {
removeButtonView.setOnClickListener(e -> onRemoveButtonClick()); removeButtonView.setOnClickListener(e -> onRemoveButtonClick());
sideButtons.addView(removeButtonView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 32, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 0, -2, 0, 0)); sideButtons.addView(removeButtonView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 32, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 0, -2, 0, 0));
premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(4), false); premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(4), false, resourcesProvider);
premiumButtonView.setIcon(R.raw.unlock_icon); premiumButtonView.setIcon(R.raw.unlock_icon);
premiumButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> onPremiumButtonClick()); premiumButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> onPremiumButtonClick());
try { try {

View file

@ -171,8 +171,9 @@ public class ChannelBoostLayout extends FrameLayout {
StatisticActivity.OverviewCell overviewCell = (StatisticActivity.OverviewCell) holder.itemView; StatisticActivity.OverviewCell overviewCell = (StatisticActivity.OverviewCell) holder.itemView;
overviewCell.setData(0, Integer.toString(boostsStatus.level), null, LocaleController.getString("BoostsLevel2", R.string.BoostsLevel2)); overviewCell.setData(0, Integer.toString(boostsStatus.level), null, LocaleController.getString("BoostsLevel2", R.string.BoostsLevel2));
if (boostsStatus.premium_audience != null || boostsStatus.premium_audience.total == 0) { if (boostsStatus.premium_audience != null && boostsStatus.premium_audience.total == 0) {
overviewCell.setData(1, "~" + (int) boostsStatus.premium_audience.part, String.format(Locale.US, "%.1f", (float) boostsStatus.premium_audience.part / (float) boostsStatus.premium_audience.total) + "%", LocaleController.getString("PremiumSubscribers", R.string.PremiumSubscribers)); float percent = (((float) boostsStatus.premium_audience.part / (float) boostsStatus.premium_audience.total) * 100f);
overviewCell.setData(1, "~" + (int) boostsStatus.premium_audience.part, String.format(Locale.US, "%.1f",percent) + "%", LocaleController.getString("PremiumSubscribers", R.string.PremiumSubscribers));
} else { } else {
overviewCell.setData(1, "~0", "0%", LocaleController.getString("PremiumSubscribers", R.string.PremiumSubscribers)); overviewCell.setData(1, "~0", "0%", LocaleController.getString("PremiumSubscribers", R.string.PremiumSubscribers));
} }
@ -303,6 +304,7 @@ public class ChannelBoostLayout extends FrameLayout {
usersLoading = false; usersLoading = false;
if (response != null) { if (response != null) {
TLRPC.TL_stories_boostersList list = (TLRPC.TL_stories_boostersList) response; TLRPC.TL_stories_boostersList list = (TLRPC.TL_stories_boostersList) response;
MessagesController.getInstance(currentAccount).putUsers(list.users, false);
boosters.addAll(list.boosters); boosters.addAll(list.boosters);
hasNext = !TextUtils.isEmpty(list.next_offset) && boosters.size() < list.count; hasNext = !TextUtils.isEmpty(list.next_offset) && boosters.size() < list.count;
nextRemaining = list.count - boosters.size(); nextRemaining = list.count - boosters.size();

View file

@ -959,14 +959,20 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
req.from_switch_webview = (flags & FLAG_FROM_INLINE_SWITCH) != 0; req.from_switch_webview = (flags & FLAG_FROM_INLINE_SWITCH) != 0;
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
req.platform = "android"; req.platform = "android";
req.from_side_menu = (flags & FLAG_FROM_SIDE_MENU) != 0;; req.from_side_menu = (flags & FLAG_FROM_SIDE_MENU) != 0;
if (hasThemeParams) { if (hasThemeParams) {
req.theme_params = new TLRPC.TL_dataJSON(); req.theme_params = new TLRPC.TL_dataJSON();
req.theme_params.data = themeParams; req.theme_params.data = themeParams;
req.flags |= 1; req.flags |= 1;
} }
req.flags |= 8; if (!TextUtils.isEmpty(buttonUrl)) {
req.url = buttonUrl; req.flags |= 8;
req.url = buttonUrl;
}
if (!TextUtils.isEmpty(startParam)) {
req.start_param = startParam;
req.flags |= 16;
}
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response instanceof TLRPC.TL_simpleWebViewResultUrl) { if (response instanceof TLRPC.TL_simpleWebViewResultUrl) {
@ -1058,7 +1064,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
return; return;
} }
String botName = currentBot.short_name; String botName = currentBot.short_name;
description = LocaleController.formatString("BotRemoveFromMenuAll", R.string.BotRemoveFromMenuAll, botName); description = LocaleController.formatString("BotRemoveFromMenu", R.string.BotRemoveFromMenu, botName);
TLRPC.TL_attachMenuBot finalCurrentBot = currentBot; TLRPC.TL_attachMenuBot finalCurrentBot = currentBot;
new AlertDialog.Builder(LaunchActivity.getLastFragment().getContext()) new AlertDialog.Builder(LaunchActivity.getLastFragment().getContext())
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle)) .setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))

View file

@ -2855,7 +2855,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
break; break;
} }
} }
description = LocaleController.formatString("BotRemoveFromMenuAll", R.string.BotRemoveFromMenuAll, botName); description = LocaleController.formatString("BotRemoveFromMenu", R.string.BotRemoveFromMenu, botName);
new AlertDialog.Builder(getContext()) new AlertDialog.Builder(getContext())
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle)) .setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))
.setMessage(AndroidUtilities.replaceTags(attachMenuBot != null ? description : LocaleController.formatString("BotRemoveInlineFromMenu", R.string.BotRemoveInlineFromMenu, botName))) .setMessage(AndroidUtilities.replaceTags(attachMenuBot != null ? description : LocaleController.formatString("BotRemoveInlineFromMenu", R.string.BotRemoveInlineFromMenu, botName)))

View file

@ -166,6 +166,8 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
private ZoomControlView zoomControlView; private ZoomControlView zoomControlView;
private AnimatorSet zoomControlAnimation; private AnimatorSet zoomControlAnimation;
private Runnable zoomControlHideRunnable; private Runnable zoomControlHideRunnable;
private Runnable afterCameraInitRunnable;
private Boolean isCameraFrontfaceBeforeEnteringEditMode = null;
private TextView counterTextView; private TextView counterTextView;
private TextView tooltipTextView; private TextView tooltipTextView;
private ImageView switchCameraButton; private ImageView switchCameraButton;
@ -359,7 +361,12 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
resumeCameraPreview(); resumeCameraPreview();
AndroidUtilities.runOnUIThread(()-> setCurrentSpoilerVisible(-1, true), 150); AndroidUtilities.runOnUIThread(()-> setCurrentSpoilerVisible(-1, true), 150);
} }
@Override
public void onEditModeChanged(boolean isEditMode) {
onPhotoEditModeChanged(isEditMode);
}
@Override @Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) { public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
PhotoAttachPhotoCell cell = getCellForIndex(index); PhotoAttachPhotoCell cell = getCellForIndex(index);
@ -1753,6 +1760,20 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
} }
PhotoViewer.getInstance().openPhotoForSelect(arrayList, index, type, false, new BasePhotoProvider() { PhotoViewer.getInstance().openPhotoForSelect(arrayList, index, type, false, new BasePhotoProvider() {
@Override
public void onOpen() {
pauseCameraPreview();
}
@Override
public void onClose() {
resumeCameraPreview();
}
public void onEditModeChanged(boolean isEditMode) {
onPhotoEditModeChanged(isEditMode);
}
@Override @Override
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
return null; return null;
@ -2155,7 +2176,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
} }
if (cameraView == null) { if (cameraView == null) {
final boolean lazy = !LiteMode.isEnabled(LiteMode.FLAGS_CHAT); final boolean lazy = !LiteMode.isEnabled(LiteMode.FLAGS_CHAT);
cameraView = new CameraView(getContext(), parentAlert.openWithFrontFaceCamera, lazy) { cameraView = new CameraView(getContext(), isCameraFrontfaceBeforeEnteringEditMode != null ? isCameraFrontfaceBeforeEnteringEditMode : parentAlert.openWithFrontFaceCamera, lazy) {
Bulletin.Delegate bulletinDelegate = new Bulletin.Delegate() { Bulletin.Delegate bulletinDelegate = new Bulletin.Delegate() {
@Override @Override
@ -2279,6 +2300,9 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
}); });
cameraInitAnimation.start(); cameraInitAnimation.start();
} }
if (afterCameraInitRunnable != null) {
afterCameraInitRunnable.run();
}
} }
}); });
@ -2324,17 +2348,23 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
cameraView.setVisibility(GONE); cameraView.setVisibility(GONE);
cameraIcon.setVisibility(GONE); cameraIcon.setVisibility(GONE);
} }
checkCameraViewPosition(); if (cameraOpened) {
cameraIcon.setAlpha(0f);
} else {
checkCameraViewPosition();
}
invalidate(); invalidate();
} }
if (zoomControlView != null) { if (zoomControlView != null) {
zoomControlView.setZoom(0.0f, false); zoomControlView.setZoom(0.0f, false);
cameraZoom = 0.0f; cameraZoom = 0.0f;
} }
cameraView.setTranslationX(cameraViewLocation[0]); if (!cameraOpened) {
cameraView.setTranslationY(cameraViewLocation[1] + currentPanTranslationY); cameraView.setTranslationX(cameraViewLocation[0]);
cameraIcon.setTranslationX(cameraViewLocation[0]); cameraView.setTranslationY(cameraViewLocation[1] + currentPanTranslationY);
cameraIcon.setTranslationY(cameraViewLocation[1] + cameraViewOffsetY + currentPanTranslationY); cameraIcon.setTranslationX(cameraViewLocation[0]);
cameraIcon.setTranslationY(cameraViewLocation[1] + cameraViewOffsetY + currentPanTranslationY);
}
} }
public void hideCamera(boolean async) { public void hideCamera(boolean async) {
@ -3488,6 +3518,24 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
} }
} }
private void onPhotoEditModeChanged(boolean isEditMode) {
if (needCamera && !noCameraPermissions) {
if (isEditMode) {
if (cameraView != null) {
isCameraFrontfaceBeforeEnteringEditMode = cameraView.isFrontface();
hideCamera(true);
}
} else {
afterCameraInitRunnable = () -> {
pauseCameraPreview();
afterCameraInitRunnable = null;
isCameraFrontfaceBeforeEnteringEditMode = null;
};
showCamera();
}
}
}
@Override @Override
void onHidden() { void onHidden() {
if (cameraView != null) { if (cameraView != null) {

View file

@ -514,7 +514,7 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
removeButtonView.setClickable(true); removeButtonView.setClickable(true);
buttonsView.addView(removeButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.BOTTOM, 0, 0, 0, 19)); buttonsView.addView(removeButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.BOTTOM, 0, 0, 0, 19));
premiumButtonView = new PremiumButtonView(context, false); premiumButtonView = new PremiumButtonView(context, false, resourcesProvider);
premiumButtonView.setButton(LocaleController.getString("UnlockPremiumEmoji", R.string.UnlockPremiumEmoji), ev -> { premiumButtonView.setButton(LocaleController.getString("UnlockPremiumEmoji", R.string.UnlockPremiumEmoji), ev -> {
showPremiumAlert(); showPremiumAlert();
}); });
@ -1560,7 +1560,7 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
float endMarginDp = 8; float endMarginDp = 8;
if (!single) { if (!single) {
if (!UserConfig.getInstance(currentAccount).isPremium()) { if (!UserConfig.getInstance(currentAccount).isPremium()) {
unlockButtonView = new PremiumButtonView(context, AndroidUtilities.dp(4), false); unlockButtonView = new PremiumButtonView(context, AndroidUtilities.dp(4), false, resourcesProvider);
unlockButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), ev -> { unlockButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), ev -> {
premiumButtonClicked = SystemClock.elapsedRealtime(); premiumButtonClicked = SystemClock.elapsedRealtime();
showPremiumAlert(); showPremiumAlert();

View file

@ -3493,7 +3493,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
addButtonView.addView(addButtonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); addButtonView.addView(addButtonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
addView(addButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(addButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
premiumButtonView = new PremiumButtonView(getContext(), false); premiumButtonView = new PremiumButtonView(getContext(), false, resourcesProvider);
premiumButtonView.setIcon(R.raw.unlock_icon); premiumButtonView.setIcon(R.raw.unlock_icon);
addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
} }
@ -3736,7 +3736,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
}); });
buttonsView.addView(removeButtonView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 26, Gravity.END | Gravity.TOP)); buttonsView.addView(removeButtonView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 26, Gravity.END | Gravity.TOP));
premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(16), false); premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(16), false, resourcesProvider);
premiumButtonView.setIcon(R.raw.unlock_icon); premiumButtonView.setIcon(R.raw.unlock_icon);
premiumButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> openPremiumAnimatedEmojiFeature()); premiumButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> openPremiumAnimatedEmojiFeature());

View file

@ -86,12 +86,21 @@ public abstract class Brush {
return 0; return 0;
} }
public int getDefaultColor() {
return PersistColorPalette.COLOR_BLACK;
}
public static class Radial extends Brush { public static class Radial extends Brush {
@Override @Override
public int getIconRes() { public int getIconRes() {
return R.raw.photo_pen; return R.raw.photo_pen;
} }
@Override
public int getDefaultColor() {
return PersistColorPalette.COLOR_RED;
}
} }
public static class Elliptical extends Brush { public static class Elliptical extends Brush {
@ -140,6 +149,11 @@ public abstract class Brush {
public float getDefaultWeight() { public float getDefaultWeight() {
return 0.5f; return 0.5f;
} }
@Override
public int getDefaultColor() {
return PersistColorPalette.COLOR_YELLOW;
}
} }
public static class Neon extends Brush { public static class Neon extends Brush {
@ -191,6 +205,11 @@ public abstract class Brush {
public float getDefaultWeight() { public float getDefaultWeight() {
return 0.5f; return 0.5f;
} }
@Override
public int getDefaultColor() {
return PersistColorPalette.COLOR_GREEN;
}
} }
public static class Arrow extends Brush { public static class Arrow extends Brush {
@ -209,6 +228,11 @@ public abstract class Brush {
public float getDefaultWeight() { public float getDefaultWeight() {
return 0.25f; return 0.25f;
} }
@Override
public int getDefaultColor() {
return PersistColorPalette.COLOR_ORANGE;
}
} }
public static class Eraser extends Brush { public static class Eraser extends Brush {

View file

@ -185,6 +185,9 @@ public class Input {
long dt = System.currentTimeMillis() - lastVelocityUpdate; long dt = System.currentTimeMillis() - lastVelocityUpdate;
velocity = MathUtils.clamp(velocity - dt / 125f, 0.6f, 1f); velocity = MathUtils.clamp(velocity - dt / 125f, 0.6f, 1f);
if (renderView.getCurrentBrush() != null && renderView.getCurrentBrush() instanceof Brush.Arrow) {
velocity = 1 - velocity;
}
lastScale = scale; lastScale = scale;
lastVelocityUpdate = System.currentTimeMillis(); lastVelocityUpdate = System.currentTimeMillis();
@ -195,7 +198,7 @@ public class Input {
stylusToolPressed = (event.getButtonState() & MotionEvent.BUTTON_STYLUS_PRIMARY) == MotionEvent.BUTTON_STYLUS_PRIMARY; stylusToolPressed = (event.getButtonState() & MotionEvent.BUTTON_STYLUS_PRIMARY) == MotionEvent.BUTTON_STYLUS_PRIMARY;
} }
if (renderView.getCurrentBrush() != null) { if (renderView.getCurrentBrush() != null) {
weight = 1 + (weight - 1) * AndroidUtilities.lerp(1, renderView.getCurrentBrush().getSmoothThicknessRate(), MathUtils.clamp(realPointsCount / 16f, 0, 1)); weight = 1 + (weight - 1) * AndroidUtilities.lerp(renderView.getCurrentBrush().getSmoothThicknessRate(), 1, MathUtils.clamp(realPointsCount / 16f, 0, 1));
} }
Point location = new Point(tempPoint[0], tempPoint[1], weight); Point location = new Point(tempPoint[0], tempPoint[1], weight);
@ -299,7 +302,7 @@ public class Input {
float angle = lastAngle; float angle = lastAngle;
final Point loc = points[pointsCount - 1]; final Point loc = points[pointsCount - 1];
double z = lastThickLocation == null ? location.z : lastThickLocation.z; double z = lastThickLocation == null ? location.z : lastThickLocation.z;
float arrowLength = renderView.getCurrentWeight() * (float) z * 4.5f; float arrowLength = renderView.getCurrentWeight() * (float) z * 12f;
commit = false; commit = false;
if (arrowAnimator != null) { if (arrowAnimator != null) {
@ -311,13 +314,17 @@ public class Input {
arrowAnimator.addUpdateListener(anm -> { arrowAnimator.addUpdateListener(anm -> {
float t = (float) anm.getAnimatedValue(); float t = (float) anm.getAnimatedValue();
double leftCos = Math.cos(angle - Math.PI / 4 * 3.3);
double leftSin = Math.sin(angle - Math.PI / 4 * 3.5);
paintPath(new Path(new Point[]{ paintPath(new Path(new Point[]{
new Point(loc.x + Math.cos(angle - Math.PI / 4 * 3) * arrowLength * lastT[0], loc.y + Math.sin(angle - Math.PI / 4 * 3.2) * arrowLength * lastT[0], z), new Point(loc.x + leftCos * arrowLength * lastT[0], loc.y + leftSin * arrowLength * lastT[0], z),
new Point(loc.x + Math.cos(angle - Math.PI / 4 * 3) * arrowLength * t, loc.y + Math.sin(angle - Math.PI / 4 * 3.2) * arrowLength * t, z, true) new Point(loc.x + leftCos * arrowLength * t, loc.y + leftSin * arrowLength * t, z, true)
})); }));
double rightCos = Math.cos(angle + Math.PI / 4 * 3.3);
double rightSin = Math.sin(angle + Math.PI / 4 * 3.5);
paintPath(new Path(new Point[]{ paintPath(new Path(new Point[]{
new Point(loc.x + Math.cos(angle + Math.PI / 4 * 3) * arrowLength * lastT[0], loc.y + Math.sin(angle + Math.PI / 4 * 3.2) * arrowLength * lastT[0], z), new Point(loc.x + rightCos * arrowLength * lastT[0], loc.y + rightSin * arrowLength * lastT[0], z),
new Point(loc.x + Math.cos(angle + Math.PI / 4 * 3) * arrowLength * t, loc.y + Math.sin(angle + Math.PI / 4 * 3.2) * arrowLength * t, z, true) new Point(loc.x + rightCos * arrowLength * t, loc.y + rightSin * arrowLength * t, z, true)
})); }));
if (!vibrated[0] && t > .4f) { if (!vibrated[0] && t > .4f) {
@ -467,7 +474,7 @@ public class Input {
double x = midPoint1.x * minus_t_squard + 2 * prev1.x * t * (1 - t) + midPoint2.x * t_squared; double x = midPoint1.x * minus_t_squard + 2 * prev1.x * t * (1 - t) + midPoint2.x * t_squared;
double y = midPoint1.y * minus_t_squard + 2 * prev1.y * t * (1 - t) + midPoint2.y * t_squared; double y = midPoint1.y * minus_t_squard + 2 * prev1.y * t * (1 - t) + midPoint2.y * t_squared;
double z = midPoint1.z * a1 + prev1.z * a2 + midPoint2.z * a3; double z = midPoint1.z * a1 + prev1.z * a2 + midPoint2.z * a3;
z = 1 + (z - 1) * AndroidUtilities.lerp(1, smoothThickness, MathUtils.clamp(realPointsCount / 16f, 0, 1)); z = 1 + (z - 1) * AndroidUtilities.lerp(smoothThickness, 1, MathUtils.clamp(realPointsCount / 16f, 0, 1));
return new Point(x, y, z); return new Point(x, y, z);
} }

View file

@ -9,35 +9,53 @@ import org.telegram.ui.Components.Paint.Views.PaintTextOptionsView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
public class PersistColorPalette { public class PersistColorPalette {
public final static int COLORS_COUNT = 14;
private final static List<Integer> DEFAULT_COLORS = Arrays.asList( public final static int COLOR_BLACK = 0xff000000;
0xff000000, public final static int COLOR_WHITE = 0xffffffff;
0xffFFFFFF, public final static int COLOR_RED = 0xffff453a;
0xff1D99FF, public final static int COLOR_ORANGE = 0xffff8a00;
0xff03BCD4, public final static int COLOR_YELLOW = 0xffffd60a;
0xff39BA2B, public final static int COLOR_GREEN = 0xff34c759;
0xffF9A30F, public final static int COLOR_LIGHT_BLUE = 0xff63e6e2;
0xffFA6E16, public final static int COLOR_BLUE = 0xff0a84ff;
0xffE83544, public final static int COLOR_VIOLET = 0xffbf5af2;
0xffB24DFF,
private final static List<Integer> DEFAULT_MODIFIABLE_COLORS = Arrays.asList(
0xffD7A07C, 0xffD7A07C,
0xffAC734C, 0xff7faffe,
0xff90512C, 0xffA58FDB,
0xff532E1F, 0xffDB95AE,
0xff818181 0xffBADC9F
); );
private final static Integer DEFAULT_MARKER_COLOR = 0xff0a84ff;
private final static List<Integer> PRESET_COLORS = Arrays.asList(
COLOR_RED,
COLOR_ORANGE,
COLOR_YELLOW,
COLOR_GREEN,
COLOR_LIGHT_BLUE,
COLOR_BLUE,
COLOR_VIOLET,
COLOR_BLACK,
COLOR_WHITE
);
public final static int MODIFIABLE_COLORS_COUNT = DEFAULT_MODIFIABLE_COLORS.size();
public final static int PRESET_COLORS_COUNT = PRESET_COLORS.size();
public final static int COLORS_COUNT = MODIFIABLE_COLORS_COUNT + PRESET_COLORS_COUNT;
private final static int BRUSH_TEXT = -1;
private static PersistColorPalette[] instances = new PersistColorPalette[UserConfig.MAX_ACCOUNT_COUNT]; private static PersistColorPalette[] instances = new PersistColorPalette[UserConfig.MAX_ACCOUNT_COUNT];
private SharedPreferences mConfig; private final SharedPreferences mConfig;
private List<Integer> colors = new ArrayList<>(COLORS_COUNT); private final List<Integer> colors = new ArrayList<>(COLORS_COUNT);
private final HashMap<Integer, Integer> brushColor = new HashMap<>(Brush.BRUSHES_LIST.size());
private List<Integer> pendingChange = new ArrayList<>(COLORS_COUNT); private List<Integer> pendingChange = new ArrayList<>(COLORS_COUNT);
private Integer markerColor; private boolean needSaveBrushColor;
private int currentBrush; private int currentBrush;
private int currentAlignment; private int currentAlignment;
@ -45,6 +63,7 @@ public class PersistColorPalette {
private float currentWeight; private float currentWeight;
private String currentTypeface; private String currentTypeface;
private boolean fillShapes; private boolean fillShapes;
private boolean inTextMode;
public PersistColorPalette(int currentUser) { public PersistColorPalette(int currentUser) {
mConfig = ApplicationLoader.applicationContext.getSharedPreferences("photo_color_palette_" + currentUser, Context.MODE_PRIVATE); mConfig = ApplicationLoader.applicationContext.getSharedPreferences("photo_color_palette_" + currentUser, Context.MODE_PRIVATE);
@ -74,6 +93,17 @@ public class PersistColorPalette {
mConfig.edit().putInt("text_type", currentTextType).apply(); mConfig.edit().putInt("text_type", currentTextType).apply();
} }
public void setInTextMode(boolean inTextMode) {
if (this.inTextMode != inTextMode) {
this.inTextMode = inTextMode;
if (inTextMode) {
setCurrentBrush(BRUSH_TEXT, false);
} else {
setCurrentBrush(mConfig.getInt("brush", 0), false);
}
}
}
public int getCurrentAlignment() { public int getCurrentAlignment() {
return currentAlignment; return currentAlignment;
} }
@ -114,8 +144,20 @@ public class PersistColorPalette {
} }
public void setCurrentBrush(int currentBrush) { public void setCurrentBrush(int currentBrush) {
setCurrentBrush(currentBrush, true);
}
public void setCurrentBrush(int currentBrush, boolean saveBrush) {
this.currentBrush = currentBrush; this.currentBrush = currentBrush;
mConfig.edit().putInt("brush", currentBrush).apply(); if (saveBrush) {
mConfig.edit().putInt("brush", currentBrush).apply();
}
Integer color = brushColor.get(currentBrush);
if (color != null) {
selectColor(color, false);
saveColors();
}
} }
public boolean getFillShapes() { public boolean getFillShapes() {
@ -129,7 +171,15 @@ public class PersistColorPalette {
public void cleanup() { public void cleanup() {
pendingChange.clear(); pendingChange.clear();
pendingChange.addAll(DEFAULT_COLORS); pendingChange.addAll(DEFAULT_MODIFIABLE_COLORS);
SharedPreferences.Editor editor = mConfig.edit();
for (int i = 0; i < Brush.BRUSHES_LIST.size(); i++) {
editor.remove("brush_color_" + i);
}
editor.remove("brush_color_" + BRUSH_TEXT);
brushColor.clear();
editor.apply();
saveColors(); saveColors();
} }
@ -141,76 +191,123 @@ public class PersistColorPalette {
public int getColor(int index) { public int getColor(int index) {
checkIndex(index); checkIndex(index);
if (index < 0 || index >= colors.size()) { List<Integer> allColors = getAllColors();
if (index >= 0 && index < DEFAULT_COLORS.size()) { if (index >= allColors.size()) {
return DEFAULT_COLORS.get(index); if (index < PRESET_COLORS_COUNT) {
return PRESET_COLORS.get(index);
} else {
return DEFAULT_MODIFIABLE_COLORS.get(index - PRESET_COLORS_COUNT);
} }
return DEFAULT_COLORS.get(0);
} }
return colors.get(index); return allColors.get(index);
}
public int getCurrentColor() {
Integer currentColor = brushColor.get(currentBrush);
if (currentColor == null) {
currentColor = (int) mConfig.getLong("brush_color_" + currentBrush, currentBrush == BRUSH_TEXT ? COLOR_WHITE : Brush.BRUSHES_LIST.get(currentBrush).getDefaultColor());
brushColor.put(currentBrush, currentColor);
}
return currentColor;
}
public int getCurrentColorPosition() {
int currentColor = getCurrentColor();
List<Integer> allColors = getAllColors();
for (int i = 0; i < allColors.size(); i++) {
if (allColors.get(i) == currentColor) {
return i;
}
}
return 0;
}
private List<Integer> getAllColors() {
List<Integer> allColors = new ArrayList<>(PRESET_COLORS);
allColors.addAll(colors);
return allColors;
} }
public void selectColor(int color) { public void selectColor(int color) {
int i = colors.indexOf(color); selectColor(color, true);
}
public void selectColor(int color, boolean updateBrush) {
List<Integer> allColors = getAllColors();
int i = allColors.indexOf(color);
if (i != -1) { if (i != -1) {
selectColorIndex(i); if (updateBrush) {
setCurrentBrushColorByColorIndex(i);
}
} else { } else {
List<Integer> from = new ArrayList<>(pendingChange.isEmpty() ? colors : pendingChange); List<Integer> from = new ArrayList<>(pendingChange.isEmpty() ? colors : pendingChange);
pendingChange.clear(); pendingChange.clear();
pendingChange.add(color); pendingChange.add(color);
pendingChange.addAll(from);
if (pendingChange.size() < DEFAULT_COLORS.size()) { for (int j = 0; j < from.size() - 1; j++) {
for (int j = pendingChange.size(); j < DEFAULT_COLORS.size(); ++j) { pendingChange.add(from.get(j));
pendingChange.add(DEFAULT_COLORS.get(j)); }
if (pendingChange.size() < DEFAULT_MODIFIABLE_COLORS.size()) {
for (int j = pendingChange.size(); j < DEFAULT_MODIFIABLE_COLORS.size(); ++j) {
pendingChange.add(DEFAULT_MODIFIABLE_COLORS.get(j));
} }
} else if (pendingChange.size() > DEFAULT_COLORS.size()) { } else if (pendingChange.size() > DEFAULT_MODIFIABLE_COLORS.size()) {
pendingChange = pendingChange.subList(0, DEFAULT_COLORS.size()); pendingChange = pendingChange.subList(0, DEFAULT_MODIFIABLE_COLORS.size());
}
if (updateBrush) {
brushColor.put(currentBrush, color);
needSaveBrushColor = true;
} }
} }
} }
public void selectColorIndex(int index) { public void setCurrentBrushColorByColorIndex(int index) {
int color = index < 0 || index >= colors.size() ? DEFAULT_COLORS.get(index) : colors.get(index); int color = getColor(index);
List<Integer> from = new ArrayList<>(pendingChange.isEmpty() ? colors : pendingChange); brushColor.put(currentBrush, color);
pendingChange.clear(); needSaveBrushColor = true;
pendingChange.add(color);
for (int i = 0; i < COLORS_COUNT; i++) {
if (i >= from.size()) {
pendingChange.add(DEFAULT_COLORS.get(i));
} else if (from.get(i) != color) {
pendingChange.add(from.get(i));
}
}
if (pendingChange.size() < DEFAULT_COLORS.size()) {
for (int j = pendingChange.size(); j < DEFAULT_COLORS.size(); ++j) {
pendingChange.add(DEFAULT_COLORS.get(j));
}
} else if (pendingChange.size() > DEFAULT_COLORS.size()) {
pendingChange = pendingChange.subList(0, DEFAULT_COLORS.size());
}
} }
private void loadColors() { private void loadColors() {
for (int i = 0; i < COLORS_COUNT; i++) { for (int i = 0; i < MODIFIABLE_COLORS_COUNT; i++) {
colors.add((int) mConfig.getLong("color_" + i, DEFAULT_COLORS.get(i))); colors.add((int) mConfig.getLong("color_" + i, DEFAULT_MODIFIABLE_COLORS.get(i)));
} }
markerColor = (int) mConfig.getLong("color_marker", DEFAULT_MARKER_COLOR);
for (int i = 0; i < Brush.BRUSHES_LIST.size(); i++) {
int color = (int) mConfig.getLong("brush_color_" + i, Brush.BRUSHES_LIST.get(i).getDefaultColor());
brushColor.put(i, color);
}
int color = (int) mConfig.getLong("brush_color_" + BRUSH_TEXT, COLOR_WHITE);
brushColor.put(BRUSH_TEXT, color);
}
public void resetCurrentColor() {
setCurrentBrush(0);
} }
public void saveColors() { public void saveColors() {
if (pendingChange.isEmpty()) { if (pendingChange.isEmpty() && !needSaveBrushColor) {
return; return;
} }
SharedPreferences.Editor editor = mConfig.edit(); SharedPreferences.Editor editor = mConfig.edit();
for (int i = 0; i < COLORS_COUNT; i++) { if (!pendingChange.isEmpty()) {
editor.putLong("color_" + i, i < pendingChange.size() ? pendingChange.get(i) : (long) DEFAULT_COLORS.get(i)); for (int i = 0; i < MODIFIABLE_COLORS_COUNT; i++) {
editor.putLong("color_" + i, i < pendingChange.size() ? pendingChange.get(i) : (long) DEFAULT_MODIFIABLE_COLORS.get(i));
}
colors.clear();
colors.addAll(pendingChange);
pendingChange.clear();
}
if (needSaveBrushColor) {
Integer currentBrushColor = brushColor.get(currentBrush);
if (currentBrushColor != null) {
editor.putLong("brush_color_" + currentBrush, currentBrushColor);
}
needSaveBrushColor = false;
} }
editor.apply(); editor.apply();
colors.clear();
colors.addAll(pendingChange);
pendingChange.clear();
} }
} }

View file

@ -269,7 +269,8 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
inBubbleMode = context instanceof BubbleActivity; inBubbleMode = context instanceof BubbleActivity;
PersistColorPalette palette = PersistColorPalette.getInstance(currentAccount); PersistColorPalette palette = PersistColorPalette.getInstance(currentAccount);
colorSwatch.color = palette.getColor(0); palette.resetCurrentColor();
colorSwatch.color = palette.getCurrentColor();
colorSwatch.brushWeight = palette.getCurrentWeight(); colorSwatch.brushWeight = palette.getCurrentWeight();
queue = new DispatchQueue("Paint"); queue = new DispatchQueue("Paint");
@ -664,6 +665,7 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
int childWidth = child.getWidth() - child.getPaddingLeft() - child.getPaddingRight(); int childWidth = child.getWidth() - child.getPaddingLeft() - child.getPaddingRight();
int childHeight = child.getHeight() - child.getPaddingTop() - child.getPaddingBottom(); int childHeight = child.getHeight() - child.getPaddingTop() - child.getPaddingBottom();
float cx = child.getX() + child.getPaddingLeft() + childWidth / 2f, cy = child.getY() + child.getPaddingTop() + childHeight / 2f; float cx = child.getX() + child.getPaddingLeft() + childWidth / 2f, cy = child.getY() + child.getPaddingTop() + childHeight / 2f;
int colorCircle = colorSwatch.color;
if (tabsNewSelectedIndex != -1) { if (tabsNewSelectedIndex != -1) {
ViewGroup barView2 = (ViewGroup) getBarView(tabsNewSelectedIndex); ViewGroup barView2 = (ViewGroup) getBarView(tabsNewSelectedIndex);
View newView = (barView2 == null ? barView : barView2).getChildAt(0); View newView = (barView2 == null ? barView : barView2).getChildAt(0);
@ -677,6 +679,8 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
View animateToView = colorsListView.getChildAt(0); View animateToView = colorsListView.getChildAt(0);
cx = AndroidUtilities.lerp(cx, colorsListView.getX() - barView.getLeft() + animateToView.getX() + animateToView.getWidth() / 2f, toolsTransformProgress); cx = AndroidUtilities.lerp(cx, colorsListView.getX() - barView.getLeft() + animateToView.getX() + animateToView.getWidth() / 2f, toolsTransformProgress);
cy = AndroidUtilities.lerp(cy, colorsListView.getY() - barView.getTop() + animateToView.getY() + animateToView.getHeight() / 2f, toolsTransformProgress); cy = AndroidUtilities.lerp(cy, colorsListView.getY() - barView.getTop() + animateToView.getY() + animateToView.getHeight() / 2f, toolsTransformProgress);
int paletteFirstColor = palette.getColor(0);
colorCircle = ColorUtils.blendARGB(colorSwatch.color, paletteFirstColor, toolsTransformProgress);
} }
checkRainbow(cx, cy); checkRainbow(cx, cy);
@ -688,16 +692,21 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
AndroidUtilities.rectTmp.set(cx - rad, cy - rad, cx + rad, cy + rad); AndroidUtilities.rectTmp.set(cx - rad, cy - rad, cx + rad, cy + rad);
canvas.drawArc(AndroidUtilities.rectTmp, 0, 360, false, colorPickerRainbowPaint); canvas.drawArc(AndroidUtilities.rectTmp, 0, 360, false, colorPickerRainbowPaint);
colorSwatchPaint.setColor(colorSwatch.color); colorSwatchPaint.setColor(colorCircle);
colorSwatchPaint.setAlpha((int) (colorSwatchPaint.getAlpha() * child.getAlpha())); colorSwatchPaint.setAlpha((int) (colorSwatchPaint.getAlpha() * child.getAlpha()));
colorSwatchOutlinePaint.setColor(colorSwatch.color); colorSwatchOutlinePaint.setColor(colorCircle);
colorSwatchOutlinePaint.setAlpha((int) (0xFF * child.getAlpha())); colorSwatchOutlinePaint.setAlpha((int) (0xFF * child.getAlpha()));
float rad2 = rad - AndroidUtilities.dp(3f); float rad2 = rad - AndroidUtilities.dp(3f);
if (colorsListView != null && colorsListView.getSelectedColorIndex() != 0) {
rad2 = AndroidUtilities.lerp(rad - AndroidUtilities.dp(3f), rad + AndroidUtilities.dp(2), toolsTransformProgress);
}
PaintColorsListView.drawColorCircle(canvas, cx, cy, rad2, colorSwatchPaint.getColor()); PaintColorsListView.drawColorCircle(canvas, cx, cy, rad2, colorSwatchPaint.getColor());
colorSwatchOutlinePaint.setAlpha((int) (colorSwatchOutlinePaint.getAlpha() * toolsTransformProgress * child.getAlpha())); if (colorsListView != null && colorsListView.getSelectedColorIndex() == 0) {
canvas.drawCircle(cx, cy, rad - (AndroidUtilities.dp(3f) + colorSwatchOutlinePaint.getStrokeWidth()) * (1f - toolsTransformProgress), colorSwatchOutlinePaint); colorSwatchOutlinePaint.setAlpha((int) (colorSwatchOutlinePaint.getAlpha() * toolsTransformProgress * child.getAlpha()));
canvas.drawCircle(cx, cy, rad - (AndroidUtilities.dp(3f) + colorSwatchOutlinePaint.getStrokeWidth()) * (1f - toolsTransformProgress), colorSwatchOutlinePaint);
}
} }
canvas.restore(); canvas.restore();
@ -867,16 +876,18 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
@Override @Override
public void onColorSelected(int color) { public void onColorSelected(int color) {
showColorList(false); showColorList(false);
palette.selectColor(color);
palette.saveColors();
PersistColorPalette.getInstance(currentAccount).selectColor(color);
PersistColorPalette.getInstance(currentAccount).saveColors();
setNewColor(color); setNewColor(color);
colorsListView.setSelectedColorIndex(palette.getCurrentColorPosition());
colorsListView.getAdapter().notifyDataSetChanged(); colorsListView.getAdapter().notifyDataSetChanged();
} }
}).setColorListener(color -> { }).setColorListener(color -> {
PersistColorPalette.getInstance(currentAccount).selectColor(color); palette.selectColor(color);
PersistColorPalette.getInstance(currentAccount).saveColors(); palette.saveColors();
setNewColor(color); setNewColor(color);
colorsListView.setSelectedColorIndex(palette.getCurrentColorPosition());
colorsListView.getAdapter().notifyDataSetChanged(); colorsListView.getAdapter().notifyDataSetChanged();
}).show(); }).show();
return; return;
@ -1275,6 +1286,10 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
tabsNewSelectedIndex = index; tabsNewSelectedIndex = index;
final View newView = getBarView(tabsNewSelectedIndex); final View newView = getBarView(tabsNewSelectedIndex);
PersistColorPalette.getInstance(currentAccount).setInTextMode(index == 2);
colorSwatch.color = PersistColorPalette.getInstance(currentAccount).getCurrentColor();
setCurrentSwatch(colorSwatch, true);
tabsSelectionAnimator = ValueAnimator.ofFloat(0, 1).setDuration(300); tabsSelectionAnimator = ValueAnimator.ofFloat(0, 1).setDuration(300);
tabsSelectionAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); tabsSelectionAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
tabsSelectionAnimator.addUpdateListener(animation -> { tabsSelectionAnimator.addUpdateListener(animation -> {
@ -2028,8 +2043,10 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
ignoreToolChangeAnimationOnce = true; ignoreToolChangeAnimationOnce = true;
} }
renderView.setBrush(brush); renderView.setBrush(brush);
int wasColor = colorSwatch.color;
colorSwatch.color = PersistColorPalette.getInstance(currentAccount).getCurrentColor();
colorSwatch.brushWeight = weightDefaultValueOverride.get(); colorSwatch.brushWeight = weightDefaultValueOverride.get();
setCurrentSwatch(colorSwatch, true); setCurrentSwatch(colorSwatch, true, wasColor);
renderInputView.invalidate(); renderInputView.invalidate();
} }
@ -2141,12 +2158,16 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
if (show) { if (show) {
colorsListView.setVisibility(VISIBLE); colorsListView.setVisibility(VISIBLE);
colorsListView.setSelectedColorIndex(0); colorsListView.setSelectedColorIndex(PersistColorPalette.getInstance(currentAccount).getCurrentColorPosition());
} }
} }
} }
private void setCurrentSwatch(Swatch swatch, boolean updateInterface) { private void setCurrentSwatch(Swatch swatch, boolean updateInterface) {
setCurrentSwatch(swatch, updateInterface, null);
}
private void setCurrentSwatch(Swatch swatch, boolean updateInterface, Integer prevColor) {
if (colorSwatch != swatch) { if (colorSwatch != swatch) {
colorSwatch.color = swatch.color; colorSwatch.color = swatch.color;
colorSwatch.colorLocation = swatch.colorLocation; colorSwatch.colorLocation = swatch.colorLocation;
@ -2160,7 +2181,18 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
renderView.setBrushSize(swatch.brushWeight); renderView.setBrushSize(swatch.brushWeight);
if (updateInterface) { if (updateInterface) {
if (bottomLayout != null) { int newColor = colorSwatch.color;
if (prevColor != null && prevColor != newColor) {
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(150);
animator.addUpdateListener(animation -> {
float val = (float) animation.getAnimatedValue();
colorSwatch.color = ColorUtils.blendARGB(prevColor, newColor, val);
if (bottomLayout != null) {
bottomLayout.invalidate();
}
});
animator.start();
} else if (bottomLayout != null) {
bottomLayout.invalidate(); bottomLayout.invalidate();
} }
} }

View file

@ -25,7 +25,7 @@ public class PaintColorsListView extends RecyclerListView {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint outlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint outlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private int selectedColorIndex = 0; private int selectedColorIndex = -1;
private PersistColorPalette colorPalette; private PersistColorPalette colorPalette;
private Consumer<Integer> colorListener; private Consumer<Integer> colorListener;
@ -69,7 +69,7 @@ public class PaintColorsListView extends RecyclerListView {
setOverScrollMode(OVER_SCROLL_NEVER); setOverScrollMode(OVER_SCROLL_NEVER);
setOnItemClickListener((view, position) -> { setOnItemClickListener((view, position) -> {
colorListener.accept(colorPalette.getColor(position)); colorListener.accept(colorPalette.getColor(position));
colorPalette.selectColorIndex(position); colorPalette.setCurrentBrushColorByColorIndex(position);
}); });
} }
@ -129,6 +129,10 @@ public class PaintColorsListView extends RecyclerListView {
getAdapter().notifyDataSetChanged(); getAdapter().notifyDataSetChanged();
} }
public int getSelectedColorIndex() {
return selectedColorIndex;
}
public void setProgress(float progress, boolean toShow) { public void setProgress(float progress, boolean toShow) {
if (toShow) { if (toShow) {
progress = CubicBezierInterpolator.EASE_OUT.getInterpolation(progress); progress = CubicBezierInterpolator.EASE_OUT.getInterpolation(progress);

View file

@ -62,8 +62,8 @@ public class PaintToolsView extends LinearLayout {
buttons[a].setAnimation(brush.getIconRes(), 28, 28); buttons[a].setAnimation(brush.getIconRes(), 28, 28);
buttons[a].setOnClickListener(v -> { buttons[a].setOnClickListener(v -> {
animateNextIndex(finalI); animateNextIndex(finalI);
delegate.onBrushSelected(brush);
delegate.onGetPalette().setCurrentBrush(finalI - 1); delegate.onGetPalette().setCurrentBrush(finalI - 1);
delegate.onBrushSelected(brush);
}); });
} else if (i == Brush.BRUSHES_LIST.size() + 1) { } else if (i == Brush.BRUSHES_LIST.size() + 1) {
buttons[a].setImageResource(R.drawable.msg_add); buttons[a].setImageResource(R.drawable.msg_add);

View file

@ -725,7 +725,6 @@ public class PhotoFilterView extends FrameLayout implements FilterShaders.Filter
blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
blurLinearButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); blurLinearButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton));
} }
updateFiltersEmpty();
} }
public MediaController.SavedFilterState getSavedFilterState() { public MediaController.SavedFilterState getSavedFilterState() {

View file

@ -85,7 +85,7 @@ public class DoubledLimitsBottomSheet extends BottomSheetWithRecyclerListView im
divider.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground, resourcesProvider)); divider.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground, resourcesProvider));
containerView.addView(divider, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 72, Gravity.BOTTOM, 0, 0, 0, 0)); containerView.addView(divider, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 72, Gravity.BOTTOM, 0, 0, 0, 0));
premiumButtonView = new PremiumButtonView(getContext(), true); premiumButtonView = new PremiumButtonView(getContext(), true, resourcesProvider);
premiumButtonView.buttonTextView.setText(PremiumPreviewFragment.getPremiumButtonText(currentAccount, selectedTier)); premiumButtonView.buttonTextView.setText(PremiumPreviewFragment.getPremiumButtonText(currentAccount, selectedTier));
containerView.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM, 16, 0, 16, 12)); containerView.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM, 16, 0, 16, 12));

View file

@ -336,7 +336,7 @@ public class GiftPremiumBottomSheet extends BottomSheetWithRecyclerListView impl
public void onViewCreated(FrameLayout containerView) { public void onViewCreated(FrameLayout containerView) {
super.onViewCreated(containerView); super.onViewCreated(containerView);
premiumButtonView = new PremiumButtonView(getContext(), true); premiumButtonView = new PremiumButtonView(getContext(), true, resourcesProvider);
FrameLayout buttonContainer = new FrameLayout(getContext()); FrameLayout buttonContainer = new FrameLayout(getContext());
buttonContainer.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.CENTER_VERTICAL, 16, 0, 16, 0)); buttonContainer.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.CENTER_VERTICAL, 16, 0, 16, 0));

View file

@ -463,6 +463,7 @@ public class LimitPreviewView extends LinearLayout {
defaultText.setText(LocaleController.formatString("BoostsLevel", R.string.BoostsLevel, boosts.level)); defaultText.setText(LocaleController.formatString("BoostsLevel", R.string.BoostsLevel, boosts.level));
premiumCount.setText(LocaleController.formatString("BoostsLevel", R.string.BoostsLevel, boosts.level + 1)); premiumCount.setText(LocaleController.formatString("BoostsLevel", R.string.BoostsLevel, boosts.level + 1));
} }
((FrameLayout.LayoutParams) premiumCount.getLayoutParams()).gravity = Gravity.RIGHT;
setType(LimitReachedBottomSheet.TYPE_BOOSTS); setType(LimitReachedBottomSheet.TYPE_BOOSTS);
defaultCount.setVisibility(View.GONE); defaultCount.setVisibility(View.GONE);
premiumText.setVisibility(View.GONE); premiumText.setVisibility(View.GONE);

View file

@ -192,7 +192,7 @@ public class LimitReachedBottomSheet extends BottomSheetWithRecyclerListView {
super.onViewCreated(containerView); super.onViewCreated(containerView);
Context context = containerView.getContext(); Context context = containerView.getContext();
premiumButtonView = new PremiumButtonView(context, true); premiumButtonView = new PremiumButtonView(context, true, resourcesProvider);
if (!hasFixedSize) { if (!hasFixedSize) {
divider = new View(context) { divider = new View(context) {
@ -820,10 +820,18 @@ public class LimitReachedBottomSheet extends BottomSheetWithRecyclerListView {
if (type == TYPE_BOOSTS_FOR_USERS) { if (type == TYPE_BOOSTS_FOR_USERS) {
descriptionStr = getBoostsDescriptionString(); descriptionStr = getBoostsDescriptionString();
} else if (type == TYPE_BOOSTS_FOR_POSTING) { } else if (type == TYPE_BOOSTS_FOR_POSTING) {
descriptionStr = LocaleController.formatString( if (boostsStatus.level == 0) {
"ChannelNeedBoostsDescription", R.string.ChannelNeedBoostsDescription, descriptionStr = LocaleController.formatString(
LocaleController.formatPluralString("MoreBoosts", boostsStatus.next_level_boosts, boostsStatus.next_level_boosts) "ChannelNeedBoostsDescription", R.string.ChannelNeedBoostsDescription,
); LocaleController.formatPluralString("MoreBoosts", boostsStatus.next_level_boosts, boostsStatus.next_level_boosts)
);
} else {
descriptionStr = LocaleController.formatString(
"ChannelNeedBoostsDescriptionNextLevel", R.string.ChannelNeedBoostsDescriptionNextLevel,
LocaleController.formatPluralString("MoreBoosts", boostsStatus.next_level_boosts, boostsStatus.next_level_boosts),
LocaleController.formatPluralString("BoostStories", boostsStatus.level)
);
}
} else if (type == TYPE_ADD_MEMBERS_RESTRICTED) { } else if (type == TYPE_ADD_MEMBERS_RESTRICTED) {
premiumLocked = true; premiumLocked = true;
if (!canSendLink) { if (!canSendLink) {
@ -944,7 +952,11 @@ public class LimitReachedBottomSheet extends BottomSheetWithRecyclerListView {
if (type == TYPE_BOOSTS_FOR_USERS) { if (type == TYPE_BOOSTS_FOR_USERS) {
title.setText(getBoostsTitleString()); title.setText(getBoostsTitleString());
} else if (type == TYPE_BOOSTS_FOR_POSTING) { } else if (type == TYPE_BOOSTS_FOR_POSTING) {
title.setText(LocaleController.getString("BoostingEnableStories", R.string.BoostingEnableStories)); if (boostsStatus.level == 0) {
title.setText(LocaleController.getString("BoostingEnableStories", R.string.BoostingEnableStories));
} else {
title.setText(LocaleController.getString("BoostingIncreaseLevel", R.string.BoostingIncreaseLevel));
}
} else if (type == TYPE_ADD_MEMBERS_RESTRICTED) { } else if (type == TYPE_ADD_MEMBERS_RESTRICTED) {
if (canSendLink) { if (canSendLink) {
title.setText(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink)); title.setText(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink));
@ -990,7 +1002,11 @@ public class LimitReachedBottomSheet extends BottomSheetWithRecyclerListView {
description.setText(AndroidUtilities.replaceTags(descriptionStr)); description.setText(AndroidUtilities.replaceTags(descriptionStr));
description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
description.setGravity(Gravity.CENTER_HORIZONTAL); description.setGravity(Gravity.CENTER_HORIZONTAL);
description.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider)); if (type == TYPE_BOOSTS_FOR_POSTING) {
description.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText, resourcesProvider));
} else {
description.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
}
addView(description, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 24, 0, 24, 24)); addView(description, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 24, 0, 24, 24));
updatePremiumButtonText(); updatePremiumButtonText();

View file

@ -56,11 +56,11 @@ public class PremiumButtonView extends FrameLayout {
CounterView counterView; CounterView counterView;
public boolean drawGradient = true; public boolean drawGradient = true;
public PremiumButtonView(@NonNull Context context, boolean createOverlayTextView) { public PremiumButtonView(@NonNull Context context, boolean createOverlayTextView, Theme.ResourcesProvider resourcesProvider) {
this(context, AndroidUtilities.dp(8), createOverlayTextView); this(context, AndroidUtilities.dp(8), createOverlayTextView, resourcesProvider);
} }
public PremiumButtonView(@NonNull Context context, int radius, boolean createOverlayTextView) { public PremiumButtonView(@NonNull Context context, int radius, boolean createOverlayTextView, Theme.ResourcesProvider resourcesProvider) {
super(context); super(context);
this.radius = radius; this.radius = radius;
@ -93,14 +93,14 @@ public class PremiumButtonView extends FrameLayout {
overlayTextView = new AnimatedTextView(context, true, true, true); overlayTextView = new AnimatedTextView(context, true, true, true);
overlayTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0); overlayTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
overlayTextView.setGravity(Gravity.CENTER); overlayTextView.setGravity(Gravity.CENTER);
overlayTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText)); overlayTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText, resourcesProvider));
overlayTextView.setTextSize(AndroidUtilities.dp(14)); overlayTextView.setTextSize(AndroidUtilities.dp(14));
overlayTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); overlayTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
overlayTextView.getDrawable().setAllowCancel(true); overlayTextView.getDrawable().setAllowCancel(true);
overlayTextView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(8), Color.TRANSPARENT, ColorUtils.setAlphaComponent(Color.WHITE, 120))); overlayTextView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(8), Color.TRANSPARENT, ColorUtils.setAlphaComponent(Color.WHITE, 120)));
addView(overlayTextView); addView(overlayTextView);
paintOverlayPaint.setColor(Theme.getColor(Theme.key_featuredStickers_addButton)); paintOverlayPaint.setColor(Theme.getColor(Theme.key_featuredStickers_addButton, resourcesProvider));
updateOverlayProgress(); updateOverlayProgress();
} }
} }

View file

@ -320,7 +320,7 @@ public class PremiumFeatureBottomSheet extends BottomSheet implements Notificati
if (!onlySelectedType) { if (!onlySelectedType) {
linearLayout.addView(bottomPages, LayoutHelper.createLinear(11 * premiumFeatures.size(), 5, Gravity.CENTER_HORIZONTAL, 0, 0, 0, 10)); linearLayout.addView(bottomPages, LayoutHelper.createLinear(11 * premiumFeatures.size(), 5, Gravity.CENTER_HORIZONTAL, 0, 0, 0, 10));
} }
premiumButtonView = new PremiumButtonView(getContext(), true); premiumButtonView = new PremiumButtonView(getContext(), true, resourcesProvider);
premiumButtonView.buttonLayout.setOnClickListener(v -> { premiumButtonView.buttonLayout.setOnClickListener(v -> {
if (fragment instanceof ChatActivity) { if (fragment instanceof ChatActivity) {
((ChatActivity) fragment).closeMenu(); ((ChatActivity) fragment).closeMenu();

View file

@ -195,7 +195,7 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView i
super.onViewCreated(containerView); super.onViewCreated(containerView);
currentAccount = UserConfig.selectedAccount; currentAccount = UserConfig.selectedAccount;
PremiumButtonView premiumButtonView = new PremiumButtonView(getContext(), false); PremiumButtonView premiumButtonView = new PremiumButtonView(getContext(), false, resourcesProvider);
premiumButtonView.setButton(PremiumPreviewFragment.getPremiumButtonText(currentAccount, null), v -> { premiumButtonView.setButton(PremiumPreviewFragment.getPremiumButtonText(currentAccount, null), v -> {
PremiumPreviewFragment.sentPremiumButtonClick(); PremiumPreviewFragment.sentPremiumButtonClick();
PremiumPreviewFragment.buyPremium(fragment, "profile"); PremiumPreviewFragment.buyPremium(fragment, "profile");

View file

@ -871,7 +871,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
pickerBottomFrameLayout.addView(pickerBottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48)); pickerBottomFrameLayout.addView(pickerBottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48));
containerView.addView(pickerBottomFrameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM)); containerView.addView(pickerBottomFrameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
premiumButtonView = new PremiumButtonView(context, false); premiumButtonView = new PremiumButtonView(context, false, resourcesProvider);
premiumButtonView.setIcon(R.raw.unlock_icon); premiumButtonView.setIcon(R.raw.unlock_icon);
premiumButtonView.setVisibility(View.INVISIBLE); premiumButtonView.setVisibility(View.INVISIBLE);
containerView.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 8, 0, 8, 8)); containerView.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 8, 0, 8, 8));

View file

@ -146,6 +146,11 @@ public class ViewPagerFixed extends FrameLayout {
this.adapter = adapter; this.adapter = adapter;
viewTypes[0] = adapter.getItemViewType(currentPosition); viewTypes[0] = adapter.getItemViewType(currentPosition);
viewPages[0] = adapter.createView(viewTypes[0]); viewPages[0] = adapter.createView(viewTypes[0]);
if (viewPages[0] == null && currentPosition != 0) {
currentPosition = 0;
viewTypes[0] = adapter.getItemViewType(currentPosition);
viewPages[0] = adapter.createView(viewTypes[0]);
}
adapter.bindView(viewPages[0], currentPosition, viewTypes[0]); adapter.bindView(viewPages[0], currentPosition, viewTypes[0]);
addView(viewPages[0]); addView(viewPages[0]);
viewPages[0].setVisibility(View.VISIBLE); viewPages[0].setVisibility(View.VISIBLE);

View file

@ -367,6 +367,9 @@ public class SpoilerEffect extends Drawable {
continue; continue;
} }
if (renderCount >= particlePoints[a].length - 2) {
continue;
}
particlePoints[a][renderCount] = p.x; particlePoints[a][renderCount] = p.x;
particlePoints[a][renderCount + 1] = p.y; particlePoints[a][renderCount + 1] = p.y;
renderCount += 2; renderCount += 2;

View file

@ -547,11 +547,11 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
if (attachMenuBot.side_menu_disclaimer_needed) { if (attachMenuBot.side_menu_disclaimer_needed) {
WebAppDisclaimerAlert.show(this, (ignore) -> { WebAppDisclaimerAlert.show(this, (ignore) -> {
attachMenuBot.side_menu_disclaimer_needed = false; attachMenuBot.side_menu_disclaimer_needed = false;
showAttachMenuBot(attachMenuBot); showAttachMenuBot(attachMenuBot, null);
MediaDataController.getInstance(currentAccount).updateAttachMenuBotsInCache(); MediaDataController.getInstance(currentAccount).updateAttachMenuBotsInCache();
}, null); }, null);
} else { } else {
showAttachMenuBot(attachMenuBot); showAttachMenuBot(attachMenuBot, null);
} }
return; return;
} }
@ -948,10 +948,10 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
RestrictedLanguagesSelectActivity.checkRestrictedLanguages(false); RestrictedLanguagesSelectActivity.checkRestrictedLanguages(false);
} }
private void showAttachMenuBot(TLRPC.TL_attachMenuBot attachMenuBot) { private void showAttachMenuBot(TLRPC.TL_attachMenuBot attachMenuBot, String startApp) {
BotWebViewSheet webViewSheet = new BotWebViewSheet(this, getLastFragment().getResourceProvider()); BotWebViewSheet webViewSheet = new BotWebViewSheet(this, getLastFragment().getResourceProvider());
webViewSheet.setParentActivity(this); webViewSheet.setParentActivity(this);
webViewSheet.requestWebView(currentAccount, attachMenuBot.bot_id, attachMenuBot.bot_id, attachMenuBot.short_name, null, BotWebViewSheet.TYPE_SIMPLE_WEB_VIEW_BUTTON, 0, false, BotWebViewSheet.FLAG_FROM_SIDE_MENU); webViewSheet.requestWebView(currentAccount, attachMenuBot.bot_id, attachMenuBot.bot_id, attachMenuBot.short_name, null, BotWebViewSheet.TYPE_SIMPLE_WEB_VIEW_BUTTON, 0, false, null, null, false, startApp, null, BotWebViewSheet.FLAG_FROM_SIDE_MENU);
webViewSheet.show(); webViewSheet.show();
} }
@ -2239,6 +2239,8 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
messageId = null; messageId = null;
} }
} else if (segments.size() == 1) {
startApp = data.getQueryParameter("startapp");
} }
} }
if (messageId != null) { if (messageId != null) {
@ -3724,15 +3726,18 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
} }
if (isBoost) { if (isBoost) {
processBoostDialog(peerId, dismissLoading); TLRPC.Chat chat = MessagesController.getInstance(intentAccount).getChat(-peerId);
return; if (ChatObject.isChannelAndNotMegaGroup(chat)) {
processBoostDialog(peerId, dismissLoading);
return;
}
} }
if (setAsAttachBot != null && attachMenuBotToOpen == null) { if ((setAsAttachBot != null || botAppStartParam != null) && attachMenuBotToOpen == null) {
TLRPC.User user = MessagesController.getInstance(intentAccount).getUser(peerId); TLRPC.User user = MessagesController.getInstance(intentAccount).getUser(peerId);
if (user != null && user.bot) { if (user != null && user.bot) {
if (user.bot_attach_menu) { if (user.bot_attach_menu) {
processAttachMenuBot(intentAccount, peerId, attachMenuBotChoose, user, setAsAttachBot); processAttachMenuBot(intentAccount, peerId, attachMenuBotChoose, user, setAsAttachBot, botAppStartParam);
} else { } else {
BulletinFactory.of(mainFragmentsStack.get(mainFragmentsStack.size() - 1)).createErrorBulletin(LocaleController.getString(R.string.BotCantAddToAttachMenu)).show(); BulletinFactory.of(mainFragmentsStack.get(mainFragmentsStack.size() - 1)).createErrorBulletin(LocaleController.getString(R.string.BotCantAddToAttachMenu)).show();
} }
@ -4569,7 +4574,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
args.putInt("message_id", messageId); args.putInt("message_id", messageId);
} }
TLRPC.Chat chatLocal = MessagesController.getInstance(currentAccount).getChat(channelId); TLRPC.Chat chatLocal = MessagesController.getInstance(currentAccount).getChat(channelId);
if (chatLocal != null && isBoost) { if (chatLocal != null && ChatObject.isChannelAndNotMegaGroup(chatLocal) && isBoost) {
processBoostDialog(-channelId, dismissLoading); processBoostDialog(-channelId, dismissLoading);
} else if (chatLocal != null && chatLocal.forum) { } else if (chatLocal != null && chatLocal.forum) {
openForumFromLink(-channelId, 0, messageId, () -> { openForumFromLink(-channelId, 0, messageId, () -> {
@ -4601,7 +4606,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
notFound = false; notFound = false;
MessagesController.getInstance(currentAccount).putChats(res.chats, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false);
TLRPC.Chat chat = res.chats.get(0); TLRPC.Chat chat = res.chats.get(0);
if (chat != null && isBoost) { if (chat != null && isBoost && ChatObject.isChannelAndNotMegaGroup(chat)) {
processBoostDialog(-channelId, null); processBoostDialog(-channelId, null);
} else if (chat != null && chat.forum) { } else if (chat != null && chat.forum) {
if (threadId != null) { if (threadId != null) {
@ -4742,16 +4747,24 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
return; return;
} }
boostsController.userCanBoostChannel(peerId, canApplyBoost -> { boostsController.userCanBoostChannel(peerId, canApplyBoost -> {
LimitReachedBottomSheet limitReachedBottomSheet = new LimitReachedBottomSheet(getLastFragment(), this, TYPE_BOOSTS_FOR_USERS, currentAccount, null);
limitReachedBottomSheet.setCanApplyBoost(canApplyBoost);
BaseFragment lastFragment = getLastFragment(); BaseFragment lastFragment = getLastFragment();
if (lastFragment == null) {
return;
}
Theme.ResourcesProvider resourcesProvider = lastFragment.getResourceProvider();
if (lastFragment.storyViewer != null && lastFragment.storyViewer.isFullyVisible()) {
resourcesProvider = lastFragment.storyViewer.getResourceProvider();
}
LimitReachedBottomSheet limitReachedBottomSheet = new LimitReachedBottomSheet(lastFragment, this, TYPE_BOOSTS_FOR_USERS, currentAccount, resourcesProvider);
limitReachedBottomSheet.setCanApplyBoost(canApplyBoost);
boolean isCurrentChat = false; boolean isCurrentChat = false;
if (lastFragment instanceof ChatActivity) { if (lastFragment instanceof ChatActivity) {
isCurrentChat = ((ChatActivity) lastFragment).getDialogId() == peerId; isCurrentChat = ((ChatActivity) lastFragment).getDialogId() == peerId;
} }
limitReachedBottomSheet.setBoostsStats(boostsStatus, isCurrentChat); limitReachedBottomSheet.setBoostsStats(boostsStatus, isCurrentChat);
limitReachedBottomSheet.setDialogId(peerId); limitReachedBottomSheet.setDialogId(peerId);
limitReachedBottomSheet.show(); lastFragment.showDialog(limitReachedBottomSheet);
try { try {
if (dismissLoading != null) { if (dismissLoading != null) {
dismissLoading.run(); dismissLoading.run();
@ -4763,7 +4776,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}); });
} }
private void processAttachMenuBot(int intentAccount, long peerId, String attachMenuBotChoose, TLRPC.User user, String setAsAttachBot) { private void processAttachMenuBot(int intentAccount, long peerId, String attachMenuBotChoose, TLRPC.User user, String setAsAttachBot, String startAppParam) {
TLRPC.TL_messages_getAttachMenuBot getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot(); TLRPC.TL_messages_getAttachMenuBot getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot();
getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId); getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId);
ConnectionsManager.getInstance(intentAccount).sendRequest(getAttachMenuBot, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> { ConnectionsManager.getInstance(intentAccount).sendRequest(getAttachMenuBot, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> {
@ -4771,6 +4784,10 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
TLRPC.TL_attachMenuBotsBot attachMenuBotsBot = (TLRPC.TL_attachMenuBotsBot) response1; TLRPC.TL_attachMenuBotsBot attachMenuBotsBot = (TLRPC.TL_attachMenuBotsBot) response1;
MessagesController.getInstance(intentAccount).putUsers(attachMenuBotsBot.users, false); MessagesController.getInstance(intentAccount).putUsers(attachMenuBotsBot.users, false);
TLRPC.TL_attachMenuBot attachMenuBot = attachMenuBotsBot.bot; TLRPC.TL_attachMenuBot attachMenuBot = attachMenuBotsBot.bot;
if (startAppParam != null) {
showAttachMenuBot(attachMenuBot, startAppParam);
return;
}
BaseFragment lastFragment_ = mainFragmentsStack.get(mainFragmentsStack.size() - 1); BaseFragment lastFragment_ = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
if (AndroidUtilities.isTablet() && !(lastFragment_ instanceof ChatActivity) && !rightFragmentsStack.isEmpty()) { if (AndroidUtilities.isTablet() && !(lastFragment_ instanceof ChatActivity) && !rightFragmentsStack.isEmpty()) {
lastFragment_ = rightFragmentsStack.get(rightFragmentsStack.size() - 1); lastFragment_ = rightFragmentsStack.get(rightFragmentsStack.size() - 1);
@ -5169,9 +5186,6 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
} }
public void checkAppUpdate(boolean force) { public void checkAppUpdate(boolean force) {
if (!BuildVars.isStandaloneApp()) {
return;
}
if (!force && BuildVars.DEBUG_VERSION || !force && !BuildVars.CHECK_UPDATES) { if (!force && BuildVars.DEBUG_VERSION || !force && !BuildVars.CHECK_UPDATES) {
return; return;
} }

View file

@ -2715,6 +2715,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
default void onPreOpen() {} default void onPreOpen() {}
default void onPreClose() {} default void onPreClose() {}
default void onEditModeChanged(boolean isEditMode) {}
default boolean onDeletePhoto(int index) { default boolean onDeletePhoto(int index) {
return true; return true;
} }
@ -6039,9 +6040,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
@Override @Override
protected void setupMentionContainer() { protected void setupMentionContainer() {
if (parentChatActivity != null) {
return;
}
mentionContainer.getAdapter().setAllowStickers(false); mentionContainer.getAdapter().setAllowStickers(false);
mentionContainer.getAdapter().setAllowBots(false); mentionContainer.getAdapter().setAllowBots(false);
mentionContainer.getAdapter().setAllowChats(false); mentionContainer.getAdapter().setAllowChats(false);
@ -9875,6 +9873,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (currentEditMode == mode || (isCurrentVideo && photoProgressViews[0].backgroundState != 3) && !isCurrentVideo && (centerImage.getBitmap() == null || photoProgressViews[0].backgroundState != -1) || changeModeAnimation != null || imageMoveAnimation != null || isCaptionOpen()) { if (currentEditMode == mode || (isCurrentVideo && photoProgressViews[0].backgroundState != 3) && !isCurrentVideo && (centerImage.getBitmap() == null || photoProgressViews[0].backgroundState != -1) || changeModeAnimation != null || imageMoveAnimation != null || isCaptionOpen()) {
return; return;
} }
if (placeProvider != null && (currentEditMode == EDIT_MODE_NONE || mode == EDIT_MODE_NONE)) {
placeProvider.onEditModeChanged(mode != EDIT_MODE_NONE);
}
windowView.setClipChildren(mode == EDIT_MODE_FILTER); windowView.setClipChildren(mode == EDIT_MODE_FILTER);
int navigationBarColorFrom = 0x7f000000; int navigationBarColorFrom = 0x7f000000;
if (navigationBar.getBackground() instanceof ColorDrawable) { if (navigationBar.getBackground() instanceof ColorDrawable) {

View file

@ -583,7 +583,7 @@ public class PremiumPreviewFragment extends BaseFragment implements Notification
}); });
contentView.addView(listView); contentView.addView(listView);
premiumButtonView = new PremiumButtonView(context, false); premiumButtonView = new PremiumButtonView(context, false, getResourceProvider());
updateButtonText(false); updateButtonText(false);
buttonContainer = new FrameLayout(context); buttonContainer = new FrameLayout(context);

View file

@ -2161,7 +2161,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
args.putLong("chat_id", chatId); args.putLong("chat_id", chatId);
args.putBoolean("is_megagroup", chat.megagroup); args.putBoolean("is_megagroup", chat.megagroup);
if (!chatInfo.can_view_stats) { if (!chatInfo.can_view_stats) {
args.putBoolean("only_boosts", chat.megagroup); args.putBoolean("only_boosts", true);
} }
StatisticActivity fragment = new StatisticActivity(args); StatisticActivity fragment = new StatisticActivity(args);
presentFragment(fragment); presentFragment(fragment);
@ -4448,9 +4448,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
private final AccelerateDecelerateInterpolator floatingInterpolator = new AccelerateDecelerateInterpolator(); private final AccelerateDecelerateInterpolator floatingInterpolator = new AccelerateDecelerateInterpolator();
private void createFloatingActionButton(Context context) { private void createFloatingActionButton(Context context) {
if (!getMessagesController().storiesEnabled()) {
return;
}
if (getDialogId() > 0L) { if (getDialogId() > 0L) {
return; return;
} }
if (!ChatObject.isChannelAndNotMegaGroup(-getDialogId(), currentAccount)) {
return;
}
StoriesController storiesController = getMessagesController().getStoriesController(); StoriesController storiesController = getMessagesController().getStoriesController();
if (!storiesController.canPostStories(getDialogId())) { if (!storiesController.canPostStories(getDialogId())) {
return; return;
@ -4489,7 +4495,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
args.putBoolean("is_megagroup", chat.megagroup); args.putBoolean("is_megagroup", chat.megagroup);
args.putBoolean("start_from_boosts", true); args.putBoolean("start_from_boosts", true);
if (chatInfo == null || !chatInfo.can_view_stats) { if (chatInfo == null || !chatInfo.can_view_stats) {
args.putBoolean("only_boosts", chat.megagroup); args.putBoolean("only_boosts", true);
}; };
StatisticActivity fragment = new StatisticActivity(args); StatisticActivity fragment = new StatisticActivity(args);
presentFragment(fragment); presentFragment(fragment);
@ -5933,18 +5939,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (writeButton != null) { if (writeButton != null) {
writeButton.setTranslationY((actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight + searchTransitionOffset - AndroidUtilities.dp(29.5f)); writeButton.setTranslationY((actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight + searchTransitionOffset - AndroidUtilities.dp(29.5f));
if (storyView != null) { boolean writeButtonVisible = diff > 0.2f && !searchMode && (imageUpdater == null || setAvatarRow == -1);
storyView.setExpandCoords(avatarContainer2.getMeasuredWidth() - AndroidUtilities.dp(111), (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight + searchTransitionOffset); if (writeButtonVisible && chatId != 0) {
writeButtonVisible = ChatObject.isChannel(currentChat) && !currentChat.megagroup && chatInfo != null && chatInfo.linked_chat_id != 0 && infoHeaderRow != -1;
} }
if (!openAnimationInProgress) { if (!openAnimationInProgress) {
boolean setVisible = diff > 0.2f && !searchMode && (imageUpdater == null || setAvatarRow == -1);
if (setVisible && chatId != 0) {
setVisible = ChatObject.isChannel(currentChat) && !currentChat.megagroup && chatInfo != null && chatInfo.linked_chat_id != 0 && infoHeaderRow != -1;
}
boolean currentVisible = writeButton.getTag() == null; boolean currentVisible = writeButton.getTag() == null;
if (setVisible != currentVisible) { if (writeButtonVisible != currentVisible) {
if (setVisible) { if (writeButtonVisible) {
writeButton.setTag(null); writeButton.setTag(null);
} else { } else {
writeButton.setTag(0); writeButton.setTag(0);
@ -5956,7 +5958,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
if (animated) { if (animated) {
writeButtonAnimation = new AnimatorSet(); writeButtonAnimation = new AnimatorSet();
if (setVisible) { if (writeButtonVisible) {
writeButtonAnimation.setInterpolator(new DecelerateInterpolator()); writeButtonAnimation.setInterpolator(new DecelerateInterpolator());
writeButtonAnimation.playTogether( writeButtonAnimation.playTogether(
ObjectAnimator.ofFloat(writeButton, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(writeButton, View.SCALE_X, 1.0f),
@ -5982,9 +5984,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}); });
writeButtonAnimation.start(); writeButtonAnimation.start();
} else { } else {
writeButton.setScaleX(setVisible ? 1.0f : 0.2f); writeButton.setScaleX(writeButtonVisible ? 1.0f : 0.2f);
writeButton.setScaleY(setVisible ? 1.0f : 0.2f); writeButton.setScaleY(writeButtonVisible ? 1.0f : 0.2f);
writeButton.setAlpha(setVisible ? 1.0f : 0.0f); writeButton.setAlpha(writeButtonVisible ? 1.0f : 0.0f);
} }
} }
@ -5999,6 +6001,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
} }
} }
if (storyView != null) {
storyView.setExpandCoords(avatarContainer2.getMeasuredWidth() - AndroidUtilities.dp(writeButtonVisible ? 111 : 40), (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight + searchTransitionOffset);
}
} }
avatarX = -AndroidUtilities.dpf2(47f) * diff; avatarX = -AndroidUtilities.dpf2(47f) * diff;

View file

@ -2536,7 +2536,7 @@ public class SelectAnimatedEmojiDialog extends FrameLayout implements Notificati
addButtonView.addView(addButtonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); addButtonView.addView(addButtonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
addView(addButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(addButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
premiumButtonView = new PremiumButtonView(getContext(), false); premiumButtonView = new PremiumButtonView(getContext(), false, resourcesProvider);
premiumButtonView.setIcon(R.raw.unlock_icon); premiumButtonView.setIcon(R.raw.unlock_icon);
addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
} }

View file

@ -2572,6 +2572,8 @@ public class StatisticActivity extends BaseFragment implements NotificationCente
Integer colorKey = (Integer) secondary[i].getTag(); Integer colorKey = (Integer) secondary[i].getTag();
if (colorKey != null) { if (colorKey != null) {
secondary[i].setTextColor(Theme.getColor(colorKey)); secondary[i].setTextColor(Theme.getColor(colorKey));
} else {
secondary[i].setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
} }
} }
} }

View file

@ -1035,8 +1035,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if (popupMenu != null) { if (popupMenu != null) {
popupMenu.dismiss(); popupMenu.dismiss();
} }
setActive(false); Runnable openEdit = () -> {
final Runnable openEdit = () -> {
StoryRecorder editor = StoryRecorder.getInstance(activity, currentAccount); StoryRecorder editor = StoryRecorder.getInstance(activity, currentAccount);
long time = 0; long time = 0;
if (playerSharedScope != null && playerSharedScope.player != null) { if (playerSharedScope != null && playerSharedScope.player != null) {
@ -1051,11 +1050,16 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
entry = entry.copy(); entry = entry.copy();
} }
editor.openEdit(StoryRecorder.SourceView.fromStoryViewer(storyViewer), entry, time, true); editor.openEdit(StoryRecorder.SourceView.fromStoryViewer(storyViewer), entry, time, true);
editor.setOnFullyOpenListener(() -> {
editOpened = true;
setActive(false);
});
editor.setOnPrepareCloseListener((t, close, sent) -> { editor.setOnPrepareCloseListener((t, close, sent) -> {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
if (playerSharedScope.player == null) { if (playerSharedScope.player == null) {
delegate.setPopupIsVisible(false); delegate.setPopupIsVisible(false);
setActive(true); setActive(true);
editOpened = false;
onImageReceiverThumbLoaded = () -> { onImageReceiverThumbLoaded = () -> {
AndroidUtilities.cancelRunOnUIThread(close); AndroidUtilities.cancelRunOnUIThread(close);
AndroidUtilities.runOnUIThread(close); AndroidUtilities.runOnUIThread(close);
@ -1075,10 +1079,11 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if (muteIconView != null) { if (muteIconView != null) {
muteIconView.setAnimation(sharedResources.muteDrawable); muteIconView.setAnimation(sharedResources.muteDrawable);
} }
if (videoDuration > 0 && t > videoDuration * .4f) { if (videoDuration > 0 && t > videoDuration - 1400) {
t = 0L; t = 0L;
} }
setActive(t, true); setActive(t, true);
editOpened = false;
AndroidUtilities.runOnUIThread(close, 400); AndroidUtilities.runOnUIThread(close, 400);
if (sent) { if (sent) {
updatePosition(); updatePosition();
@ -1721,10 +1726,27 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} }
private void toggleArchiveForStory(long dialogId) { private void toggleArchiveForStory(long dialogId) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId); boolean hide;
boolean hide = !user.stories_hidden; TLRPC.User user = null;
TLRPC.Chat chat = null;
TLObject object = null;
String name = null;
if (dialogId > 0) {
user = MessagesController.getInstance(currentAccount).getUser(dialogId);
object = user;
name = user.first_name;
hide = !user.stories_hidden;
} else {
chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
object = chat;
name = chat.title;
hide = !chat.stories_hidden;
}
MessagesController messagesController = MessagesController.getInstance(currentAccount); MessagesController messagesController = MessagesController.getInstance(currentAccount);
TLObject finalObject = object;
String finalName = name;
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
messagesController.getStoriesController().toggleHidden(dialogId, hide, false, true); messagesController.getStoriesController().toggleHidden(dialogId, hide, false, true);
BulletinFactory.UndoObject undoObject = new BulletinFactory.UndoObject(); BulletinFactory.UndoObject undoObject = new BulletinFactory.UndoObject();
@ -1736,11 +1758,11 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
}; };
CharSequence str; CharSequence str;
if (!hide) { if (!hide) {
str = AndroidUtilities.replaceTags(LocaleController.formatString("StoriesMovedToDialogs", R.string.StoriesMovedToDialogs, ContactsController.formatName(user.first_name, null, 10))); str = AndroidUtilities.replaceTags(LocaleController.formatString("StoriesMovedToDialogs", R.string.StoriesMovedToDialogs, ContactsController.formatName(finalName, null, 10)));
} else { } else {
str = AndroidUtilities.replaceTags(LocaleController.formatString("StoriesMovedToContacts", R.string.StoriesMovedToContacts, ContactsController.formatName(user.first_name, null, 10))); str = AndroidUtilities.replaceTags(LocaleController.formatString("StoriesMovedToContacts", R.string.StoriesMovedToContacts, ContactsController.formatName(finalName, null, 10)));
} }
BulletinFactory.of(storyContainer, resourcesProvider).createUsersBulletin(Arrays.asList(user), str, null, undoObject).setTag(2).show(); BulletinFactory.of(storyContainer, resourcesProvider).createUsersBulletin(Arrays.asList(finalObject), str, null, undoObject).setTag(2).show();
}, 200); }, 200);
} }
@ -3174,8 +3196,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if (thumbDrawable == null) { if (thumbDrawable == null) {
thumbDrawable = ImageLoader.createStripedBitmap(storyItem.media.document.thumbs); thumbDrawable = ImageLoader.createStripedBitmap(storyItem.media.document.thumbs);
} }
// imageReceiver.setImage(null, null, ImageLocation.getForDocument(storyItem.media.document), filter + "_pframe", ImageLocation.getForDocument(size, storyItem.media.document), filter, thumbDrawable, 0, null, storyItem, 0); imageReceiver.setImage(null, null, ImageLocation.getForDocument(storyItem.media.document), filter + "_pframe", ImageLocation.getForDocument(size, storyItem.media.document), filter, thumbDrawable, 0, null, storyItem, 0);
imageReceiver.setImage(null, null, ImageLocation.getForDocument(size, storyItem.media.document), filter, null, null, thumbDrawable, 0, null, storyItem, 0);
} else { } else {
TLRPC.Photo photo = storyItem.media != null ? storyItem.media.photo : null; TLRPC.Photo photo = storyItem.media != null ? storyItem.media.photo : null;
if (photo != null && photo.sizes != null) { if (photo != null && photo.sizes != null) {
@ -3183,12 +3204,12 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
thumbDrawable = ImageLoader.createStripedBitmap(photo.sizes); thumbDrawable = ImageLoader.createStripedBitmap(photo.sizes);
} }
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, Integer.MAX_VALUE); TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, Integer.MAX_VALUE);
// TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 800); TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 800);
// if (thumbSize != size) { // if (thumbSize != size) {
// imageReceiver.setImage(ImageLocation.getForPhoto(size, photo), filter, ImageLocation.getForPhoto(thumbSize, photo), filter, null, null, thumbDrawable, 0, null, storyItem, 0); // imageReceiver.setImage(null, null, ImageLocation.getForPhoto(size, photo), filter, ImageLocation.getForPhoto(thumbSize, photo), filter, thumbDrawable, 0, null, storyItem, 0);
// } else { // } else {
imageReceiver.setImage(null, null, ImageLocation.getForPhoto(size, photo), filter, null, null, thumbDrawable, 0, null, storyItem, 0); imageReceiver.setImage(null, null, ImageLocation.getForPhoto(size, photo), filter, null, null, thumbDrawable, 0, null, storyItem, 0);
// } // }
} else { } else {
imageReceiver.clearImage(); imageReceiver.clearImage();
} }
@ -3999,6 +4020,8 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} }
} }
public boolean editOpened;
public void setActive(boolean active) { public void setActive(boolean active) {
setActive(0, active); setActive(0, active);
} }
@ -4570,7 +4593,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
caption = Emoji.replaceEmoji(caption, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); caption = Emoji.replaceEmoji(caption, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(caption); SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(caption);
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
if (MessagesController.getInstance(currentAccount).storyEntitiesAllowed(user)) { if (dialogId < 0 || MessagesController.getInstance(currentAccount).storyEntitiesAllowed(user)) {
MessageObject.addLinks(true, spannableStringBuilder); MessageObject.addLinks(true, spannableStringBuilder);
} }
} else if (currentStory.storyItem != null) { } else if (currentStory.storyItem != null) {
@ -4584,7 +4607,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
spannableStringBuilder = SpannableStringBuilder.valueOf(MessageObject.replaceAnimatedEmoji(spannableStringBuilder, text.entities, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false)); spannableStringBuilder = SpannableStringBuilder.valueOf(MessageObject.replaceAnimatedEmoji(spannableStringBuilder, text.entities, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false));
SpannableStringBuilder.valueOf(Emoji.replaceEmoji(spannableStringBuilder, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false)); SpannableStringBuilder.valueOf(Emoji.replaceEmoji(spannableStringBuilder, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false));
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
if (MessagesController.getInstance(currentAccount).storyEntitiesAllowed(user)) { if (dialogId < 0 || MessagesController.getInstance(currentAccount).storyEntitiesAllowed(user)) {
MessageObject.addLinks(true, spannableStringBuilder); MessageObject.addLinks(true, spannableStringBuilder);
MessageObject.addEntitiesToText(spannableStringBuilder, text.entities, false, true, true, false); MessageObject.addEntitiesToText(spannableStringBuilder, text.entities, false, true, true, false);
} }
@ -4598,7 +4621,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
spannableStringBuilder = SpannableStringBuilder.valueOf(MessageObject.replaceAnimatedEmoji(spannableStringBuilder, currentStory.storyItem.entities, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false)); spannableStringBuilder = SpannableStringBuilder.valueOf(MessageObject.replaceAnimatedEmoji(spannableStringBuilder, currentStory.storyItem.entities, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false));
SpannableStringBuilder.valueOf(Emoji.replaceEmoji(spannableStringBuilder, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false)); SpannableStringBuilder.valueOf(Emoji.replaceEmoji(spannableStringBuilder, storyCaptionView.captionTextview.getPaint().getFontMetricsInt(), false));
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
if (MessagesController.getInstance(currentAccount).storyEntitiesAllowed(user)) { if (dialogId < 0 || MessagesController.getInstance(currentAccount).storyEntitiesAllowed(user)) {
MessageObject.addLinks(true, spannableStringBuilder); MessageObject.addLinks(true, spannableStringBuilder);
MessageObject.addEntitiesToText(spannableStringBuilder, currentStory.storyItem.entities, false, true, true, false); MessageObject.addEntitiesToText(spannableStringBuilder, currentStory.storyItem.entities, false, true, true, false);
} }
@ -4713,15 +4736,14 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if (UserObject.getPublicUsername(user) == null) { if (UserObject.getPublicUsername(user) == null) {
return null; return null;
} }
return String.format(Locale.US, "https://t.me/%s/s/%s", UserObject.getPublicUsername(user), currentStory.storyItem.id); return String.format(Locale.US, "https://t.me/%1$s/s/%2$s", UserObject.getPublicUsername(user), currentStory.storyItem.id);
} else { } else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
if (ChatObject.getPublicUsername(chat) == null) { if (ChatObject.getPublicUsername(chat) == null) {
return null; return null;
} }
return String.format(Locale.US, "https://t.me/%s/s/%s", ChatObject.getPublicUsername(chat), currentStory.storyItem.id); return String.format(Locale.US, "https://t.me/%1$s/s/%2$s", ChatObject.getPublicUsername(chat), currentStory.storyItem.id);
} }
// return String.format(Locale.US, "tg://resolve?domain=%s&story=%s", user.username, currentStory.storyItem.id);
} }
public File getPath() { public File getPath() {

View file

@ -737,7 +737,7 @@ public class SelfStoryViewsPage extends FrameLayout implements NotificationCente
view = new FixedHeightEmptyCell(getContext(), 70); view = new FixedHeightEmptyCell(getContext(), 70);
break; break;
case USER_ITEM: case USER_ITEM:
view = new ReactedUserHolderView(ReactedUserHolderView.STYLE_STORY, currentAccount, getContext(), resourcesProvider) { view = new ReactedUserHolderView(ReactedUserHolderView.STYLE_STORY, currentAccount, getContext(), resourcesProvider, false) {
@Override @Override
public void openStory(long dialogId, Runnable onDone) { public void openStory(long dialogId, Runnable onDone) {
BaseFragment lastFragment = LaunchActivity.getLastFragment(); BaseFragment lastFragment = LaunchActivity.getLastFragment();

View file

@ -110,7 +110,7 @@ public class StealthModeAlert extends BottomSheet {
linearLayout.addView(itemCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,0, 0, 10, 0, 0)); linearLayout.addView(itemCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,0, 0, 10, 0, 0));
button = new PremiumButtonView(context, AndroidUtilities.dp(8), true); button = new PremiumButtonView(context, AndroidUtilities.dp(8), true, resourcesProvider);
button.drawGradient = false; button.drawGradient = false;
button.overlayTextView.getDrawable().setSplitByWords(false); button.overlayTextView.getDrawable().setSplitByWords(false);
button.setIcon(R.raw.unlock_icon); button.setIcon(R.raw.unlock_icon);

View file

@ -3208,7 +3208,7 @@ public class StoriesController {
public boolean canPostStories(long dialogId) { public boolean canPostStories(long dialogId) {
if (dialogId < 0) { if (dialogId < 0) {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
if (chat == null) { if (chat == null || !ChatObject.isChannelAndNotMegaGroup(chat)) {
return false; return false;
} }
return chat.creator || chat.admin_rights != null && chat.admin_rights.post_stories; return chat.creator || chat.admin_rights != null && chat.admin_rights.post_stories;

View file

@ -202,7 +202,8 @@ public class StoriesViewPager extends ViewPager {
private void updateActiveStory() { private void updateActiveStory() {
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
((PeerStoriesView) ((FrameLayout) getChildAt(i)).getChildAt(0)).setActive((Integer) getChildAt(i).getTag() == getCurrentItem()); PeerStoriesView peerStoriesView = ((PeerStoriesView) ((FrameLayout) getChildAt(i)).getChildAt(0));
peerStoriesView.setActive((Integer) getChildAt(i).getTag() == getCurrentItem() && !peerStoriesView.editOpened);
} }
} }

View file

@ -221,6 +221,8 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
private static final LongSparseArray<CharSequence> replyDrafts = new LongSparseArray<>(); private static final LongSparseArray<CharSequence> replyDrafts = new LongSparseArray<>();
public boolean fromBottomSheet; public boolean fromBottomSheet;
private boolean paused;
private long playerSavedPosition;
public static boolean isShowingImage(MessageObject messageObject) { public static boolean isShowingImage(MessageObject messageObject) {
if (lastStoryItem == null || messageObject.type != MessageObject.TYPE_STORY && !messageObject.isWebpage() || runOpenAnimationAfterLayout) { if (lastStoryItem == null || messageObject.type != MessageObject.TYPE_STORY && !messageObject.isWebpage() || runOpenAnimationAfterLayout) {
@ -1301,6 +1303,10 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
currentPlayerScope.surfaceView = surfaceView; currentPlayerScope.surfaceView = surfaceView;
FileStreamLoadOperation.setPriorityForDocument(playerHolder.document, FileLoader.PRIORITY_HIGH); FileStreamLoadOperation.setPriorityForDocument(playerHolder.document, FileLoader.PRIORITY_HIGH);
FileLoader.getInstance(currentAccount).changePriority(FileLoader.PRIORITY_HIGH, playerHolder.document, null, null, null, null, null); FileLoader.getInstance(currentAccount).changePriority(FileLoader.PRIORITY_HIGH, playerHolder.document, null, null, null, null, null);
if (t == 0 && playerSavedPosition != 0) {
t = playerSavedPosition;
currentPlayerScope.firstFrameRendered = true;
}
currentPlayerScope.player.start(isPaused(), uri, t, isInSilentMode); currentPlayerScope.player.start(isPaused(), uri, t, isInSilentMode);
currentPlayerScope.invalidate(); currentPlayerScope.invalidate();
} }
@ -1319,6 +1325,7 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
surfaceView.setVisibility(View.VISIBLE); surfaceView.setVisibility(View.VISIBLE);
} }
} }
playerSavedPosition = 0;
updatePlayingMode(); updatePlayingMode();
} }
@ -2501,6 +2508,20 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
} }
} else if (id == NotificationCenter.openArticle || id == NotificationCenter.articleClosed) { } else if (id == NotificationCenter.openArticle || id == NotificationCenter.articleClosed) {
updatePlayingMode(); updatePlayingMode();
if (id == NotificationCenter.openArticle) {
if (playerHolder != null) {
playerSavedPosition = playerHolder.currentPosition;
playerHolder.release(null);
playerHolder = null;
} else {
playerSavedPosition = 0;
}
} else if (!paused) {
PeerStoriesView peerView = getCurrentPeerView();
if (peerView != null) {
getCurrentPeerView().updatePosition();
}
}
} }
} }
@ -2530,9 +2551,20 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
} }
public void onResume() { public void onResume() {
PeerStoriesView peerView = getCurrentPeerView(); paused = false;
if (peerView != null) { if (!ArticleViewer.getInstance().isVisible()) {
getCurrentPeerView().updatePosition(); PeerStoriesView peerView = getCurrentPeerView();
if (peerView != null) {
getCurrentPeerView().updatePosition();
}
}
}
public void onPause() {
paused = true;
if (playerHolder != null) {
playerHolder.release(null);
playerHolder = null;
} }
} }

View file

@ -217,6 +217,7 @@ public class CaptionContainerView extends FrameLayout {
editText.setFocusableInTouchMode(true); editText.setFocusableInTouchMode(true);
editText.getEditText().hintLayoutYFix = true; editText.getEditText().hintLayoutYFix = true;
editText.getEditText().drawHint = this::drawHint; editText.getEditText().drawHint = this::drawHint;
editText.getEditText().setSupportRtlHint(true);
captionBlur = new BlurringShader.StoryBlurDrawer(blurManager, editText.getEditText(), customBlur() ? BlurringShader.StoryBlurDrawer.BLUR_TYPE_CAPTION : BlurringShader.StoryBlurDrawer.BLUR_TYPE_CAPTION_XFER); captionBlur = new BlurringShader.StoryBlurDrawer(blurManager, editText.getEditText(), customBlur() ? BlurringShader.StoryBlurDrawer.BLUR_TYPE_CAPTION : BlurringShader.StoryBlurDrawer.BLUR_TYPE_CAPTION_XFER);
editText.getEditText().setHintColor(0x80ffffff); editText.getEditText().setHintColor(0x80ffffff);
editText.getEditText().setHintText(LocaleController.getString("AddCaption", R.string.AddCaption), false); editText.getEditText().setHintText(LocaleController.getString("AddCaption", R.string.AddCaption), false);
@ -800,6 +801,7 @@ public class CaptionContainerView extends FrameLayout {
return; return;
} }
final EditTextCaption e = editText.getEditText(); final EditTextCaption e = editText.getEditText();
canvas.translate(-e.hintLayoutX, 0);
canvas.saveLayerAlpha(0, 0, hintTextBitmap.getWidth(), hintTextBitmap.getHeight(), 0xff, Canvas.ALL_SAVE_FLAG); canvas.saveLayerAlpha(0, 0, hintTextBitmap.getWidth(), hintTextBitmap.getHeight(), 0xff, Canvas.ALL_SAVE_FLAG);
rectF.set(0, 1, hintTextBitmap.getWidth(), hintTextBitmap.getHeight() - 1); rectF.set(0, 1, hintTextBitmap.getWidth(), hintTextBitmap.getHeight() - 1);
drawBlur(captionBlur, canvas, rectF, 0, true, -editText.getX() - e.getPaddingLeft(), -editText.getY() - e.getPaddingTop() - e.getExtendedPaddingTop(), true); drawBlur(captionBlur, canvas, rectF, 0, true, -editText.getX() - e.getPaddingLeft(), -editText.getY() - e.getPaddingTop() - e.getExtendedPaddingTop(), true);

View file

@ -358,7 +358,8 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
inBubbleMode = context instanceof BubbleActivity; inBubbleMode = context instanceof BubbleActivity;
PersistColorPalette palette = PersistColorPalette.getInstance(currentAccount); PersistColorPalette palette = PersistColorPalette.getInstance(currentAccount);
colorSwatch.color = palette.getColor(0); palette.resetCurrentColor();
colorSwatch.color = palette.getCurrentColor();
colorSwatch.brushWeight = palette.getCurrentWeight(); colorSwatch.brushWeight = palette.getCurrentWeight();
queue = new DispatchQueue("Paint"); queue = new DispatchQueue("Paint");
@ -745,6 +746,7 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
int childWidth = child.getWidth() - child.getPaddingLeft() - child.getPaddingRight(); int childWidth = child.getWidth() - child.getPaddingLeft() - child.getPaddingRight();
int childHeight = child.getHeight() - child.getPaddingTop() - child.getPaddingBottom(); int childHeight = child.getHeight() - child.getPaddingTop() - child.getPaddingBottom();
float cx = child.getX() + child.getPaddingLeft() + childWidth / 2f, cy = child.getY() + child.getPaddingTop() + childHeight / 2f; float cx = child.getX() + child.getPaddingLeft() + childWidth / 2f, cy = child.getY() + child.getPaddingTop() + childHeight / 2f;
int colorCircle = colorSwatch.color;
if (tabsNewSelectedIndex != -1) { if (tabsNewSelectedIndex != -1) {
ViewGroup barView2 = (ViewGroup) getBarView(tabsNewSelectedIndex); ViewGroup barView2 = (ViewGroup) getBarView(tabsNewSelectedIndex);
View newView = (barView2 == null ? barView : barView2).getChildAt(0); View newView = (barView2 == null ? barView : barView2).getChildAt(0);
@ -758,6 +760,8 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
View animateToView = colorsListView.getChildAt(0); View animateToView = colorsListView.getChildAt(0);
cx = lerp(cx, colorsListView.getX() - barView.getLeft() + animateToView.getX() + animateToView.getWidth() / 2f, toolsTransformProgress); cx = lerp(cx, colorsListView.getX() - barView.getLeft() + animateToView.getX() + animateToView.getWidth() / 2f, toolsTransformProgress);
cy = lerp(cy, colorsListView.getY() - barView.getTop() + animateToView.getY() + animateToView.getHeight() / 2f, toolsTransformProgress); cy = lerp(cy, colorsListView.getY() - barView.getTop() + animateToView.getY() + animateToView.getHeight() / 2f, toolsTransformProgress);
int paletteFirstColor = palette.getColor(0);
colorCircle = ColorUtils.blendARGB(colorSwatch.color, paletteFirstColor, toolsTransformProgress);
} }
checkRainbow(cx, cy); checkRainbow(cx, cy);
@ -769,16 +773,21 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
AndroidUtilities.rectTmp.set(cx - rad, cy - rad, cx + rad, cy + rad); AndroidUtilities.rectTmp.set(cx - rad, cy - rad, cx + rad, cy + rad);
canvas.drawArc(AndroidUtilities.rectTmp, 0, 360, false, colorPickerRainbowPaint); canvas.drawArc(AndroidUtilities.rectTmp, 0, 360, false, colorPickerRainbowPaint);
colorSwatchPaint.setColor(colorSwatch.color); colorSwatchPaint.setColor(colorCircle);
colorSwatchPaint.setAlpha((int) (colorSwatchPaint.getAlpha() * child.getAlpha())); colorSwatchPaint.setAlpha((int) (colorSwatchPaint.getAlpha() * child.getAlpha()));
colorSwatchOutlinePaint.setColor(colorSwatch.color); colorSwatchOutlinePaint.setColor(colorCircle);
colorSwatchOutlinePaint.setAlpha((int) (0xFF * child.getAlpha())); colorSwatchOutlinePaint.setAlpha((int) (0xFF * child.getAlpha()));
float rad2 = rad - dp(3f); float rad2 = rad - dp(3f);
if (colorsListView != null && colorsListView.getSelectedColorIndex() != 0) {
rad2 = lerp(rad - dp(3f), rad + dp(2), toolsTransformProgress);
}
PaintColorsListView.drawColorCircle(canvas, cx, cy, rad2, colorSwatchPaint.getColor()); PaintColorsListView.drawColorCircle(canvas, cx, cy, rad2, colorSwatchPaint.getColor());
colorSwatchOutlinePaint.setAlpha((int) (colorSwatchOutlinePaint.getAlpha() * toolsTransformProgress * child.getAlpha())); if (colorsListView != null && colorsListView.getSelectedColorIndex() == 0) {
canvas.drawCircle(cx, cy, rad - (dp(3f) + colorSwatchOutlinePaint.getStrokeWidth()) * (1f - toolsTransformProgress), colorSwatchOutlinePaint); colorSwatchOutlinePaint.setAlpha((int) (colorSwatchOutlinePaint.getAlpha() * toolsTransformProgress * child.getAlpha()));
canvas.drawCircle(cx, cy, rad - (AndroidUtilities.dp(3f) + colorSwatchOutlinePaint.getStrokeWidth()) * (1f - toolsTransformProgress), colorSwatchOutlinePaint);
}
} }
canvas.restore(); canvas.restore();
@ -970,16 +979,17 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
public void onColorSelected(int color) { public void onColorSelected(int color) {
showColorList(false); showColorList(false);
PersistColorPalette.getInstance(currentAccount).selectColor(color); palette.selectColor(color);
PersistColorPalette.getInstance(currentAccount).saveColors(); palette.saveColors();
setNewColor(color); setNewColor(color);
colorsListView.setSelectedColorIndex(palette.getCurrentColorPosition());
colorsListView.getAdapter().notifyDataSetChanged(); colorsListView.getAdapter().notifyDataSetChanged();
} }
}).setColorListener(color -> { }).setColorListener(color -> {
PersistColorPalette.getInstance(currentAccount).selectColor(color); palette.selectColor(color);
PersistColorPalette.getInstance(currentAccount).saveColors(); palette.saveColors();
setNewColor(color); setNewColor(color);
colorsListView.getAdapter().notifyDataSetChanged(); colorsListView.setSelectedColorIndex(palette.getCurrentColorPosition());
colorPickerBottomSheet = null; colorPickerBottomSheet = null;
}).show(); }).show();
return; return;
@ -1648,6 +1658,10 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
tabsNewSelectedIndex = index; tabsNewSelectedIndex = index;
final View newView = getBarView(tabsNewSelectedIndex); final View newView = getBarView(tabsNewSelectedIndex);
PersistColorPalette.getInstance(currentAccount).setInTextMode(index == 2);
colorSwatch.color = PersistColorPalette.getInstance(currentAccount).getCurrentColor();
setCurrentSwatch(colorSwatch, true);
tabsSelectionAnimator = ValueAnimator.ofFloat(0, 1).setDuration(300); tabsSelectionAnimator = ValueAnimator.ofFloat(0, 1).setDuration(300);
tabsSelectionAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); tabsSelectionAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
tabsSelectionAnimator.addUpdateListener(animation -> { tabsSelectionAnimator.addUpdateListener(animation -> {
@ -2836,8 +2850,10 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
ignoreToolChangeAnimationOnce = true; ignoreToolChangeAnimationOnce = true;
} }
renderView.setBrush(brush); renderView.setBrush(brush);
int wasColor = colorSwatch.color;
colorSwatch.color = PersistColorPalette.getInstance(currentAccount).getCurrentColor();
colorSwatch.brushWeight = weightDefaultValueOverride.get(); colorSwatch.brushWeight = weightDefaultValueOverride.get();
setCurrentSwatch(colorSwatch, true); setCurrentSwatch(colorSwatch, true, wasColor);
renderInputView.invalidate(); renderInputView.invalidate();
} }
@ -2952,12 +2968,16 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
if (show) { if (show) {
colorsListView.setVisibility(VISIBLE); colorsListView.setVisibility(VISIBLE);
colorsListView.setSelectedColorIndex(0); colorsListView.setSelectedColorIndex(PersistColorPalette.getInstance(currentAccount).getCurrentColorPosition());
} }
} }
} }
private void setCurrentSwatch(Swatch swatch, boolean updateInterface) { private void setCurrentSwatch(Swatch swatch, boolean updateInterface) {
setCurrentSwatch(swatch, updateInterface, null);
}
private void setCurrentSwatch(Swatch swatch, boolean updateInterface, Integer prevColor) {
if (colorSwatch != swatch) { if (colorSwatch != swatch) {
colorSwatch.color = swatch.color; colorSwatch.color = swatch.color;
colorSwatch.colorLocation = swatch.colorLocation; colorSwatch.colorLocation = swatch.colorLocation;
@ -2971,7 +2991,18 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
renderView.setBrushSize(swatch.brushWeight); renderView.setBrushSize(swatch.brushWeight);
if (updateInterface) { if (updateInterface) {
if (bottomLayout != null) { int newColor = colorSwatch.color;
if (prevColor != null && prevColor != newColor) {
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(150);
animator.addUpdateListener(animation -> {
float val = (float) animation.getAnimatedValue();
colorSwatch.color = ColorUtils.blendARGB(prevColor, newColor, val);
if (bottomLayout != null) {
bottomLayout.invalidate();
}
});
animator.start();
} else if (bottomLayout != null) {
bottomLayout.invalidate(); bottomLayout.invalidate();
} }
} }

View file

@ -180,6 +180,7 @@ public class PreviewView extends FrameLayout {
} }
}); });
audioPlayer.preparePlayer(Uri.fromFile(new File(entry.audioPath)), "other"); audioPlayer.preparePlayer(Uri.fromFile(new File(entry.audioPath)), "other");
audioPlayer.setVolume(entry.audioVolume);
if (videoPlayer != null && getDuration() > 0) { if (videoPlayer != null && getDuration() > 0) {
long startPos = (long) (entry.left * getDuration()); long startPos = (long) (entry.left * getDuration());
@ -605,6 +606,9 @@ public class PreviewView extends FrameLayout {
videoPlayer.preparePlayer(uri, "other"); videoPlayer.preparePlayer(uri, "other");
videoPlayer.setPlayWhenReady(pauseLinks.isEmpty()); videoPlayer.setPlayWhenReady(pauseLinks.isEmpty());
videoPlayer.setLooping(true); videoPlayer.setLooping(true);
if (entry.isEditSaved) {
seekTo = (long) ((entry.left * entry.duration) + seekTo);
}
if (seekTo > 0) { if (seekTo > 0) {
videoPlayer.seekTo(seekTo); videoPlayer.seekTo(seekTo);
} }
@ -614,6 +618,9 @@ public class PreviewView extends FrameLayout {
timelineView.setVideo(entry.getOriginalFile().getAbsolutePath(), getDuration()); timelineView.setVideo(entry.getOriginalFile().getAbsolutePath(), getDuration());
timelineView.setVideoLeft(entry.left); timelineView.setVideoLeft(entry.left);
timelineView.setVideoRight(entry.right); timelineView.setVideoRight(entry.right);
if (timelineView != null && seekTo > 0) {
timelineView.setProgress(seekTo);
}
} }
} }
@ -703,7 +710,7 @@ public class PreviewView extends FrameLayout {
} }
long pos = videoPlayer.getCurrentPosition(); long pos = videoPlayer.getCurrentPosition();
if (getDuration() > 0) { if (getDuration() > 1) {
final float progress = pos / (float) getDuration(); final float progress = pos / (float) getDuration();
if (!timelineView.isDragging() && (progress < entry.left || progress > entry.right) && System.currentTimeMillis() - seekedLastTime > MIN_DURATION / 2) { if (!timelineView.isDragging() && (progress < entry.left || progress > entry.right) && System.currentTimeMillis() - seekedLastTime > MIN_DURATION / 2) {
seekedLastTime = System.currentTimeMillis(); seekedLastTime = System.currentTimeMillis();

View file

@ -578,6 +578,11 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 512); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 512);
NotificationCenter.getGlobalInstance().runDelayedNotifications(); NotificationCenter.getGlobalInstance().runDelayedNotifications();
checkBackgroundVisibility(); checkBackgroundVisibility();
if (onFullyOpenListener != null) {
onFullyOpenListener.run();
onFullyOpenListener = null;
}
} }
}); });
if (value < 1 && wasSend) { if (value < 1 && wasSend) {
@ -679,6 +684,11 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
onCloseListener = listener; onCloseListener = listener;
} }
private Runnable onFullyOpenListener;
public void setOnFullyOpenListener(Runnable listener) {
onFullyOpenListener = listener;
}
private Utilities.Callback3<Long, Runnable, Boolean> onClosePrepareListener; private Utilities.Callback3<Long, Runnable, Boolean> onClosePrepareListener;
public void setOnPrepareCloseListener(Utilities.Callback3<Long, Runnable, Boolean> listener) { public void setOnPrepareCloseListener(Utilities.Callback3<Long, Runnable, Boolean> listener) {
onClosePrepareListener = listener; onClosePrepareListener = listener;
@ -2311,7 +2321,7 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
file = StoryEntry.makeCacheFile(currentAccount, false); file = StoryEntry.makeCacheFile(currentAccount, false);
try { try {
bitmap.compress(Bitmap.CompressFormat.JPEG, forDraft ? 95 : 75, new FileOutputStream(file)); bitmap.compress(Bitmap.CompressFormat.JPEG, forDraft ? 95 : 99, new FileOutputStream(file));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -2764,10 +2774,10 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
} else if (currentEditMode > EDIT_MODE_NONE) { } else if (currentEditMode > EDIT_MODE_NONE) {
switchToEditMode(EDIT_MODE_NONE, true); switchToEditMode(EDIT_MODE_NONE, true);
return false; return false;
} else if (currentPage == PAGE_PREVIEW && (outputEntry == null || !outputEntry.isEdit)) { } else if (currentPage == PAGE_PREVIEW && (outputEntry == null || !outputEntry.isEdit || (paintView != null && paintView.hasChanges()) || outputEntry.editedMedia || outputEntry.editedCaption)) {
if (paintView != null && paintView.onBackPressed()){ if (paintView != null && paintView.onBackPressed()) {
return false; return false;
} else if (fromGallery && (paintView == null || !paintView.hasChanges()) && (outputEntry == null || outputEntry.filterFile == null) || !previewButtons.isShareEnabled()) { } else if ((fromGallery && (paintView == null || !paintView.hasChanges()) && (outputEntry == null || outputEntry.filterFile == null) || !previewButtons.isShareEnabled()) && (outputEntry == null || !outputEntry.isEdit)) {
navigateTo(PAGE_CAMERA, true); navigateTo(PAGE_CAMERA, true);
} else { } else {
showDismissEntry(); showDismissEntry();
@ -4179,7 +4189,7 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), resourcesProvider); AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), resourcesProvider);
builder.setTitle(LocaleController.getString("DiscardChanges", R.string.DiscardChanges)); builder.setTitle(LocaleController.getString("DiscardChanges", R.string.DiscardChanges));
builder.setMessage(LocaleController.getString("PhotoEditorDiscardAlert", R.string.PhotoEditorDiscardAlert)); builder.setMessage(LocaleController.getString("PhotoEditorDiscardAlert", R.string.PhotoEditorDiscardAlert));
if (outputEntry != null) { if (outputEntry != null && !outputEntry.isEdit) {
builder.setNeutralButton(outputEntry.isDraft ? LocaleController.getString("StoryKeepDraft") : LocaleController.getString("StorySaveDraft"), (di, i) -> { builder.setNeutralButton(outputEntry.isDraft ? LocaleController.getString("StoryKeepDraft") : LocaleController.getString("StorySaveDraft"), (di, i) -> {
if (outputEntry == null) { if (outputEntry == null) {
return; return;
@ -4203,12 +4213,16 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
navigateTo(PAGE_CAMERA, true); navigateTo(PAGE_CAMERA, true);
}); });
} }
builder.setPositiveButton(outputEntry != null && outputEntry.isDraft ? LocaleController.getString("StoryDeleteDraft") : LocaleController.getString("Discard", R.string.Discard), (dialogInterface, i) -> { builder.setPositiveButton(outputEntry != null && outputEntry.isDraft && !outputEntry.isEdit ? LocaleController.getString("StoryDeleteDraft") : LocaleController.getString("Discard", R.string.Discard), (dialogInterface, i) -> {
if (outputEntry != null && outputEntry.isDraft) { if (outputEntry != null && !outputEntry.isEdit && outputEntry.isDraft) {
MessagesController.getInstance(currentAccount).getStoriesController().getDraftsController().delete(outputEntry); MessagesController.getInstance(currentAccount).getStoriesController().getDraftsController().delete(outputEntry);
outputEntry = null; outputEntry = null;
} }
navigateTo(PAGE_CAMERA, true); if (outputEntry != null && outputEntry.isEdit) {
close(true);
} else {
navigateTo(PAGE_CAMERA, true);
}
}); });
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog dialog = builder.create(); AlertDialog dialog = builder.create();

View file

@ -491,7 +491,11 @@ public class TimelineView extends View {
return false; return false;
} }
if (hasVideo && !hasAudio && event.getY() < h - py - getVideoHeight() - py && event.getAction() == MotionEvent.ACTION_DOWN) { if (hasVideo && !hasAudio && event.getAction() == MotionEvent.ACTION_DOWN && event.getY() < h - py - getVideoHeight() - py) {
return false;
}
if (hasAudio && !hasVideo && event.getAction() == MotionEvent.ACTION_DOWN && event.getY() < h - py - getAudioHeight() - py) {
return false; return false;
} }
@ -583,6 +587,8 @@ public class TimelineView extends View {
if (!hadDragChange && d < 0 && audioLeft <= (audioRight - MAX_SELECT_DURATION / (float) audioDuration)) { if (!hadDragChange && d < 0 && audioLeft <= (audioRight - MAX_SELECT_DURATION / (float) audioDuration)) {
pressHandle = HANDLE_AUDIO_REGION; pressHandle = HANDLE_AUDIO_REGION;
} }
} else {
minValue = Math.max(minValue, (videoLeft * videoDuration + scroll - audioOffset) / (float) audioDuration);
} }
float wasAudioLeft = audioLeft; float wasAudioLeft = audioLeft;
audioLeft = Utilities.clamp(audioLeft + d, maxValue, minValue); audioLeft = Utilities.clamp(audioLeft + d, maxValue, minValue);
@ -603,6 +609,8 @@ public class TimelineView extends View {
if (!hadDragChange && d > 0 && audioRight >= (audioLeft + MAX_SELECT_DURATION / (float) audioDuration)) { if (!hadDragChange && d > 0 && audioRight >= (audioLeft + MAX_SELECT_DURATION / (float) audioDuration)) {
pressHandle = HANDLE_AUDIO_REGION; pressHandle = HANDLE_AUDIO_REGION;
} }
} else {
maxValue = Math.min(maxValue, (videoRight * videoDuration + scroll - audioOffset) / (float) audioDuration);
} }
float wasAudioRight = audioRight; float wasAudioRight = audioRight;
audioRight = Utilities.clamp(audioRight + d, maxValue, minValue); audioRight = Utilities.clamp(audioRight + d, maxValue, minValue);
@ -731,7 +739,7 @@ public class TimelineView extends View {
} }
private long minAudioSelect() { private long minAudioSelect() {
return (long) Math.max(MIN_SELECT_DURATION, Math.min(videoDuration, MAX_SELECT_DURATION) * 0.25f); return (long) Math.max(MIN_SELECT_DURATION, Math.min(videoDuration, MAX_SELECT_DURATION) * 0.15f);
} }
private void moveAudioOffset(final float d) { private void moveAudioOffset(final float d) {
@ -754,6 +762,7 @@ public class TimelineView extends View {
} }
audioOffset = Utilities.clamp(audioOffset + (long) d, mmx, mmn); audioOffset = Utilities.clamp(audioOffset + (long) d, mmx, mmn);
if (delegate != null) { if (delegate != null) {
delegate.onAudioLeftChange(audioLeft);
delegate.onAudioRightChange(audioRight); delegate.onAudioRightChange(audioRight);
} }
} else if (audioOffset + (long) d < mn) { } else if (audioOffset + (long) d < mn) {
@ -769,6 +778,7 @@ public class TimelineView extends View {
audioOffset = Utilities.clamp(audioOffset + (long) d, mmx, mmn); audioOffset = Utilities.clamp(audioOffset + (long) d, mmx, mmn);
if (delegate != null) { if (delegate != null) {
delegate.onAudioLeftChange(audioLeft); delegate.onAudioLeftChange(audioLeft);
delegate.onAudioRightChange(audioRight);
} }
} else { } else {
audioOffset += (long) d; audioOffset += (long) d;
@ -776,24 +786,6 @@ public class TimelineView extends View {
} else { } else {
audioOffset = Utilities.clamp(audioOffset + (long) d, (long) (getBaseDuration() - audioDuration * audioRight), (long) (-audioLeft * audioDuration)); audioOffset = Utilities.clamp(audioOffset + (long) d, (long) (getBaseDuration() - audioDuration * audioRight), (long) (-audioLeft * audioDuration));
} }
// final float minLeft = Math.max(0, scroll - audioOffset) / (float) audioDuration;
// final float maxRight = Math.min(1, Math.max(0, scroll - audioOffset + videoScrollDuration) / (float) audioDuration);
// boolean changedLeftRight = false;
// final float pastDuration = audioRight - audioLeft;
// if (audioLeft < minLeft) {
// audioLeft = minLeft;
// audioRight = Math.min(1, audioLeft + pastDuration);
// changedLeftRight = true;
// }
// if (audioRight > maxRight) {
// audioRight = maxRight;
// audioLeft = Math.max(0, audioRight - pastDuration);
// changedLeftRight = true;
// }
// if (delegate != null && changedLeftRight) {
// delegate.onAudioLeftChange(audioLeft);
// delegate.onAudioRightChange(audioRight);
// }
if (!hasVideo && (progress / (float) audioDuration < audioLeft || progress / (float) audioDuration > audioRight)) { if (!hasVideo && (progress / (float) audioDuration < audioLeft || progress / (float) audioDuration > audioRight)) {
progress = (long) (audioLeft * audioDuration); progress = (long) (audioLeft * audioDuration);
if (delegate != null) { if (delegate != null) {

View file

@ -43,7 +43,7 @@ public class UnlockPremiumView extends FrameLayout {
} }
linearLayout.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 16, 17, 17, 16)); linearLayout.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 16, 17, 17, 16));
premiumButtonView = new PremiumButtonView(context, false); premiumButtonView = new PremiumButtonView(context, false, resourcesProvider);
String text; String text;
if (type == TYPE_STICKERS) { if (type == TYPE_STICKERS) {

View file

@ -5758,7 +5758,6 @@
<string name="BotCantAddToAttachMenu">This bot can\'t be added to the attachment menu.</string> <string name="BotCantAddToAttachMenu">This bot can\'t be added to the attachment menu.</string>
<string name="BotAlreadyAddedToAttachMenu">This bot is already in your attachment menu.</string> <string name="BotAlreadyAddedToAttachMenu">This bot is already in your attachment menu.</string>
<string name="BotRemoveFromMenu">This will remove **%1$s** shortcuts from all menus.</string> <string name="BotRemoveFromMenu">This will remove **%1$s** shortcuts from all menus.</string>
<string name="BotRemoveFromMenuAll">This will remove **%1$s** shortcuts from all menus.</string>
<string name="BotRemoveInlineFromMenu">Remove **%1$s** from suggestions?</string> <string name="BotRemoveInlineFromMenu">Remove **%1$s** from suggestions?</string>
<string name="BotWebViewRequestGeolocationPermission">Allow **%1$s** to access to your location?\n\nThe developer of **%1$s** will be able to access your location when this web app is open.</string> <string name="BotWebViewRequestGeolocationPermission">Allow **%1$s** to access to your location?\n\nThe developer of **%1$s** will be able to access your location when this web app is open.</string>
<string name="BotWebViewRequestGeolocationPermissionWithHint">Allow **%1$s** to access to your location?\n\nThe developer of **%1$s** will be able to access your location when this web app is open.\n\nGo to Settings > Permissions and turn **Location** on to share location data.</string> <string name="BotWebViewRequestGeolocationPermissionWithHint">Allow **%1$s** to access to your location?\n\nThe developer of **%1$s** will be able to access your location when this web app is open.\n\nGo to Settings > Permissions and turn **Location** on to share location data.</string>
@ -7223,6 +7222,7 @@
<string name="TermsOfUse">Terms of Use</string> <string name="TermsOfUse">Terms of Use</string>
<string name="BoostExpireOn">boost expires on %s</string> <string name="BoostExpireOn">boost expires on %s</string>
<string name="ChannelNeedBoostsDescription">Your channel need %s to enable posting stories.\n\nAsk your Premium subscribers to boost your channel with this link:</string> <string name="ChannelNeedBoostsDescription">Your channel need %s to enable posting stories.\n\nAsk your Premium subscribers to boost your channel with this link:</string>
<string name="ChannelNeedBoostsDescriptionNextLevel">Your channel need %1$s to be able post **%2$s** per day.\n\nAsk your Premium subscribers to boost your channel with this link:</string>
<string name="ChannelNeedBoostsDescriptionLevel1">This channel need %s to enable stories. Help make it possible!</string> <string name="ChannelNeedBoostsDescriptionLevel1">This channel need %s to enable stories. Help make it possible!</string>
<string name="ChannelNeedBoostsDescriptionLevelNext">This channel need %1$s to be able post **%2$s** per day. Help make it possible!</string> <string name="ChannelNeedBoostsDescriptionLevelNext">This channel need %1$s to be able post **%2$s** per day. Help make it possible!</string>
<string name="ChannelNeedBoostsAlreadyBoostedDescriptionLevel1">This channel need %s more boosts to enable stories.</string> <string name="ChannelNeedBoostsAlreadyBoostedDescriptionLevel1">This channel need %s more boosts to enable stories.</string>
@ -7245,4 +7245,5 @@
<string name="BoostStories_few">**%d**&#160;stories</string> <string name="BoostStories_few">**%d**&#160;stories</string>
<string name="BoostStories_many">**%d**&#160;stories</string> <string name="BoostStories_many">**%d**&#160;stories</string>
<string name="BoostStories_other">**%d**&#160;stories</string> <string name="BoostStories_other">**%d**&#160;stories</string>
<string name="BoostingIncreaseLevel">Increase Story Limit</string>
</resources> </resources>

View file

@ -13,8 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
#Sat Mar 12 05:53:50 MSK 2016 #Sat Mar 12 05:53:50 MSK 2016
APP_VERSION_CODE=3919 APP_VERSION_CODE=3926
APP_VERSION_NAME=10.1.0 APP_VERSION_NAME=10.1.1
APP_PACKAGE=org.telegram.messenger APP_PACKAGE=org.telegram.messenger
RELEASE_KEY_PASSWORD=android RELEASE_KEY_PASSWORD=android
RELEASE_KEY_ALIAS=androidkey RELEASE_KEY_ALIAS=androidkey