mirror of
https://github.com/DrKLO/Telegram.git
synced 2025-01-14 21:53:55 +01:00
update to 10.1.1 (3926)
This commit is contained in:
parent
750eedfc96
commit
fea5ca949a
55 changed files with 680 additions and 277 deletions
|
@ -34,10 +34,11 @@ CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && \
|
|||
cd /home/gradle && \
|
||||
gradle :TMessagesProj_App:bundleBundleAfat_SDK23Release && \
|
||||
gradle :TMessagesProj_App:bundleBundleAfatRelease && \
|
||||
gradle :TMessagesProj_App:assembleAfatStandalone && \
|
||||
gradle :TMessagesProj_AppStandalone:assembleAfatStandalone && \
|
||||
gradle :TMessagesProj_App: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_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/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols
|
|
@ -24,8 +24,8 @@ public class BuildVars {
|
|||
public static boolean USE_CLOUD_STRINGS = true;
|
||||
public static boolean CHECK_UPDATES = true;
|
||||
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
|
||||
public static int BUILD_VERSION = 3919;
|
||||
public static String BUILD_VERSION_STRING = "10.1.0";
|
||||
public static int BUILD_VERSION = 3926;
|
||||
public static String BUILD_VERSION_STRING = "10.1.1";
|
||||
public static int APP_ID = 4;
|
||||
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
||||
|
||||
|
|
|
@ -1046,13 +1046,14 @@ public class FileRefController extends BaseController {
|
|||
TLRPC.TL_stories_stories stories = (TLRPC.TL_stories_stories) response;
|
||||
TLRPC.StoryItem newStoryItem = null;
|
||||
if (!stories.stories.isEmpty()) {
|
||||
if (stories.stories.get(0).media != null) {
|
||||
newStoryItem = stories.stories.get(0);
|
||||
if (stories.stories.get(0).media.photo != null) {
|
||||
result = getFileReference(stories.stories.get(0).media.photo, requester.location, needReplacement, locationReplacement);
|
||||
TLRPC.StoryItem storyItem = stories.stories.get(0);
|
||||
if (storyItem.media != null) {
|
||||
newStoryItem = storyItem;
|
||||
if (storyItem.media.photo != null) {
|
||||
result = getFileReference(storyItem.media.photo, requester.location, needReplacement, locationReplacement);
|
||||
}
|
||||
if (stories.stories.get(0).media.document != null) {
|
||||
result = getFileReference(stories.stories.get(0).media.document, requester.location, needReplacement, locationReplacement);
|
||||
if (storyItem.media.document != null) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ public class NotificationCenter {
|
|||
public static final int uploadStoryEnd = totalEvents++;
|
||||
public static final int customTypefacesLoaded = totalEvents++;
|
||||
public static final int stealthModeChanged = totalEvents++;
|
||||
public static final int onReceivedChannelDifference = totalEvents++;
|
||||
public static final int onReceivedChannelDifference = totalEvents++;;
|
||||
|
||||
public static boolean alreadyLogged;
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import android.media.AudioManager;
|
|||
import android.media.SoundPool;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
|
@ -284,6 +285,24 @@ public class NotificationsController extends BaseController {
|
|||
private static final LongSparseArray<String> sharedPrefCachedKeys = new LongSparseArray<>();
|
||||
|
||||
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);
|
||||
int index = sharedPrefCachedKeys.indexOfKey(hash);
|
||||
if (index >= 0) {
|
||||
|
|
|
@ -25,12 +25,12 @@ public class NotificationsSettingsFacade {
|
|||
|
||||
|
||||
public boolean isDefault(long dialogId, int topicId) {
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId);
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void clearPreference(long dialogId, int topicId) {
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId);
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
|
||||
getPreferences().edit()
|
||||
.remove(PROPERTY_NOTIFY + key)
|
||||
.remove(PROPERTY_CUSTOM + key)
|
||||
|
@ -44,20 +44,20 @@ public class NotificationsSettingsFacade {
|
|||
|
||||
|
||||
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)) {
|
||||
return getPreferences().getInt(property + key, defaultValue);
|
||||
}
|
||||
key = NotificationsController.getSharedPrefKey(dialogId, 0);
|
||||
key = NotificationsController.getSharedPrefKey(dialogId, 0, true);
|
||||
return getPreferences().getInt(property + key, 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)) {
|
||||
return getPreferences().getLong(property + key, defaultValue);
|
||||
}
|
||||
key = NotificationsController.getSharedPrefKey(dialogId, 0);
|
||||
key = NotificationsController.getSharedPrefKey(dialogId, 0, true);
|
||||
return getPreferences().getLong(property + key, defaultValue);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class NotificationsSettingsFacade {
|
|||
return;
|
||||
}
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId);
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
|
||||
MessagesController messagesController = MessagesController.getInstance(currentAccount);
|
||||
ConnectionsManager connectionsManager = ConnectionsManager.getInstance(currentAccount);
|
||||
MessagesStorage messagesStorage = MessagesStorage.getInstance(currentAccount);
|
||||
|
@ -191,7 +191,7 @@ public class NotificationsSettingsFacade {
|
|||
String soundPathPref;
|
||||
String soundDocPref;
|
||||
if (dialogId != 0) {
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId);
|
||||
String key = NotificationsController.getSharedPrefKey(dialogId, topicId, true);
|
||||
soundPref = "sound_" + key;
|
||||
soundPathPref = "sound_path_" + key;
|
||||
soundDocPref = "sound_document_id_" + key;
|
||||
|
|
|
@ -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();
|
||||
this.audioDisabled = audioDisabled;
|
||||
this.paused = paused;
|
||||
if (position > 0) {
|
||||
currentPosition = position;
|
||||
}
|
||||
dispatchQueue.postRunnable(initRunnable = () -> {
|
||||
if (released) {
|
||||
return;
|
||||
|
@ -134,8 +137,8 @@ public class VideoPlayerHolderBase {
|
|||
videoPlayer.play();
|
||||
}
|
||||
}
|
||||
if (t > 0) {
|
||||
videoPlayer.seekTo(t);
|
||||
if (position > 0) {
|
||||
videoPlayer.seekTo(position);
|
||||
}
|
||||
|
||||
// videoPlayer.setVolume(isInSilentMode ? 0 : 1f);
|
||||
|
|
|
@ -416,6 +416,7 @@ public abstract class BaseFragment {
|
|||
FileLog.e(e);
|
||||
}
|
||||
if (storyViewer != null) {
|
||||
storyViewer.onPause();
|
||||
storyViewer.updatePlayingMode();
|
||||
}
|
||||
if (overlayStoryViewer != null) {
|
||||
|
|
|
@ -782,7 +782,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
private int descriptionX;
|
||||
private int titleX;
|
||||
private int authorX;
|
||||
private boolean siteNameRtl;
|
||||
private float siteNameLeft, siteNameLayoutWidth;
|
||||
private int siteNameWidth;
|
||||
private StaticLayout siteNameLayout;
|
||||
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);
|
||||
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);
|
||||
linkPreviewHeight += height;
|
||||
totalHeight += height;
|
||||
|
@ -7675,7 +7679,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
try {
|
||||
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);
|
||||
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);
|
||||
linkPreviewHeight += height;
|
||||
totalHeight += height;
|
||||
|
@ -10233,12 +10241,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
if (siteNameLayout != null) {
|
||||
Theme.chat_replyNamePaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outSiteNameText : Theme.key_chat_inSiteNameText));
|
||||
canvas.save();
|
||||
int x;
|
||||
if (siteNameRtl) {
|
||||
x = backgroundWidth - siteNameWidth - AndroidUtilities.dp(32);
|
||||
} else {
|
||||
x = (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
|
||||
}
|
||||
float x = -siteNameLeft + (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
|
||||
canvas.translate(linkX + x, linkPreviewY - AndroidUtilities.dp(3));
|
||||
siteNameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
@ -10599,15 +10602,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
Theme.chat_replyNamePaint.setAlpha((int) (alpha * Theme.chat_replyLinePaint.getAlpha()));
|
||||
}
|
||||
canvas.save();
|
||||
int x;
|
||||
if (siteNameRtl) {
|
||||
x = backgroundWidth - siteNameWidth - AndroidUtilities.dp(32);
|
||||
if (isSmallImage) {
|
||||
x -= AndroidUtilities.dp(48 + 6);
|
||||
}
|
||||
} else {
|
||||
x = (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
|
||||
}
|
||||
float x = -siteNameLeft + (hasInvoicePreview ? 0 : AndroidUtilities.dp(10));
|
||||
canvas.translate(linkX + x, linkPreviewY - AndroidUtilities.dp(3));
|
||||
siteNameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
|
|
@ -115,7 +115,7 @@ public class FeaturedStickerSetCell2 extends FrameLayout implements Notification
|
|||
delButton.setText(LocaleController.getString("StickersRemove", R.string.StickersRemove));
|
||||
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.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> onPremiumButtonClick());
|
||||
unlockButton.setVisibility(View.GONE);
|
||||
|
|
|
@ -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 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);
|
||||
this.style = style;
|
||||
this.currentAccount = currentAccount;
|
||||
|
@ -145,9 +149,11 @@ public class ReactedUserHolderView extends FrameLayout {
|
|||
reactView = new BackupImageView(context);
|
||||
addView(reactView, LayoutHelper.createFrameRelatively(24, 24, Gravity.END | Gravity.CENTER_VERTICAL, 0, 0, 12, 0));
|
||||
|
||||
overlaySelectorView = new View(context);
|
||||
overlaySelectorView.setBackground(Theme.getSelectorDrawable(false));
|
||||
addView(overlaySelectorView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
if (useOverlaySelector) {
|
||||
overlaySelectorView = new View(context);
|
||||
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) {
|
||||
|
|
|
@ -149,7 +149,7 @@ public class StickerSetCell extends FrameLayout {
|
|||
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));
|
||||
|
||||
premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(4), false);
|
||||
premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(4), false, resourcesProvider);
|
||||
premiumButtonView.setIcon(R.raw.unlock_icon);
|
||||
premiumButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> onPremiumButtonClick());
|
||||
try {
|
||||
|
|
|
@ -171,8 +171,9 @@ public class ChannelBoostLayout extends FrameLayout {
|
|||
StatisticActivity.OverviewCell overviewCell = (StatisticActivity.OverviewCell) holder.itemView;
|
||||
|
||||
overviewCell.setData(0, Integer.toString(boostsStatus.level), null, LocaleController.getString("BoostsLevel2", R.string.BoostsLevel2));
|
||||
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));
|
||||
if (boostsStatus.premium_audience != null && boostsStatus.premium_audience.total == 0) {
|
||||
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 {
|
||||
overviewCell.setData(1, "~0", "0%", LocaleController.getString("PremiumSubscribers", R.string.PremiumSubscribers));
|
||||
}
|
||||
|
@ -303,6 +304,7 @@ public class ChannelBoostLayout extends FrameLayout {
|
|||
usersLoading = false;
|
||||
if (response != null) {
|
||||
TLRPC.TL_stories_boostersList list = (TLRPC.TL_stories_boostersList) response;
|
||||
MessagesController.getInstance(currentAccount).putUsers(list.users, false);
|
||||
boosters.addAll(list.boosters);
|
||||
hasNext = !TextUtils.isEmpty(list.next_offset) && boosters.size() < list.count;
|
||||
nextRemaining = list.count - boosters.size();
|
||||
|
|
|
@ -959,14 +959,20 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
|
|||
req.from_switch_webview = (flags & FLAG_FROM_INLINE_SWITCH) != 0;
|
||||
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
|
||||
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) {
|
||||
req.theme_params = new TLRPC.TL_dataJSON();
|
||||
req.theme_params.data = themeParams;
|
||||
req.flags |= 1;
|
||||
}
|
||||
req.flags |= 8;
|
||||
req.url = buttonUrl;
|
||||
if (!TextUtils.isEmpty(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(() -> {
|
||||
if (response instanceof TLRPC.TL_simpleWebViewResultUrl) {
|
||||
|
@ -1058,7 +1064,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
|
|||
return;
|
||||
}
|
||||
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;
|
||||
new AlertDialog.Builder(LaunchActivity.getLastFragment().getContext())
|
||||
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))
|
||||
|
|
|
@ -2855,7 +2855,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
|
|||
break;
|
||||
}
|
||||
}
|
||||
description = LocaleController.formatString("BotRemoveFromMenuAll", R.string.BotRemoveFromMenuAll, botName);
|
||||
description = LocaleController.formatString("BotRemoveFromMenu", R.string.BotRemoveFromMenu, botName);
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))
|
||||
.setMessage(AndroidUtilities.replaceTags(attachMenuBot != null ? description : LocaleController.formatString("BotRemoveInlineFromMenu", R.string.BotRemoveInlineFromMenu, botName)))
|
||||
|
|
|
@ -166,6 +166,8 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
|
|||
private ZoomControlView zoomControlView;
|
||||
private AnimatorSet zoomControlAnimation;
|
||||
private Runnable zoomControlHideRunnable;
|
||||
private Runnable afterCameraInitRunnable;
|
||||
private Boolean isCameraFrontfaceBeforeEnteringEditMode = null;
|
||||
private TextView counterTextView;
|
||||
private TextView tooltipTextView;
|
||||
private ImageView switchCameraButton;
|
||||
|
@ -359,7 +361,12 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
|
|||
resumeCameraPreview();
|
||||
AndroidUtilities.runOnUIThread(()-> setCurrentSpoilerVisible(-1, true), 150);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEditModeChanged(boolean isEditMode) {
|
||||
onPhotoEditModeChanged(isEditMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
|
||||
PhotoAttachPhotoCell cell = getCellForIndex(index);
|
||||
|
@ -1753,6 +1760,20 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
|
|||
}
|
||||
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
|
||||
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
|
||||
return null;
|
||||
|
@ -2155,7 +2176,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
|
|||
}
|
||||
if (cameraView == null) {
|
||||
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() {
|
||||
@Override
|
||||
|
@ -2279,6 +2300,9 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
|
|||
});
|
||||
cameraInitAnimation.start();
|
||||
}
|
||||
if (afterCameraInitRunnable != null) {
|
||||
afterCameraInitRunnable.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2324,17 +2348,23 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
|
|||
cameraView.setVisibility(GONE);
|
||||
cameraIcon.setVisibility(GONE);
|
||||
}
|
||||
checkCameraViewPosition();
|
||||
if (cameraOpened) {
|
||||
cameraIcon.setAlpha(0f);
|
||||
} else {
|
||||
checkCameraViewPosition();
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
if (zoomControlView != null) {
|
||||
zoomControlView.setZoom(0.0f, false);
|
||||
cameraZoom = 0.0f;
|
||||
}
|
||||
cameraView.setTranslationX(cameraViewLocation[0]);
|
||||
cameraView.setTranslationY(cameraViewLocation[1] + currentPanTranslationY);
|
||||
cameraIcon.setTranslationX(cameraViewLocation[0]);
|
||||
cameraIcon.setTranslationY(cameraViewLocation[1] + cameraViewOffsetY + currentPanTranslationY);
|
||||
if (!cameraOpened) {
|
||||
cameraView.setTranslationX(cameraViewLocation[0]);
|
||||
cameraView.setTranslationY(cameraViewLocation[1] + currentPanTranslationY);
|
||||
cameraIcon.setTranslationX(cameraViewLocation[0]);
|
||||
cameraIcon.setTranslationY(cameraViewLocation[1] + cameraViewOffsetY + currentPanTranslationY);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
void onHidden() {
|
||||
if (cameraView != null) {
|
||||
|
|
|
@ -514,7 +514,7 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
|
|||
removeButtonView.setClickable(true);
|
||||
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 -> {
|
||||
showPremiumAlert();
|
||||
});
|
||||
|
@ -1560,7 +1560,7 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
|
|||
float endMarginDp = 8;
|
||||
if (!single) {
|
||||
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 -> {
|
||||
premiumButtonClicked = SystemClock.elapsedRealtime();
|
||||
showPremiumAlert();
|
||||
|
|
|
@ -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));
|
||||
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);
|
||||
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));
|
||||
|
||||
premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(16), false);
|
||||
premiumButtonView = new PremiumButtonView(context, AndroidUtilities.dp(16), false, resourcesProvider);
|
||||
premiumButtonView.setIcon(R.raw.unlock_icon);
|
||||
premiumButtonView.setButton(LocaleController.getString("Unlock", R.string.Unlock), e -> openPremiumAnimatedEmojiFeature());
|
||||
|
||||
|
|
|
@ -86,12 +86,21 @@ public abstract class Brush {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public int getDefaultColor() {
|
||||
return PersistColorPalette.COLOR_BLACK;
|
||||
}
|
||||
|
||||
public static class Radial extends Brush {
|
||||
|
||||
@Override
|
||||
public int getIconRes() {
|
||||
return R.raw.photo_pen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultColor() {
|
||||
return PersistColorPalette.COLOR_RED;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Elliptical extends Brush {
|
||||
|
@ -140,6 +149,11 @@ public abstract class Brush {
|
|||
public float getDefaultWeight() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultColor() {
|
||||
return PersistColorPalette.COLOR_YELLOW;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Neon extends Brush {
|
||||
|
@ -191,6 +205,11 @@ public abstract class Brush {
|
|||
public float getDefaultWeight() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultColor() {
|
||||
return PersistColorPalette.COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Arrow extends Brush {
|
||||
|
@ -209,6 +228,11 @@ public abstract class Brush {
|
|||
public float getDefaultWeight() {
|
||||
return 0.25f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultColor() {
|
||||
return PersistColorPalette.COLOR_ORANGE;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Eraser extends Brush {
|
||||
|
|
|
@ -185,6 +185,9 @@ public class Input {
|
|||
|
||||
long dt = System.currentTimeMillis() - lastVelocityUpdate;
|
||||
velocity = MathUtils.clamp(velocity - dt / 125f, 0.6f, 1f);
|
||||
if (renderView.getCurrentBrush() != null && renderView.getCurrentBrush() instanceof Brush.Arrow) {
|
||||
velocity = 1 - velocity;
|
||||
}
|
||||
lastScale = scale;
|
||||
lastVelocityUpdate = System.currentTimeMillis();
|
||||
|
||||
|
@ -195,7 +198,7 @@ public class Input {
|
|||
stylusToolPressed = (event.getButtonState() & MotionEvent.BUTTON_STYLUS_PRIMARY) == MotionEvent.BUTTON_STYLUS_PRIMARY;
|
||||
}
|
||||
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);
|
||||
|
||||
|
@ -299,7 +302,7 @@ public class Input {
|
|||
float angle = lastAngle;
|
||||
final Point loc = points[pointsCount - 1];
|
||||
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;
|
||||
if (arrowAnimator != null) {
|
||||
|
@ -311,13 +314,17 @@ public class Input {
|
|||
arrowAnimator.addUpdateListener(anm -> {
|
||||
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[]{
|
||||
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 + 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 * lastT[0], loc.y + leftSin * arrowLength * lastT[0], z),
|
||||
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[]{
|
||||
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 + 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 * lastT[0], loc.y + rightSin * arrowLength * lastT[0], z),
|
||||
new Point(loc.x + rightCos * arrowLength * t, loc.y + rightSin * arrowLength * t, z, true)
|
||||
}));
|
||||
|
||||
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 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;
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -9,35 +9,53 @@ import org.telegram.ui.Components.Paint.Views.PaintTextOptionsView;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class PersistColorPalette {
|
||||
public final static int COLORS_COUNT = 14;
|
||||
|
||||
private final static List<Integer> DEFAULT_COLORS = Arrays.asList(
|
||||
0xff000000,
|
||||
0xffFFFFFF,
|
||||
0xff1D99FF,
|
||||
0xff03BCD4,
|
||||
0xff39BA2B,
|
||||
0xffF9A30F,
|
||||
0xffFA6E16,
|
||||
0xffE83544,
|
||||
0xffB24DFF,
|
||||
public final static int COLOR_BLACK = 0xff000000;
|
||||
public final static int COLOR_WHITE = 0xffffffff;
|
||||
public final static int COLOR_RED = 0xffff453a;
|
||||
public final static int COLOR_ORANGE = 0xffff8a00;
|
||||
public final static int COLOR_YELLOW = 0xffffd60a;
|
||||
public final static int COLOR_GREEN = 0xff34c759;
|
||||
public final static int COLOR_LIGHT_BLUE = 0xff63e6e2;
|
||||
public final static int COLOR_BLUE = 0xff0a84ff;
|
||||
public final static int COLOR_VIOLET = 0xffbf5af2;
|
||||
|
||||
private final static List<Integer> DEFAULT_MODIFIABLE_COLORS = Arrays.asList(
|
||||
0xffD7A07C,
|
||||
0xffAC734C,
|
||||
0xff90512C,
|
||||
0xff532E1F,
|
||||
0xff818181
|
||||
0xff7faffe,
|
||||
0xffA58FDB,
|
||||
0xffDB95AE,
|
||||
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 SharedPreferences mConfig;
|
||||
private List<Integer> colors = new ArrayList<>(COLORS_COUNT);
|
||||
private final SharedPreferences mConfig;
|
||||
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 Integer markerColor;
|
||||
private boolean needSaveBrushColor;
|
||||
|
||||
private int currentBrush;
|
||||
private int currentAlignment;
|
||||
|
@ -45,6 +63,7 @@ public class PersistColorPalette {
|
|||
private float currentWeight;
|
||||
private String currentTypeface;
|
||||
private boolean fillShapes;
|
||||
private boolean inTextMode;
|
||||
|
||||
public PersistColorPalette(int currentUser) {
|
||||
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();
|
||||
}
|
||||
|
||||
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() {
|
||||
return currentAlignment;
|
||||
}
|
||||
|
@ -114,8 +144,20 @@ public class PersistColorPalette {
|
|||
}
|
||||
|
||||
public void setCurrentBrush(int currentBrush) {
|
||||
setCurrentBrush(currentBrush, true);
|
||||
}
|
||||
|
||||
public void setCurrentBrush(int currentBrush, boolean saveBrush) {
|
||||
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() {
|
||||
|
@ -129,7 +171,15 @@ public class PersistColorPalette {
|
|||
|
||||
public void cleanup() {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -141,76 +191,123 @@ public class PersistColorPalette {
|
|||
|
||||
public int getColor(int index) {
|
||||
checkIndex(index);
|
||||
if (index < 0 || index >= colors.size()) {
|
||||
if (index >= 0 && index < DEFAULT_COLORS.size()) {
|
||||
return DEFAULT_COLORS.get(index);
|
||||
List<Integer> allColors = getAllColors();
|
||||
if (index >= allColors.size()) {
|
||||
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) {
|
||||
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) {
|
||||
selectColorIndex(i);
|
||||
if (updateBrush) {
|
||||
setCurrentBrushColorByColorIndex(i);
|
||||
}
|
||||
} else {
|
||||
List<Integer> from = new ArrayList<>(pendingChange.isEmpty() ? colors : pendingChange);
|
||||
|
||||
pendingChange.clear();
|
||||
pendingChange.add(color);
|
||||
pendingChange.addAll(from);
|
||||
if (pendingChange.size() < DEFAULT_COLORS.size()) {
|
||||
for (int j = pendingChange.size(); j < DEFAULT_COLORS.size(); ++j) {
|
||||
pendingChange.add(DEFAULT_COLORS.get(j));
|
||||
|
||||
for (int j = 0; j < from.size() - 1; j++) {
|
||||
pendingChange.add(from.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()) {
|
||||
pendingChange = pendingChange.subList(0, DEFAULT_COLORS.size());
|
||||
} else if (pendingChange.size() > DEFAULT_MODIFIABLE_COLORS.size()) {
|
||||
pendingChange = pendingChange.subList(0, DEFAULT_MODIFIABLE_COLORS.size());
|
||||
}
|
||||
if (updateBrush) {
|
||||
brushColor.put(currentBrush, color);
|
||||
needSaveBrushColor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void selectColorIndex(int index) {
|
||||
int color = index < 0 || index >= colors.size() ? DEFAULT_COLORS.get(index) : colors.get(index);
|
||||
List<Integer> from = new ArrayList<>(pendingChange.isEmpty() ? colors : pendingChange);
|
||||
pendingChange.clear();
|
||||
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());
|
||||
}
|
||||
public void setCurrentBrushColorByColorIndex(int index) {
|
||||
int color = getColor(index);
|
||||
brushColor.put(currentBrush, color);
|
||||
needSaveBrushColor = true;
|
||||
}
|
||||
|
||||
private void loadColors() {
|
||||
for (int i = 0; i < COLORS_COUNT; i++) {
|
||||
colors.add((int) mConfig.getLong("color_" + i, DEFAULT_COLORS.get(i)));
|
||||
for (int i = 0; i < MODIFIABLE_COLORS_COUNT; 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() {
|
||||
if (pendingChange.isEmpty()) {
|
||||
if (pendingChange.isEmpty() && !needSaveBrushColor) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = mConfig.edit();
|
||||
for (int i = 0; i < COLORS_COUNT; i++) {
|
||||
editor.putLong("color_" + i, i < pendingChange.size() ? pendingChange.get(i) : (long) DEFAULT_COLORS.get(i));
|
||||
if (!pendingChange.isEmpty()) {
|
||||
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();
|
||||
|
||||
colors.clear();
|
||||
colors.addAll(pendingChange);
|
||||
pendingChange.clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -269,7 +269,8 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
|
|||
inBubbleMode = context instanceof BubbleActivity;
|
||||
|
||||
PersistColorPalette palette = PersistColorPalette.getInstance(currentAccount);
|
||||
colorSwatch.color = palette.getColor(0);
|
||||
palette.resetCurrentColor();
|
||||
colorSwatch.color = palette.getCurrentColor();
|
||||
colorSwatch.brushWeight = palette.getCurrentWeight();
|
||||
|
||||
queue = new DispatchQueue("Paint");
|
||||
|
@ -664,6 +665,7 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
|
|||
int childWidth = child.getWidth() - child.getPaddingLeft() - child.getPaddingRight();
|
||||
int childHeight = child.getHeight() - child.getPaddingTop() - child.getPaddingBottom();
|
||||
float cx = child.getX() + child.getPaddingLeft() + childWidth / 2f, cy = child.getY() + child.getPaddingTop() + childHeight / 2f;
|
||||
int colorCircle = colorSwatch.color;
|
||||
if (tabsNewSelectedIndex != -1) {
|
||||
ViewGroup barView2 = (ViewGroup) getBarView(tabsNewSelectedIndex);
|
||||
View newView = (barView2 == null ? barView : barView2).getChildAt(0);
|
||||
|
@ -677,6 +679,8 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
|
|||
View animateToView = colorsListView.getChildAt(0);
|
||||
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);
|
||||
int paletteFirstColor = palette.getColor(0);
|
||||
colorCircle = ColorUtils.blendARGB(colorSwatch.color, paletteFirstColor, toolsTransformProgress);
|
||||
}
|
||||
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);
|
||||
canvas.drawArc(AndroidUtilities.rectTmp, 0, 360, false, |